:root {
  --ink: #0f1c27;
  --ink-2: #2a3946;
  --muted: #687480;
  --line: #e6e1d8;
  --line-2: #d6d0c4;
  --paper: #f7f4ee;
  --card: #ffffff;
  --accent: #0d8a9e;
  --accent-soft: #e2f3f5;
  --wa: #1d9f53;
  --wa-dark: #178244;
  --stage: #13202b;
  --radius: 14px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

/* ---------- Topbar ---------- */
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--ink);
  color: #fff;
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 30px; width: auto; filter: invert(1); }
.brand-sep { width: 1px; height: 22px; background: rgba(255,255,255,.25); }
.brand-title { font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: .04em; text-transform: uppercase; }
.crumbs { display: flex; gap: 8px; font-size: 14px; color: rgba(255,255,255,.6); }
.crumbs strong { color: #fff; font-weight: 600; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  min-height: calc(100vh - 56px);
}

/* ---------- Stage ---------- */
.stage {
  position: sticky; top: 0;
  height: calc(100vh - 56px);
  background:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 64px 64px,
    radial-gradient(ellipse at 50% 45%, #22374a, #0f1922 75%);
  display: flex; flex-direction: column;
  min-width: 0;
}
.stage-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px 0;
}
.seg { display: inline-flex; background: rgba(255,255,255,.07); border-radius: 999px; padding: 3px; }
.seg-btn {
  border: 0; background: transparent; color: rgba(255,255,255,.7);
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
}
.seg-btn[aria-pressed="true"] { background: #fff; color: var(--ink); }
.tool-group { display: flex; gap: 6px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,.14); background: transparent; color: rgba(255,255,255,.85);
  font-size: 13px; font-weight: 500; padding: 7px 11px; border-radius: 999px;
}
.tool:hover { background: rgba(255,255,255,.08); }
.tool[aria-pressed="false"] { color: rgba(255,255,255,.45); }
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stage-canvas { flex: 1; min-height: 0; padding: 8px 12px; display: flex; }
.stage-canvas svg { width: 100%; height: 100%; }
.stage-note {
  margin: 0; padding: 0 18px 14px; text-align: center;
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.4);
}

