/* Interior Planner - app components on top of styles.css (CI). Tokens only, no raw colors.
   The editor uses the full window width (palette | plan | properties); the other pages keep the
   CI widths. Plan drawing colors come from the plan tokens in styles.css. */

[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.grow { flex: 1; }
.small { font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.btn.sm { padding: 4px 10px; font-size: 13.5px; }
.btn.danger, .btn.primary.danger { background: var(--danger); border-color: var(--danger); color: var(--panel); }
.btn.on { border-color: var(--tone); color: var(--tone-text); }
.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); font-weight: 600; }
.btn.disabled { opacity: .45; pointer-events: none; }
a.btn { display: inline-block; text-decoration: none; text-align: center; }
input[type="color"] { width: 100%; min-width: 48px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.app-top { padding-bottom: 10px; }
.app-top.wide { max-width: none; width: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.userbox { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.user-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.btn.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 9px; align-self: stretch; }

/* ---------- Pages ---------- */
.page { max-width: 1040px; }
.page.wide-page { max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 4px; }
.page-head h1 { font-size: clamp(26px, 4vw, 34px); }
.page-head .row { gap: 8px; }

/* Plans */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.plan-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; min-width: 0; transition: border-color .15s;
}
.plan-card:hover { border-color: var(--accent); }
.plan-open { display: block; color: var(--text); text-decoration: none; }
.plan-preview { display: block; width: 100%; aspect-ratio: 16 / 10; background: var(--canvas); border-bottom: 1px solid var(--border); }
.plan-info { padding: 12px 14px 4px; display: grid; gap: 2px; }
.plan-info strong { font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-actions { display: flex; gap: 6px; padding: 8px 14px 12px; flex-wrap: wrap; }
.preview-room { fill: var(--floor); }
.preview-wall { stroke: var(--wall); stroke-linecap: square; }
.preview-item { fill: var(--muted); fill-opacity: .45; }
.empty-state { text-align: center; padding: 50px 20px; display: grid; gap: 12px; justify-items: center; }
.tpl-list { display: grid; gap: 8px; }
.tpl { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.tpl:hover { border-color: var(--accent); }
.tpl input { margin-top: 4px; accent-color: var(--accent); }
.tpl > span { display: grid; gap: 2px; }
.tpl:has(input:checked) { border-color: var(--tone); box-shadow: 0 0 0 1px var(--tone) inset; }

/* Furniture page */
.lib-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.lib-filters .field.grow { flex: 1 1 220px; }
.lib-filters input[type="search"] { width: 100%; }
.furn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.furn-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 4px 12px; align-content: start; min-width: 0;
}
.furn-card .thumb { grid-row: span 3; width: 72px; height: 72px; }
.furn-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.furn-card .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.furn-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; grid-column: 1 / -1; margin-top: 4px; }
.furn-actions { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; margin-top: 6px; }
.thumb { display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.thumb-img { width: 100%; height: 100%; object-fit: contain; background: var(--panel); display: block; }
.count { color: var(--muted); font-size: 14px; }

/* ---------- Editor ---------- */
body.editor-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr) 290px; gap: 12px;
  padding: 0 16px 16px;
}
.plan-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.plan-name {
  font: inherit; font-weight: 700; font-size: 17px; color: var(--text); background: none; border: 1px solid transparent;
  border-radius: 8px; padding: 3px 8px; cursor: pointer; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plan-name:hover { border-color: var(--border); background: var(--panel-2); }
.save-state { white-space: nowrap; }
.banner {
  margin: 0 16px 10px; padding: 8px 12px; border-radius: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  font-weight: 600; font-size: 14px;
}

/* palette */
.library { padding: 0; display: flex; flex-direction: column; min-height: 0; }
.lib-head { padding: 12px 12px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--border); }
.lib-title { display: flex; align-items: baseline; justify-content: space-between; }
.lib-title h2 { font-size: 17px; }
.lib-head input, .lib-head select { width: 100%; }
.lib-actions { display: flex; gap: 6px; }
.lib-actions .btn { flex: 1; }
.lib-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; min-height: 0; }
.lib-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 6px 4px; }
.lib-item {
  font: inherit; color: var(--text); width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px;
  align-items: center; text-align: left; padding: 5px 6px; border: 1px solid transparent; border-radius: 10px;
  background: none; cursor: grab;
}
.lib-item:hover { background: var(--panel-2); border-color: var(--border); }
.lib-item:active { cursor: grabbing; }
.lib-item .thumb-svg, .lib-item .thumb-img { width: 42px; height: 42px; border-radius: 8px; background: var(--panel-2); }
.lib-text { display: grid; min-width: 0; line-height: 1.3; }
.lib-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-text strong { font-size: 14px; }
.lib-text .muted, .lib-size { font-size: 12px; }
.lib-tip { padding: 8px 12px 10px; border-top: 1px solid var(--border); margin: 0; }

