:root {
  --ink: #20261a; --muted: #6a7462; --accent: #6f9f4a; --line: #e3e9cb; --gold: #96cc76;
  --btn: linear-gradient(135deg, #c7dd4a, #96cc76); --chip: #f4f9ef;
  --rose: #e2a792; --white: #dfe2e6; --yellow: #e0b65a; --ok: #3fb57a; --warn: #f2b84b;
  --sans: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: Outfit, Manrope, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --panel-h: 196px; --side: 0px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font: 15px/1.45 var(--sans); -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; }
button { cursor: pointer; }
.glass { background: rgba(13, 16, 10, .55); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); }

/* ---------- camera ---------- */
#cameraArea { position: fixed; top: 0; left: 0; bottom: 0; right: var(--side); overflow: hidden; }
#stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(var(--s, 1)); }
#stage.mirror { transform: translate(-50%, -50%) scale(calc(-1 * var(--s, 1)), var(--s, 1)); }
#stage video, #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage #gl { opacity: 0; }
#debug { position: fixed; left: 8px; bottom: 8px; z-index: 9; font: 11px/1.3 ui-monospace, monospace; background: rgba(0,0,0,.6); color: #8ef0bd; padding: 3px 6px; border-radius: 6px; }

/* hand outline shown while no hand is visible */
#handHint { position: absolute; left: 50%; top: 46%; width: min(46vw, 260px); transform: translate(-50%, -50%);
  opacity: 0; transition: opacity .4s var(--ease); pointer-events: none; }
#handHint.show { opacity: .8; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(1.04); } }

/* ---------- top bar ---------- */
.top { position: fixed; top: 0; left: 0; right: var(--side); display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 22px; background: linear-gradient(rgba(0,0,0,.6), transparent); z-index: 3; }
.round { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; border: 0; text-decoration: none; font-size: 18px; }
.titles { flex: 1; min-width: 0; }
.titles small { display: block; font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.titles h1 { margin: 1px 0 0; font: 500 17px/1.2 var(--serif); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles span { font-size: 12px; color: rgba(255,255,255,.7); }
.mini-loader { display: inline-flex; align-items: center; gap: 6px; }
.pl-logo { width: 16px; height: 16px; flex: none; color: var(--gold); animation: plBob 1.3s ease-in-out infinite; }
.pl-logo .g { transform-box: fill-box; transform-origin: center; animation: plGem 1.3s ease-in-out infinite; }
@keyframes plBob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }
@keyframes plGem { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .pl-logo, .pl-logo .g { animation: none !important; } }

/* ---------- guide pill ---------- */
#guide { position: fixed; left: calc((100% - var(--side)) / 2); top: calc(74px + var(--safe-t)); transform: translateX(-50%);
  z-index: 3; width: max-content; max-width: min(92vw, 460px); }
#pill { display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.14); color: #fff;
  border-radius: 99px; padding: 7px 14px 7px 8px; text-align: left; transition: border-color .3s, background .3s; }
#progress { --p: 0; width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c, var(--warn)) calc(var(--p) * 360deg), rgba(255,255,255,.18) 0); }
#progress::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: rgba(13,16,10,.9); }
#tip { font-weight: 600; font-size: 14px; }
#guide[data-state="ready"] #pill { border-color: rgba(63,181,122,.8); background: rgba(20, 60, 38, .6); }
#guide[data-state="ready"] #progress, #guide[data-state="photo"] #progress { --c: var(--ok); }
#guide[data-state="photo"] #pill { border-color: rgba(150,204,118,.8); }
#checks { list-style: none; margin: 8px auto 0; padding: 10px; display: none; flex-wrap: wrap; justify-content: center; gap: 5px;
  border-radius: 14px; max-width: 360px; }
#guide.open #checks { display: flex; }
#checks li { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.1); color: rgba(255,255,255,.75); }
#checks li::before { content: "•"; margin-right: 4px; color: var(--warn); }
#checks li.ok { background: rgba(63,181,122,.25); color: #fff; }
#checks li.ok::before { content: "✓"; color: #8ef0bd; }

/* ---------- shutter / photo controls ---------- */
.controls { position: fixed; left: calc((100% - var(--side)) / 2); transform: translateX(-50%);
  bottom: calc(var(--panel-h) + 18px + var(--safe-b)); z-index: 3; display: flex; gap: 14px; align-items: center; }
#shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25);
  box-shadow: 0 6px 24px rgba(0,0,0,.35); transition: transform .2s var(--ease), opacity .3s, background .3s; }
#shutter:not(:disabled) { background: var(--btn); color: var(--btn-ink, #1d2f10); }
#shutter:not(:disabled):active { transform: scale(.92); }
#shutter:disabled { opacity: .45; cursor: default; }
.pillbtn { border: 0; border-radius: 99px; padding: 12px 20px; font-weight: 700; display: none; align-items: center; gap: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.3); white-space: nowrap; }
#retake { color: #fff; }
#save { background: var(--btn); color: var(--btn-ink, #1d2f10); }
body.frozen #shutter { display: none; }
body.frozen .pillbtn { display: inline-flex; }

