:root {
  --bg: #1e0f36;
  --bg2: #2a1650;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-b: rgba(255, 255, 255, 0.14);
  --text: #f1ecfa;
  --muted: #b9acd3;
  --accent: #7c3aed;
  --accent-2: #a78bfa;
  --gold: #e9c46a;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #3b1d6e 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #2b1356 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
a { color: var(--accent-2); }
.top { max-width: 760px; margin: 0 auto; padding: 20px 16px 4px; }
.back-site { font-size: 14px; text-decoration: none; color: var(--muted); }
.top h1 { margin: 8px 0 4px; font-size: clamp(28px, 6vw, 40px); letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff, var(--accent-2) 60%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 0; color: var(--muted); }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 48px; }
.glass {
  background: var(--glass); border: 1px solid var(--glass-b); border-radius: var(--radius);
  padding: 20px; margin: 14px 0; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
h2 { margin: 0 0 12px; font-size: 22px; }
h3 { margin: 0 0 10px; font-size: 18px; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  flex: 1 1 120px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--glass-b); background: rgba(255, 255, 255, 0.03);
}
.seg label:has(input:checked) { border-color: var(--accent-2); background: rgba(124, 58, 237, 0.25); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
.field { display: block; font-weight: 600; margin-bottom: 16px; }
.field input {
  display: block; width: 100%; max-width: 200px; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--glass-b); border-radius: 10px;
}
.opt { font-weight: 400; color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0; }
.err { color: var(--danger); min-height: 1.2em; margin: 4px 0; }
.status { min-height: 1.4em; margin: 6px 0; color: var(--accent-2); }
.status.bad { color: var(--danger); }
.status.good { color: var(--ok); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions.center { justify-content: center; }
.btn {
  appearance: none; border: 1px solid var(--glass-b); background: rgba(255, 255, 255, 0.06); color: var(--text);
  font: inherit; font-weight: 600; padding: 11px 18px; border-radius: 12px; cursor: pointer; text-align: center;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); }
.btn:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b21b6); border-color: transparent; box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.tips { margin-top: 16px; color: var(--muted); }
.tips summary { cursor: pointer; color: var(--text); font-weight: 600; }
.privacy { font-size: 13px; color: var(--muted); margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--glass-b); }
#history { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--glass-b); }
#history-list { list-style: none; padding: 0; margin: 0; }
#history-list li { margin: 6px 0; }
#history-list a { text-decoration: none; display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); color: var(--text); }
#history-list a:hover { background: rgba(255, 255, 255, 0.09); }
#history-list .when { color: var(--muted); font-size: 14px; }

.cam-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-wrap video.mirror { transform: scaleX(-1); }
.cam-guide { position: absolute; inset: 6% 12%; width: 76%; height: 88%; fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 0.8; stroke-dasharray: 2 2; pointer-events: none; }

.stage { position: relative; border-radius: 12px; overflow: hidden; background: #000; }
.stage canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.steps { display: flex; gap: 6px; padding: 0; margin: 6px 0 10px; list-style: none; flex-wrap: wrap; }
.steps li { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--glass-b); color: var(--muted); }
.steps li.done { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); }
.steps li.skip { text-decoration: line-through; }
.steps li.cur { color: #fff; background: rgba(124, 58, 237, 0.35); border-color: var(--accent-2); }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.warn { margin: 8px 0; padding-left: 18px; color: var(--gold); font-size: 14px; }
.warn:empty { display: none; }

.result-head .eyebrow { margin: 0; color: var(--accent-2); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.overview { font-size: 18px; line-height: 1.6; }
#cv-result { width: 100%; height: auto; border-radius: 12px; margin-top: 12px; }
.sec h3 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec h3 .tag { font-size: 13px; font-weight: 500; color: var(--gold); }
.trait { margin: 14px 0; }
.trait h4 { margin: 0 0 4px; font-size: 15px; color: var(--accent-2); }
.trait p { margin: 0; }
.trait details { margin-top: 4px; font-size: 13px; color: var(--muted); }
.trait summary { cursor: pointer; }
.reflect { margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--gold); background: rgba(233, 196, 106, 0.08); border-radius: 0 10px 10px 0; font-style: italic; }
.disclaimer { font-size: 13px; color: var(--muted); text-align: center; margin: 18px 8px; }
#r-timeline-svg svg { width: 100%; height: auto; display: block; }

.busy { position: fixed; inset: 0; background: rgba(15, 6, 30, 0.75); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent-2); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
@media (max-width: 480px) {
  .glass { padding: 16px; }
  .actions .btn { flex: 1 1 auto; }
}
.install-btn {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  border: 0; border-radius: 999px; padding: 12px 20px; min-height: 48px; cursor: pointer;
  font: inherit; font-weight: 700; color: #1e0f36;
  background: linear-gradient(135deg, #f3d98b, var(--gold)); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.install-btn:hover { filter: brightness(1.05); }
.install-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(15, 6, 30, 0.7); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.sheet__card { width: 100%; max-width: 460px; margin: 0; background: #2a1650; }
.sheet ol { padding-left: 20px; margin: 8px 0 0; }
.sheet li { margin: 8px 0; }
.offline-note { position: fixed; left: 16px; right: 16px; top: 12px; z-index: 45; text-align: center; font-size: 14px; padding: 8px 12px; border-radius: 10px; background: rgba(233, 196, 106, 0.95); color: #1e0f36; }
@media (display-mode: standalone) { .back-site { display: none; } }
@media print {
  body { background: #fff; color: #000; }
  .top, .actions, #r-owner, .busy, .install-btn, .sheet { display: none !important; }
  .glass { border: 1px solid #ccc; box-shadow: none; backdrop-filter: none; background: #fff; }
}
