:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --ink: #14161b;
  --ink-2: #4b5160;
  --muted: #8a8f99;
  --line: #ebe8e2;
  --line-2: #f2f0eb;
  --accent: #2f5d7c;      /* deeper take on their blue */
  --accent-2: #538db3;    /* their blue */
  --font: 'Manrope', system-ui, sans-serif;
  --top-h: 60px;
  --panel-w: 452px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 500 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30; display: flex; align-items: center; gap: 14px; padding: 0 26px; background: rgba(245,243,239,.85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.brand-sub { font-weight: 500; font-size: 14px; color: var(--muted); }
.pill { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; color: var(--accent); background: rgba(47,93,124,.08); }
.ghost { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 8px 15px; font-size: 13px; font-weight: 600; transition: border-color .2s; }
.ghost:hover { border-color: #d6d1c8; }
.ghost svg { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.layout { position: fixed; inset: var(--top-h) 0 0 0; display: grid; grid-template-columns: 1fr var(--panel-w); }

/* ---------- stage ---------- */
.stage { position: relative; overflow: hidden; background: radial-gradient(90% 75% at 50% 42%, #ffffff 0%, #f1eee8 55%, #e4dfd6 100%); }
.stage::after { content: ''; position: absolute; left: 50%; bottom: 7%; width: 60%; height: 18%; transform: translateX(-50%); background: radial-gradient(closest-side, rgba(80,70,55,.10), transparent); pointer-events: none; }
model-viewer { position: absolute; inset: 0; width: 100%; height: 100%; --poster-color: transparent; --progress-bar-color: transparent; z-index: 1; outline: none; }
.stage.painting model-viewer { cursor: crosshair; }
.powered { position: absolute; top: 22px; left: 26px; z-index: 4; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; border-radius: 99px; background: var(--ink); color: #fff; text-decoration: none; font-size: 13px; font-weight: 500; box-shadow: 0 10px 28px rgba(20,22,27,.25); transition: transform .2s var(--ease); }
.powered:hover { transform: translateY(-1px); }
.powered span:nth-child(2) { opacity: .7; }
.powered strong { font-weight: 700; }
.powered svg { width: 12px; height: 12px; opacity: .8; }
.powered-dot { width: 7px; height: 7px; border-radius: 50%; background: #f3c81d; box-shadow: 0 0 0 3px rgba(243,200,29,.28); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(243,200,29,0); } }
.stage-title { position: absolute; top: 78px; left: 28px; z-index: 2; pointer-events: none; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.stage-title h1 { margin: 8px 0 0; font-size: clamp(30px, 3vw, 44px); line-height: 1.05; font-weight: 800; letter-spacing: -.025em; }
.stage-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.stage-controls { position: absolute; top: 22px; right: 22px; z-index: 4; display: flex; gap: 8px; }
.seg { display: inline-flex; padding: 4px; border-radius: 99px; background: var(--line-2); }
.seg.glass { background: rgba(255,255,255,.75); backdrop-filter: blur(10px); box-shadow: 0 6px 20px rgba(20,22,27,.08); }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink-2); transition: background .2s, color .2s; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: 0 4px 12px rgba(20,22,27,.18); }
.ar-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 99px; padding: 10px 16px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 8px 22px rgba(20,22,27,.22); }
.ar-btn svg { width: 17px; height: 17px; }
.stage-foot { position: absolute; left: 0; right: 0; bottom: 22px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none; }
.set-tabs { display: flex; gap: 8px; padding: 8px; border-radius: 18px; background: rgba(255,255,255,.8); backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(20,22,27,.10); pointer-events: auto; }
.set-tab { border: 0; padding: 0; background: none; border-radius: 10px; transition: transform .2s var(--ease); }
.set-tab:hover { transform: translateY(-2px); }
.set-tab canvas { display: block; width: 48px; height: 48px; border-radius: 9px; }
.set-tab[aria-current="true"] canvas { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--ink); }
.stage-hint { margin: 0; font-size: 12.5px; color: var(--muted); transition: opacity .6s; }
.loader { position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); transition: opacity .5s, visibility .5s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader p { margin: 0; color: var(--ink-2); font-weight: 600; }
.loader-tiles { display: grid; grid-template-columns: repeat(2, 22px); gap: 5px; }
.loader-tiles i { width: 22px; height: 22px; border-radius: 5px; animation: tile 1.2s var(--ease) infinite; }
.loader-tiles i:nth-child(1) { background: #c8231d; } .loader-tiles i:nth-child(2) { background: #f3c81d; animation-delay: .15s; }
.loader-tiles i:nth-child(3) { background: #1f4fb8; animation-delay: .3s; } .loader-tiles i:nth-child(4) { background: #3d9a3b; animation-delay: .45s; }
@keyframes tile { 50% { transform: scale(.7); opacity: .6; } }

/* ---------- panel ---------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 6px 26px 26px; scrollbar-width: thin; }
.block { padding: 20px 0 22px; border-bottom: 1px solid var(--line-2); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.block h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.aside { font-size: 12px; color: var(--muted); text-align: right; }
.aside strong { color: var(--ink); font-weight: 700; }
.board-wrap { width: 100%; aspect-ratio: 1; border-radius: 16px; touch-action: none; box-shadow: 0 1px 0 var(--line), 0 18px 40px rgba(20,22,27,.10); }
.board-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 16px; cursor: crosshair; }
.tools-row { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.tools-row .seg { flex: 1; }
.tools-row .seg button { flex: 1; justify-content: center; padding: 8px 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 99px; background: var(--line-2); color: var(--ink-2); transition: background .2s; }
.icon-btn:hover { background: #ebe8e1; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.tool-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); min-height: 19px; }

.palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 9px; }
.swatch { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px rgba(20,22,27,.12); transition: transform .15s var(--ease), box-shadow .15s; overflow: hidden; }
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--ink); }
.swatch.gloss::after { content: ''; position: absolute; left: 12%; top: 10%; width: 40%; height: 20%; border-radius: 6px; background: rgba(255,255,255,.55); transform: rotate(-18deg); }
.swatch.iri::after { content: ''; position: absolute; left: 12%; top: 10%; width: 40%; height: 20%; border-radius: 6px; background: rgba(255,255,255,.5); transform: rotate(-18deg); }
.palette.mini { grid-template-columns: repeat(8, 1fr); gap: 7px; }
.palette.mini .swatch { border-radius: 8px; }

.used { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 13px; font-weight: 600; transition: border-color .2s, box-shadow .2s; }
.chip i { width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.chip b { color: var(--muted); font-weight: 600; }
.chip:hover { border-color: #d6d1c8; }
.chip[aria-expanded="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.replace { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--line-2); animation: drop .25s var(--ease); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.replace-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.check input { accent-color: var(--ink); }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 99px; background: var(--line-2); margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 99px; padding: 8px 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(20,22,27,.08); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.thumbs.icons { grid-template-columns: repeat(5, 1fr); }
.thumb { border: 0; background: none; padding: 0; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.thumb canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 10px; margin-bottom: 5px; box-shadow: 0 4px 12px rgba(20,22,27,.12); transition: transform .2s var(--ease), box-shadow .2s; }
.thumb:hover canvas { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(20,22,27,.16); }
.pickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.pickers.two { grid-template-columns: 1fr 1fr; }
.pickers label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.pickers select { font: 600 13px var(--font); padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.hint { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; }
.name-form { display: flex; gap: 8px; }
.name-form input { flex: 1; min-width: 0; font: 800 17px var(--font); letter-spacing: .18em; text-transform: uppercase; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; outline: none; }
.name-form input:focus { border-color: var(--ink); }
.slider { margin-top: 14px; }
.slider-top { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.slider input { width: 100%; accent-color: var(--ink); }
.file-btn { cursor: pointer; }

.frames { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frames button { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; transition: border-color .2s, box-shadow .2s; }
.frames button strong { display: block; font-size: 14px; font-weight: 700; }
.frames button small { display: block; color: var(--muted); font-size: 12px; }
.frames button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.fr { width: 34px; height: 34px; border-radius: 8px; box-shadow: inset 0 0 0 7px currentColor, inset 0 0 0 8px rgba(0,0,0,.08); background: repeating-linear-gradient(0deg, #c8231d 0 6px, #f3c81d 6px 12px); }
.fr.black { color: #1d1d22; } .fr.white { color: #f3f3f1; }
.colophon { margin: 18px 0 0; font-size: 12px; color: var(--muted); }
.colophon a { color: var(--ink-2); }

.summary { padding: 16px 26px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.summary-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.kit-meta { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); }
.price { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1; text-align: right; }
.price small { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.summary-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 20px; border: 0; border-radius: 99px; background: var(--ink); color: #fff; font: 700 14px var(--font); letter-spacing: .01em; transition: background .2s, transform .15s; }
.btn:hover { background: #000; }
.btn:active { transform: scale(.99); }
.btn.small { width: auto; padding: 10px 18px; font-size: 13px; }
.btn.outline { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line) inset; }
.btn.outline:hover { box-shadow: 0 0 0 1px #cfc9bf inset; background: #fbfaf8; }

/* ---------- modals ---------- */
.modal { border: 0; border-radius: 22px; padding: 30px; width: min(880px, calc(100vw - 28px)); max-height: calc(100vh - 28px); box-shadow: 0 40px 100px rgba(20,22,27,.35); color: var(--ink); }
.modal::backdrop { background: rgba(20,22,27,.45); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-sm { width: min(440px, calc(100vw - 28px)); text-align: center; }
.modal-close { position: absolute; top: 12px; right: 14px; margin: 0; }
.modal-close button { border: 0; background: none; font-size: 26px; color: var(--muted); }
.modal h2 { margin: 6px 0 10px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.muted { color: var(--ink-2); }
.fine { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.order-preview { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.order-preview canvas { width: 88px; height: 88px; border-radius: 10px; box-shadow: 0 6px 16px rgba(20,22,27,.18); }
.qr { display: grid; place-items: center; margin: 12px auto; padding: 14px; background: #fff; width: fit-content; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }
.qr svg { width: 210px; height: 210px; }
.qr svg path, .qr svg rect { stroke: none; }
.sheet-page { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; align-items: start; padding-bottom: 22px; }
.sheet-page + .sheet-page { border-top: 1px dashed var(--line); padding-top: 22px; }
.sheet-page canvas { width: 100%; border-radius: 12px; }
.sheet-page h3 { margin: 4px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 28px 20px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.legend .code { font-weight: 800; text-align: center; background: var(--line-2); border-radius: 7px; padding: 2px 0; }
.legend i { width: 18px; height: 18px; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.legend b { font-weight: 800; }
.sheet-actions { position: sticky; bottom: -30px; padding: 14px 0 0; background: #fff; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease); z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { :root { --panel-w: 400px; } }
@media (max-width: 860px) {
  body { overflow: auto; }
  .topbar { padding: 0 14px; } .brand-sub, .ghost span { display: none; }
  .layout { position: static; display: block; padding-top: var(--top-h); }
  .stage { position: sticky; top: var(--top-h); height: 48vh; z-index: 5; border-bottom: 1px solid var(--line); }
  .powered { top: 12px; left: 14px; padding: 7px 12px 7px 10px; font-size: 12px; }
  .stage-title { top: 54px; left: 16px; } .stage-title h1 { font-size: 26px; } .stage-sub { font-size: 13px; } .eyebrow { font-size: 10px; }
  .stage-controls { top: auto; bottom: 12px; right: 12px; }
  .stage-foot { bottom: 64px; } .stage-hint { display: none; }
  .ar-btn { padding: 9px 13px; font-size: 12px; }
  .panel { border-left: 0; }
  .panel-scroll { overflow: visible; padding: 0 16px 150px; }
  .summary { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px rgba(20,22,27,.06); }
  .sheet-page { grid-template-columns: 1fr; }
}
@media print {
  body { overflow: visible; }
  body * { visibility: hidden; }
  #sheet-dialog, #sheet-dialog * { visibility: visible; }
  #sheet-dialog { position: absolute; inset: 0; box-shadow: none; width: 100%; max-height: none; }
  .sheet-actions, .modal-close { display: none; }
}
