:root {
  --bg: #efebe4;
  --paper: #f8f6f2;
  --ink: #1c1a17;
  --ink-2: #4a4540;
  --muted: #8a837a;
  --line: #ddd6cb;
  --line-2: #e8e2d8;
  --accent: #8b6a3e;
  --accent-ink: #6e5230;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --panel-w: 420px;
  --top-h: 60px;
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; 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: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font: 500 21px/1 var(--serif); letter-spacing: .32em; }
.brand-sub { font: italic 400 19px/1 var(--serif); color: var(--accent); }
.pill {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted);
}
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.ghost {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--line); border-radius: 99px;
  padding: 8px 14px; font-size: 13px; transition: background .2s, border-color .2s;
}
.ghost:hover { background: var(--paper); border-color: #cfc6b8; }
.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(120% 90% at 50% 38%, #faf8f4 0%, #efeae2 55%, #e2dbcf 100%);
  background-size: cover; background-position: center;
}
.stage::after { /* soft floor */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: linear-gradient(to bottom, transparent, rgba(160, 145, 125, .10));
  pointer-events: none;
}
model-viewer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  --poster-color: transparent;
  --progress-bar-color: transparent;
  outline: none;
  z-index: 1;
}
.stage-title {
  position: absolute; top: 28px; left: 32px; z-index: 2; pointer-events: none;
  transition: opacity .3s;
}
.eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.stage-title h1 { margin: 0; font: 400 clamp(30px, 3.4vw, 48px)/1.02 var(--serif); letter-spacing: -.01em; }
.stage-stone { margin: 6px 0 0; font: italic 400 20px/1.2 var(--serif); color: var(--accent-ink); }
.stage-hint {
  position: absolute; top: 34px; right: 28px; z-index: 2; font-size: 12px; color: var(--muted);
  pointer-events: none; transition: opacity .6s;
}

