:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e2e4e9;
  --text: #1d2026;
  --muted: #6b7280;
  --hover: #eef0f4;
  --accent: #2f6fed;
  --accent-soft: #e6eefe;
  /* Small text on --accent-soft: the plain accent is too pale for it in both themes. */
  --accent-ink: #1f55c4;
  --accent-text: #ffffff;
  --warn: #c8363b;
  --ok: #1f7a4d;
  --shadow: 0 8px 30px rgba(20, 24, 33, 0.16);
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --panel: #1e2126;
    --line: #2e323a;
    --text: #e8eaee;
    --muted: #9299a6;
    --hover: #2a2e36;
    --accent: #5b8ff5;
    --accent-soft: #24324d;
    --accent-ink: #a9c4ff;
    --warn: #f0767a;
    --ok: #5cc493;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); overflow: hidden;
}
[hidden] { display: none !important; }
h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 0 8px; }
p { margin: 0; }
a { color: var(--accent); }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--bg); }
.muted { color: var(--muted); font-size: 12px; }
.warn-text { color: var(--warn); font-size: 12px; }
.ok-text { color: var(--ok); font-size: 12px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.danger { color: var(--warn); }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.toggle.active, .icon-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent;
  border-radius: var(--radius); background: transparent; font-weight: 600;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--hover); }
.icon-btn.small { width: 26px; height: 26px; }

.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--hover); gap: 2px; }
.segmented button { height: 28px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; font-weight: 500; }
.segmented button:hover { background: rgba(127, 127, 127, 0.12); }
.segmented button.active { background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14); font-weight: 600; }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; padding: 0 6px; }

.topbar {
  display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 16px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand strong { font-size: 14px; white-space: nowrap; }
.brand span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.spacer { flex: 1; }
.tools { display: flex; align-items: center; gap: 4px; }
.divider { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.layout { position: relative; flex: 1; display: grid; grid-template-columns: 348px minmax(0, 1fr); min-height: 0; }
.sidebar, .inspector { background: var(--panel); min-height: 0; }
.inspector { overflow-y: auto; }
/* The Add tab is a column: the catalog grid takes the height that is left and scrolls by itself. */
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); overflow: hidden; }
.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.tab-body.scroll { display: block; overflow-y: auto; }
.tab-body > .panel { flex: none; }
/* Floats over the stage: opening it must not resize the canvas under a drag in progress. */
.inspector { position: absolute; top: 8px; right: 8px; bottom: auto; max-height: calc(100% - 46px); width: 264px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 5; }
/* In Photo view the photo strip sits at the bottom of the stage: the inspector stops above it. */
.layout:has(.stage.photo) .inspector { max-height: calc(100% - 158px); }
.layout.clean .inspector { display: none; }
.panel { padding: 16px; border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.row.tight { margin-top: 0; align-items: center; flex-wrap: nowrap; }

.link-form { display: flex; gap: 8px; align-items: flex-end; }
.link-form textarea { flex: 1; min-width: 0; min-height: 58px; font-size: 12.5px; }
.queue { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.queue:empty { display: none; }
.qrow { padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.qrow[data-status="misplaced"], .qrow[data-status="failed"] { border-color: var(--warn); }
.qtop { display: flex; align-items: center; gap: 4px; }
.qhead { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; text-align: left; }
.qthumb { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--hover); color: var(--muted); overflow: hidden; }
.qthumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.qmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qline { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 11px; color: var(--muted); }
.qbadge:empty { display: none; }
.qbadge { padding: 0 5px; border-radius: 999px; background: var(--hover); }
.qbadge[data-confidence="labelled"] { color: var(--ok); }
.qbadge[data-confidence="typical"], .qbadge[data-confidence="ordered"] { color: var(--text); }
.qpill { flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--hover); color: var(--muted); white-space: nowrap; }
.qrow[data-status="placed"] .qpill { background: color-mix(in srgb, var(--ok) 16%, var(--panel)); color: var(--ok); }
.qrow[data-status="ready"] .qpill, .qrow[data-status="reading"] .qpill { background: var(--accent-soft); color: var(--accent-ink); }
.qrow[data-status="needs-size"] .qpill, .qrow[data-status="check"] .qpill, .qrow[data-status="failed"] .qpill, .qrow[data-status="misplaced"] .qpill { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); color: var(--warn); }
.qdetail { margin-top: 4px; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.qdetail:empty { display: none; }
.qfix { display: grid; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.qfix .field { margin-top: 0; }
.qfix .row { margin-top: 0; }
.qnotes { display: grid; gap: 2px; }
.qnotes:empty { display: none; }
.qfix .muted:empty { display: none; }
input[type="text"], input[type="url"], input[type="search"], input[type="number"], select, textarea {
  height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); width: 100%;
}
textarea { height: auto; padding: 8px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input.missing { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--panel)); }
.link-form + .muted { margin: 8px 0; }
.bookmarklet {
  display: inline-block; padding: 4px 10px; border: 1px dashed var(--accent); border-radius: 999px; background: var(--panel);
  font-size: 12px; font-weight: 600; text-decoration: none; cursor: grab;
}

.catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; min-height: 76px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); text-align: center;
}
.tile:hover { background: var(--hover); border-color: var(--accent); }
.tile:active { transform: scale(0.97); }
.tile-name { font-size: 11.5px; font-weight: 500; line-height: 1.2; }
.tile-size { font-size: 10.5px; color: var(--muted); }

.count { margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: var(--hover); font-size: 11px; }
.count:empty { display: none; }
.item-list { display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.item-row { display: flex; flex-direction: column; border-radius: 8px; }
.item-row:hover { background: var(--hover); }
.item-row.active { background: var(--accent-soft); color: var(--accent-ink); }
.item-row.bad .item-name { color: var(--warn); }
.item-main { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px 5px 5px; border: 0; background: transparent; text-align: left; min-width: 0; }
.item-thumb { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 6px; background: #fff; color: #6b7280; border: 1px solid var(--line); overflow: hidden; }
.item-thumb img { width: 100%; height: 100%; object-fit: contain; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-size { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.item-price { font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-retry { align-self: flex-start; margin: 0 0 6px 55px; padding: 0; border: 0; background: none; color: var(--warn); font-size: 11.5px; font-weight: 600; text-decoration: underline; }
.item-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding: 10px 8px 2px; border-top: 1px solid var(--line); font-size: 12.5px; }
.item-total b { font-size: 16px; font-variant-numeric: tabular-nums; }
.item-total:empty { display: none; }

.field-label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.swatch { width: 26px; height: 26px; padding: 0; border: 1px solid rgba(127, 127, 127, 0.45); border-radius: 50%; }
.swatch:hover { transform: scale(1.12); }
.swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.picker { border-radius: 6px; overflow: hidden; background: conic-gradient(#e5484d, #f5d90a, #30a46c, #2f6fed, #8e4ec6, #e5484d); cursor: pointer; }
.swatch.picker::-webkit-color-swatch-wrapper { padding: 3px; }
.swatch.picker::-webkit-color-swatch { border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 3px; }

details.more { margin-top: 8px; }
details.more summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
details.more summary:hover { color: var(--text); }
details.more p { margin-top: 8px; }

.tabs { flex: none; display: flex; gap: 2px; padding: 8px 8px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; height: 34px; border: 0; border-bottom: 2px solid transparent; background: transparent;
  font-weight: 600; color: var(--muted);
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- IKEA catalog ---- */
.tab-body > .ikea-panel { flex: 1 1 0; min-height: 380px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding-bottom: 0; border-bottom: 0; }
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; flex: none; }
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 2px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 11.5px; font-weight: 500; line-height: 1.15; text-align: center;
}
.cat svg { color: var(--muted); }
.cat:hover { border-color: var(--accent); background: var(--hover); }
.cat:hover svg, .cat.active svg { color: var(--accent); }
.cat:active { transform: scale(0.96); }
.cat.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
/* One row that scrolls sideways once results are on screen. */
.cats.compact { display: flex; flex-wrap: wrap; gap: 6px; }
.cats.compact .cat { flex: none; flex-direction: row; min-height: 26px; padding: 0 10px; border-radius: 999px; white-space: nowrap; font-size: 12px; }
.cats.compact .cat svg { display: none; }
#ikea-q { flex: none; }
.ikea-filters { display: grid; gap: 8px; flex: none; }
.ikea-selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ikea-selects select { height: 28px; padding: 0 4px; font-size: 12px; text-overflow: ellipsis; }
.ikea-selects select.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.ikea-colours { display: flex; flex-wrap: wrap; gap: 5px; }
.dot { width: 20px; height: 20px; padding: 0; border: 1px solid rgba(127, 127, 127, 0.5); border-radius: 50%; }
.dot:hover { transform: scale(1.15); }
.dot.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.ikea-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: none; }
.ikea-panel:not(.browsing) .ikea-bar { display: none; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 6px 0 8px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 600;
}
.pill i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(127, 127, 127, 0.5); }
.pill svg { stroke-width: 2.4; }
.pill:hover { filter: brightness(0.94); }
.pill.clear { padding: 0 8px; background: transparent; color: var(--muted); text-decoration: underline; }
#ikea-status { flex: none; margin: 0; min-height: 17px; }
.linkish { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; text-decoration: underline; }
.ikea-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 8px; align-content: start;
  margin: 0 -16px; padding: 2px 16px 16px; overscroll-behavior: contain;
}
.ikea-panel:not(.browsing) .ikea-grid { display: none; }
.ikea-card {
  position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); min-width: 0; overflow: hidden; transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.ikea-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(20, 24, 33, 0.14); transform: translateY(-1px); }
.ikea-add { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 6px 8px 8px; border: 0; background: transparent; text-align: left; min-width: 0; flex: 1; }
.ikea-add:active { transform: scale(0.98); }
.ikea-pic { position: relative; display: block; width: 100%; aspect-ratio: 1; margin-bottom: 4px; border-radius: 6px; background: #fff; overflow: hidden; }
.ikea-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.ikea-photo.room { object-fit: cover; opacity: 0; transition: opacity 0.18s; }
.ikea-card:hover .ikea-photo.room[src] { opacity: 1; }
.ikea-badge {
  position: absolute; left: 5px; top: 5px; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  background: #1f7a4d; color: #fff;
}
.ikea-badge:empty { display: none; }
.ikea-badge[data-model="no"] { background: rgba(255, 255, 255, 0.86); color: #6b7280; font-weight: 600; }
.ikea-add b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ikea-type { font-size: 11.5px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ikea-line { display: flex; align-items: baseline; gap: 6px; min-width: 0; margin-top: 2px; }
.ikea-price { font-size: 13px; font-weight: 700; }
.ikea-size { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ikea-foot { display: none; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 8px; font-size: 11.5px; font-weight: 600; }
.ikea-card[data-state="adding"] .ikea-foot, .ikea-card[data-state="added"] .ikea-foot, .ikea-card[data-state="stuck"] .ikea-foot { display: flex; }
.ikea-note { display: inline-flex; align-items: center; gap: 5px; }
.ikea-note svg { stroke-width: 2.6; }
.ikea-card[data-state="adding"] { border-color: var(--accent); }
.ikea-card[data-state="adding"] .ikea-foot { background: var(--accent-soft); color: var(--accent-ink); }
.ikea-card[data-state="added"] { border-color: var(--ok); }
.ikea-card[data-state="added"] .ikea-foot { background: color-mix(in srgb, var(--ok) 15%, var(--panel)); color: var(--ok); }
.ikea-card[data-state="stuck"] { border-color: var(--warn); }
.ikea-card[data-state="stuck"] .ikea-foot { background: color-mix(in srgb, var(--warn) 13%, var(--panel)); color: var(--warn); }
.ikea-show { height: 20px; padding: 0 8px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; font-size: 11px; font-weight: 600; }
.ikea-show:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.ikea-more { grid-column: 1 / -1; display: grid; place-items: center; padding: 4px 0; order: 9; }
.spinner { width: 12px; height: 12px; flex: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { order: 8; padding: 6px 8px 8px; gap: 6px; pointer-events: none; }
.skeleton .ikea-pic, .skeleton b, .skeleton > span:last-child { background: linear-gradient(100deg, var(--hover) 30%, var(--line) 50%, var(--hover) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton b { height: 12px; width: 70%; border-radius: 4px; }
.skeleton > span:last-child { height: 10px; width: 45%; border-radius: 4px; }
@keyframes shimmer { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton .ikea-pic, .skeleton b, .skeleton > span:last-child { animation: none; } .ikea-card { transition: none; } }

/* Folded sections at the foot of the Add tab. */
details.fold { padding-top: 0; padding-bottom: 0; border-top: 1px solid var(--line); border-bottom: 0; }
details.fold > summary { display: flex; align-items: center; gap: 6px; height: 38px; cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform 0.12s; }
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--text); }
details.fold[open] { padding-bottom: 14px; }
.tab-body:not(.scroll) > details.fold[open] { max-height: 46%; overflow-y: auto; }
details.fold > p { margin-bottom: 8px; }
.own-picture { margin-top: 8px; cursor: pointer; }
.queue-panel { border-top: 1px solid var(--line); border-bottom: 0; max-height: 40%; overflow-y: auto; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: 38px; z-index: 12; display: grid; min-width: 232px; padding: 6px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); box-shadow: var(--shadow);
}
.menu-list button { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.menu-list button:hover { background: var(--hover); }
.menu-list button.active { color: var(--accent-ink); font-weight: 600; }
.menu-list button.active::after { content: "on"; font-size: 11px; color: var(--accent-ink); }
.menu-list button:has(kbd).active::after { content: none; }
.menu-list hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }

.progress {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; border-radius: 999px; background: rgba(20, 24, 33, 0.9); color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
}
.tag3d { flex: none; padding: 0 5px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; background: color-mix(in srgb, var(--ok) 18%, var(--panel)); color: var(--ok); }
.qmodel:empty { display: none; }
.qmodel[data-model="yes"] { color: var(--ok); font-weight: 600; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.stage.photo { background: #101114; }
.photo-img { display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.photo-bar {
  position: absolute; left: 50%; bottom: 38px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 24px); padding: 6px 8px; border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.photo-strip { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding: 2px; }
.photo-thumb {
  flex: none; width: 104px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: transparent; text-align: left; overflow: hidden;
}
.photo-thumb img { display: block; width: 100%; height: 60px; object-fit: cover; border-radius: 5px; }
.photo-thumb span { display: block; padding: 2px 2px 0; font-size: 10.5px; line-height: 1.25; color: var(--muted); height: 2.5em; overflow: hidden; }
.photo-thumb:hover span { color: var(--text); }
.photo-thumb.active { border-color: var(--accent); }
.photo-thumb.active span { color: var(--text); font-weight: 600; }
.stand-label { display: none; max-width: 92px; font-size: 11.5px; line-height: 1.3; color: var(--muted); }
/* Walk view: the same thumbnails, small, clear of the minimap. */
.photo-bar.stand { left: auto; right: 12px; transform: none; max-width: calc(100% - 270px); }
.photo-bar.stand .stand-label { display: block; }
.photo-bar.stand > .icon-btn, .photo-bar.stand > .btn, .photo-bar.stand > .divider, .photo-bar.stand .photo-thumb span { display: none; }
.photo-bar.stand .photo-thumb { width: 76px; }
.photo-bar.stand .photo-thumb img { height: 48px; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#canvas.ruler { cursor: crosshair; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute; left: 0; top: 0; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; will-change: transform;
}
/* A fixed blue: the lighter dark-theme accent does not carry white text. */
.label.gap { background: #2459c9; color: #fff; }
.label.ruler { background: #f59e0b; color: #1d2026; font-size: 13px; }
.label.room { background: rgba(255, 255, 255, 0.86); color: #1d2026; text-align: center; font-size: 12px; padding: 3px 8px; }
.label.room small { display: block; font-weight: 500; font-size: 11px; color: #555c68; }

.jump { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 24px); }
.chip {
  height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); font-size: 12px; font-weight: 500; backdrop-filter: blur(6px);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.ghost { border-style: dashed; }
.minimap {
  position: absolute; left: 12px; bottom: 42px; width: 230px; height: 172px; border: 1px solid var(--line);
  border-radius: var(--radius); background: color-mix(in srgb, var(--panel) 90%, transparent); box-shadow: var(--shadow); cursor: crosshair;
}
.walk-hint {
  position: absolute; left: 50%; top: 52px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px;
  background: rgba(20, 24, 33, 0.72); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none;
}
.toasts { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: grid; gap: 6px; width: min(560px, calc(100% - 32px)); pointer-events: none; z-index: 6; }
/* In Photo view the bottom of the stage holds the photo strip. */
.stage.photo .toasts { bottom: auto; top: 16px; }
.stage.walk .toasts { bottom: auto; top: 92px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: rgba(20, 24, 33, 0.9); color: #fff; font-size: 12.5px; box-shadow: var(--shadow); }
.toast span { flex: 1; }
.toast button { flex: none; pointer-events: auto; height: 24px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 6px; background: transparent; color: #fff; font-size: 12px; font-weight: 600; }
.toast button:hover { background: rgba(255, 255, 255, 0.16); }
.toast.bad { background: #a32a2f; }
.statusbar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 16px;
  height: 30px; padding: 0 12px; align-items: center; font-size: 12px; color: var(--muted);
  background: color-mix(in srgb, var(--panel) 88%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.statusbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status-main { color: var(--text); white-space: pre; }
#status-main.warn { color: var(--warn); }

.insp-head { display: flex; gap: 12px; align-items: center; }
.thumb { width: 64px; height: 64px; flex: none; border-radius: var(--radius); object-fit: contain; background: #fff; border: 1px solid var(--line); }
.thumb.placeholder { display: grid; place-items: center; color: var(--muted); background: var(--hover); }
.insp-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.insp-title a { font-size: 12px; }
input.name { font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.readout { width: 38px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.inspector .row { margin-top: 16px; }
.inspector .row .btn { flex: 1; justify-content: center; }
.inspector .warn-text { margin-top: 8px; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(15, 18, 24, 0.45); }
.card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.copy-text { margin-top: 10px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.card.ask { width: min(400px, 100%); font-size: 14px; line-height: 1.5; }
.card h2 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; font-size: 14px; line-height: 1.5; }
.hints details.more { margin-top: 16px; }
.hints .keys { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.hints .keys li { position: relative; padding-left: 76px; line-height: 1.6; }
.hints .keys li b { position: absolute; left: 0; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

@media (max-width: 1240px) {
  .brand span { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .btn { padding: 0 8px; }
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .ikea-grid { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .inspector { width: 256px; padding: 12px; }
  .panel { padding: 12px; }
  .minimap { width: 190px; height: 142px; }
}

.insp-summary { margin: 2px 0 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.inspector details.more { margin-top: 12px; }
.inspector details.more[open] summary { margin-bottom: 8px; }

/* The item card is a slim bar under the apartment, so it never covers a room. */
.inspector { top: auto; right: auto; bottom: 46px; left: 50%; transform: translateX(-50%); width: auto; max-width: min(760px, calc(100% - 24px)); max-height: 60%; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.inspector[hidden] { display: none; }
.inspector .insp-head { margin: 0; flex: 0 1 auto; min-width: 0; }
.inspector .insp-head .thumb { width: 44px; height: 44px; }
.inspector .insp-summary { margin: 0; }
.inspector > .field { margin: 0; flex: 0 0 auto; }
.inspector > .field > span:first-child { display: none; }
.inspector > .row { margin: 0; flex: 0 0 auto; }
.inspector > h3, .inspector > .grid3, .inspector > .swatches, .inspector > .warn-text, .inspector > div:not(.insp-head):not(.row):not(.field) { flex: 0 0 auto; margin: 0; }
.inspector > .warn-text:empty { display: none; }
.inspector details.more { margin: 0; flex: 0 0 auto; }
.inspector details.more[open] { flex: 1 1 100%; }
.layout:has(.stage.photo) .inspector { bottom: 158px; max-height: 50%; }

.ikea-panel:not(.browsing) .ikea-fold { display: none; }
.ikea-fold { flex: none; margin: 0; }
.ikea-fold[open] { display: grid; gap: 8px; }
.inspector.floating { left: 0; top: 0; bottom: auto; transform: translate(var(--ix, 0), var(--iy, 0)); width: max-content; max-width: min(680px, calc(100% - 16px)); flex-wrap: nowrap; padding: 8px 10px; gap: 10px; transition: opacity 0.12s; }
.inspector.floating.moving { opacity: 0; pointer-events: none; }
.inspector.floating input[type=range], .inspector.floating .readout, .inspector.floating .insp-title a, .inspector.floating .insp-title .muted { display: none; }
.inspector.floating .insp-head .thumb { width: 34px; height: 34px; }
.inspector.floating .insp-title input.name { width: 150px; }
.inspector.floating .insp-summary { display: none; }
.inspector.floating .btn { padding: 4px 9px; }
.inspector.floating .warn-text { display: none; }
.inspector.floating .insp-head { flex: 0 0 auto; }
.inspector.floating .insp-title input.name { width: 124px; }
.inspector.floating > .field { flex: 0 0 auto; min-width: 62px; }
.inspector.floating > .field .row.tight { display: flex; flex-wrap: nowrap; gap: 4px; }
.inspector.floating > .row { flex-wrap: nowrap; }

.group-by { display: flex; margin: 0 0 8px; }
.group-by button { flex: 1; height: 26px; font-size: 12px; }
.item-group { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 4px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.item-group:first-of-type { margin-top: 4px; }
.item-group .muted { font-weight: 500; letter-spacing: 0; text-transform: none; }

/* With "More options" open the card is a narrow column on the right, never a panel across the view. */
.inspector:not(.floating) { top: 8px; right: 8px; bottom: auto; left: auto; transform: none; display: block; width: 264px; max-width: 264px; max-height: calc(100% - 54px); overflow-y: auto; padding: 14px; }
.inspector:not(.floating) > * + * { margin-top: 10px; }
.inspector:not(.floating) details.more > * + * { margin-top: 10px; }
.inspector:not(.floating) .grid3 { gap: 6px; }
.layout:has(.stage.photo) .inspector:not(.floating) { bottom: auto; max-height: calc(100% - 166px); }

/* The printed sheet. On screen it stays hidden; in print it is the only thing on the page. */
#print-sheet { display: none; }
@media print {
  @page { margin: 14mm; }
  body.printing > *:not(#print-sheet) { display: none !important; }
  body.printing { background: #fff !important; color: #111 !important; overflow: visible !important; height: auto !important; }
  body.printing #print-sheet { display: block !important; font: 11pt/1.4 -apple-system, "Helvetica Neue", Arial, sans-serif; color: #111; }
  #print-sheet header h1 { font-size: 20pt; margin: 0; }
  #print-sheet header p { margin: 2pt 0 10pt; color: #555; }
  #print-sheet .print-pictures { display: grid; grid-template-columns: 1fr 1fr; gap: 10pt; }
  #print-sheet figure { margin: 0; }
  #print-sheet figure img { width: 100%; border: 0.5pt solid #ccc; border-radius: 4pt; display: block; }
  #print-sheet figcaption { font-size: 8.5pt; color: #666; margin-top: 3pt; }
  #print-sheet .print-rooms { font-size: 9pt; color: #444; margin: 8pt 0 4pt; }
  #print-sheet h2 { font-size: 11pt; margin: 12pt 0 3pt; padding-bottom: 2pt; border-bottom: 0.75pt solid #999; break-after: avoid; }
  #print-sheet table { width: 100%; border-collapse: collapse; }
  #print-sheet tr { break-inside: avoid; }
  #print-sheet td { padding: 3pt 0; border-bottom: 0.25pt solid #ddd; vertical-align: top; font-size: 9.5pt; }
  #print-sheet td.p-name a { display: block; font-size: 7.5pt; color: #666; text-decoration: none; }
  #print-sheet td.p-size { width: 34%; color: #444; white-space: nowrap; padding-left: 8pt; }
  #print-sheet td.p-price { width: 14%; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
  #print-sheet .print-total { display: flex; justify-content: space-between; margin-top: 10pt; padding-top: 6pt; border-top: 1pt solid #111; font-size: 12pt; }
  #print-sheet .print-note { font-size: 8pt; color: #777; margin-top: 10pt; }
}

/* The Design tab: a short conversation with the planner. */
.tab-body.vibe { display: flex; flex-direction: column; min-height: 0; padding: 12px 16px 14px; gap: 10px; }
.tab-body.vibe[hidden] { display: none; }
.vibe-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.vibe-msg { max-width: 94%; padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.4; }
.vibe-msg p { margin: 0; }
.vibe-msg.user { align-self: flex-end; background: var(--accent-soft, rgba(79, 124, 255, 0.18)); }
.vibe-msg.bot { align-self: flex-start; background: var(--hover); }
.vibe-msg.bad { color: var(--danger, #e5484d); }
.vibe-msg.working p::after { content: ' ...'; opacity: 0.6; }
.vibe-list { margin: 8px 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.vibe-list li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.linklike { background: none; border: 0; padding: 0; color: inherit; text-align: left; text-decoration: underline; text-decoration-color: rgba(127, 127, 127, 0.5); cursor: pointer; font: inherit; }
.linklike:hover { text-decoration-color: currentColor; }
.vibe-starters { display: grid; gap: 6px; flex: none; }
.vibe-starter { text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; font-size: 12px; cursor: pointer; }
.vibe-starter:hover { background: var(--hover); }
.vibe-form { display: flex; gap: 8px; align-items: flex-end; flex: none; }
.vibe-form textarea { flex: 1; resize: none; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field, transparent); color: inherit; font: inherit; font-size: 13px; }

/* Height off the floor: a labelled number in the item toolbar. */
.inspector > .field.lift { display: flex; align-items: center; gap: 6px; }
.inspector > .field.lift > span:first-child { display: inline; font-size: 11px; color: var(--muted); white-space: nowrap; }
.inspector > .field.lift input { width: 68px; }
.inspector.floating > .field.lift > span:first-child { font-size: 0; }
.inspector.floating > .field.lift > span:first-child::before { content: 'Height'; font-size: 11px; }
.inspector > .field.lift .btn[hidden] { display: none; }

/* Offered when a small thing overlaps a bigger one: it is usually meant to stand on it. */
.inspector .on-top { white-space: nowrap; border-color: var(--warn, #e5484d); }
.inspector .on-top[hidden] { display: none; }
.inspector.floating details.more summary { white-space: nowrap; }

/* A hanging lamp's toolbar is as short as any other: the cord length only. The note about its
   height and the "Centre over the table" button show with More options open. */
.inspector.floating > .hanging { display: flex; align-items: center; flex: 0 0 auto; }
.inspector.floating > .hanging > p, .inspector.floating > .hanging > .row { display: none; }
.inspector.floating > .hanging .field { display: flex; align-items: center; gap: 6px; margin: 0; }
.inspector.floating > .hanging .field > span:first-child { font-size: 0; }
.inspector.floating > .hanging .field > span:first-child::before { content: 'Cord'; font-size: 11px; color: var(--muted); }
.inspector.floating > .hanging input { width: 68px; }

/* The dialog that turns a layout into a link. */
.card.ask h2 { margin: 0 0 12px; }
.card.ask input[type=text] { width: 100%; margin-bottom: 10px; }
.card.ask input[hidden], .card.ask button[hidden] { display: none; }

/* The state of the layout link, in the top bar. A click opens the link dialog. */
.sync-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; margin-right: 4px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer; }
.sync-pill[hidden] { display: none; }
.sync-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sync-pill[data-mode=synced]::before { background: #2e9e5b; }
.sync-pill[data-mode=saving]::before, .sync-pill[data-mode=loading]::before { background: var(--accent); }
.sync-pill[data-mode=offline], .sync-pill[data-mode=refused] { color: var(--warn); border-color: var(--warn); }
.sync-pill[data-mode=offline]::before, .sync-pill[data-mode=refused]::before { background: var(--warn); }

/* ---- the day simulation ("Us") ---- */
.sim-bar {
  position: absolute; left: 50%; bottom: 38px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 24px); padding: 6px 8px 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.sim-bar[hidden], .stage.photo .sim-bar { display: none; }
/* Walk view keeps the photo strip and the minimap at the bottom. */
.stage.walk .sim-bar { bottom: auto; top: 50px; }
.sim-clock { flex: none; min-width: 62px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sim-scenes { display: flex; gap: 4px; min-width: 0; overflow-x: auto; }
.sim-scenes button { flex: none; height: 26px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 12px; }
.sim-scenes button:hover { border-color: var(--accent); }
.sim-scenes button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sim-bar .btn { flex: none; border-radius: 999px; white-space: nowrap; }
.stage.sim-on:not(.photo):not(.walk) .toasts { bottom: 92px; }
.stage.sim-on.walk .toasts { top: 100px; }

.label.sim-bubble {
  width: max-content; max-width: 220px; padding: 6px 11px 7px; border-radius: 14px; white-space: normal; text-align: center;
  background: #fffdfa; color: #2a2d33; font-size: 12.5px; font-weight: 500; line-height: 1.3; box-shadow: 0 4px 14px rgba(20, 24, 33, 0.22);
}
.label.sim-bubble[hidden] { display: none; }
.label.sim-bubble b { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--who, #5b8def); }
.label.sim-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -4px; width: 10px; height: 10px; border-radius: 2px;
  background: inherit; transform: translateX(-50%) rotate(45deg);
}

.sim-person { padding: 10px 0 6px; border-top: 1px solid var(--line); }
.sim-person:first-child { padding-top: 0; border-top: 0; }
.sim-person textarea { min-height: 76px; font-size: 13px; line-height: 1.4; }
.sim-now { margin: 0 0 2px; font-size: 13px; }
.sim-prompt { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--hover); font-size: 12.5px; line-height: 1.45; }
.sim-lines { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.4; }
.sim-lines b { margin-right: 6px; }
#sim-write[hidden], #sim-reset[hidden] { display: none; }
#sim-status.bad { color: var(--warn); }
#sim-status:empty { display: none; }

/* ---- "Who are you?" ---- */
.card.who .who-row { display: flex; gap: 10px; margin: 14px 0 6px; }
.card.who .who-btn { flex: 1; height: 54px; justify-content: center; gap: 10px; font-size: 15px; font-weight: 600; border-radius: 14px; }
.card.who .who-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