/* ---------- Panel ---------- */
.panel { padding: 28px 26px 40px; border-left: 1px solid var(--line); min-width: 0; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.model-head h1 {
  margin: 2px 0 6px; font-family: var(--display); font-weight: 700;
  font-size: 46px; line-height: 1; letter-spacing: .01em; text-transform: uppercase;
}
.tagline { margin: 0 0 16px; color: var(--ink-2); font-size: 15px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 0 0 22px; }
.stats div { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { width: 54px; height: 5px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.meter::after { content: ""; position: absolute; inset: 0; width: calc(var(--v) * 20%); background: var(--ink); border-radius: 3px; }

/* ---------- Model picker ---------- */
.model-picker { margin: -6px -26px 22px; padding: 0 26px 18px; border-bottom: 1px solid var(--line); }
.model-picker .sub { margin-top: 0; }
.mp-strip {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 2px 2px 8px; margin: 0 -2px; scrollbar-width: thin;
}
.mp-card {
  flex: none; width: 104px; scroll-snap-align: start;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 10px 8px 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  transition: border-color .15s, transform .15s;
}
.mp-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.mp-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fbfaf7; }
.mp-card svg { width: 28px; height: 72px; margin-bottom: 6px; }
.mp-card svg path { fill: #e9e4d8; stroke: var(--ink-2); stroke-width: .8; }
.mp-card[aria-pressed="true"] svg path { fill: var(--accent); stroke: var(--ink); }
.mp-name { font-family: var(--display); font-weight: 700; font-size: 15px; line-height: 1.05; text-transform: uppercase; letter-spacing: .02em; }
.mp-fam { font-size: 11px; color: var(--muted); line-height: 1.2; }
.mp-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-price { margin-top: 3px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mp-price s { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.m-price { margin: -8px 0 14px; font-size: 14px; color: var(--ink-2); }
.m-price strong { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.m-price s { color: var(--muted); }
.sale { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: #fde8df; color: #b4401c; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
.m-link { display: inline-block; margin: -10px 0 4px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.m-link:hover { text-decoration: underline; }
.steps-title { margin: 20px 0 10px; }
.btn-light { background: #fff !important; color: var(--ink) !important; border: 1.5px solid var(--line-2) !important; }

/* ---------- Steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.step.is-open { border-color: var(--line-2); box-shadow: 0 6px 24px -14px rgba(15,28,39,.35); }
.step-head {
  width: 100%; border: 0; background: transparent; text-align: left;
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--paper); color: var(--ink-2);
  border: 1px solid var(--line);
}
.step.is-done .step-num { background: var(--ink); color: #fff; border-color: var(--ink); }
.step-title { display: block; font-weight: 600; font-size: 15px; }
.step-value { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-price { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step-price.plus { color: var(--accent); }
.step-body { display: none; padding: 2px 16px 16px; }
.step.is-open .step-body { display: block; }
.sub { margin: 14px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sub:first-child { margin-top: 4px; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* option buttons */
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.opts.cols-2 { grid-template-columns: 1fr 1fr; }
.opt {
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; min-height: 52px;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--line-2); }
.opt[aria-pressed="true"] { border-color: var(--ink); background: #fbfaf7; box-shadow: inset 0 0 0 1px var(--ink); }
.opt-label { font-weight: 600; font-size: 14px; line-height: 1.25; }
.opt-meta { font-size: 12.5px; color: var(--muted); }
.opt-meta.plus { color: var(--accent); font-weight: 600; }
.opt-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.opt.with-thumb { flex-direction: row; align-items: center; gap: 10px; }
.opt-thumb { width: 38px; height: 38px; border-radius: 8px; flex: none; background: var(--paper) center/contain no-repeat; border: 1px solid var(--line); }

/* size table */
.sizes { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.size-row {
  width: 100%; border: 0; border-top: 1px solid var(--line); background: #fff;
  display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr 0.9fr; gap: 6px; align-items: center;
  padding: 9px 12px; text-align: left; font-size: 14px; font-variant-numeric: tabular-nums;
}
.size-row:first-child { border-top: 0; }
.size-row.head { background: var(--paper); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: default; }
.size-row:not(.head):hover { background: #fbfaf7; }
.size-row[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.size-row .len { font-weight: 700; }
.size-row .pr { text-align: right; color: var(--muted); }
.size-row .pr.plus { color: var(--accent); font-weight: 600; }
.size-custom { grid-template-columns: 1fr auto; }
.custom-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field-pair { display: flex; gap: 4px; }
.field select, .field input {
  width: 100%; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 8px; background: #fff;
}

/* segmented inside steps */
.pill-seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; background: #fff; }
.pill-seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.pill-seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sw {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.sw-custom { position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: conic-gradient(#f06b4f, #f4b63f, #9ed9c3, #3cc6d8, #14365c, #d63a7a, #f06b4f); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.sw-custom input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.color-rows { display: grid; gap: 10px; }
.color-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.preset {
  flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px 5px 5px; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
}
.preset:hover { border-color: var(--line-2); }
.preset i { width: 22px; height: 22px; border-radius: 50%; background: var(--g); display: block; }

.upload {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; color: var(--ink-2);
}
.upload input { font-size: 12.5px; max-width: 100%; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0; text-decoration: underline; text-underline-offset: 2px; }

.step-next {
  margin-top: 14px; border: 0; background: var(--ink); color: #fff;
  font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 10px;
}
.step-next:hover { background: var(--ink-2); }

/* ---------- Summary ---------- */
.summary {
  margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.summary h2 { margin: 0 0 10px; font-family: var(--display); font-size: 24px; text-transform: uppercase; letter-spacing: .02em; }
.sum-lines { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.sum-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.sum-lines li span:first-child { color: var(--ink-2); }
.sum-lines li span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.sum-lines li .plus { color: var(--accent); font-weight: 600; }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.sum-total span { font-weight: 600; }
.sum-total strong { font-family: var(--display); font-size: 38px; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-total strong.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.06); color: var(--accent); } }
.sum-quote { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); background: #fff6e5; border-radius: 8px; padding: 8px 10px; }
.cta {
  margin-top: 14px; width: 100%; border: 0; border-radius: 12px; padding: 14px;
  background: var(--wa); color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.cta:hover { background: var(--wa-dark); }
.cta svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.6; }
.cta svg .fill { fill: #fff; stroke: none; }
.cta-ghost { margin-top: 8px; width: 100%; border: 1.5px solid var(--line-2); background: #fff; border-radius: 12px; padding: 11px; font-weight: 600; font-size: 14px; }
.cta-ghost:hover { border-color: var(--ink); }
.sum-fine { margin: 10px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Mobile bar & toast ---------- */
.mobile-bar { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr) 400px; }
}
@media (max-width: 860px) {
  .topbar { height: 50px; padding: 0 16px; }
  .crumbs { display: none; }
  .brand-logo { height: 26px; }
  .brand-title { font-size: 17px; }
  .app { display: block; min-height: 0; }
  .stage { position: sticky; top: 0; z-index: 4; height: 46svh; min-height: 300px; }
  .stage-toolbar { padding: 10px 12px 0; }
  .tool span { display: none; }
  .tool { padding: 7px 9px; }
  .seg-btn { padding: 6px 11px; font-size: 12.5px; }
  .stage-canvas { padding: 4px 6px; }
  .stage-note { padding-bottom: 8px; font-size: 10.5px; }
  .panel { border-left: 0; padding: 20px 16px 110px; }
  .model-picker { margin: -4px -16px 18px; padding: 0 16px 14px; }
  .mp-card { width: 96px; }
  .model-head h1 { font-size: 38px; }
  .stats { gap: 6px 14px; }
  .meter { width: 40px; }
  .size-row { grid-template-columns: 1fr 1fr 0.9fr 1fr 0.9fr; padding: 9px 10px; font-size: 13px; }
  .custom-fields { grid-template-columns: 1fr; }
  .step, .summary { scroll-margin-top: calc(max(46svh, 300px) + 10px); }
  .mobile-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -16px rgba(0,0,0,.4);
  }
  .mb-price { display: flex; flex-direction: column; line-height: 1.1; }
  .mb-price span { font-size: 12px; color: var(--muted); }
  .mb-price strong { font-family: var(--display); font-size: 26px; font-variant-numeric: tabular-nums; }
  .mb-btn { border: 0; background: var(--wa); color: #fff; font-weight: 700; padding: 12px 22px; border-radius: 12px; font-size: 15px; }
  .toast { bottom: 84px; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
}
