:root {
  /* Tanatel-inspired palette; also defined in data/brand.json. */
  --primary: #353331;
  --primary-dark: #242320;
  --accent: #93714e;
  --bg: #f8f3eb;
  --surface: #fffdfa;
  --text: #242320;
  --text2: #6f685f;
  --border: #e3dbd0;
  --selection: #87684a;
  --error: #ab3430;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link {
  position: fixed; left: 12px; top: 8px; z-index: 200; padding: 9px 14px;
  border-radius: 5px; background: #111; color: #fff; transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
:where(button, [role="button"], select, input, a):focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
#brand { display: flex; align-items: center; gap: 10px; }
#brand-logo {
  width: 34px; height: 34px; border-radius: 6px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
#brand-name { font-weight: 700; font-size: 16px; }
#brand-tagline { font-size: 11px; color: var(--text2); }
#topbar-actions { display: flex; align-items: center; gap: 8px; }
.locale-control select { padding: 6px 7px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; }
#price-pill {
  font-weight: 700; font-size: 18px; padding: 6px 14px;
  border-radius: 18px; background: #eef4f9; color: var(--primary-dark);
  min-width: 90px; text-align: center;
}

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f0f0f0; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: #eee; }
.btn.danger { color: var(--error); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.small.active { border-color: var(--primary); background: #eaf3fa; color: var(--primary-dark); }
.frame-placement-mode { display: flex; gap: 6px; margin: 0 0 6px; }
.placement-hint { margin: 0 0 10px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Layout ---------- */
#layout { display: flex; flex: 1; min-height: 0; }
#mobile-nav { display: none; }

/* ---------- Left panel ---------- */
#panel-left {
  width: 340px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
#category-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; border-bottom: 1px solid var(--border); }
.category-tab {
  flex: 1 1 30%; text-align: center; padding: 8px 4px; border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text2);
  border: 1px solid transparent; user-select: none;
}
.category-tab { background: transparent; font-family: inherit; }
.category-tab:hover { background: #f2f2f2; }
.category-tab.active { background: var(--primary); color: #fff; }
#filter-bar { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; }
.filter-select {
  max-width: 148px; padding: 5px 7px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px;
}
.filter-check { display: inline-flex; align-items: center; font-size: 12px; color: var(--text2); }
.filter-count { align-self: center; margin-left: auto; font-size: 11px; color: var(--text2); }
.filter-chip {
  padding: 5px 12px; border-radius: 14px; border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; user-select: none; color: var(--text2);
  background: var(--surface);
}
.filter-chip:hover { border-color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#product-list { flex: 1; padding: 10px; overflow-y: auto; }

.scrollable { overflow-y: auto; }
.scrollable::-webkit-scrollbar { width: 8px; }
.scrollable::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* Product cards */
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); margin: 14px 4px 8px; }
.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.product-card {
  border: 2px solid var(--border); border-radius: 8px; padding: 8px; cursor: pointer;
  background: var(--surface); display: flex; flex-direction: column; gap: 6px;
  transition: border-color .12s, transform .12s;
}
.product-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.product-card.selected { border-color: var(--selection); box-shadow: 0 0 0 2px rgba(0,88,163,.15); }
.product-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fafafa; border-radius: 4px; }
.product-card .p-name { font-size: 12px; font-weight: 600; line-height: 1.25; min-height: 30px; }
.product-card .p-meta { font-size: 11px; color: var(--text2); }
.product-card .p-price { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.product-card .p-colors { display: flex; gap: 4px; }
.product-card .p-facts { display: grid; gap: 2px; color: var(--text2); font-size: 10px; line-height: 1.35; }
.product-card .p-status {
  align-self: flex-start; padding: 2px 6px; border-radius: 10px;
  background: #e8f3eb; color: #176b35; font-size: 10px; font-weight: 700;
}
.product-card .p-status.included { background: #eef1f4; color: var(--text2); }
.color-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }

.empty-note { color: var(--text2); font-size: 13px; padding: 24px 8px; text-align: center; line-height: 1.5; }

/* ---------- Viewport ---------- */
#viewport { flex: 1; position: relative; min-width: 0; background: #e8ecf0; }
#canvas-holder { position: absolute; inset: 0; }
#canvas-holder canvas { display: block; }
#viewport-hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(17,17,17,.8); color: #fff; padding: 8px 18px; border-radius: 20px;
  border: 0; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; z-index: 3;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#viewport-hint:hover { background: var(--primary-dark); }
.drop-preview {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  max-width: 420px; padding: 9px 14px; border-radius: 18px; z-index: 4;
  background: rgba(22, 115, 62, .92); color: #fff; font-size: 12px;
  pointer-events: none; text-align: center;
}
.drop-preview.invalid { background: rgba(181, 38, 38, .94); }
#viewport.catalog-drop-valid { box-shadow: inset 0 0 0 4px rgba(22, 115, 62, .75); }
#viewport.catalog-drop-invalid { box-shadow: inset 0 0 0 4px rgba(181, 38, 38, .75); }
#loading-overlay {
  position: fixed; inset: 0; background: rgba(245,245,245,.96);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 1000;
}
.loading-card { width: min(100%, 360px); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
#loading-text { overflow-wrap: anywhere; }
#loading-progress { width: 100%; height: 12px; accent-color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .loading-card .spinner { animation: none; } }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Right panel ---------- */
#panel-right {
  width: 320px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
}
.validation-panel { padding: 10px; border-bottom: 1px solid var(--border); max-height: 230px; overflow-y: auto; }
.validation-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; }
.validation-list { display: grid; gap: 6px; margin-top: 7px; }
.validation-issue { padding: 7px 8px; border-left: 3px solid #bc2525; border-radius: 4px; background: #fff1f1; font-size: 11px; }
.validation-issue.warning { border-left-color: #b36b00; background: #fff8e8; }
.validation-code { display: block; margin-bottom: 2px; color: var(--text2); font-family: monospace; font-size: 10px; }
.validation-action { margin-top: 5px; padding: 3px 8px; border: 1px solid currentColor; border-radius: 4px; background: transparent; cursor: pointer; font-size: 11px; }
#inspector { flex: 1; padding: 14px; min-height: 0; }

.insp-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.insp-sub { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.insp-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.insp-row .label { color: var(--text2); }
.insp-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: 5px 14px; font-size: 12px; cursor: pointer; }
.seg button.active { background: var(--primary); color: #fff; }
.frame-list-item {
  display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 13px;
}
.frame-list-item:hover { background: #fafafa; }
.frame-list-item.selected { border-color: var(--primary); background: #f0f6fb; }
.frame-list-item .fl-size { font-weight: 700; }
.frame-list-item .fl-design { color: var(--text2); font-size: 12px; }
.frame-list-item .fl-del { margin-left: auto; color: var(--error); cursor: pointer; font-size: 16px; padding: 0 4px; border: 0; background: transparent; }
.sliding-composer {
  display: grid; gap: 9px; margin: 4px 0 14px; padding: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fafafa;
}
.composer-field, .composer-panel-grid label {
  display: grid; gap: 4px; color: var(--text2); font-size: 11px;
}
.sliding-composer select {
  min-width: 0; width: 100%; padding: 6px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff; color: var(--text);
}
.composer-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.interior-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #f2f2f2; font-size: 12px; }
.interior-row img { width: 34px; height: 34px; object-fit: contain; }
.interior-row .ir-name { flex: 1; line-height: 1.2; }
.move-btn { border: 1px solid var(--border); background: var(--surface); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.move-btn:hover { background: #eee; }

/* ---------- Summary ---------- */
#summary-panel { border-top: 1px solid var(--border); display: flex; flex-direction: column; max-height: 42%; }
#summary-header { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#summary-title { font-weight: 700; font-size: 14px; }
#summary-count { font-size: 12px; color: var(--text2); }
#summary-items { max-height: 220px; padding: 6px 14px; }
#summary-actions { padding: 10px 14px 12px; border-top: 1px solid var(--border); }
#summary-actions .btn { width: 100%; }
.summary-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; }
.summary-row .s-qty { width: 26px; text-align: center; font-weight: 700; color: var(--text2); }
.summary-row .s-name { flex: 1; line-height: 1.2; }
.summary-article-code { display: block; margin-top: 4px; color: var(--text2); font-size: 10px; letter-spacing: .01em; }
.summary-row .s-price { font-weight: 600; }
.summary-group-heading { padding: 12px 0 5px; font-size: 12px; font-weight: 700; color: var(--text2); }
.summary-row.included-component .s-price { color: var(--text2); font-weight: 400; }

/* ---------- HUD (measurements + selection toolbar) ---------- */
#hud-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#measure-layer { position: absolute; inset: 0; overflow: hidden; }
.measure-label {
  position: absolute; left: 0; top: 0;
  background: rgba(17, 17, 17, .92); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  white-space: nowrap; will-change: transform;
}
.measure-label.editable {
  background: rgb(0, 124, 200); pointer-events: auto; cursor: text;
}
.measure-label.editable:hover { filter: brightness(1.15); }
.measure-label.editable:focus-visible { outline: 2px solid #007cc8; outline-offset: 2px; }
.measure-input {
  width: 46px; border: none; border-radius: 8px; background: #fff;
  font: inherit; color: #111; text-align: center; padding: 0 2px; outline: none;
}

/* ---------- Viewport camera controls ---------- */
#viewport-controls {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 6px; z-index: 3;
}
#viewport-controls button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 15px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
#viewport-controls button:hover { background: #f0f0f0; }

#render-quality-control {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--text2); font-size: 12px;
}
#render-quality-control label { font-weight: 600; }
#render-quality {
  min-height: 30px; max-width: 160px; border: 0; border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}

/* ---------- Scene action toggles (bottom-left, like original) ---------- */
#scene-actions {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 6px; z-index: 3;
}
#scene-actions button {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 18px; padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--text2);
}
#scene-actions button:hover { background: #f0f0f0; }
#scene-actions button:disabled { opacity: .6; cursor: wait; }
#scene-actions button.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ---------- Room config popover (Customise room) ---------- */
#room-config {
  position: absolute; right: 0; bottom: 12px; left: 0;
  z-index: 3; text-align: center; pointer-events: none;
}
#btn-room, #room-popover { pointer-events: auto; }
#room-popover {
  position: fixed; top: 68px; bottom: 18px; left: 18px; transform: none;
  background: var(--surface); border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); width: 390px;
  overflow-y: auto; text-align: left;
}
#room-popover.hidden { display: none !important; }
/* swatch rows (room popover) */
.st-swatches { display: flex; gap: 5px; }
.st-swatches .color-dot { width: 18px; height: 18px; cursor: pointer; border-radius: 50%; }
.st-swatches .color-dot.active { outline: 2px solid var(--primary); }
#room-popover .st-swatches { justify-content: flex-start; }
#room-popover .st-swatches.wrap { flex-wrap: wrap; gap: 6px; }
#room-popover .color-dot { width: 24px; height: 24px; border: 1px solid rgba(0,0,0,.18); background-size: cover; }
#room-popover .color-dot.tile {
  background-image: none; /* texture set inline */
}
#room-popover .color-dot.active { outline: 2px solid var(--primary); outline-offset: 1px; }
#btn-room.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.room-editor-header, .room-editor-actions, .room-tool-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.room-editor-header { position: sticky; top: -12px; z-index: 2; background: var(--surface); padding: 12px 0 8px; }
#room-editor-status { color: var(--text2); font-size: 11px; }
.room-presets { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
.room-presets button { border: 1px solid var(--border); border-radius: 16px; background: #fff; padding: 5px 9px; cursor: pointer; }
.room-presets button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.room-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.room-fields label { color: var(--text2); font-size: 11px; }
.room-fields input { width: 100%; margin-top: 3px; padding: 6px; border: 1px solid var(--border); border-radius: 4px; }
.room-wall-target { display: grid; gap: 3px; color: var(--text2); font-size: 11px; margin: 5px 0; }
.room-wall-target select { width: 100%; padding: 7px; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: var(--text); }
.room-help { margin: 3px 0 7px; color: var(--text2); font-size: 11px; line-height: 1.35; }
.room-entity-list { max-height: 128px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; margin: 5px 0; }
.room-entity { display: grid; grid-template-columns: 1fr auto; gap: 5px; padding: 6px 8px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 12px; }
.room-entity:last-child { border-bottom: 0; }
.room-entity.selected { background: #eaf3fa; outline: 1px solid var(--primary); }
.room-entity input { width: 74px; padding: 3px; }
.room-tool-row { justify-content: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.room-validation { margin: 8px 0; color: var(--error); font-size: 12px; }
.room-validation .warning { color: #8a5a00; }
.room-editor-actions { position: sticky; bottom: -12px; background: var(--surface); padding: 10px 0 12px; justify-content: flex-end; }
.measure-label.room-dimension {
  background: rgb(0, 124, 200); font-size: 12px; padding: 3px 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.measure-label.room-dimension.depth { transform-origin: center; }
.selection-toolbar {
  position: absolute; left: 0; top: 0; z-index: 6; min-width: 210px;
  padding: 8px; border-radius: 8px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.22);
  pointer-events: auto; font-size: 12px;
}
.st-title { font-weight: 700; }
.st-dims { color: var(--text2); margin: 2px 0 6px; }
.st-actions { display: flex; gap: 5px; }
.st-btn { border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 3px 8px; cursor: pointer; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 22px; border-radius: 22px;
  font-size: 13px; z-index: 100; transition: opacity .3s;
}
#toast.error { background: var(--error); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .product-card.selected, .category-tab.active, .color-dot.active { outline: 2px solid SelectedItem; }
}

/* ---------- Responsive planner shell ---------- */
@media (max-width: 1100px) {
  #panel-left { width: 290px; }
  #panel-right { width: 270px; }
  #topbar { padding-inline: 10px; }
  #topbar-actions { gap: 3px; min-width: 0; }
  #topbar-actions .btn { padding-inline: 10px; }
  #price-pill { min-width: 76px; padding-inline: 9px; }
  .product-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  html, body { width: 100%; height: 100%; }
  #app { height: 100vh; height: 100dvh; }
  #topbar { height: 54px; min-height: 54px; gap: 8px; }
  #brand { flex: 0 0 auto; }
  #brand-logo { width: 31px; height: 31px; }
  #brand-tagline { display: none; }
  #brand-name { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  #topbar-actions { flex: 1; justify-content: flex-end; overflow-x: auto; scrollbar-width: none; }
  #topbar-actions::-webkit-scrollbar { display: none; }
  #topbar-actions > * { flex: 0 0 auto; }
  #topbar-actions .btn { padding: 7px 9px; font-size: 11px; }
  #btn-open-doors { display: none; }
  #price-pill { min-width: 68px; padding: 5px 8px; font-size: 15px; }

  #layout { position: relative; }
  #viewport, #panel-left, #panel-right { position: absolute; inset: 0; width: 100%; border: 0; }
  #viewport { display: none; }
  #panel-left, #panel-right { display: none; z-index: 8; }
  body[data-mobile-panel="catalog"] #panel-left { display: flex; }
  body[data-mobile-panel="design"] #viewport { display: block; }
  body[data-mobile-panel="summary"] #panel-right { display: flex; }
  #category-tabs { flex-wrap: nowrap; overflow-x: auto; padding: 8px; }
  .category-tab { flex: 0 0 auto; min-width: 88px; padding-inline: 10px; }
  #filter-bar { max-height: 116px; overflow-y: auto; }
  #product-list { padding-bottom: 24px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #summary-panel { max-height: 48%; }

  #mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); min-height: 58px;
    background: var(--surface); border-top: 1px solid var(--border); z-index: 20;
  }
  #mobile-nav button {
    border: 0; background: transparent; color: var(--text2); cursor: pointer;
    display: grid; place-items: center; align-content: center; gap: 2px; font-size: 19px;
  }
  #mobile-nav button span { font-size: 10px; font-weight: 700; }
  #mobile-nav button[aria-selected="true"] { color: var(--primary); background: #eef5fb; }

  #scene-actions { left: 8px; bottom: 8px; flex-direction: row; gap: 4px; }
  #scene-actions button { width: 37px; height: 37px; padding: 0; border-radius: 50%; font-size: 15px; }
  #scene-actions .scene-label { display: none; }
  #viewport-controls { right: 8px; bottom: 8px; flex-direction: row; }
  #render-quality-control { top: 64px; right: 8px; }
  #room-config { bottom: 54px; }
  #room-popover { inset: 8px; width: auto; border-radius: 12px; }
  .selection-toolbar { max-width: calc(100vw - 20px); }
  .drop-preview { bottom: 104px; width: calc(100% - 24px); }

}

@media (max-width: 390px) {
  #brand-name { display: none; }
  #topbar-actions .btn { padding-inline: 7px; }
  .product-grid { grid-template-columns: 1fr; }
  .room-fields { grid-template-columns: repeat(2, 1fr); }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px) {
  #topbar { height: 46px; min-height: 46px; }
  #mobile-nav { min-height: 48px; }
}

/* ---------- Configurator shell ---------- */

.sheet-eyebrow {
  color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}

.planner-shell { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.project-notice { flex: none; margin: 0; padding: 8px 16px; background: var(--surface); font-size: 12px; overflow-wrap: anywhere; }
.planner-shell #layout { position: relative; display: block; flex: 1; overflow: hidden; }
.planner-shell #viewport {
  position: absolute; inset: 0; display: block; width: 100%;
  transition: left .22s ease, width .22s ease;
}
.planner-sheet {
  position: absolute; z-index: 12; display: flex; flex-direction: column; background: var(--surface);
  box-shadow: 0 -12px 48px rgba(15, 24, 35, .18); transition: transform .22s ease, opacity .22s ease;
}
.catalog-sheet {
  top: 0; bottom: 0; left: 0; width: 360px; height: auto;
  border: 0; border-right: 1px solid var(--border); border-radius: 0;
  transform: translateX(calc(-100% - 24px)); pointer-events: none; opacity: 0;
  box-shadow: 12px 0 38px rgba(15, 24, 35, .16);
}
.planner-shell #panel-left.catalog-sheet { width: 360px; }
body[data-catalog-open="true"] .catalog-sheet { transform: translateX(0); pointer-events: auto; opacity: 1; }
body[data-catalog-open="true"] .planner-shell #viewport { left: 360px; width: calc(100% - 360px); }
.inspector-sheet {
  top: 16px; right: 16px; bottom: 76px; width: min(390px, calc(100% - 32px));
  border: 1px solid var(--border); border-radius: 18px; transform: translateX(calc(100% + 40px));
  pointer-events: none; opacity: 0;
}
body[data-inspector-open="true"] .inspector-sheet { transform: translateX(0); pointer-events: auto; opacity: 1; }
.sheet-grabber { display: none; width: 42px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: #c9c9c9; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px 12px; border-bottom: 1px solid var(--border); }
.sheet-header h2 { margin-top: 2px; font-size: 21px; }
.sheet-header-actions { display: flex; align-items: center; gap: 6px; }
.sheet-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; font-size: 26px; line-height: 1; }
.sheet-close:hover { background: var(--bg); }
.catalog-sheet #product-list { display: grid; align-content: start; flex: 1; padding: 12px 20px 20px; }
.catalog-sheet .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.catalog-sheet #filter-bar { padding-inline: 20px; }
body:not([data-advanced-catalog="true"]) .catalog-sheet #filter-bar { display: none !important; }
.guided-back { align-self: start; margin: 0 0 6px; border: 0; background: transparent; color: var(--primary); cursor: pointer; font: inherit; font-weight: 750; }
.guided-heading { margin: 2px 0 14px; }
.guided-heading h3 { margin-bottom: 5px; font-size: 20px; }
.guided-heading p { color: var(--text2); line-height: 1.45; }
.guided-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 10px; }
.guided-choice {
  display: flex; align-items: center; gap: 13px; min-height: 82px; padding: 16px;
  border: 2px solid var(--border); border-radius: 12px; background: #fff; color: var(--text);
  cursor: pointer; text-align: start; font: inherit;
}
.guided-choice:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, #fff); }
.guided-choice > span:not(.guided-swatch) { display: grid; gap: 4px; }
.guided-choice strong { font-size: 15px; }
.guided-choice small { color: var(--text2); font-size: 11px; }
.guided-swatch { flex: 0 0 auto; width: 34px; height: 34px; border: 1px solid rgba(0,0,0,.18); border-radius: 50%; }
.guided-alternatives { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.guided-alternatives .guided-choice { min-height: 66px; border-width: 1px; }
.guided-products { grid-template-columns: repeat(2, minmax(0, 1fr)); }

#category-tabs {
  position: absolute; z-index: 11; right: 50%; bottom: 12px; transform: translateX(50%);
  display: flex; flex-wrap: nowrap; gap: 6px; width: min(940px, calc(100% - 40px)); padding: 8px;
  overflow-x: auto; border: 1px solid var(--border); border-radius: 26px; background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 8px 28px rgba(15, 24, 35, .18); backdrop-filter: blur(12px); scrollbar-width: none;
}
#category-tabs::-webkit-scrollbar { display: none; }
#category-tabs .category-tab { flex: 1 0 auto; min-width: 96px; padding: 10px 14px; border-radius: 20px; }
#category-tabs .category-tab.active { background: var(--primary); }
body[data-catalog-open="true"] #category-tabs { right: 20px; left: 380px; transform: none; width: auto; }
.planner-shell #panel-right #inspector { flex: 1; }
.planner-shell #mobile-nav { display: none; }
.planner-shell #scene-actions { bottom: 78px; }
.planner-shell #viewport-controls { bottom: 78px; }
.planner-shell #room-config { bottom: 78px; }

.modal-layer { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(12, 18, 24, .62); backdrop-filter: blur(4px); }
.summary-dialog, .decision-dialog { width: min(820px, 100%); max-height: calc(100vh - 48px); overflow: hidden; border-radius: 22px; background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); }
.summary-dialog { display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 14px; border-bottom: 1px solid var(--border); }
.modal-header h1 { margin-top: 3px; font-size: 28px; }
.summary-total { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 24px; background: var(--bg); }
.summary-total strong { color: var(--primary-dark); font-size: 26px; }
.summary-dialog #summary-items { flex: 1; max-height: none; padding: 12px 24px; }
.summary-dialog .summary-row { padding: 10px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.summary-dialog #summary-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; padding: 16px 24px 22px; }
.summary-dialog #summary-actions .btn { width: auto; }
#summary-validation .validation-panel { max-height: 150px; }
.decision-dialog { padding: 30px; }
.decision-dialog h1 { margin: 6px 0 10px; font-size: 30px; }
.decision-dialog > p:not(.sheet-eyebrow) { color: var(--text2); line-height: 1.5; }
#cover-cap-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.cover-cap-option { padding: 14px; border: 2px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; text-align: start; }
.cover-cap-option.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, #fff); }
.decision-actions { display: flex; justify-content: end; gap: 8px; }

@media (max-width: 1100px) {
  .planner-shell #brand-tagline, .planner-shell .optional-action { display: none; }
  .planner-shell #topbar-actions { overflow: visible; }
  .planner-shell #panel-left.catalog-sheet { width: 330px; }
  body[data-catalog-open="true"] .planner-shell #viewport { left: 330px; width: calc(100% - 330px); }
  body[data-catalog-open="true"] #category-tabs { left: 342px; }
}

@media (max-width: 760px) {

  .planner-shell #topbar { padding-inline: 8px; }
  .planner-shell #brand-name { font-size: 13px; }
  .planner-shell #brand-logo { width: 30px; height: 30px; }
  .planner-shell .locale-control { display: none; }
  .planner-shell #topbar-actions { flex: 0 1 auto; overflow: visible; }
  .planner-shell #price-pill { min-width: 68px; padding-inline: 8px; font-size: 14px; }
  .planner-shell #btn-summary { padding-inline: 12px; }
  .planner-shell #layout { position: relative; }
  .planner-shell #viewport, .planner-shell #panel-left, .planner-shell #panel-right { position: absolute; display: flex; }
  .catalog-sheet {
    top: auto; right: 0; bottom: 64px; left: 0; width: auto; height: min(58vh, 480px);
    border: 1px solid var(--border); border-radius: 20px 20px 0 0;
    transform: translateY(calc(100% + 80px));
    box-shadow: 0 -12px 48px rgba(15, 24, 35, .18);
  }
  .planner-shell #panel-left.catalog-sheet {
    top: auto; right: 0; bottom: 64px; left: 0;
    width: auto; height: min(58vh, 480px);
  }
  body[data-catalog-open="true"] .catalog-sheet { transform: translateY(0); }
  body[data-catalog-open="true"] .planner-shell #viewport { left: 0; width: 100%; }
  .catalog-sheet .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guided-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guided-alternatives { grid-template-columns: 1fr; }
  .inspector-sheet { top: auto; right: 0; bottom: 64px; left: 0; width: 100%; height: min(58vh, 480px); border-radius: 20px 20px 0 0; transform: translateY(calc(100% + 80px)); }
  body[data-inspector-open="true"] .inspector-sheet { transform: translateY(0); }
  .sheet-grabber { display: block; }
  #category-tabs, body[data-catalog-open="true"] #category-tabs { right: 8px; bottom: 8px; left: 8px; transform: none; width: auto; }
  #category-tabs .category-tab { min-width: 90px; }
  .planner-shell #scene-actions { bottom: 72px; left: 8px; flex-direction: row; }
  .planner-shell #scene-actions .scene-label { display: none; }
  .planner-shell #scene-actions button { width: 36px; height: 36px; padding: 0; }
  .planner-shell #viewport-controls { right: 8px; bottom: 72px; flex-direction: row; }
  .planner-shell #room-config { bottom: 72px; }
  .summary-dialog, .decision-dialog { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .modal-layer { align-items: end; padding: 0; }
  .summary-dialog #summary-actions .btn { flex: 1 1 100%; }
  #cover-cap-options { grid-template-columns: 1fr; }
  .decision-actions { flex-direction: column-reverse; }
  .decision-actions .btn { width: 100%; }
  #room-popover { top: 58px; right: 8px; bottom: 74px; left: 8px; width: auto; }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px) {
  .catalog-sheet, .inspector-sheet { top: 6px; bottom: 58px; left: 50%; width: min(620px, calc(100% - 16px)); height: auto; transform: translate(-50%, calc(100% + 80px)); }
  body[data-catalog-open="true"] .catalog-sheet, body[data-inspector-open="true"] .inspector-sheet { transform: translate(-50%, 0); }
  body[data-catalog-open="true"] .planner-shell #viewport { left: 0; width: 100%; }
  .catalog-sheet .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #category-tabs, body[data-catalog-open="true"] #category-tabs { right: 8px; bottom: 5px; left: 8px; transform: none; width: auto; padding: 4px; }
  #category-tabs .category-tab { padding-block: 7px; }
  .planner-shell #scene-actions, .planner-shell #viewport-controls, .planner-shell #room-config { bottom: 58px; }
}

#technical-office-result { padding: 12px 20px; border-top: 1px solid var(--border, #dfdfdf); }
#technical-office-result ul { padding-inline-start: 20px; }
#technical-office-files { max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
#technical-office-files a { display: inline-block; padding: 4px 0; }
#summary-actions { flex-wrap: wrap; }

.customer-reference-dialog { width: min(540px, 100%); overflow: auto; }
.customer-reference-dialog .modal-header { padding: 0; border: 0; gap: 16px; }
.customer-reference-dialog h1 { font-size: 24px; }
.customer-reference-dialog label { display: block; margin: 20px 0 8px; font-weight: 700; }
#customer-reference-input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
#customer-reference-input[aria-invalid="true"] { border-color: var(--error, #c00); }
.customer-reference-dialog .field-error { min-height: 1.5em; color: var(--error, #c00); font-size: 14px; }
@media (max-width: 600px) { .customer-reference-dialog { width: 100%; } }

.suggestion-list { display: grid; gap: 8px; }
.suggestion-card .p-name { min-height: 0; line-height: 1.5; }
.suggestion-description { display: block; padding: 0 18px 16px; color: var(--text2); line-height: 1.5; }

/* RIMAL combinations and 128 mm fit guidance. */
.interior-presets { margin: 8px 0 16px; }
.interior-presets .insp-sub { margin: 0 2px 8px; }
.interior-presets-target { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-weight: 600; }
.interior-presets-notice { margin: 7px 2px 10px; color: var(--text2); font-size: 11px; }
.interior-presets-feedback { margin: 10px 2px 0; font-size: 12px; }
.interior-presets-feedback.error { color: var(--error, #a32727); }
.shelf-slot-row select { border: 1px solid var(--border); color: var(--text); background: var(--surface); border-radius: 6px; min-width: 0; padding: 5px; }
.interior-presets-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.interior-preset-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.interior-preset-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: contain; border-radius: 4px; }
.interior-preset-card strong { font-size: 12px; }
.interior-preset-card p { font-size: 11px; color: var(--text2); line-height: 1.4; margin: 0; flex: 1; }
.interior-preset-card .btn { min-height: 28px; }
.shelf-slot-row { gap: 8px; align-items: center; }
.shelf-slot-row select { width: min(230px, 64%); }
.interior-conflict-advice { padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.interior-conflict-advice strong, .interior-conflict-advice p { flex: 1 1 100%; margin: 0; }
.interior-conflict-advice p { font-size: 12px; color: var(--text2); }
@media (max-width: 440px) { .interior-presets-grid { grid-template-columns: 1fr; } }