.toolbar {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 6px; padding: 6px;
  background: rgba(250, 248, 244, .82); backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .7); border-radius: 99px;
  box-shadow: 0 10px 30px rgba(60, 45, 25, .10), 0 1px 0 rgba(255,255,255,.8) inset;
}
.tool {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  border: 0; background: transparent; padding: 9px 14px; border-radius: 99px; font-size: 13px;
  transition: background .2s, color .2s;
}
.tool svg { width: 18px; height: 18px; }
.tool:hover { background: rgba(0, 0, 0, .05); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tool-ar { background: var(--ink); color: var(--paper); }
.tool-ar:hover { background: #000; }
.icon-only { padding: 9px 10px; }


/* dimension overlay */
.dim-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.dim-lines line { stroke: var(--ink); stroke-width: 1.2; }
.dim-lines .tick { stroke-width: 1.2; }
.dim-label {
  border: 0; padding: 3px 9px; border-radius: 99px; pointer-events: none;
  background: var(--ink); color: var(--paper); font: 500 12px/1.3 var(--sans); white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.dim-label small { opacity: .6; font-weight: 400; margin-left: 2px; }
.dim-pt { width: 1px; height: 1px; pointer-events: none; opacity: 0; }
.dims-off .dim-label, .dims-off .dim-lines { display: none; }

/* loader */
.loader {
  position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); transition: opacity .6s var(--ease), visibility .6s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader p { margin: 0; font: italic 400 22px var(--serif); color: var(--ink-2); }
.loader-slab {
  width: 120px; height: 72px; border-radius: 4px;
  background: linear-gradient(115deg, #ece9e3 0%, #ece9e3 38%, #2b4a39 40%, #ece9e3 43%, #e4e0d8 70%, #6d8a76 71.5%, #e4e0d8 73%);
  background-size: 300% 100%;
  animation: slab 2.4s linear infinite;
  box-shadow: 0 18px 40px rgba(60,45,25,.18);
}
@keyframes slab { to { background-position: -300% 0; } }

/* ---------- panel ---------- */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--paper); border-left: 1px solid var(--line-2);
}
.panel-scroll { flex: 1; overflow-y: auto; padding: 8px 26px 24px; scrollbar-width: thin; }
.step { padding: 22px 0 24px; border-bottom: 1px solid var(--line-2); }
.step:last-of-type { border-bottom: 0; }
.step > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.num { font: 500 11px var(--sans); color: var(--accent); letter-spacing: .1em; }
.step h2 { margin: 0; font: 500 24px/1 var(--serif); }
.aside { margin-left: auto; font-size: 12px; color: var(--muted); }
.badge {
  margin-left: auto; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-ink); background: #efe6d8; padding: 3px 8px; border-radius: 99px;
}
.blurb { margin: 12px 0 0; color: var(--ink-2); font-size: 13px; }
.hint { margin: -4px 0 14px; color: var(--ink-2); font-size: 13px; }

.piece-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.piece {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px 10px; border: 1px solid var(--line); border-radius: 12px; background: transparent;
  font-size: 12px; transition: border-color .2s, background .2s, box-shadow .2s;
}
.piece svg { width: 42px; height: 34px; stroke-width: 1.3; color: var(--ink-2); }
.piece:hover { border-color: #c9bfb0; }
.piece[aria-checked="true"] { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink) inset; }

.stone-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stone {
  position: relative; aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0;
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08) inset, 0 3px 8px rgba(60,45,25,.12);
  transition: transform .25s var(--ease), box-shadow .25s;
}
.stone:hover { transform: translateY(-2px); }
.stone[aria-checked="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink), 0 6px 14px rgba(60,45,25,.18); }
.stone .tier { position: absolute; right: -2px; bottom: -2px; font-size: 9px; background: var(--paper); border-radius: 99px; padding: 1px 4px; color: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.stone-note { margin-top: 14px; min-height: 64px; }
.stone-name { margin: 0 0 2px; font: 500 20px/1.2 var(--serif); }
.stone-note p:last-child { margin: 0; color: var(--ink-2); font-size: 13px; }

.slab-wrap {
  position: relative; border-radius: 10px; overflow: hidden; background: #ddd;
  box-shadow: 0 10px 26px rgba(60,45,25,.14); touch-action: none; cursor: grab; aspect-ratio: 1;
}
.slab-wrap.dragging { cursor: grabbing; }
.slab-wrap canvas { display: block; width: 100%; height: 100%; }
.slab-scale {
  position: absolute; left: 10px; bottom: 9px; display: flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: .06em; color: rgba(255,255,255,.85); text-shadow: 0 1px 2px rgba(0,0,0,.5);
  pointer-events: none;
}
.slab-scale span { width: 28px; height: 1px; background: currentColor; }
.slab-tools { display: flex; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 99px; background: transparent; font-size: 12px;
  transition: border-color .2s, background .2s;
}
.chip svg { width: 15px; height: 15px; }
.chip:hover { border-color: #c9bfb0; background: #fff; }
.chip[aria-checked="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.slider { margin: 0 0 14px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.slider-top label { font-size: 13px; color: var(--ink-2); }
.slider-top output { font: 500 15px var(--sans); font-variant-numeric: tabular-nums; }
.slider-top output small { color: var(--muted); font-weight: 400; margin-left: 2px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill, 50%), var(--line) var(--fill, 50%));
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -8px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink);
}

.opt { margin-bottom: 16px; }
.opt-label { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button {
  text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.seg button strong { display: block; font-weight: 500; font-size: 13px; }
.seg button small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.seg button:hover { border-color: #c9bfb0; }
.seg button[aria-checked="true"] { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink) inset; }

.backlight { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: linear-gradient(120deg, #f3f0e4, #eef2e2); cursor: pointer; }
.backlight input { position: absolute; opacity: 0; pointer-events: none; }
.track { flex: none; width: 38px; height: 22px; border-radius: 99px; background: #cfc7ba; position: relative; transition: background .25s; }
.knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.backlight input:checked + .track { background: #b9963f; }
.backlight input:checked + .track .knob { transform: translateX(16px); }
.backlight input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }
.bl-text strong { display: block; font-weight: 500; }
.bl-text small { color: var(--ink-2); font-size: 12px; }

.colophon { margin: 18px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }

.summary {
  padding: 16px 26px 18px; border-top: 1px solid var(--line-2); background: var(--paper);
  box-shadow: 0 -10px 30px rgba(60,45,25,.05);
}
.summary-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.price .label { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.price .amount { font: 500 27px/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.facts { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.summary-row { flex-wrap: wrap; }
.cta {
  width: 100%; display: inline-flex; justify-content: center; align-items: center; gap: 10px;
  padding: 15px 18px; border: 0; border-radius: 12px; background: var(--ink); color: var(--paper);
  font-size: 14px; font-weight: 500; letter-spacing: .02em; transition: background .2s, transform .2s;
}
.cta:hover { background: #000; }
.cta:active { transform: scale(.99); }
.cta.small { width: auto; padding: 11px 18px; }
.cta:disabled { opacity: .6; cursor: progress; }
.fine { margin: 8px 0 0; text-align: center; font-size: 11px; color: var(--muted); }

/* ---------- modals ---------- */
.modal {
  border: 0; padding: 0; border-radius: 18px; background: var(--paper); color: var(--ink);
  width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  box-shadow: 0 40px 100px rgba(30, 20, 10, .35);
}
.modal::backdrop { background: rgba(28, 24, 18, .45); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .35s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-sm { width: min(420px, calc(100vw - 32px)); padding: 30px; text-align: center; }
.modal-close { position: absolute; top: 10px; right: 12px; margin: 0; z-index: 2; }
.modal-close button { border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--muted); padding: 6px 10px; }
.modal h2 { margin: 0 0 8px; font: 500 32px/1.1 var(--serif); }
.muted { color: var(--ink-2); margin: 0 0 16px; }

.enq { display: grid; grid-template-columns: 1fr 1fr; }
.enq-visual { background: linear-gradient(160deg, #f4f1eb, #e6dfd3); padding: 26px; border-radius: 18px 0 0 18px; }
.enq-visual img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; display: block; }
.spec { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; font-size: 13px; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; text-align: right; }
.spec .total { font: 500 20px var(--serif); }
.enq-form { padding: 30px 30px 24px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.enq-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.enq-form input:not([type=checkbox]), .enq-form textarea {
  font: inherit; font-size: 14px; color: var(--ink); padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; resize: vertical;
}
.enq-form input:focus, .enq-form textarea:focus { border-color: var(--ink); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.enq-form .check { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink); }
.enq-form .check input { margin-top: 3px; accent-color: var(--ink); }
.enq-form .cta { margin-top: 6px; }

.enq-done { padding: 56px 40px 44px; text-align: center; max-width: 560px; margin: 0 auto; }
.done-mark { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-size: 24px; }
.done-actions { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.done-actions form { margin: 0; }
.ghost-btn { color: var(--ink); font-size: 13px; text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 2px; }

.qr { display: grid; place-items: center; margin: 8px auto 4px; padding: 14px; background: #fff; border-radius: 14px; width: fit-content; }
.qr svg { width: 220px; height: 220px; display: block; }
.qr svg path, .qr svg rect { stroke: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 50;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 99px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { :root { --panel-w: 380px; } .stone-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; } }
@media (max-width: 860px) {
  body { overflow: auto; }
  :root { --top-h: 54px; }
  .topbar { padding: 0 14px; }
  .brand-mark { font-size: 17px; letter-spacing: .26em; }
  .brand-sub { font-size: 16px; }
  .pill { font-size: 9px; padding: 3px 7px; letter-spacing: .06em; }
  .brand-sub { display: none; }
  .ghost { font-size: 0; gap: 0; }
  .ghost svg { width: 18px; height: 18px; }
  .ghost { padding: 7px 11px; }
  .layout { position: static; display: block; padding-top: var(--top-h); }
  .stage { position: sticky; top: var(--top-h); height: 54vh; z-index: 4; border-bottom: 1px solid var(--line-2); }
  .stage-title { top: 14px; left: 16px; }
  .stage-title h1 { font-size: 26px; }
  .stage-stone { font-size: 16px; }
  .stage-hint { display: none; }
  .eyebrow { font-size: 10px; }
  .toolbar { bottom: 12px; max-width: calc(100% - 20px); }
  .tool span { display: none; }
  .tool-ar span { display: inline; }
  .tool { padding: 9px 11px; }
  .panel { border-left: 0; }
  .panel-scroll { overflow: visible; padding: 4px 18px 140px; }
  .summary { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .summary-row { margin-bottom: 10px; }
  .price .amount { font-size: 22px; }
  .fine { display: none; }
  .modal .fine { display: block; }
  .enq { grid-template-columns: 1fr; }
  .enq-visual { border-radius: 18px 18px 0 0; padding: 18px; }
  .enq-form { padding: 22px 18px; }
  .stone-grid { gap: 10px; }
}

/* backlit onyx: lights down */
.stage { transition: background .6s; }
.stage.night { background: radial-gradient(110% 85% at 50% 40%, #3a332b 0%, #1b1815 55%, #0e0c0a 100%); }
.stage.night::after { background: linear-gradient(to bottom, transparent, rgba(0,0,0,.25)); }
.stage.night .stage-title h1 { color: #f3ede3; }
.stage.night .stage-stone { color: #d8b878; }
.stage.night .eyebrow, .stage.night .stage-hint { color: #a89d8e; }
.stage.night .dim-lines line { stroke: #f3ede3; }
.field-row label { min-width: 0; }
.enq-form input:not([type=checkbox]) { width: 100%; }
.enq-visual img:not([src]), .enq-visual img[src=""] {
  visibility: hidden;
}
.enq-visual .snap-frame { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%) 0 0 / 200% 100%, rgba(0,0,0,.03); animation: shimmer 1.4s linear infinite; }
.enq-visual .snap-frame.ready { animation: none; background: none; }
.enq-visual .snap-frame img { position: absolute; inset: 0; height: 100%; }
@keyframes shimmer { to { background-position: -200% 0, 0 0; } }

/* powered-by capsule */
.powered {
  position: absolute; top: 22px; left: 32px; z-index: 4;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px 10px 14px; border-radius: 99px;
  background: var(--ink); color: var(--paper); text-decoration: none;
  font: 400 13.5px/1 var(--sans); letter-spacing: .02em;
  box-shadow: 0 8px 24px rgba(28, 22, 14, .22), 0 0 0 1px rgba(255,255,255,.08) inset;
  transition: transform .25s var(--ease), box-shadow .25s;
}
.powered:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(28, 22, 14, .3), 0 0 0 1px rgba(255,255,255,.12) inset; }
.powered-by { opacity: .7; }
.powered strong { font-weight: 600; letter-spacing: .04em; }
.powered svg { width: 13px; height: 13px; opacity: .8; }
.powered-dot { width: 7px; height: 7px; border-radius: 50%; background: #d8b878; box-shadow: 0 0 0 3px rgba(216,184,120,.25); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(216,184,120,0); } }
.stage.night .powered { background: #f3ede3; color: var(--ink); }
.stage-title { top: 80px; }
@media (max-width: 860px) {
  .powered { top: 12px; left: 14px; padding: 6px 11px 6px 9px; font-size: 11px; }
  .stage-title { top: 52px; }
}
.colophon a { color: var(--ink-2); }

@media (min-width: 560px) and (max-width: 860px) {
  .stone-grid { grid-template-columns: repeat(9, 1fr); }
  .slab-wrap { max-width: 480px; margin: 0 auto; }
}
