/* FamilyShield AI preview — themes: Day, Dark, Night, Gloss (default).
   Layouts: Split (default), Board. Remembered in localStorage, settable
   by URL params (?theme=gloss&layout=board). Motion respects
   prefers-reduced-motion. Text is never blurred. */

@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }

:root {
  --income: #f59e0b; --debt: #ef4444; --medical: #ec4899;
  --emergency: #10b981; --education: #3b82f6; --estate: #8b5cf6;
  --radius: 18px;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html[data-theme="gloss"] {
  --bg: linear-gradient(135deg, #2b1055 0%, #155e63 55%, #7c2d5e 100%);
  --panel: rgba(255, 255, 255, 0.14);
  --panel-solid: #241547;
  --ink: #fdfcff;
  --muted: #d8d2f0;
  --line: rgba(255, 255, 255, 0.35);
  --accent: #ffb347;
  --bar-bg: rgba(255, 255, 255, 0.25);
  --btn: linear-gradient(90deg, #ff7a59, #ffb347);
  --btn-ink: #2b1055;
  color-scheme: dark;
}
html[data-theme="day"] {
  --bg: linear-gradient(160deg, #fef9e7, #e0f2fe 60%, #fce7f3);
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --ink: #1f2430;
  --muted: #5b6472;
  --line: #d7dee9;
  --accent: #d97706;
  --bar-bg: #e5eaf1;
  --btn: linear-gradient(90deg, #f59e0b, #f97316);
  --btn-ink: #ffffff;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: linear-gradient(160deg, #0f172a, #1e293b);
  --panel: #1e293b;
  --panel-solid: #1e293b;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #fbbf24;
  --bar-bg: #334155;
  --btn: linear-gradient(90deg, #b45309, #d97706);
  --btn-ink: #ffffff;
  color-scheme: dark;
}
html[data-theme="night"] {
  --bg: radial-gradient(1200px 700px at 70% -10%, #1e1b4b, #030712 70%);
  --panel: #0b1120;
  --panel-solid: #0b1120;
  --ink: #e0e7ff;
  --muted: #8b93b8;
  --line: #232946;
  --accent: #a5b4fc;
  --bar-bg: #1c2340;
  --btn: linear-gradient(90deg, #4338ca, #6d28d9);
  --btn-ink: #ffffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  background-attachment: fixed;
}
header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; padding: 18px 22px 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.shield {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: conic-gradient(from 40deg, var(--income), var(--medical), var(--estate), var(--education), var(--emergency), var(--income));
  display: grid; place-items: center;
}
.shield::after {
  content: ""; width: 18px; height: 22px; background: var(--panel-solid);
  clip-path: polygon(50% 0, 100% 18%, 100% 55%, 50% 100%, 0 55%, 0 18%);
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.switches { display: flex; gap: 14px; flex-wrap: wrap; }
.switch-group { display: flex; gap: 6px; align-items: center; }
.switch-group button, .nav button, .tools button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer;
}
.switch-group button.on { background: var(--btn); color: var(--btn-ink); border-color: transparent; font-weight: 700; }

main { padding: 14px 22px 30px; }
html[data-layout="split"] main {
  display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 18px; align-items: start;
}
html[data-layout="board"] main {
  display: grid; grid-template-columns: 1fr; gap: 18px; max-width: 980px; margin: 0 auto;
}
html[data-layout="board"] .side { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
html[data-layout="board"] .score-card { grid-column: 1 / -1; }
@media (max-width: 1100px) {
  html[data-layout="split"] main, html[data-layout="board"] .side { grid-template-columns: 1fr; }
}
.side { display: grid; gap: 18px; }
/* Grid children must be allowed to shrink: without min-width: 0 a wide
   child (QR canvas, AC-1 grid) forces its track wider and the columns
   collide visually. The step panel and the report column never overlap. */
.step-card, .side, .side > .card { min-width: 0; }
.qr-wrap canvas { max-width: 100%; height: auto; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; backdrop-filter: none;
}
.card h3 { margin: 0 0 10px; font-size: 17px; }
.muted { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.disclaimer { font-weight: 700; font-size: 13.5px; border-top: 1px dashed var(--line); padding-top: 10px; }

.progress { display: flex; gap: 5px; margin: 8px 0 14px; }
.dot { width: 22px; height: 6px; border-radius: 3px; background: var(--bar-bg); }
.dot.seen { background: var(--accent); opacity: 0.55; }
.dot.now { background: var(--accent); opacity: 1; }
.step-meta { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.step-card h2 { margin: 4px 0 10px; font-size: 21px; line-height: 1.3; }
.is { font-size: 14.5px; line-height: 1.55; margin: 6px 0; }
.isnot { font-size: 14.5px; line-height: 1.55; margin: 6px 0; color: var(--muted); }
.example {
  font-size: 13.5px; line-height: 1.5; border-left: 4px solid var(--accent);
  padding: 6px 10px; background: var(--bar-bg); border-radius: 0 10px 10px 0; margin: 12px 0;
}
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; font-size: 14.5px; }
.field input[type="number"], .field select {
  width: 170px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-solid); color: var(--ink); font: inherit;
}
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--education); }
.field:has(input[type="checkbox"]) { justify-content: flex-start; }
.nav { display: flex; justify-content: space-between; margin-top: 16px; }
.nav button.primary { background: var(--btn); color: var(--btn-ink); border-color: transparent; font-weight: 700; }
.nav button:disabled { opacity: 0.45; cursor: default; }

.score-frame {
  border-radius: calc(var(--radius) + 4px); padding: 4px;
  background: conic-gradient(from var(--a), var(--income), var(--medical), var(--estate), var(--education), var(--emergency), var(--income));
  animation: spin 7s linear infinite;
}
@keyframes spin { to { --a: 360deg; } }
.score-card { text-align: center; }
.ring {
  --p: 0%;
  width: 168px; height: 168px; margin: 10px auto; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p), var(--bar-bg) 0);
  display: grid; place-items: center;
}
.ring-in {
  width: 132px; height: 132px; border-radius: 50%; background: var(--panel-solid);
  display: grid; place-items: center; align-content: center;
}
#score-num { font-size: 42px; font-weight: 800; line-height: 1; }
.score-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.delta { font-weight: 700; font-size: 14px; }
.delta.up { color: var(--emergency); } .delta.down { color: var(--debt); } .delta.flat { color: var(--muted); }

.part { margin: 14px 0; }
.part-head { display: flex; align-items: center; gap: 8px; }
.part-score { margin-left: auto; font-weight: 800; }
.chip { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex: none; }
.bar { width: 100%; height: 12px; display: block; margin: 6px 0 4px; }
.bar-bg { fill: var(--bar-bg); }
.meaning { font-size: 13.5px; line-height: 1.5; margin: 2px 0 0; color: var(--muted); }
.gap-line { font-size: 16.5px; font-weight: 700; line-height: 1.45; }
.ac1 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.ac1 span { display: block; font-size: 11.5px; color: var(--muted); }
.ac1 strong { font-size: 14px; }
.plan-step { margin: 12px 0; }
.plan-step p { font-size: 14px; line-height: 1.55; margin: 4px 0 0; }
.tools { display: flex; gap: 10px; padding: 0 22px 26px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  .score-frame { animation: none; }
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* --- FPS-2026.2 additions: verdicts, protection map, what-if, share --- */
.verdict {
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px;
  color: #fff; white-space: nowrap;
}
.v-strong { background: #059669; }
.v-ontrack { background: #2563eb; }
.v-building { background: #d97706; }
.v-attention { background: #dc2626; }
.summary-line { font-size: 14.5px; margin: 4px 0; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
@media (max-width: 560px) { .map-grid { grid-template-columns: 1fr; } }
.map-item {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; font-size: 13px;
}
.map-item .map-mark { font-weight: 800; width: 16px; text-align: center; flex: none; }
.map-item.have .map-mark { color: var(--emergency); }
.map-item.miss { opacity: 0.75; }
.map-item.miss .map-mark { color: var(--debt); }
.map-state { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.whatif-row {
  display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px;
}
.whatif-row span { flex: 1; }
.whatif-row button, .share-row button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer;
}
.whatif-row button { background: var(--btn); color: var(--btn-ink); border-color: transparent; font-weight: 700; }
.share-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
@media print {
  header .switches, .step-card, .nav, .tools, .share-row { display: none !important; }
  body { background: #fff; color: #111; }
  main { display: block !important; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}

/* --- Optional save/sync sign-in, QR, algorithm row --- */
.sync-panel { margin: 14px 22px 0; text-align: center; }
.sync-panel h2 { margin: 4px 0 8px; }
.gate-btns {
  display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 16px 0 8px;
}
.social {
  width: 280px; max-width: 90vw; padding: 11px 16px; border-radius: 999px;
  border: 1px solid var(--line); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--panel-solid); color: var(--ink);
}
.social.g { background: #ffffff; color: #1f2430; }
.social.f { background: #1877f2; color: #ffffff; border-color: transparent; }
.social.a { background: #111111; color: #ffffff; border-color: transparent; }
.social.guest { background: var(--panel); color: var(--ink); }
.auth-area { display: flex; align-items: center; gap: 10px; }
.auth-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.auth-chip img { width: 30px; height: 30px; border-radius: 50%; }
.auth-ini {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--btn); color: var(--btn-ink); font-size: 13px; font-weight: 800;
}
.signout {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.qr-wrap { display: flex; justify-content: center; margin: 10px 0 4px; }
.qr-wrap canvas {
  width: 264px; height: 264px; border-radius: 16px;
  box-shadow: 0 6px 24px rgba(20, 8, 50, 0.25);
}
.ac1 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* --- Touch-first controls: sliders, steppers, big targets --- */
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.field-num { display: block; margin: 18px 0; }
.num-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.num-head span { font-size: 15.5px; line-height: 1.35; }
.num-input {
  width: 148px; height: 48px; padding: 8px 12px; text-align: right;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-solid); color: var(--ink);
  font: inherit; font-size: 17px; font-weight: 600;
}
.num-controls { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.stepbtn {
  width: 48px; height: 48px; flex: none; border-radius: 50%; border: none;
  background: var(--btn); color: var(--btn-ink); font-size: 26px; font-weight: 800;
  cursor: pointer; display: grid; place-items: center; line-height: 1;
}
input[type="range"].num-range {
  flex: 1; height: 40px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
input[type="range"].num-range::-webkit-slider-runnable-track {
  height: 10px; border-radius: 5px; background: var(--bar-bg);
}
input[type="range"].num-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; margin-top: -10px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel-solid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
input[type="range"].num-range::-moz-range-track {
  height: 10px; border-radius: 5px; background: var(--bar-bg);
}
input[type="range"].num-range::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel-solid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.slider-hint { margin: 4px 0 0; font-size: 13px; }
.field input[type="checkbox"] { width: 30px; height: 30px; flex: none; }
.field select { height: 48px; font-size: 16px; border-radius: 12px; }
.field:has(input[type="checkbox"]) { min-height: 48px; font-size: 15.5px; }
.nav button { min-height: 52px; padding: 12px 26px; font-size: 16px; }
.switch-group button { min-height: 42px; padding: 9px 16px; font-size: 14px; }
.social { min-height: 52px; }
.whatif-row button, .share-row button, .tools button { min-height: 44px; padding: 10px 16px; }
.dot { height: 8px; }
.bar { height: 14px; }

/* --- Locale bar, detection banner, listen, explainer --- */
.locale-bar {
  display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 22px 2px; align-items: center;
}
.locale-bar label { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.locale-bar select {
  height: 44px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-solid); color: var(--ink); font: inherit; font-size: 15px;
}
.detected {
  margin: 12px 22px 0; padding: 12px 16px; border-radius: 12px; font-size: 14.5px;
  border: 1px dashed var(--accent); color: var(--ink); background: var(--panel);
}
.region-note {
  font-size: 13.5px; line-height: 1.55; border-left: 4px solid var(--education);
  padding: 6px 10px; background: var(--bar-bg); border-radius: 0 10px 10px 0; margin: 12px 0;
}
.listen-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.listen-btn {
  min-height: 44px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600;
}
.explainer {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(10, 4, 30, 0.72); padding: 18px;
}
.explainer[hidden] { display: none; }
.explainer-card {
  width: min(680px, 100%); border-radius: 22px; padding: 26px;
  background: linear-gradient(150deg, #2b1055, #155e63 60%, #7c2d5e); color: #fdfcff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.explainer-progress { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.explainer-progress span { display: block; height: 100%; background: #ffb347; transition: width 0.4s ease; }
.explainer-slide h2 { font-size: 27px; margin: 16px 0 8px; }
.explainer-slide p { font-size: 17px; line-height: 1.55; }
.ex-kicker { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #d8d2f0; margin-top: 14px; }
.ex-visual { margin: 14px 0; }
.ex-big { font-size: 84px; font-weight: 800; line-height: 1.05; }
.ex-gap { font-size: 56px; }
.ex-plan { font-size: 44px; }
.ex-note {
  width: 84px; height: 84px; border-radius: 50%; border: 4px solid #fff;
  display: grid; place-items: center; font-size: 48px;
}
.explainer-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.explainer-controls button {
  min-height: 48px; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* --- Simple words mode + language picker --- */
.simple-toggle {
  min-height: 44px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 10px;
}
.simple-toggle::after {
  content: ""; width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--bar-bg); border: 1px solid var(--line);
  box-shadow: inset -14px 0 0 0 var(--panel-solid);
  transition: box-shadow 0.2s ease, background 0.2s ease;
}
.simple-toggle.on { border-color: var(--accent); }
.simple-toggle.on::after {
  background: var(--accent);
  box-shadow: inset 14px 0 0 0 var(--panel-solid);
}
.impact {
  font-size: 16px; line-height: 1.5; font-weight: 600;
  border: 2px solid var(--accent); border-radius: 14px;
  padding: 12px 14px; margin: 12px 0; background: var(--panel);
}
.impact-badge {
  display: inline-block; margin-inline-start: 8px; padding: 3px 12px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 800; white-space: nowrap;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip-btn {
  flex: 1 1 120px; min-height: 56px; padding: 8px 10px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.chip-btn .chip-name { font-size: 16px; font-weight: 700; }
.chip-btn .chip-amt { font-size: 13px; color: var(--muted); }
.chip-btn.on { border-color: var(--accent); background: var(--bar-bg); }
.chip-btn.on .chip-amt { color: var(--ink); }
.field-check-big {
  font-size: 17px !important; min-height: 64px !important;
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: var(--panel); cursor: pointer;
}
.field-check-big input[type="checkbox"] { width: 34px !important; height: 34px !important; }

/* --- Settings panel + first-run welcome --- */
.settings-btn {
  min-height: 44px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 700;
}
.settings, .welcome { margin: 14px 22px 0; }
.settings .locale-bar { padding: 10px 0 2px; }
.settings-switches { margin-bottom: 6px; }
.welcome h2 { margin-top: 4px; }
.welcome-opts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 10px;
}
@media (max-width: 560px) { .welcome-opts { grid-template-columns: 1fr; } }
.welcome-opt {
  min-height: 96px; padding: 18px; border-radius: 16px; cursor: pointer;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; text-align: start;
  display: flex; flex-direction: column; gap: 6px;
}
.welcome-opt strong { font-size: 20px; }
.welcome-opt span { font-size: 14.5px; color: var(--muted); line-height: 1.5; }
.welcome-opt:hover, .welcome-opt:focus-visible { border-color: var(--accent); }

/* --- Report readability: the report is the screen users judge.
   Solid panel in every theme, larger text, near-full-strength ink. --- */
#report-card { background: var(--panel-solid); }
#report-card h3 { font-size: 19px; }
#report-card .gap-line { font-size: 18px; }
#report-card .muted { color: var(--ink); opacity: 0.78; font-size: 14.5px; }
#report-card .meaning { color: var(--ink); opacity: 0.88; font-size: 15px; }
#report-card .summary-line { font-size: 15.5px; }
#report-card .part-head strong { font-size: 16px; }
#report-card .part-score { font-size: 16px; }
#report-card .disclaimer { color: var(--ink); }
.ac1-note {
  font-size: 14px; line-height: 1.55; font-weight: 600;
  border-left: 4px solid var(--accent); padding: 8px 12px;
  background: var(--bar-bg); border-radius: 0 10px 10px 0; margin: 0 0 14px;
}

/* --- v8 revamp: guided layout, sticky score bar, welcome modal --- */
html[data-layout="guide"] main {
  display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start;
  max-width: 780px; margin: 0 auto; width: 100%; box-sizing: border-box;
}
.scorebar {
  display: none; position: sticky; top: 8px; z-index: 30;
  align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 22px 0; padding: 9px 14px;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: 0 6px 20px rgba(20, 8, 50, 0.18);
  font-size: 14.5px;
}
html[data-layout="guide"] .scorebar { display: flex; }
@media (max-width: 1100px) { .scorebar { display: flex; } }
.scorebar strong { font-size: 19px; }
.sb-chip {
  background: var(--btn); color: var(--btn-ink); font-weight: 700;
  border-radius: 999px; padding: 2px 10px; font-size: 13px;
}
.sb-step { color: var(--muted); font-size: 13.5px; }
.sb-btn {
  margin-left: auto; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 700;
  font-size: 14px; padding: 8px 14px; min-height: 40px;
}
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
main section.card { scroll-margin-top: 84px; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 58;
  background: rgba(14, 7, 34, 0.55); backdrop-filter: blur(2px);
}
#welcome {
  position: fixed; z-index: 59; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, calc(100vw - 28px));
  max-height: calc(100dvh - 36px); overflow: auto;
  margin: 0; box-shadow: 0 24px 70px rgba(10, 4, 30, 0.45);
}
body.modal-open { overflow: hidden; }
.welcome-lang {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  font-weight: 600; margin: 6px 0 14px; flex-wrap: wrap;
}
.welcome-lang select {
  font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-solid); color: var(--ink);
  min-height: 44px;
}

/* --- v9 journey redesign: hero, colour zones, tab bar, score reveal --- */
.hero { display: none; }
html[data-layout="guide"] .hero {
  display: block; margin: 16px 22px 0; padding: 22px 20px; border-radius: 18px;
  background: linear-gradient(120deg, #4c1d95, #7c3aed 55%, #db2777);
  color: #fff; text-align: center;
}
.hero h2 { margin: 0 0 6px; font-size: 23px; line-height: 1.3; }
.hero p { margin: 0; font-size: 16px; opacity: 0.92; }
.zone { border-top: 5px solid var(--zone, var(--line)); }
.zone-answer { --zone: #8b5cf6; }
.zone-score { --zone: #f59e0b; }
.zone-understand { --zone: #0d9488; }
.zone-improve { --zone: #16a34a; }
.zone-share { --zone: #db2777; }
.score-card {
  background: linear-gradient(160deg, var(--panel-solid), var(--panel-solid)) padding-box,
    linear-gradient(160deg, #f59e0b, #ec4899, #8b5cf6) border-box;
  border: 2px solid transparent;
}
.score-card.celebrate .ring { animation: ringpop 0.9s ease; }
@keyframes ringpop {
  0% { transform: scale(0.92); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
/* One stage at a time in Guide; Split/Board keep the all-in-one page. */
html[data-layout="guide"] body[data-view="answer"] .side { display: none; }
html[data-layout="guide"] body[data-view="score"] .step-card,
html[data-layout="guide"] body[data-view="score"] #hero,
html[data-layout="guide"] body[data-view="score"] #plan-card,
html[data-layout="guide"] body[data-view="score"] #whatif-card,
html[data-layout="guide"] body[data-view="score"] #share-card,
html[data-layout="guide"] body[data-view="improve"] .step-card,
html[data-layout="guide"] body[data-view="improve"] #hero,
html[data-layout="guide"] body[data-view="improve"] .score-frame,
html[data-layout="guide"] body[data-view="improve"] #report-card,
html[data-layout="guide"] body[data-view="improve"] #share-card,
html[data-layout="guide"] body[data-view="share"] .step-card,
html[data-layout="guide"] body[data-view="share"] #hero,
html[data-layout="guide"] body[data-view="share"] .score-frame,
html[data-layout="guide"] body[data-view="share"] #report-card,
html[data-layout="guide"] body[data-view="share"] #plan-card,
html[data-layout="guide"] body[data-view="share"] #whatif-card { display: none; }
.tabbar { display: none; }
html[data-layout="guide"] .tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--panel-solid); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around; box-shadow: 0 -6px 20px rgba(20, 8, 50, 0.15);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; cursor: pointer; color: var(--muted);
  font: inherit; font-size: 12.5px; padding: 6px 2px; min-height: 54px;
  border-radius: 12px;
}
.tabbar button .tab-ico { font-size: 21px; line-height: 1; }
.tabbar button.on { color: var(--accent); font-weight: 700; }
html[data-layout="guide"] body { padding-bottom: 78px; }

/* --- v10: confetti on the score reveal --- */
.score-card { position: relative; }
.confetti-piece {
  position: absolute; top: -6px; width: 8px; height: 12px; border-radius: 2px;
  pointer-events: none; z-index: 6; opacity: 0.95;
  animation-name: confetti-fall; animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(280px) rotate(620deg); opacity: 0; }
}
.tools a { color: var(--accent); font-weight: 600; }