/* stage */
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 8px 10px; }
.tools button { font-weight: 600; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.btn.glyph { min-width: 34px; font-size: 16px; line-height: 1.2; padding: 3px 8px; }
.zoom-label { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.canvas-wrap {
  position: relative; flex: 1; min-height: 300px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--canvas); box-shadow: var(--shadow);
}
.plan-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: var(--canvas); user-select: none; }
.plan-svg:focus { outline: none; }
.plan-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.plan-svg[data-tool="wall"], .plan-svg[data-tool="room"], .plan-svg[data-tool="measure"] { cursor: crosshair; }
.plan-svg[data-tool="door"], .plan-svg[data-tool="window"] { cursor: copy; }
.plan-svg.panning { cursor: grabbing; }
.view3d { position: absolute; inset: 0; }
.view3d canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.view3d .loading, .view3d .msg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }
.hint {
  position: absolute; left: 10px; bottom: 8px; margin: 0; max-width: calc(100% - 180px); padding: 4px 9px; border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--muted); pointer-events: none;
}
.coords:empty { display: none; }
.coords {
  position: absolute; right: 10px; bottom: 8px; padding: 4px 9px; border-radius: 8px; color: var(--muted);
  background: color-mix(in srgb, var(--panel) 88%, transparent); font-variant-numeric: tabular-nums; pointer-events: none;
}

/* plan drawing */
.g-minor { stroke: var(--grid); stroke-width: 1; fill: none; }
.g-major { stroke: var(--grid-major); stroke-width: 1; fill: none; }
.room:not([style]) { fill: var(--floor); }
.room { stroke: none; cursor: move; }
.room.sel { filter: brightness(.97); }
.wall-out { fill: var(--wall-edge); stroke: var(--wall-edge); stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-linejoin: miter; }
.wall { fill: var(--wall); stroke: transparent; stroke-width: 10px; vector-effect: non-scaling-stroke; cursor: move; }
.wall.sel { fill: var(--tone); }
.opening { cursor: ew-resize; }
.opening .gap { fill: var(--canvas); stroke: none; }
.opening .jamb { stroke: var(--wall-edge); stroke-width: 1.5px; vector-effect: non-scaling-stroke; fill: none; }
.opening .leaf { stroke: var(--wall-edge); stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.opening .swing { stroke: var(--muted); stroke-width: 1px; vector-effect: non-scaling-stroke; fill: none; stroke-dasharray: 4 3; }
.opening .pane { stroke: var(--glass); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.opening.sel .gap { fill: color-mix(in srgb, var(--tone) 30%, var(--canvas)); }
.opening.sel .leaf, .opening.sel .jamb { stroke: var(--tone); }
.opening.ghost { opacity: .75; pointer-events: none; }
.opening.ghost .gap { fill: color-mix(in srgb, var(--accent) 45%, var(--canvas)); }
.item { cursor: move; }
.sym * { stroke: rgb(0 0 0 / .45); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sym .sh { fill: rgb(0 0 0 / .13); }
.sym .hl { fill: rgb(255 255 255 / .32); }
.sym .ln { fill: none; }
.sym .dash { stroke-dasharray: 3 3; }
.sym .dark { fill: rgb(0 0 0 / .6); stroke: none; }
.sym .dark-ring { fill: none; stroke: rgb(0 0 0 / .6); stroke-width: 2px; }
.item.clash .sym .base { stroke: var(--danger); stroke-width: 2.5px; }
.item.sel .sym .base { stroke: var(--tone); stroke-width: 2px; }

.overlay text { font: 600 12px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--canvas); stroke-width: 3px; stroke-linejoin: round; }
.overlay .room-name { font-size: 14px; font-weight: 700; fill: var(--text); }
.overlay .room-area { font-size: 12px; fill: var(--muted); }
.overlay .wall-dim { font-size: 11px; fill: var(--dim); font-weight: 600; }
.overlay .dim-text { fill: var(--dim); font-size: 11.5px; }
.dim-line { stroke: var(--dim); stroke-width: 1; pointer-events: none; }
.dim-line.sel, .dim-line.live { stroke: var(--tone); }
.dim-line.measure { stroke: var(--focus); stroke-width: 1.5; }
.dim-line.gap-dim { stroke: var(--tone); stroke-dasharray: 3 3; }
.sel-outline { fill: none; stroke: var(--tone); stroke-width: 1.5; stroke-dasharray: 5 3; pointer-events: none; }
.rot-line { stroke: var(--tone); stroke-width: 1.5; pointer-events: none; }
.handle { fill: var(--panel); stroke: var(--tone); stroke-width: 2; cursor: grab; pointer-events: all; }
.handle.rot { fill: var(--tone); stroke: var(--panel); }
.handle:hover { fill: var(--accent); }
.preview-line { fill: none; stroke: var(--tone); stroke-width: 3; stroke-dasharray: 6 4; pointer-events: none; }
.preview-rect { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--tone); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.snap-dot { fill: var(--focus); stroke: var(--panel); stroke-width: 1.5; pointer-events: none; }

/* properties */
.inspector { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; align-content: start; }
.insp-head { display: flex; gap: 10px; align-items: center; }
.insp-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.insp-head .thumb-svg { flex: none; background: var(--panel-2); border-radius: 8px; }
.insp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.insp-grid .span2 { grid-column: 1 / -1; }
.insp-grid input, .insp-grid select { width: 100%; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.insp-source { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.insp-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 -4px; }
.room-list, .shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 14px; }
.room-list li { display: flex; justify-content: space-between; gap: 8px; }
.shop-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; }
.shop-list .qty { color: var(--muted); font-variant-numeric: tabular-nums; }
.shop-list a, .shop-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price { font-variant-numeric: tabular-nums; }
.total { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 6px; }
.keys summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12.5px; margin: 8px 0 0; }
.keys dt { font-weight: 700; white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }

