/* ==========================================================================
   Koko Materials · Room Visualizer
   ========================================================================== */
:root {
  --brand: #2c5aa0;
  --brand-dark: #1f4580;
  --brand-soft: #e8eef8;
  --accent: #f5e52a;
  --orange: #e0703a;
  --ink: #1d2433;
  --ink-2: #4b5363;
  --muted: #7a8190;
  --line: #e3e6eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --danger: #d93b3b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  background: none; font-weight: 500; font-size: 14.5px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible, .tool-btn:focus-visible, .chip:focus-visible, .seg:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(44, 90, 160, .3); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-outline { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-outline:hover { border-color: #c9ced6; }
.btn-outline.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn-outline-light { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-outline-light:hover { background: var(--bg); }
.btn-text { color: var(--ink); padding: 0 12px; }
.btn-text:hover { background: var(--bg); }
.btn-text.active { color: var(--brand); background: var(--brand-soft); }
.btn-ghost { color: var(--ink-2); background: var(--bg); }
.btn-ghost:hover { background: #eceef2; }
.btn-ghost.danger { color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-xl { height: 60px; font-size: 18px; font-weight: 600; width: 100%; border-radius: 8px; }
.btn-xl svg.lucide { width: 24px; height: 24px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.sm { width: 30px; height: 30px; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
}
.count-badge.red { background: var(--danger); }

/* ---------------------------------------------------------------- spinner / toast / modal */
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(44, 90, 160, .18); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1d2433; color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .5); display: none;
  align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal.open { display: flex; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; background: #fff; border-radius: 14px; padding: 26px; width: 520px; max-width: 100%;
  max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow-lg);
}
.modal-sm { width: 400px; text-align: center; }
.modal-lg { width: 980px; }
.modal-card h3 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.modal-card > p { margin: 0 0 18px; font-size: 14px; }
.modal-x { position: absolute; right: 14px; top: 14px; border: 0; background: none; padding: 6px; border-radius: 6px; color: var(--muted); }
.modal-x:hover { background: var(--bg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label, .ed-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid input, .form-grid textarea, .ed-field input, .ed-field select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px; background: #fff; font-weight: 400; color: var(--ink);
}
.form-grid input:focus, .form-grid textarea:focus, .ed-field input:focus, .ed-field select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.page-loader { position: fixed; inset: 0; background: rgba(255, 255, 255, .85); display: grid; place-content: center; justify-items: center; gap: 12px; z-index: 150; }

/* ==========================================================================
   Room select
   ========================================================================== */
.select-wrap { max-width: 1760px; margin: 0 auto; padding: 24px 96px 40px; }
.select-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 48px; align-items: start; }
.select-intro { max-width: 470px; }
.select-intro h1 { font-size: 32px; line-height: 1.5; font-weight: 500; margin: 0 0 24px; }
.accent { color: var(--brand); }
.select-points { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; font-size: 18px; }
.select-points li { display: flex; align-items: center; gap: 10px; }
.select-points svg.lucide { width: 22px; height: 22px; }
.upload-note { margin: 12px 0 0; font-size: 14px; }
.btn-xl[disabled] { opacity: .6; cursor: not-allowed; }
a.btn-xl { display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn-qr { margin-top: 24px; height: 54px; font-size: 16px; font-weight: 400; box-shadow: none; }
.select-illustration { border-radius: 12px; overflow: hidden; background: #e9eaec; box-shadow: var(--shadow); }
.illus { width: 100%; height: auto; display: block; }
.section-title { font-size: 20px; font-weight: 500; color: var(--ink-2); margin: 36px 0 18px; }

/* illustration animation: cursor picks a swatch, taps the wall and the floor */
.illus .cursor { animation: cursor 7s ease-in-out infinite; }
@keyframes cursor {
  0%, 8% { transform: translate(250px, 70px); }
  20%, 28% { transform: translate(98px, 160px); }
  42%, 50% { transform: translate(458px, 110px); }
  64%, 72% { transform: translate(610px, 286px); }
  90%, 100% { transform: translate(250px, 70px); }
}
.illus .illus-floor-tiles { opacity: 0; animation: floorOn 7s infinite; }
@keyframes floorOn { 0%, 66% { opacity: 0; } 72%, 94% { opacity: 1; } 100% { opacity: 0; } }
.illus .sw2 { animation: swPick 7s infinite; }
@keyframes swPick { 0%, 20% { stroke: #fff; } 24%, 90% { stroke: var(--orange); } 100% { stroke: #fff; } }
.illus .hot .tick { opacity: 0; }
.illus .hot-wall .tick { animation: tickW 7s infinite; }
.illus .hot-floor .tick { animation: tickF 7s infinite; }
@keyframes tickW { 0%, 46% { opacity: 0; } 50%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tickF { 0%, 68% { opacity: 0; } 72%, 94% { opacity: 1; } 100% { opacity: 0; } }
.illus .done { animation: done 7s infinite; transform-origin: 530px 60px; }
@keyframes done { 0%, 74% { opacity: 0; transform: scale(.6); } 80%, 94% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .illus * { animation: none !important; }
  .illus .illus-floor-tiles, .illus .hot .tick, .illus .done { opacity: 1; }
  .illus .cursor { transform: translate(458px, 110px); }
}

.demo-rooms { background: #eef0f3; border-radius: 12px; padding: 12px 16px 20px; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: none; padding: 12px 24px; font-size: 17px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; font-size: 15.5px; color: var(--ink);
}
.chip:hover { border-color: #c9ced6; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.room-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.room-grid.small { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
.room-card {
  position: relative; display: block; border-radius: 6px; overflow: hidden; aspect-ratio: 5 / 3;
  background: #dfe2e6; box-shadow: var(--shadow); text-decoration: none;
}
.room-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.room-card:hover img { transform: scale(1.04); }
.room-card-label {
  position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .95); color: var(--ink); padding: 5px 10px; border-radius: 6px; font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(6px); transition: .2s;
}
.room-card:hover .room-card-label, .room-card:focus-visible .room-card-label { opacity: 1; transform: none; }
.room-card.current { outline: 3px solid var(--brand); outline-offset: -3px; }
.room-card.current .room-card-label { opacity: 1; transform: none; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.my-rooms .room-card-label { opacity: 1; transform: none; }
.select-footer { display: flex; justify-content: center; padding: 10px 0 28px; }
.select-footer img { height: 48px; width: auto; object-fit: contain; }
.qr-box { display: grid; place-items: center; min-height: 216px; margin: 8px auto; }
.qr-box img, .qr-box canvas { padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.qr-status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.qr-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ==========================================================================
   Visualizer
   ========================================================================== */
.page-viz { height: 100vh; overflow: hidden; }
.viz { display: grid; grid-template-columns: 318px minmax(0, 1fr); height: 100vh; }

/* sidebar */
.side { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 8px 8px 0; position: relative; }
.side-logo { display: flex; justify-content: center; padding: 4px 0 10px; }
.side-logo img { height: 52px; width: auto; }
.surface-toggle { display: grid; gap: 10px; margin-bottom: 12px; }
.seg {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; font-size: 15px;
}
.seg.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.seg { min-width: 0; padding: 0 4px; white-space: nowrap; }
/* Four tabs do not fit side by side with icon and label in a row: icon on top. */
.surface-toggle.many { gap: 6px; }
.surface-toggle.many .seg { flex-direction: column; gap: 2px; height: 54px; font-size: 13px; }
.surface-toggle.many .seg svg.lucide { width: 18px; height: 18px; }
.side-tools { display: grid; grid-template-columns: 48px 1fr 48px auto; gap: 8px; margin-bottom: 8px; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; min-width: 40px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 15px; position: relative;
}
.tool-btn:hover { background: var(--bg); }
.tool-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tool-btn .count-badge { position: absolute; top: -6px; right: -6px; }
#favBtn svg { color: var(--danger); }
#favBtn.on { background: #fdecec; border-color: #f3b4b4; }
#favBtn.on svg { fill: var(--danger); }
.view-toggle { display: flex; }
.view-toggle .tool-btn { border-radius: 0; width: 40px; }
.view-toggle .tool-btn:first-child { border-radius: 6px 0 0 6px; }
.view-toggle .tool-btn:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.search-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; margin-bottom: 8px; }
.search-row input { border: 0; outline: 0; height: 38px; flex: 1; min-width: 0; font-size: 14px; background: none; }
.filter-panel {
  position: absolute; left: 8px; right: 8px; top: 170px; z-index: 30; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 14px; max-height: calc(100vh - 200px); overflow: auto;
}
.filter-group { margin-bottom: 12px; }
.filter-group h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.filter-options { display: grid; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; cursor: pointer; }
.check em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 12px; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.filter-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sort-row { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; border-bottom: 1px solid var(--line); color: var(--ink-2); position: relative; }
.sort-row select { appearance: none; border: 0; background: none; flex: 1; font-size: 14.5px; padding: 4px 24px 4px 0; cursor: pointer; }
.sort-row .sort-caret { position: absolute; right: 4px; pointer-events: none; }
.product-list { flex: 1; overflow-y: auto; padding: 8px 2px 16px; display: grid; gap: 10px; align-content: start; }
.product-list[data-view="grid"] { grid-template-columns: 1fr 1fr; }
.p-card {
  display: grid; grid-template-columns: 100px 1fr; gap: 10px; padding: 7px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s; outline: none;
}
.p-card:hover, .p-card:focus-visible { border-color: #b9c0cb; box-shadow: var(--shadow); }
.p-card.selected { border: 2px solid #5b6270; padding: 6px; }
.p-thumb { position: relative; width: 100px; height: 100px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.p-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fav {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(120, 124, 132, .75); color: #fff; display: grid; place-items: center; padding: 0;
}
.fav svg.lucide { width: 15px; height: 15px; fill: #fff; }
.fav.on { background: #fff; }
.fav.on svg.lucide { color: var(--danger); fill: var(--danger); }
.p-info { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--ink-2); min-width: 0; padding-top: 4px; }
.p-info b { font-size: 13.5px; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.p-more {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; font-size: 12.5px; color: var(--ink-2); text-decoration: none;
}
.p-more:hover { color: var(--brand); }
.p-more svg.lucide { width: 15px; height: 15px; }
.product-list[data-view="grid"] .p-card { grid-template-columns: 1fr; gap: 6px; }
.product-list[data-view="grid"] .p-thumb { width: 100%; height: auto; aspect-ratio: 1; }
.product-list[data-view="grid"] .p-info span { display: none; }
.product-list[data-view="grid"] .p-info b { white-space: nowrap; font-size: 12.5px; }
.product-list[data-view="grid"] .p-more { font-size: 11.5px; }
.empty-list { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty-list svg.lucide { width: 32px; height: 32px; }

/* stage */
.stage-wrap { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0 12px; min-width: 0; height: 100vh; gap: 8px; }
.topbar {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 0 0 8px 8px; padding: 8px 10px; box-shadow: var(--shadow);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.menu { position: relative; border-left: 1px solid var(--line); padding-left: 6px; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 230px; z-index: 40; display: grid;
}
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 10px 12px;
  border-radius: 6px; font-size: 14px; color: var(--ink); text-decoration: none;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--bg); }
.menu-pop .count-badge { margin-left: auto; }
.stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.canvas-box { position: relative; box-shadow: var(--shadow); background: #ddd; }
.canvas-box canvas { width: 100%; height: 100%; display: block; }
.compare-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; cursor: ew-resize; user-select: none; -webkit-user-drag: none; }
.compare-handle {
  position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #fff; cursor: ew-resize;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}
.compare-handle span {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); color: var(--brand);
}
.compare-tags { position: absolute; inset: 12px 12px auto; display: flex; justify-content: space-between; pointer-events: none; }
.compare-tags span { background: rgba(29, 36, 51, .75); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 20px; }
.stage-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px;
  background: rgba(29, 36, 51, .72); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 20px; pointer-events: none;
  max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-hint svg.lucide { width: 15px; height: 15px; }
.powered {
  position: absolute; right: 8px; bottom: 8px; background: rgba(255, 255, 255, .92); border-radius: 4px; padding: 3px 8px;
  font-size: 11.5px; color: var(--muted);
}
.powered b { color: var(--brand); }
.stage-loader { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246, 247, 249, .7); text-align: center; }
.stage-loader.soft { background: none; pointer-events: none; }
.stage-loader .err { max-width: 420px; background: #fff; padding: 18px; border-radius: 10px; box-shadow: var(--shadow); }

/* bottom bar */
.bottombar {
  position: relative; display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 8px 8px 0 0;
  padding: 6px 10px; box-shadow: var(--shadow); min-height: 58px;
}
.applied-chip { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 4px 10px 4px 2px; border-right: 1px solid var(--line); text-align: left; }
.applied-chip:hover { background: var(--bg); border-radius: 6px; }
.layers { position: relative; }
.layers svg.lucide { width: 24px; height: 24px; }
.layers .count-badge { position: absolute; top: -8px; right: -8px; }
.applied-text { display: flex; flex-direction: column; line-height: 1.25; }
.applied-text small { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.applied-text b { font-size: 13.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-i { color: var(--muted); }
.bottom-actions { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pop {
  position: absolute; bottom: calc(100% + 10px); right: 10px; width: 330px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 16px; z-index: 40;
}
.pop-wide { width: 420px; }
.pop-left { left: 10px; right: auto; }
.pop h4 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.pop h4 small { font-weight: 400; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.swatch { aspect-ratio: 1; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .12); background: var(--c); }
.swatch.active { outline: 3px solid var(--brand); outline-offset: 2px; }
.range { display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.range b { justify-self: end; margin-top: -24px; color: var(--ink); font-weight: 500; }
.range input { accent-color: var(--brand); width: 100%; }
.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.layout-btn {
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 11px; color: var(--ink-2);
}
.layout-btn:hover { border-color: #c9ced6; }
.layout-btn.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.layout-ico { width: 42px; height: 38px; }
.layout-ico rect { fill: #cfd6e2; stroke: #fff; stroke-width: 1; }
.layout-ico rect.alt { fill: #a9b6cc; }
.layout-btn.active .layout-ico rect { fill: #9fb6dd; }
.layout-btn.active .layout-ico rect.alt { fill: #6f90c8; }
.applied-list { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.applied-row { display: grid; grid-template-columns: 48px 1fr auto auto; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.applied-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
.applied-row div { display: flex; flex-direction: column; font-size: 12.5px; min-width: 0; }
.applied-row small { color: var(--muted); }
.applied-row b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.applied-row span { color: var(--ink-2); }
.info-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; }
.info-card img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; }
.info-card div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); }
.info-card b { font-size: 14.5px; color: var(--ink); }
.info-card a { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-weight: 500; text-decoration: none; }
.info-card a svg.lucide { width: 14px; height: 14px; }
.selection-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.sel-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sel-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.sel-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); }
.sel-body b { color: var(--ink); font-size: 14.5px; }
.sel-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ==========================================================================
   Editor
   ========================================================================== */
.page-editor { height: 100vh; overflow: hidden; }
.editor { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100vh; }
.ed-side { background: #fff; border-right: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.ed-head { display: flex; align-items: center; gap: 12px; }
.ed-logo { height: 40px; width: auto; }
.ed-side h2 { font-size: 19px; margin: 4px 0 0; font-weight: 600; }
.ed-steps { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink-2); display: grid; gap: 6px; }
.ed-surfaces { display: grid; gap: 6px; }
.ed-surface {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: left; font-size: 14px;
}
.ed-surface.active { border-color: var(--brand); background: var(--brand-soft); }
.ed-surface small { margin-left: auto; color: var(--muted); font-size: 12px; }
.ed-surface .dot { width: 10px; height: 10px; border-radius: 50%; }
.ed-add { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-props { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.ed-props:empty { display: none; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-foot { margin-top: auto; display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; padding-top: 12px; position: sticky; bottom: 0; background: #fff; }
.ed-main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; background: #1f2327; }
.ed-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #2a2f35; flex-wrap: wrap; }
.ed-toolbar.disabled .tool { opacity: .4; pointer-events: none; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 6px; border: 1px solid #454c55; background: #343a41; color: #e8eaed; font-size: 13.5px; }
.tool:hover { background: #3d444c; }
.tool.active { background: var(--brand); border-color: var(--brand); }
.ed-tip { color: #c5cad1; font-size: 13px; margin-left: 8px; }
.ed-stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; }
#edCanvas { position: absolute; inset: 0; cursor: crosshair; }
#previewCanvas { box-shadow: var(--shadow-lg); }

/* ==========================================================================
   Mobile upload page
   ========================================================================== */
.page-mobile { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.mobile-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.mobile-logo { height: 56px; width: auto; margin: 0 auto 16px; }
.mobile-card h1 { font-size: 21px; font-weight: 600; margin: 0 0 8px; }
.mobile-card p { font-size: 14px; }
.mobile-done svg.lucide { width: 56px; height: 56px; color: #22a06b; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
  .select-wrap { padding: 20px 32px 32px; }
  .topbar .btn-text, .bottom-actions .btn-text { padding: 0 8px; font-size: 13.5px; }
}
@media (max-width: 1080px) {
  .select-hero { grid-template-columns: 1fr; }
  .select-intro { max-width: none; }
  .room-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .viz { grid-template-columns: 280px minmax(0, 1fr); }
  .topbar-right .btn span, .bottom-actions .btn { font-size: 0; gap: 0; }
  .bottom-actions .btn svg.lucide, .topbar-right .btn svg.lucide { width: 20px; height: 20px; }
  .topbar-right .btn { font-size: 0; gap: 0; padding: 0 10px; }
}
@media (max-width: 760px) {
  .select-wrap { padding: 16px; }
  .select-intro h1 { font-size: 24px; }
  .select-points { font-size: 16px; }
  .room-grid, .room-grid.small { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .room-card-label { opacity: 1; transform: none; font-size: 12px; }
  .chip { height: 36px; font-size: 14px; }

  .page-viz { height: auto; overflow: auto; }
  .viz { display: flex; flex-direction: column-reverse; height: auto; }
  .stage-wrap { height: auto; padding: 0 8px; }
  .stage { height: 62vw; min-height: 240px; }
  .side { border-right: 0; border-top: 1px solid var(--line); max-height: none; }
  .side-logo { display: none; }
  .product-list { overflow: visible; }
  .filter-panel { position: fixed; top: auto; bottom: 0; left: 0; right: 0; border-radius: 16px 16px 0 0; max-height: 75vh; }
  .applied-text b { max-width: 110px; }
  .pop, .pop-wide { position: fixed; left: 8px; right: 8px; bottom: 76px; width: auto; }
  .stage-hint { font-size: 11.5px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }

  .page-editor { height: auto; overflow: auto; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .ed-main { height: 70vh; order: -1; }
}
.ed-grid > label, .ed-field { min-width: 0; }
.ed-field input, .ed-field select { width: 100%; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.page-loader p { margin: 0; text-align: center; max-width: 320px; }

/* ---- Fixtures (Gemini) ------------------------------------------------- */
/* The fixture layer sits on the tiled room: the "empty" patch where the old
   fixture was, then the chosen product. Clicks go to the outlines below. */
.fix-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fix-hit { position: absolute; inset: 0; width: 100%; height: 100%; }
.fix-hit polygon { fill: rgba(44, 90, 160, 0); stroke: rgba(255, 255, 255, .0); stroke-width: .003; cursor: pointer; transition: fill .15s; vector-effect: non-scaling-stroke; }
.fix-hit polygon:hover { fill: rgba(44, 90, 160, .18); stroke: #fff; stroke-width: 2; }
.fix-hit polygon.sel { fill: rgba(44, 90, 160, .22); stroke: #2c5aa0; stroke-width: 2.5; stroke-dasharray: 6 4; }
.seg .seg-spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
.fix-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 10px; }
.fix-pick .chip { height: 32px; padding: 0 10px; font-size: 13px; }
.fix-note { font-size: 12.5px; color: var(--muted); padding: 2px 4px 10px; line-height: 1.45; }
.fix-note b { color: var(--text, #1f2937); }
.p-card .p-kind { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef3fb; color: #2c5aa0; width: fit-content; }
.p-sub { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 2px 4px; text-transform: uppercase; letter-spacing: .04em; }
.fix-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 2px 10px; }
.fix-tools .tool-btn { padding: 0 9px; height: 30px; font-size: 12.5px; }

/* ---- Make it realistic --------------------------------------------------- */
.btn-real { background: linear-gradient(135deg, #7c3aed, #2c5aa0); border: 0; color: #fff; }
.btn-real:hover { filter: brightness(1.08); color: #fff; }
.real-view { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246, 247, 249, .96); z-index: 20; padding: 10px; }
/* Sized to the stage, not to the picture: a percentage max-height does not hold in an
   auto-height grid row, so a tall render ran off the bottom. */
.real-frame { position: absolute; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.real-frame > #realImg { display: block; width: 100%; height: 100%; }
.real-loading { display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--muted); }
.real-loading b { color: #1f2937; font-size: 16px; }
.real-bar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: #fff; padding: 6px 8px 6px 14px; border-radius: 30px; box-shadow: var(--shadow); }
.real-tag { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; color: #7c3aed; }
.real-tag svg.lucide { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
