:root {
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #1c1d1f;
  --ink-2: #55585e;
  --muted: #8a8d93;
  --line: #e8e4de;
  --soft: #f3f0eb;
  --accent: #e4572e;
  --accent-2: #c9471f;
  --accent-soft: #fde9e2;
  --teal: #1f4e5a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 8px 24px rgba(20, 20, 20, .06);
  --left: 300px;
  --right: 320px;
  --top: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.small { font-size: 12px; }

.app { display: grid; grid-template-columns: var(--left) 1fr var(--right); grid-template-rows: var(--top) 1fr; height: 100vh; height: 100dvh; }

/* top bar */
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.mark svg { width: 34px; height: 34px; }
.mark rect { fill: var(--accent); stroke: none; }
.mark path { stroke: #fff; stroke-width: 2.4; }
.mark .core { fill: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; font-weight: 800; letter-spacing: -.01em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }
.modes { margin: 0 auto; display: flex; background: var(--soft); border-radius: 999px; padding: 4px; }
.modes button { padding: 8px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: background .2s, color .2s; }
.modes button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(228, 87, 46, .35); }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 250px; justify-content: flex-end; }
.ghost { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.ghost:hover { background: var(--soft); }
.primary { background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; transition: background .15s; }
.primary:hover { background: var(--accent-2); }
.q-total { background: rgba(255, 255, 255, .2); padding: 2px 8px; border-radius: 999px; font-size: 12.5px; }
.q-total:empty { display: none; }

/* panels */
.panel { background: var(--panel); overflow-y: auto; padding: 18px; scrollbar-width: thin; }
.panel.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.panel.right { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; background: #fbfaf8; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { flex: 1; padding: 9px 10px; border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s; }
.pills button.on { background: var(--accent); color: #fff; }
.pills.small button { padding: 7px 8px; font-size: 12.5px; }
.panel-note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.designs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.design { display: flex; flex-direction: column; gap: 5px; text-align: left; }
.design .sw { aspect-ratio: 1; border-radius: 12px; background-size: cover; background-position: center; border: 2px solid transparent; outline: 1px solid var(--line); transition: transform .15s, border-color .15s; }
.design:hover .sw { transform: translateY(-1px); }
.design.on .sw { border-color: var(--accent); outline-color: transparent; box-shadow: 0 0 0 3px var(--accent-soft); }
.design span { font-size: 11.5px; font-weight: 600; color: var(--ink-2); line-height: 1.2; }
.design.upload .sw { display: grid; place-items: center; background: var(--soft); border: 2px dashed #d8d2c8; outline: none; color: var(--muted); font-size: 26px; font-weight: 300; }
.add-print { margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 13px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; font-size: 15px; }
.add-print .plus { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 20px; line-height: 1; }
.add-print:hover { background: #fbdcd1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card h3 { margin: 0; font-size: 14px; font-weight: 800; }
.tag { font-size: 11px; font-weight: 700; color: var(--accent-2); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; }
.tag:empty { display: none; }
.sel-name { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sel-name img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.sel-name strong { display: block; font-size: 14px; }
.sel-name span { font-size: 12px; color: var(--muted); }
.field { margin: 8px 0 10px; }
.field label, label.sub { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
label.sub { margin: 12px 0 6px; }
output { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--p, 50%), #e7e2da var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: #e7e2da; }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); margin-top: -7px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); }
input.kelvin::-webkit-slider-runnable-track { background: linear-gradient(to right, #ffae5c, #fff3e2, #cfe2ff); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.row-btns { display: flex; gap: 8px; margin-top: 6px; }
.row-btns.col { flex-direction: column; }
.soft { background: var(--soft); padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 600; flex: 1; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.soft:hover { background: #ebe6de; }
.soft.danger { color: #b3261e; }
.soft.wide, .primary.wide { width: 100%; justify-content: center; }

.layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.layers li { display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.layers li:hover { background: var(--soft); }
.layers li.on { background: var(--accent-soft); border-color: #f6c7b7; }
.layers img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.layers .l-txt { flex: 1; min-width: 0; }
.layers .l-txt strong { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layers .l-txt span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.layers button { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); }
.layers button:hover { background: #fff; }
.layers li.off .l-txt, .layers li.off img { opacity: .45; }
.layers .empty { color: var(--muted); font-size: 13px; cursor: default; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.bg-grid button { aspect-ratio: 4/3; border-radius: 10px; background-size: cover; background-position: center; border: 2px solid transparent; outline: 1px solid var(--line); }
.bg-grid button.on { border-color: var(--accent); }
.bg-grid .up { display: grid; place-items: center; background: var(--soft); outline: none; border: 2px dashed #d8d2c8; font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.2; }
.wall-size { display: flex; gap: 8px; margin: 8px 0; }
.wall-size label { flex: 1; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.wall-size input { width: 100%; margin-top: 4px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 9px; }

/* stage */
.stage { position: relative; overflow: hidden; background: #d9d4cc; }
.view { position: absolute; inset: 0; }
.view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#viewPhoto { background: #111; }
.photo-handles { position: absolute; inset: 0; pointer-events: none; }
.handle { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); pointer-events: auto; cursor: grab; touch-action: none; }
.handle.wall { border-color: #2aa7a0; }
.handle:active { cursor: grabbing; transform: scale(1.15); }
.dim-label { position: absolute; transform: translate(-50%, -100%); background: #fff; color: var(--ink); font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); pointer-events: none; white-space: nowrap; z-index: 3; }
.stage-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(28, 29, 31, .78); color: #fff; font-size: 12.5px; font-weight: 500; padding: 8px 14px; border-radius: 999px; backdrop-filter: blur(6px); pointer-events: none; transition: opacity .4s; white-space: nowrap; }
.stage-tools { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; }
.stage-tools button { width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--ink); }
.stage-tools button:hover { background: #fff; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #fff; background: #16181b; }
.stage-msg div { max-width: 380px; }
.stage-msg h3 { margin: 0 0 8px; font-size: 18px; }
.stage-msg p { margin: 0 0 16px; color: #c9ccd1; font-size: 14px; line-height: 1.5; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: #efebe5; color: var(--ink-2); font-size: 14px; font-weight: 600; z-index: 4; transition: opacity .4s; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #e4ddd3; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20, 20, 22, .5); display: grid; place-items: center; z-index: 20; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { position: relative; background: #fff; border-radius: 20px; width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.small-card { width: min(420px, 100%); }
.modal h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.01em; }
.close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; color: var(--muted); }
.close:hover { background: var(--soft); }
.quote-table { width: 100%; border-collapse: collapse; margin: 14px 0 8px; font-size: 13px; }
.quote-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.quote-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.quote-table td:last-child, .quote-table th:last-child { text-align: right; }
.quote-table tfoot td { font-weight: 800; border: 0; font-size: 14px; }
.rates summary { font-size: 12.5px; color: var(--ink-2); font-weight: 600; cursor: pointer; margin-bottom: 8px; }
.rates div { display: flex; gap: 8px; }
.rates label { flex: 1; font-size: 11.5px; color: var(--muted); }
.rates input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-top: 3px; }
.quote-shot { width: 100%; border-radius: 12px; margin: 10px 0 14px; display: block; aspect-ratio: 16/9; object-fit: cover; background: var(--soft); }
#leadForm label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
#leadForm input, #leadForm textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfbf9; }
#leadForm input:focus, #leadForm textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.two { display: flex; gap: 10px; }
.two label { flex: 1; }
.done { text-align: center; padding: 20px 0 6px; }
.tick { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 32px; font-weight: 700; }
.done p { margin: 0 auto 18px; max-width: 380px; }

.toast { position: fixed; left: 50%; top: 78px; transform: translate(-50%, -12px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* WebXR overlay */
.xr-overlay { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; pointer-events: none; z-index: 50; }
.xr-overlay > * { pointer-events: auto; }
.xr-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: rgba(0, 0, 0, .55); color: #fff; padding: 10px 12px; border-radius: 14px; font-size: 14px; }
.xr-top .soft { flex: 0; }
.xr-bottom { display: flex; gap: 10px; justify-content: center; }
.xr-bottom .soft { flex: 0 0 52px; font-size: 24px; }
.xr-bottom .primary { padding: 14px 26px; font-size: 16px; }

.sheet-tabs { display: none; }

/* phones and small tablets: stage on top, panels become a bottom sheet */
@media (max-width: 900px) {
  :root { --top: 56px; }
  body { overflow: hidden; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top) 52vh auto 1fr; grid-template-rows: var(--top) 52dvh auto 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand { min-width: 0; }
  .brand-text span { display: none; }
  .brand-text strong { font-size: 14px; }
  .top-actions { min-width: 0; gap: 4px; }
  .top-actions .ghost span, .q-label { display: none; }
  .ghost { padding: 8px; }
  .primary#btnQuote { padding: 8px 12px; }
  .q-total { background: none; padding: 0; font-size: 13px; }
  .q-total:empty::before { content: 'Quote'; }
  .q-total:empty { display: inline; }
  .modes { position: absolute; top: calc(var(--top) + 10px); left: 50%; transform: translateX(-50%); z-index: 6; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); }
  .modes button { padding: 7px 13px; font-size: 12.5px; white-space: nowrap; }
  .stage { grid-row: 2; }
  .sheet-tabs { grid-row: 3; display: flex; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 8px; gap: 4px; }
  .sheet-tabs button { flex: 1; padding: 8px 4px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
  .sheet-tabs button.on { background: var(--accent); color: #fff; }
  .panel { grid-row: 4; grid-column: 1; border: 0 !important; padding: 14px 16px 24px; }
  .panel.right { background: var(--panel); }
  .panel.right .card { box-shadow: none; }
  .app[data-sheet="left"] .panel.right { display: none; }
  .app:not([data-sheet="left"]) .panel.left { display: none; }
  .app[data-sheet="adjust"] .panel.right > .card:not(#cardSelected),
  .app[data-sheet="layers"] .panel.right > .card:not(:nth-child(2)),
  .app[data-sheet="scene"] .panel.right > .card:not(#cardScene) { display: none; }
  .designs { grid-template-columns: repeat(4, 1fr); }
  .add-print { position: sticky; bottom: 0; margin-top: 8px; box-shadow: 0 -8px 16px #fff; }
  .stage-hint { bottom: 10px; font-size: 11.5px; white-space: normal; width: max-content; max-width: calc(100% - 32px); text-align: center; }
  .stage-tools { top: 58px; right: 10px; }
  .toast { top: 64px; }
}
@media (max-width: 380px) {
  .designs { grid-template-columns: repeat(3, 1fr); }
  .brand-text strong { font-size: 13px; }
}