/* ---------- Dialogs + toast ---------- */
dialog.dlg { width: min(480px, calc(100vw - 32px)); color: var(--text); padding: 20px 22px; max-height: calc(100vh - 32px); }
dialog.dlg.wide { width: min(820px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgb(0 0 0 / .4); }
.dlg-form { display: grid; gap: 12px; }
.dlg .field input:not([type="color"]), .dlg .field select { width: 100%; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow);
  font-weight: 600; font-size: 14px; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: var(--panel); }

/* item editor */
.item-form { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 16px; align-items: start; }
.item-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.item-form-grid .span2 { grid-column: span 2; }
.item-preview { width: 132px; height: 132px; display: grid; place-items: center; background: var(--canvas); border: 1px solid var(--border); border-radius: 12px; }

.msg.error { color: var(--danger); font-weight: 600; }

/* ---------- Tables (users) ---------- */
.table-wrap { overflow-x: auto; }
.add-user { align-items: flex-end; }
.add-user .field { flex: 1 1 260px; }
.add-user .check { padding-bottom: 8px; }
table.users { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); }
.users td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.u-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.u-email { overflow-wrap: anywhere; }
.page.narrow { max-width: 900px; }

/* Login */
.login-main { display: grid; place-items: center; min-height: calc(100vh - 140px); }
.login-card { max-width: 440px; width: 100%; text-align: center; display: grid; gap: 12px; justify-items: center; padding: 30px 26px; }
.login-mark { border-radius: 16px; }
.login-btn { width: 100%; padding: 10px 14px; }
.setup { text-align: left; width: 100%; }
.setup-list { margin: 6px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 250px minmax(0, 1fr) 260px; }
}
@media (max-width: 980px) {
  body.editor-page { height: auto; overflow: visible; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .stage { order: 1; }
  .library { order: 2; max-height: 420px; }
  .inspector { order: 3; }
  .canvas-wrap { min-height: 62vh; }
  .plan-title { order: 5; flex-basis: 100%; }
}
@media (max-width: 600px) {
  .user-name { display: none; }
  .page-head { align-items: flex-start; }
  .item-form { grid-template-columns: minmax(0, 1fr); }
  .item-preview { display: none; }
  .hint { display: none; }
  .item-form-grid .span2 { grid-column: 1 / -1; }
}

/* context menu (IP.menu) */
.ctx-menu { position: fixed; z-index: 60; min-width: 200px; padding: 5px; display: grid; gap: 1px; border-radius: 10px; box-shadow: var(--shadow); }
.ctx-item {
  font: inherit; font-size: 14px; text-align: left; padding: 7px 10px; border: 0; border-radius: 7px;
  background: none; color: var(--text); cursor: pointer; white-space: nowrap;
}
.ctx-item.danger-text { color: var(--danger); }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--panel-2); outline: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* sharing furniture */
.share { display: grid; gap: 10px; }
.share-add { display: flex; gap: 10px; align-items: flex-end; }
.share-add .grow { flex: 1; }
.share-head { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 0; }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 40vh; overflow-y: auto; }
.share-list li:not(.share-none) {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2);
}
.share-who { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.share-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.share-tag { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.lib-tags { display: grid; gap: 3px; justify-items: end; }
.lib-tags:empty { display: none; }
.furn-by { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* furniture with its own 3D model: faint footprint, parts drawn on top */
.sym.model .base { fill-opacity: .2; stroke-dasharray: 3 3; }

/* consent page of the MCP sign-in (consent.html) */
.consent-card { text-align: left; justify-items: stretch; }
.consent-card .login-mark { justify-self: center; }
.consent-card h1 { text-align: center; font-size: 26px; line-height: 1.25; }
.consent-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.consent-actions { justify-content: flex-end; gap: 10px; }
