:root {
  --bg: #f3eee6; --bg-deep: #e9e0d2; --card: #fffcf7; --ink: #1c1916; --muted: #5c5348;
  --line: #e2d8c8; --gold: #8d6b2c; --gold-soft: #c4a46a; --gold-pale: #f3e6c8;
  --danger: #8a3b12; --warn: #8a6212; --ok: #1f6b3a;
  --shadow: 0 10px 30px rgba(28, 25, 22, 0.08); --radius: 18px;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --bar-h: 0px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans); color: var(--ink); min-height: 100dvh; -webkit-font-smoothing: antialiased;
  background: radial-gradient(1200px 500px at 50% -80px, #fffaf0 0%, transparent 60%), var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
.page { width: min(1240px, 100%); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 14px calc(28px + var(--bar-h) + env(safe-area-inset-bottom)); }

.hero { text-align: center; margin: 4px 0 16px; }
.eyebrow { letter-spacing: .16em; text-transform: uppercase; font-size: 11px; font-weight: 600; color: var(--gold); margin: 0 0 6px; }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 6vw, 46px); letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.05; }
.lede { margin: 0 auto; max-width: 34rem; color: var(--muted); font-size: 15.5px; line-height: 1.45; }

/* layout */
.layout { display: grid; gap: 16px; }
@media (min-width: 640px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); align-items: start; gap: 14px; }
  .viewer-col { position: sticky; top: 8px; }
  .viewer-card { height: calc(100dvh - var(--bar-h) - 16px - env(safe-area-inset-bottom)); max-height: 760px; min-height: 260px; }
}
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); gap: 16px; }
  .viewer-col { top: 14px; }
  .viewer-card { height: min(calc(100dvh - 28px), 760px); }
}
@media (max-width: 959px) { :root { --bar-h: 68px; } }
@media (max-width: 639px) {
  .viewer-col { position: sticky; top: 0; z-index: 6; margin: 0 -14px; padding: 0 8px 8px; background: linear-gradient(var(--bg) 85%, transparent); }
  .viewer-card { height: clamp(230px, 36dvh, 440px); transition: height .2s; }
  .hero { margin-bottom: 10px; }
  body.typing .viewer-card { height: 200px; }
}
body.typing .bar { display: none !important; }
@media (min-width: 640px) and (max-width: 959px) {
  .hero h1 { font-size: 30px; } .hero { margin-bottom: 10px; }
}

