:root {
  --ground: #FAF8F4;
  --card: #FFFFFF;
  --ink: #26262A;
  --ink-soft: #55555C;
  --line: #E6E1D8;
  --accent: #2F6E73;
  --accent-tint: #EEF5F4;
  --opal: conic-gradient(from 200deg, #8FD3C8, #B9B2F0, #F3B4C2, #A9D4F0, #F5DFAE, #8FD3C8);
  --radius: 18px;
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ground); }
body { -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.boot { margin: auto; font-weight: 700; color: var(--ink-soft); }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.logo { width: 28px; height: 28px; border-radius: 54% 46% 50% 50% / 56% 50% 50% 44%; background: var(--opal); display: flex; align-items: center; justify-content: center; flex: none; }
.logo::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--ground); }
.badge { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-tint); padding: 4px 9px; border-radius: 999px; }
.linkbtn { background: none; border: none; color: var(--ink); font-weight: 600; font-size: 15px; padding: 10px 4px; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Text */
h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.lead { font-size: 17px; line-height: 1.5; color: var(--ink-soft); margin: 0; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: 0; }
.small { font-size: 13px; line-height: 1.45; color: var(--ink-soft); margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 999px; border: none; background: var(--ink); color: #FFFFFF; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn.small-btn { min-height: 44px; font-size: 15px; width: auto; padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* Hero on welcome */
.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.hero-art { width: 120px; height: 120px; border-radius: 54% 46% 50% 50% / 56% 50% 50% 44%; background: var(--opal); display: flex; align-items: center; justify-content: center; }
.hero-art::after { content: ""; width: 60px; height: 60px; border-radius: 50%; background: var(--ground); }

/* Quiz */
.group-title { font-size: 14px; font-weight: 700; color: var(--ink-soft); margin: 10px 0 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-card { position: relative; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 0; overflow: hidden; cursor: pointer; color: var(--ink); min-height: 44px; }
.style-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.swatch { display: flex; height: 56px; }
.swatch span { flex: 1; }
.style-card .name { display: block; font-weight: 700; font-size: 15px; padding: 10px 12px 2px; }
.style-card .line { display: block; font-size: 12.5px; line-height: 1.35; color: var(--ink-soft); padding: 0 12px 12px; }
.num { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #FFFFFF; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sticky { position: sticky; bottom: 0; padding: 12px 0 max(8px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(250,248,244,0), var(--ground) 30%); }

/* Result */
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result-card .swatch { height: 96px; }
.result-card .body { padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 0 14px; min-height: 40px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }

/* Choice cards */
.choice { display: flex; align-items: center; gap: 14px; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; color: var(--ink); min-height: 76px; }
.choice .icon { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-tint); display: flex; align-items: center; justify-content: center; flex: none; }
.choice strong { display: block; font-size: 17px; }
.choice span { display: block; font-size: 14px; color: var(--ink-soft); margin-top: 2px; }

/* Photo */
.photo-frame { position: relative; border-radius: var(--radius); overflow: hidden; background: #EDEAE4; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; }
.photo-frame img { width: 100%; height: 100%; object-fit: contain; display: block; background: #EDEAE4; }
.ai-tag { position: absolute; left: 10px; bottom: 10px; background: rgba(38,38,42,0.78); color: #FFFFFF; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; }
.toggle { display: flex; background: #EDEAE4; border-radius: 999px; padding: 4px; gap: 4px; }
.toggle button { flex: 1; min-height: 40px; border: none; border-radius: 999px; background: transparent; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; background: var(--opal); animation: spin 1.4s linear infinite; mask: radial-gradient(circle, transparent 52%, #000 54%); -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%); }
@keyframes spin { to { transform: rotate(360deg); } }
.working { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 24px 0; }
.error { background: #FBEBEB; color: #7A1F1F; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin: 0; }

/* Live */
.live { position: fixed; inset: 0; background: #111113; color: #FFFFFF; display: flex; flex-direction: column; z-index: 10; }
.live video.out { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #111113; }
.live video.in { position: absolute; top: max(64px, calc(env(safe-area-inset-top) + 56px)); right: 12px; width: 92px; height: 120px; object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,0.7); background: #222; }
.live .bar { position: absolute; top: 0; left: 0; right: 0; padding: max(12px, env(safe-area-inset-top)) 14px 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0)); }
.live .status { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #F3B4C2; }
.live .dot.on { background: #8FD3C8; }
.live .bottom { padding: 12px 14px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.6) 35%); display: flex; flex-direction: column; gap: 12px; }
.live .chip { background: rgba(255,255,255,0.12); color: #FFFFFF; border-color: rgba(255,255,255,0.25); }
.live .chip[aria-pressed="true"] { background: #FFFFFF; color: #111113; }
.live .stop { background: #FFFFFF; color: #111113; }
.live .msg { text-align: center; font-size: 14px; color: rgba(255,255,255,0.85); margin: 0; }
.live .ai-tag { left: 14px; bottom: auto; top: max(64px, calc(env(safe-area-inset-top) + 56px)); }

.footer { margin-top: auto; display: flex; justify-content: center; }
