:root {
  --bg: #0e1320;
  --panel: #161d2e;
  --panel-2: #1b2438;
  --border: #2a3550;
  --text: #eef2ff;
  --muted: #93a0bd;
  --accent: #4f8cff;
  --accent-2: #7ee0b6;
  --warn: #ffb454;
  --danger: #ff7a7a;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-size: 21px; font-weight: 800; }
.brand span { color: var(--accent); }
header .rail { display: flex; gap: 14px; margin-left: 8px; }
header .rail a { color: var(--muted); text-decoration: none; font-size: 14px; }
header .rail a:hover { color: var(--text); }
.donate { margin-left: auto; display: flex; gap: 8px; }
.donate a {
  font-size: 13px; padding: 7px 13px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border); color: var(--text); background: var(--panel);
}
.donate a.kofi:hover { border-color: #ff6aa5; }
.donate a.paypal:hover { border-color: var(--accent-2); }

main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 26px 18px 60px; }

.view { display: none; }
.view.active { display: block; }

.hero { text-align: center; padding: 12px 0 6px; }
.hero .emoji { font-size: 56px; }
.hero h1 { font-size: 34px; line-height: 1.2; margin: 8px 0 10px; }
.hero h1 em { color: var(--accent-2); font-style: normal; }
.lede { color: var(--muted); font-size: 16px; line-height: 1.6; max-width: 640px; margin: 0 auto 18px; }
.lede strong { color: var(--text); }

.privacy-note {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 16px; font-size: 14px; color: var(--muted); max-width: 640px; margin: 0 auto 18px; text-align: center;
}
.privacy-note strong { color: var(--accent-2); }

.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  max-width: 640px; margin: 0 auto 22px;
}
.steps div {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 8px; text-align: center; font-size: 13px; color: var(--muted);
}

button {
  font-family: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--border);
  font-size: 15px; font-weight: 700; padding: 13px 24px; transition: transform .05s, filter .15s;
}
button:active { transform: scale(.98); }
button.primary { background: #be123c; color: #fff; border: none; }
button.primary:hover { filter: brightness(1.1); }
button.primary.small { padding: 9px 16px; font-size: 13px; }
button.ghost { background: var(--panel-2); color: var(--text); }
button.ghost:hover { border-color: var(--accent); }
button.ghost.small { padding: 9px 16px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

#btn-start { display: block; margin: 0 auto 12px; font-size: 17px; padding: 15px 34px; }
.error { color: var(--danger); font-size: 14px; text-align: center; margin: 10px auto; max-width: 560px; }

.how { max-width: 640px; margin: 26px auto 0; }
.how h2 { font-size: 18px; margin-bottom: 10px; }
.how ul { list-style: none; }
.how li { padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); line-height: 1.55; }
.how li strong { color: var(--text); }

/* camera */
.camera-box {
  position: relative; width: min(100%, 460px); aspect-ratio: 4 / 3; margin: 14px auto;
  background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.camera-box.small { width: min(100%, 300px); }
.scan-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(0,0,0,.65); color: #fff; font-size: 13px; padding: 7px 14px; border-radius: 999px;
}
.scan-note { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
#btn-rescan { display: block; margin: 0 auto 6px; }

/* Result-view persistent camera preview (owner defect fix). Reuses the SAME
   live MediaStream as the scan view — the camera stays visible after the
   estimate so the user can reposition and re-scan. Never hidden, never uploaded. */
.result-camera { margin-top: 4px; margin-bottom: 4px; }
.result-live-hint { font-size: 12px; max-width: calc(100% - 24px); text-align: center; line-height: 1.35; }
.result-camera-note { margin: 2px 0 8px; }
#btn-rescan-result { display: block; margin: 0 auto 16px; }
#age-value[data-just-updated] { animation: age-flash .6s ease-out; }
@keyframes age-flash { 0% { opacity: .35; } 100% { opacity: 1; } }

/* result */
#view-result h2 { text-align: center; margin-bottom: 6px; }
.honesty { text-align: center; color: var(--muted); font-size: 14px; max-width: 620px; margin: 0 auto 14px; }
.result-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 460px; margin: 0 auto 20px; padding: 22px; text-align: center;
}
.age-main { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.age-main span:first-child { font-size: 64px; font-weight: 800; color: var(--accent-2); }
.age-unit { color: var(--muted); font-size: 16px; }
.age-range { color: var(--muted); font-size: 14px; margin-top: 4px; }
.age-gender { margin-top: 10px; font-size: 13px; color: var(--muted); }

.features { max-width: 620px; margin: 0 auto 20px; }
.features h3, .appearance h3 { font-size: 18px; margin-bottom: 4px; }
.features-note, .exp-note, .program-note { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.feature-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 13px; text-align: center;
}
.feature-card .z { font-size: 13px; color: var(--muted); }
.feature-card .a { font-size: 26px; font-weight: 800; }
.feature-card.hot { border-color: var(--warn); background: rgba(255,180,84,.08); }
.feature-card.hot .z { color: var(--warn); }
.fastest { text-align: center; color: var(--warn); font-size: 14px; margin-top: 12px; font-weight: 600; }

/* experimental appearance */
.appearance {
  max-width: 620px; margin: 0 auto 22px; background: var(--panel);
  border: 1px dashed #6b5a8a; border-radius: var(--radius); padding: 16px;
}
.exp-tag {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  background: #6b5a8a; color: #fff; border-radius: 4px; padding: 2px 7px; margin-bottom: 8px;
}
.appearance .consent { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 10px; }
.appearance .consent p { font-size: 13px; color: var(--muted); white-space: pre-line; line-height: 1.55; margin-bottom: 10px; }
.appearance .consent button + button { margin-left: 8px; }
.appearance-result-guesses { margin-top: 10px; }
.guess-row { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--border); }
.guess-row .pct { color: var(--accent-2); font-weight: 700; }
.exp-unavailable, .exp-refusal, .exp-loading, .exp-skipped { color: var(--muted); font-size: 13px; margin-top: 10px; }
.exp-loading { color: var(--accent-2); animation: pulse 1.2s ease-in-out infinite; }
.exp-skipped { color: var(--muted); font-style: italic; }
@keyframes pulse { 50% { opacity: .45; } }

/* share feedback toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--accent);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; z-index: 60;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast[hidden] { display: none; }

.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* program */
.program-list { max-width: 620px; margin: 0 auto 16px; }
.program-group { margin-bottom: 18px; }
.program-group h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.exercise-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
}
.exercise-card .n { font-weight: 700; flex: 1; }
.exercise-card .m { font-size: 12px; color: var(--muted); max-width: 300px; }
.exercise-card .badge { font-size: 11px; color: var(--accent-2); background: rgba(126,224,182,.1); border: 1px solid rgba(126,224,182,.3); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }

/* coach */
.coach-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; max-width: 720px; margin: 0 auto; }
.coach-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.exercise-name { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.exercise-motion { color: var(--muted); font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
.coach-phase { font-size: 13px; color: var(--warn); margin-bottom: 6px; min-height: 18px; }
.coach-metric { font-size: 26px; font-weight: 800; margin-bottom: 12px; }
.progress-track { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; width: 0; background: var(--accent-2); transition: width .15s linear; }
.coach-controls { display: flex; gap: 10px; }

@media (max-width: 640px) {
  .coach-grid { grid-template-columns: 1fr; }
}

/* reward */
.reward-overlay {
  position: fixed; inset: 0; background: rgba(5,8,16,.82); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.reward-overlay[hidden] { display: none; }
.reward-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 28px; text-align: center; max-width: 460px; width: 100%;
}
.reward-emoji { font-size: 64px; }
.reward-card h3 { font-size: 24px; margin: 6px 0 12px; }
.reward-card video { width: 100%; border-radius: 12px; max-height: 260px; object-fit: cover; }
.reward-fallback { font-size: 56px; padding: 26px 0; animation: bounce 1s infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-12px); } }
.reward-card button { margin-top: 16px; }

/* done */
.done-card { text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); max-width: 480px; margin: 40px auto; padding: 34px; }
.done-card h2 { margin: 10px 0 8px; }
.done-card p { color: var(--muted); margin-bottom: 18px; }

footer {
  border-top: 1px solid var(--border); padding: 16px 22px; display: flex; gap: 14px;
  font-size: 13px; color: var(--muted); flex-wrap: wrap; justify-content: center;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }
.foot-note a { color: #be123c; }

/* >>> theme-by-name (2026-11-02) >>> */
/* Theme derived from the site's MEANING, not a random variant.
 * A face and a personal answer = soft rose and a humanist face. It should feel warm, not clinical.
 * Ad layout is deliberately NOT set here — container width and rail geometry are
 * measured and verified separately by check-ad-layout.mjs.
 */
:root {
  --bg: #fdf8f9;
  --card: #ffffff;
  --ink: #2a1a20;
  --muted: #7c6a70;
  --line: #f2e2e7;
  --brand: #be123c;
  --brand-strong: #be123c;
  --accent: #f43f5e;
  --radius: 16px;
  --font-sans: 'DM Sans', 'Avenir', 'Century Gothic', sans-serif;
  /* The dark block above defines the surface + text tokens. Every component
     below reads --panel / --panel-2 / --border / --text, so leaving them
     unset renders the camera box, coach panel, consent box and progress track
     as dark navy cards on a near-white page — the "few dark boxes with
     greyed-out text" defect (measured 2026-11-13). */
  --panel: #ffffff;
  --panel-2: #fdf2f5;
  --border: #f2e2e7;
  --text: #2a1a20;
}
body { font-family: var(--font-sans); background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-family: var(--font-sans); font-weight: 500; letter-spacing: -0.015em; }
.card, .panel, section[class*="card"] { border-radius: var(--radius); }
/* <<< theme-by-name <<< */

/* Privacy architecture section (2026-11-08) — the selling point of every site. */
.privacy-section{margin-top:34px;padding-top:24px;border-top:2px solid #e2e8f0}
.privacy-section h2{font-size:1.35em;margin-bottom:10px}
.privacy-section h3{font-size:1.05em;margin:20px 0 8px}
.privacy-steps{margin:10px 0 14px;padding-left:22px}
.privacy-steps li{margin-bottom:8px;line-height:1.6}
.privacy-section kbd{background:#f1f5f9;border:1px solid #cbd5e1;border-bottom-width:2px;
  border-radius:4px;padding:1px 5px;font-size:.85em;font-family:ui-monospace,Menlo,monospace}