/* ---------- bottom panel (side panel on wide screens) ---------- */
.panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; color: var(--ink); background: #fff;
  border-radius: 22px 22px 0 0; padding: 14px 0 calc(12px + var(--safe-b)); box-shadow: 0 -10px 30px rgba(0,0,0,.28);
  max-height: 80vh; overflow-y: auto; }
.bar { display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 14px 8px; scroll-padding: 0 14px; }
.row::-webkit-scrollbar { display: none; }
#metals { padding: 0; gap: 6px; }
.metal { flex: none; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 99px;
  padding: 6px 11px 6px 7px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.metal[aria-pressed="true"] { background: var(--btn); border-color: #dfc07a; font-weight: 700; color: var(--btn-ink, #1d2f10); }
.dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.12); }
.dot.yellow { background: radial-gradient(circle at 35% 30%, #fff3c4, var(--yellow) 60%); }
.dot.rose { background: radial-gradient(circle at 35% 30%, #ffe1d6, var(--rose) 60%); }
.dot.white { background: radial-gradient(circle at 35% 30%, #fff, var(--white) 60%); }
#more { margin-left: auto; flex: none; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 99px; padding: 6px 11px; font-size: 13px; white-space: nowrap; }
#more b { color: var(--accent); }
.label { margin: 12px 14px 8px; font: 700 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.label em { font-style: normal; color: var(--accent); margin-left: 4px; }
.design { flex: none; width: 92px; border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 6px 6px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink); transition: border-color .2s, transform .2s var(--ease); }
.design .thumb { width: 78px; height: 78px; border-radius: 12px; background: #f4f8f0 center / contain no-repeat; }
.design small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.design[aria-pressed="true"] { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(111,159,74,.7); }
.design[aria-pressed="true"] small { color: var(--ink); font-weight: 700; }
.sizebox { display: none; padding: 0 14px; }
body.panel-open .sizebox { display: block; }
.sizebox select { width: 100%; padding: 11px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

@media (max-width: 380px) { .metal span { display: none; } .metal { padding: 6px; } }
@media (min-width: 900px) {
  :root { --side: 380px; --panel-h: 0px; }
  .panel { left: auto; top: 0; width: var(--side); border-radius: 0; max-height: none; padding-top: 22px; box-shadow: -10px 0 30px rgba(0,0,0,.25); }
  .row#designs { flex-wrap: wrap; overflow: visible; }
  .design { width: calc((100% - 16px) / 3); }
  .design .thumb { width: 100%; height: auto; aspect-ratio: 1; }
  .sizebox { display: block; }
  #more { display: none; }
  .controls { bottom: 28px; }
}

/* ---------- start screen ---------- */
#intro { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 50% 30%, #233418, #080a06 70%); text-align: center; }
#intro .card { width: min(380px, 100%); }
#intro h2 { font: 300 30px/1.15 var(--serif); letter-spacing: .06em; margin: 0 0 10px; }
#intro p { color: rgba(255,255,255,.75); margin: 0 0 8px; }
#intro ul { text-align: left; color: rgba(255,255,255,.85); padding-left: 20px; margin: 14px 0 20px; }
#start { width: 100%; padding: 14px; border: 0; border-radius: 99px; background: var(--btn); color: var(--btn-ink, #1d2f10); font-weight: 700; }
#start:disabled { opacity: .6; }
#intro #steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; }
#steps li { font-size: 13px; color: rgba(255,255,255,.5); display: flex; gap: 8px; align-items: center; }
#steps li::before { content: "○"; width: 16px; text-align: center; }
#steps li[data-state="busy"] { color: #d4e57a; }
#steps li[data-state="busy"]::before { content: "◌"; animation: spin 1s linear infinite; display: inline-block; }
#steps li[data-state="done"] { color: #fff; }
#steps li[data-state="done"]::before { content: "✓"; color: #8ef0bd; }
@keyframes spin { to { transform: rotate(360deg); } }
#startMsg { min-height: 1.4em; margin-top: 12px; font-size: 13px; color: #d4e57a; }
.private { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 14px; }
/* phones: headings scale with the screen (320px → 720px) instead of staying at one size;
   form fields at 16px so iPhones don't zoom the page when one is tapped */
@media (max-width: 720px) {
  #intro h2 { font-size: clamp(22px, 15.6px + 2vw, 30px); }
  input, select, textarea { font-size: 16px; }
}
/* phones: form fields in the page's own font (not the browser's default), placeholders and the chosen value in drop-downs
   at 14px, closer to the small field names above them (they were 16px and looked oversized), 2026-11-19. Typed text
   stays 16px so iPhones don't zoom. Fields with their own font or size rule keep it. Phones only. */
@media (max-width: 720px) {
  html body :is(input, select, textarea) { font-family: inherit; }
  html body :is(input, textarea)::placeholder { font-size: min(14px, 1em); }
  html body select:not([multiple]) { font-size: 14px; }
}