/* viewer */
.viewer-card { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 30%, #fffdf8 0%, #efe6d8 100%); box-shadow: var(--shadow); }
.viewer { position: absolute; inset: 0; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-top, .viewer-bottom { position: absolute; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.viewer-top { top: 10px; justify-content: space-between; }
.viewer-bottom { bottom: 10px; flex-wrap: wrap; }
.viewer-top > *, .viewer-bottom > button { pointer-events: auto; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--muted); background: rgba(255,252,247,.85); border: 1px solid var(--line); padding: 4px 8px; border-radius: 99px; }
.size { margin-left: auto; font-size: 12px; pointer-events: auto; color: var(--muted); background: rgba(255,252,247,.85); padding: 4px 8px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.chip { border: 1px solid var(--line); background: rgba(255,252,247,.92); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 34px; }
.chip:hover { border-color: var(--gold-soft); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint-drag { position: absolute; left: 0; right: 0; top: 64px; text-align: center; font-size: 12px; color: var(--muted); margin: 0; pointer-events: none; transition: opacity .6s; }
.hint-drag.gone { opacity: 0; }
@media (max-width: 420px) { .size { font-size: 11px; padding: 3px 7px; } .chip { padding: 5px 12px; } }
.seg.small { flex-wrap: nowrap; }
.seg.small button { white-space: nowrap; }
.viewer-bottom .tag { margin-left: auto; }
@media (max-width: 959px) { .size .inch { display: none; } }
@media (max-width: 479px), (min-width: 640px) and (max-width: 899px) { .viewer-bottom .tag { display: none; } }
@media (min-width: 640px) and (max-width: 759px) { .viewer-top { flex-direction: column; align-items: flex-start; gap: 6px; } .size { margin-left: 0; } .hint-drag { top: 98px; } }

/* segmented controls */
.seg { display: inline-flex; background: var(--bg-deep); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 12px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg.small button { padding: 6px 11px; font-size: 13px; min-height: 32px; }
.seg.small { background: rgba(233,224,210,.92); }
.seg.wide { display: flex; } .seg.wide button { flex: 1 1 0; min-width: 0; }
.seg button small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }

/* panel */
.panel { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 14px; min-width: 0; }
.card h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 10px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 -4px; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-family: var(--sans); font-size: 13px; font-weight: 700; flex: none; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 0; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 3px var(--gold-pale); }
.opt { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 400px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.4; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* set tabs */
.set-tabs, .set-add { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px; }
.set-add { margin-top: -6px; }
.qty-badge { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: var(--gold); color: #fff; font-size: 12px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qty-row > span:first-child { display: grid; gap: 2px; } .qty-row small { color: var(--muted); font-size: 13px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.stepper button, .step { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 22px; font-weight: 600; line-height: 1; cursor: pointer; flex: none; padding: 0; color: var(--ink); touch-action: manipulation; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 34px; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.set-tab { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.set-tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.set-tab.add { border-style: dashed; color: var(--gold); }

/* measurement rows */
.dims { display: grid; gap: 6px; }
.dim { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: "l c m" ". msg msg"; column-gap: 10px; align-items: center; padding: 6px 8px; border-radius: 12px; border: 1px solid transparent; }
.dim .letter { grid-area: l; } .dim .dim-copy { grid-area: c; min-width: 0; } .dim .mm-ctl { grid-area: m; } .dim .dim-msg { grid-area: msg; }
.dim.warn { border-color: #e7cf9a; background: #fbf3df; }
.dim.bad { border-color: #e3b19a; background: #fbe9e1; }
.dim-msg { font-size: 13px; font-weight: 600; color: var(--warn); }
.dim.bad .dim-msg { color: var(--danger); }
.dim-msg:empty { display: none; }
.letter { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--gold-pale); color: var(--gold); font-weight: 700; }
.dim-name { font-weight: 600; font-size: 15px; display: block; }
.dim-hint { font-size: 12.5px; color: var(--muted); display: block; line-height: 1.3; }
.mm-ctl { display: flex; align-items: center; gap: 4px; }
.mm { position: relative; width: 84px; }
.mm input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 30px 0 6px; font-size: 16px; text-align: right; background: #fff; }
.mm input:focus { outline: none; border-color: var(--gold-soft); box-shadow: 0 0 0 3px var(--gold-pale); }
.mm i { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--muted); pointer-events: none; }
/* narrow: controls go on their own line, full width */
@media (max-width: 459px), (min-width: 640px) and (max-width: 799px) {
  .dim { grid-template-areas: "l c" "l m" ". msg"; grid-template-columns: 30px minmax(0, 1fr); row-gap: 6px; padding: 8px 6px; }
  .mm-ctl { justify-content: flex-start; }
  .mm { width: 110px; }
}

/* swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { position: relative; display: grid; justify-items: center; gap: 4px; width: 62px; cursor: pointer; font-size: 11.5px; text-align: center; color: var(--muted); line-height: 1.15; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.sw .dot { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line), inset 0 -6px 10px rgba(0,0,0,.12); }
.sw .dot.metal { background-image: linear-gradient(135deg, rgba(255,255,255,.7), rgba(255,255,255,0) 45%, rgba(0,0,0,.18)); }
.sw .dot.same { background: repeating-linear-gradient(45deg, #fff, #fff 5px, #eee6d8 5px, #eee6d8 10px); }
.sw input:checked + .dot { box-shadow: 0 0 0 2px var(--ink); }
.sw input:focus-visible + .dot { outline: 3px solid var(--gold-soft); outline-offset: 2px; }
.sw b { font-weight: 600; color: var(--ink); }
.price-tag { font-size: 11px; font-weight: 700; color: var(--gold); }

/* toggles */
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.toggle { min-height: 52px; align-items: center; }
.toggle input { width: 24px; height: 24px; margin: 0; accent-color: var(--ink); flex: none; }
.toggle span { display: grid; gap: 2px; font-weight: 600; }
.toggle small { font-weight: 400; color: var(--muted); font-size: 13px; }
.radios { display: grid; gap: 8px; }
.radio { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.radio input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.radio .fee { margin-left: auto; color: var(--muted); font-size: 14px; }

.banner { background: var(--gold-pale); border: 1px solid var(--gold-soft); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14.5px; }
.banner .primary { padding: 8px 14px; width: auto; font-size: 14px; }
.note { font-size: 13px; color: var(--muted); margin: -6px 0 0; }
.text-note { font-size: 12.5px; margin: -2px 0 0; color: var(--muted); }
.text-note.bad { color: var(--danger); font-weight: 600; }

/* summary */
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14.5px; }
.lines li { display: flex; justify-content: space-between; gap: 12px; }
.lines li span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lines li.minus span:last-child { color: var(--ok); }
.lines li.sub { color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 10px; }
.total span { font-weight: 600; }
.total strong { font-family: var(--serif); font-size: 34px; font-variant-numeric: tabular-nums; }
.fine { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }
.center { text-align: center; }
.alerts { display: grid; gap: 6px; }
.alerts:empty { display: none; }
.alert { font-size: 14px; padding: 8px 10px; border-radius: 10px; }
.alert.err { background: #fbe9e1; color: var(--danger); }
.alert.warn { background: #fbf3df; color: var(--warn); }
.primary { width: 100%; border: 0; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 700; font-size: 17px; padding: 14px 18px; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: progress; }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 16px; font-weight: 600; cursor: pointer; }
.link { background: none; border: 0; color: var(--gold); font-weight: 600; text-decoration: underline; cursor: pointer; justify-self: center; padding: 8px; min-height: 36px; font-size: 14px; }
.danger-link { color: var(--danger); }

/* bottom bar (phones) */
.bar { display: none; }
@media (max-width: 959px) {
  .bar { display: flex; transition: transform .25s; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,252,247,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
  .bar strong { font-family: var(--serif); font-size: 26px; font-variant-numeric: tabular-nums; }
  .bar-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
  .bar .primary { width: auto; padding: 11px 18px; font-size: 15px; }
}

.dialog { border: 0; border-radius: 22px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px rgba(0,0,0,.25); background: var(--card); }
.dialog::backdrop { background: rgba(28,25,22,.45); }
.dialog-body { padding: 22px; display: grid; gap: 12px; }
.dialog h2 { font-family: var(--serif); font-size: 30px; margin: 0; }
.dialog p { margin: 0; line-height: 1.45; }
.done-summary { font-size: 14px; color: var(--muted); display: grid; gap: 4px; max-height: 40dvh; overflow: auto; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.dialog-actions .primary { width: auto; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 18px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 30; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }

.bar.off { transform: translateY(110%); }
.done-summary .lines { font-size: 14px; } .done-summary .total strong { font-size: 26px; }

/* touch: every tap target at least 44 px */
@media (pointer: coarse), (max-width: 959px) {
  .set-tab, .chip, .seg button, .link, .ghost, .primary, .seg.small button { min-height: 44px; }
  .chip { min-width: 44px; }
  .seg.small button { padding: 6px 12px; }
}
