:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1d1a17;
  --muted: #71685e;
  --line: #e7e0d6;
  --soft: #f3eee6;
  --accent: #a87b3c;
  --accent-dark: #8a6430;
  --accent-soft: #f5ead9;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(60, 40, 10, .25);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --header: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.01em; }
em { font-style: italic; color: var(--accent); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; height: var(--header); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: rgba(250, 247, 242, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-family: var(--serif); font-size: 28px; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.logo em { font-weight: 500; }
.site-header nav { display: flex; align-items: center; gap: 22px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.site-header nav a:hover { color: var(--ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 14px var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s, transform .1s; }
.btn:hover { border-color: #cdbfa9; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #3a332c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { height: 36px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: #cdbfa9; }

/* Describe search */
.describe { padding: 14px 24px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.describe-form { display: flex; align-items: center; gap: 10px; max-width: 860px; margin: 0 auto; padding: 5px 5px 5px 16px; border: 1px solid #d9cdbb; border-radius: 999px; background: var(--card); box-shadow: 0 6px 20px -14px rgba(60, 40, 10, .45); }
.describe-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.describe-form > svg { color: var(--accent); width: 20px; height: 20px; }
.describe-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 400 16px var(--sans); color: var(--ink); padding: 8px 0; }
.describe-form input::-webkit-search-cancel-button { display: none; }
.describe-feedback { display: flex; gap: 6px; align-items: center; max-width: 860px; margin: 10px auto 0; overflow-x: auto; scrollbar-width: none; white-space: nowrap; min-height: 28px; }
.describe-feedback::-webkit-scrollbar { display: none; }
.fb-label { font-size: 12px; font-weight: 600; color: var(--muted); flex: none; }
.fb-label.hint { font-weight: 400; margin-left: 6px; }
.fb-label.warn { font-weight: 400; color: #9a5a2a; white-space: normal; }
.chip { flex: none; font: 500 12px var(--sans); padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.chip.example { cursor: pointer; }
.chip.example:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip.ok { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
.chip.note { background: #eef2f6; border-color: transparent; color: #4b5a68; }
.chip.pending { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dark); border-color: var(--accent-soft); }
.chip.pending .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.fb-label.ai-says { color: var(--ink); font-style: italic; }

/* Studio */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - var(--header) - 106px); height: calc(100dvh - var(--header) - 106px); min-height: 580px; }
.viewer { position: relative; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, #fffdf9, #ebe3d8); touch-action: none; }
#ring-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#ring-canvas:active { cursor: grabbing; }
.hero { position: absolute; top: 28px; left: 32px; pointer-events: none; }
.hero h1 { font-size: clamp(30px, 3.6vw, 50px); line-height: 1.02; }
.hero p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.viewer-toolbar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; }
.viewer-toolbar .icon-btn, .viewer-toolbar .btn { box-shadow: var(--shadow); }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 14px; background: radial-gradient(ellipse at 50% 45%, #fffdf9, #ebe3d8); transition: opacity .4s; }
.loading span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.loading.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Panel */
.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 8px 24px 24px; }
.step { padding: 20px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step h2 { font-size: 24px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step h2 span { font: 600 11px var(--sans); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-dark); }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; display: flex; justify-content: space-between; }
.label b { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; font-size: 13px; }
.step h2 + .label { margin-top: 0; }

.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.opt { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; text-align: center; transition: border-color .15s, box-shadow .15s; }
.opt small { color: var(--muted); font-size: 11px; font-weight: 400; }
.opt:hover { border-color: #cdbfa9; }
.opt.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.opts.shapes { grid-template-columns: repeat(4, 1fr); }
.opts.shapes .opt { min-height: 72px; font-size: 12px; gap: 6px; }
.opts.shapes svg { width: 30px; height: 30px; fill: #eef5fb; stroke: #5d6a77; stroke-width: 1.4; }
.opts.shapes .opt.active svg { stroke: var(--accent-dark); fill: #fbf3e6; }

.opts.two { grid-template-columns: repeat(2, 1fr); }
.opts.three { grid-template-columns: repeat(3, 1fr); }
.sw.match { background: conic-gradient(#f3c56b 0 25%, #e9e7e3 0 50%, #eeb19a 0 75%, #d5d7db 0); }
.track-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 20px; margin: 4px 0 8px; }
.track-status.ok { color: #3c7a4a; }
.track-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.track-status.busy .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.opts.swatches { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.opts.swatches .opt { min-height: 84px; font-size: 12px; gap: 6px; line-height: 1.2; }
.sw { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 -3px 6px rgba(0,0,0,.18), inset 0 3px 6px rgba(255,255,255,.6), 0 0 0 1px rgba(0,0,0,.08); }

.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; min-width: 0; }
.field.grow { flex: 1 1 160px; }
.field input, .field select, .field textarea { font: 400 15px var(--sans); color: var(--ink); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.summary { border-top: 1px solid var(--line); padding: 16px 24px 20px; background: var(--card); }
.summary-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.summary-title { font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.15; }
.summary-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.price-wrap { text-align: right; flex: none; }
.price { font-weight: 600; font-size: 15px; }
.price-note { color: var(--muted); font-size: 11px; }
.actions { display: flex; gap: 8px; }

/* Content sections */
.how { padding: 88px 24px; max-width: 1100px; margin: 0 auto; text-align: center; }
.how > h2 { font-size: clamp(32px, 4vw, 48px); margin-bottom: 40px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: left; }
.cards article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.cards .num { font-family: var(--serif); color: var(--accent); font-size: 22px; }
.cards h3 { font-size: 26px; margin: 6px 0 8px; }
.cards p { color: var(--muted); margin: 0; }
.jewelers { max-width: 1100px; margin: 0 auto 88px; padding: 36px 40px; border-radius: 20px; background: var(--ink); color: #f3ede4; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.jewelers h2 { font-size: 30px; }
.jewelers p { color: #bdb3a6; margin: 6px 0 0; max-width: 560px; }
.jewelers .btn.primary { background: #fff; color: var(--ink); border-color: #fff; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* Modals */
.modal { border: 0; padding: 0; border-radius: 20px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--bg); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }
.modal.wide { width: min(1040px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(29, 26, 23, .5); backdrop-filter: blur(3px); }
.modal > *:not(.modal-head) { margin-left: 24px; margin-right: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 12px 24px; }
.modal-head h2 { font-size: 28px; }
.modal-head .icon-btn { width: 38px; height: 38px; }
.fine { color: var(--muted); font-size: 12px; margin: 12px 0 20px; }
.lead { color: var(--muted); margin: 0 0 14px; }

.tryon { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; padding-bottom: 20px; }
.stage-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.stage { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 68vh; border-radius: 14px; overflow: hidden; background: var(--soft); border: 1px dashed #d8cdbd; touch-action: none; user-select: none; }
.stage.has-photo { border-style: solid; border-color: var(--line); }
.stage-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; color: var(--muted); }
.stage-empty strong { color: var(--ink); }
.hand-hint { font-size: 46px; margin-bottom: 4px; }
#hand-img, #cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ring-overlay { position: absolute; transform: translate(-50%, -50%); cursor: move; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); pointer-events: none; }
.cam-bar { display: flex; gap: 10px; }
.tryon-controls .tip { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.tryon-controls.disabled { opacity: .45; pointer-events: none; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--card); }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 999px; font: 500 13px var(--sans); color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--ink); color: #fff; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

.share-preview { display: block; width: calc(100% - 48px); aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--soft); }
.copy-row { display: flex; gap: 8px; margin-top: 14px !important; }
.copy-row input { flex: 1; min-width: 0; font: 13px var(--sans); padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); }
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px !important; }
.share-grid .btn { padding: 0 8px; }

#designer-form { padding-bottom: 24px; }
.design-chip { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); margin-bottom: 16px; font-size: 13px; }
.design-chip img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--soft); }
.design-chip b { display: block; font-family: var(--serif); font-size: 17px; }
.design-chip span { color: var(--muted); }
.thanks { text-align: center; padding: 10px 0 30px; }
.thanks .big { font-size: 44px; }
.thanks h3 { font-size: 28px; margin: 6px 0; }
.thanks p { color: var(--muted); margin: 0 0 18px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .viewer { height: 56vh; height: 56svh; min-height: 340px; }
  .panel { border-left: 0; }
  .panel-scroll { overflow: visible; padding: 0 16px 8px; }
  .summary { position: sticky; bottom: 0; padding: 12px 16px 14px; box-shadow: 0 -8px 24px -12px rgba(0,0,0,.2); }
  .hero { top: 16px; left: 16px; }
  .hero p { display: none; }
  .hero h1 { font-size: 24px; }
  .viewer-toolbar { bottom: 14px; }
  .cards { grid-template-columns: 1fr; }
  .jewelers { margin: 0 16px 56px; padding: 28px 24px; flex-direction: column; align-items: flex-start; }
  .how { padding: 56px 16px; }
  .tryon { grid-template-columns: 1fr; }
  .site-header { padding: 0 16px; }
  .describe { padding: 10px 16px 8px; }
  .describe-form .btn { padding: 0 14px; height: 40px; }
  .site-header nav a { display: none; }
}
@media (max-width: 480px) {
  .opts { grid-template-columns: repeat(2, 1fr); }
  .opts.three { grid-template-columns: repeat(3, 1fr); }
  .opts.shapes { grid-template-columns: repeat(4, 1fr); }
  .opts.swatches { grid-template-columns: repeat(3, 1fr); }
  .share-grid { grid-template-columns: repeat(2, 1fr); }
  .modal > *:not(.modal-head) { margin-left: 16px; margin-right: 16px; }
  .share-preview { width: calc(100% - 32px); }
  .actions .btn:not(.primary) { padding: 0 12px; }
  .summary-title { font-size: 18px; }
  .viewer-toolbar .btn.primary { padding: 0 14px; font-size: 13px; }
}
