html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:root {
  --bg: #0c0d0f;
  --surface: #131518;
  --surface-2: #1a1d21;
  --surface-3: #22262b;
  --border: #2a2f35;
  --border-strong: #3a4048;
  --text: #ecebe6;
  --muted: #9097a0;
  --faint: #636a73;
  --accent: #c8f53c;
  --accent-ink: #11140a;
  --ok: #43d69a;
  --warn: #f5b041;
  --bad: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: "Cabinet Grotesk", "Satoshi", system-ui, sans-serif;
  --font-body: "Satoshi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --summary-h: 84px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabnum { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-display); font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-text span { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.topbar-meta b { color: var(--text); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(67,214,154,.18); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  height: calc(100vh - var(--topbar-h) - var(--summary-h));
  height: calc(100dvh - var(--topbar-h) - var(--summary-h));
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 40% 30%, #1b1f24 0%, #101215 55%, #0a0b0d 100%);
}
#scene { width: 100%; height: 100%; display: block; touch-action: none; }
.stage-hud {
  position: absolute; inset: 20px 20px auto 20px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  pointer-events: none;
}
.stage-hud > * { pointer-events: auto; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.stage-title h1 {
  margin: 0; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(28px, 3.4vw, 46px); letter-spacing: -.02em; line-height: 1;
}
.stage-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tool, .rgb {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  border-radius: 999px;
  background: rgba(19,21,24,.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 500;
}
.tool[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.tool:hover { border-color: var(--border-strong); }
.rgb-label { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.swatch {
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  background: var(--c); border: 2px solid transparent;
  box-shadow: 0 0 10px -2px var(--c);
}
.swatch[aria-pressed="true"] { border-color: var(--text); }
.stage-foot {
  position: absolute; left: 20px; right: 20px; bottom: 16px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  pointer-events: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 70%; }
.chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: rgba(26,29,33,.85); border: 1px solid var(--border); color: var(--text);
  backdrop-filter: blur(6px);
}
.chip b { color: var(--accent); font-weight: 700; }
.hint { margin: 0; color: var(--faint); font-size: 12px; text-align: right; }
.stage-loading {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; justify-items: center;
  color: var(--muted); font-size: 14px; background: var(--bg);
  transition: opacity .4s var(--ease);
}
.stage-loading span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.stage-loading.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- panel ---------- */
.panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.panel-block { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.field-label { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.base-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 148px; gap: 10px;
  overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.base-card {
  scroll-snap-align: start;
  text-align: left; padding: 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .2s, transform .2s var(--ease);
}
.base-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.base-card[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.base-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.base-card .nm { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 1; }
.base-card .sp { font-size: 11px; color: var(--muted); line-height: 1.3; min-height: 2.6em; }
.base-card .pr { font-size: 13px; font-weight: 700; }

.panel-controls { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; position: sticky; top: 0; z-index: 2; background: var(--surface); }
.search {
  flex: 1 1 100%; display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.search input { flex: 1; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; outline: none; min-width: 0; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.sections { padding-bottom: 24px; }
.sec { border-bottom: 1px solid var(--border); }
.sec-head {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto 16px; gap: 12px; align-items: center;
  padding: 14px 18px; background: none; border: 0; text-align: left;
}
.sec-head:hover { background: var(--surface-2); }
.sec-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
}
.sec[data-open="true"] .sec-icon { background: var(--accent); color: var(--accent-ink); }
.sec-title { display: flex; flex-direction: column; min-width: 0; }
.sec-title small { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sec-title span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-price { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sec-caret { color: var(--faint); transition: transform .25s var(--ease); }
.sec[data-open="true"] .sec-caret { transform: rotate(180deg); }
.sec-flag { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }
.sec-flag.warn { background: rgba(245,176,65,.15); color: var(--warn); }
.sec-flag.bad { background: rgba(255,107,107,.15); color: var(--bad); }

.opts { display: none; padding: 0 12px 14px; }
.sec[data-open="true"] .opts { display: block; }
.opt {
  width: 100%; display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; margin-top: 6px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; text-align: left;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--border-strong); }
.opt[aria-checked="true"] { border-color: var(--accent); background: #1c2117; }
.opt[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.opt img, .opt .ph { width: 52px; height: 52px; border-radius: 6px; object-fit: contain; background: #fff; }
.opt .ph { background: var(--surface-3); display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.opt-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.opt-name { font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.opt-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); }
.tag.ok { color: var(--ok); background: rgba(67,214,154,.1); }
.tag.warn { color: var(--warn); background: rgba(245,176,65,.12); }
.tag.bad { color: var(--bad); background: rgba(255,107,107,.12); }
.opt-price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.opt-price .d { font-size: 13.5px; font-weight: 700; }
.opt-price .d.up { color: var(--text); }
.opt-price .d.down { color: var(--ok); }
.opt-price .a { font-size: 11px; color: var(--muted); }
.more { width: 100%; margin-top: 8px; height: 36px; border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); background: none; color: var(--muted); font-size: 13px; }
.more:hover { color: var(--text); }
.empty { color: var(--muted); font-size: 13px; padding: 12px 6px; }

/* ---------- summary ---------- */
.summary {
  height: var(--summary-h);
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 24px; align-items: center;
  padding: 0 20px; border-top: 1px solid var(--border); background: #0f1113;
  position: relative; z-index: 4;
}
.summary-status { display: flex; align-items: center; gap: 10px; font-size: 13.5px; min-width: 0; }
.summary-status .pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.pill.ok { background: rgba(67,214,154,.12); color: var(--ok); }
.pill.warn { background: rgba(245,176,65,.12); color: var(--warn); }
.pill.bad { background: rgba(255,107,107,.12); color: var(--bad); }
.summary-status .msg { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-power { display: flex; flex-direction: column; gap: 5px; width: 170px; font-size: 12px; color: var(--muted); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .4s var(--ease), background .3s; }
.summary-price { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.summary-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.summary-total { display: block; white-space: nowrap; min-width: max-content; padding-right: 2px; font-family: var(--font-display); font-weight: 800; font-size: 30px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.summary-price { min-width: max-content; }
.summary-sub { font-size: 11.5px; color: var(--muted); }
.cta {
  height: 50px; padding: 0 26px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 15px; letter-spacing: .01em;
  transition: transform .15s var(--ease), box-shadow .2s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 8px 24px -8px var(--accent); }
.cta:disabled { background: var(--surface-3); color: var(--faint); box-shadow: none; transform: none; cursor: not-allowed; }
.ghost { height: 50px; padding: 0 22px; border-radius: 999px; background: none; border: 1px solid var(--border-strong); font-weight: 500; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--summary-h) + 16px); transform: translate(-50%, 16px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease); z-index: 20;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,.6);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--accent); }

/* ---------- review dialog ---------- */
.review {
  width: min(620px, calc(100vw - 32px)); max-height: 86vh; padding: 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 16px;
}
.review::backdrop { background: rgba(5,6,7,.7); backdrop-filter: blur(3px); }
.review form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.review h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.review-list li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.review-list li span:first-child { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
.review-list li span:last-child { font-variant-numeric: tabular-nums; }
.review-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.review-total strong { font-family: var(--font-display); font-size: 28px; font-weight: 800; }
.review-note { margin: 0; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.review-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
#review-ref a { color: var(--accent); font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 400px; }
  .summary-power { display: none; }
}
@media (max-width: 820px) {
  :root { --summary-h: 76px; }
  .layout { display: block; height: auto; }
  .stage { height: 58vh; min-height: 360px; }
  .panel { border-left: 0; overflow: visible; }
  .summary { position: sticky; bottom: 0; grid-template-columns: minmax(max-content, 1fr) auto; gap: 12px; }
  .summary-status { display: none; }
  .summary-price { align-items: flex-start; }
  .summary-total { font-size: 24px; }
  .cta { height: 46px; padding: 0 20px; }
  .topbar-meta span:last-child { font-size: 12px; }
  /* phones: title + tools above the model, chips below, nothing on top of the 3D view */
  .stage { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .stage-hud { position: static; flex-direction: column; gap: 12px; padding: 18px 16px 0; }
  #scene { height: 46vh; min-height: 300px; flex: none; order: 1; }
  .stage-foot { order: 2; }
  .stage-foot { position: static; padding: 0 16px 14px; }
  .stage-tools { justify-content: flex-start; }
  .chips { max-width: 100%; }
  .hint { display: none; }
  .panel-controls { top: 0; }
}
@media (max-width: 480px) {
  .topbar-meta { display: none; }
  .tool span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- refinements ---------- */
.sort { flex: 1; height: 36px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 13px; padding: 0 8px; }
.facets { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 6px; }
.facet { height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.facet:hover { color: var(--text); border-color: var(--border-strong); }
.facet[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.tip { position: absolute; pointer-events: none; padding: 8px 12px; border-radius: 8px; background: rgba(19,21,24,.92); border: 1px solid var(--border-strong); font-size: 12.5px; line-height: 1.35; max-width: 260px; opacity: 0; transform: translate(-50%, calc(-100% - 14px)); transition: opacity .15s; z-index: 3; backdrop-filter: blur(6px); }
.tip.show { opacity: 1; }
.tip small { display: block; color: var(--accent); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 10.5px; }
.tip b { font-variant-numeric: tabular-nums; }
#scene.pick { cursor: pointer; }
.base-card .oos { font-size: 11px; color: var(--warn); }
.base-card .ok { font-size: 11px; color: var(--ok); }
.sec.flash .sec-head { animation: flash 1.2s var(--ease); }
@keyframes flash { 0%, 40% { background: rgba(200,245,60,.14); } 100% { background: transparent; } }
@media (max-width: 820px) { .sort { flex: 1; } }

.stage-case { margin: 8px 0 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge3d, .tag.t3d { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); }
.tag.t3d { font-size: 10px; }

.scratch-card { border-style: dashed; }
.scratch-art { display: grid; place-items: center; width: 100%; aspect-ratio: 4/3; border-radius: 6px; background: var(--surface-3); color: var(--accent); }
.sec-flag.need { background: color-mix(in oklab, var(--accent) 16%, transparent); color: var(--accent); }

/* ---------- build it + real photos ---------- */
.tool-build { background: var(--accent); color: #0b0c0d; border-color: var(--accent); font-weight: 700; }
.tool-build:hover { filter: brightness(1.06); border-color: var(--accent); }
.tool-build[disabled] { opacity: .45; }
.build-caption { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); margin: 0; padding: 8px 16px; border-radius: 999px;
  background: rgba(15,17,19,.86); border: 1px solid var(--border-strong); font-size: 13.5px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .25s; z-index: 3; backdrop-filter: blur(6px); }
.build-caption.show { opacity: 1; }
.build-caption b { color: var(--accent); }
.photos { position: absolute; left: 0; right: 0; z-index: 2; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 18px;
  padding: 0 20px; background: radial-gradient(120% 90% at 40% 30%, #1b1f24 0%, #101215 55%, #0a0b0d 100%); }
.photos[hidden] { display: none; }
.photo-hero { margin: 0; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.photo-frame { position: relative; flex: 1; min-height: 0; border-radius: 14px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.photo-frame.dark { background: #0c0d0f; }
.photo-frame img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.photo-hero figcaption { font-size: 12.5px; color: var(--muted); }
.photo-hero figcaption b { color: var(--text); }
.photo-hero figcaption .ai { color: var(--warn, #f5b83c); }
.photo-wait { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; background: rgba(12,13,15,.82); color: var(--text); font-size: 14px; }
.photo-wait[hidden] { display: none; }
.photo-wait small { color: var(--muted); }
.photo-wait span { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.photo-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.real-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border-radius: 999px; background: var(--accent); color: #0b0c0d; font-weight: 700; border: 0; }
.real-btn[disabled] { opacity: .55; }
.photo-note { margin: 0; font-size: 12px; color: var(--faint); }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: auto; min-height: 0; padding-bottom: 4px; }
.pthumb { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); text-align: left; }
.pthumb[aria-pressed="true"] { border-color: var(--accent); }
.pthumb .im { aspect-ratio: 4/3; border-radius: 6px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.pthumb .im.dark { background: #0c0d0f; }
.pthumb img { max-width: 92%; max-height: 92%; object-fit: contain; }
.pthumb small { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.pthumb span { font-size: 12px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 820px) {
  .photos { position: static; order: 1; grid-template-columns: 1fr; padding: 4px 16px 12px; gap: 10px; background: none; }
  .stage.photos-on #scene { display: none; }
  .photo-frame { flex: none; height: 30vh; min-height: 220px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .build-caption { bottom: auto; top: 8px; font-size: 12.5px; }
}
@media (max-width: 480px) { .tool-build span { display: inline; } }

.terms { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 4px 0 2px; cursor: pointer; }
.terms input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); flex: none; }
.terms a { color: var(--accent); }
