:root {
  --navy: #0b3d6e;
  --navy-deep: #082b4f;
  --blue: #0e5aa7;
  --blue-bright: #29abe2;
  --bg-wash: #eef5fb;
  --card: #ffffff;
  --text: #16324f;
  --text-muted: #667487;
  --border: #dce8f2;
  --green: #2f9e63;
  --green-bg: #dff5e8;
  --red: #d94b52;
  --red-bg: #fbe4e5;
  --amber: #e2a733;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-size-base: 16px;
  --shadow: 0 8px 24px rgba(11,61,110,0.08);
  --shadow-sm: 0 2px 8px rgba(11,61,110,0.06);
}

[data-theme="dark"] {
  --bg-wash: #0c1a2b;
  --card: #142c46;
  --text: #eaf2fa;
  --text-muted: #93a8c2;
  --border: #22415f;
  --green: #4ade80;
  --red: #f87171;
  --green-bg: #133824;
  --red-bg: #3a1e21;
}

[data-theme="olive"] {
  --navy: #33421f;
  --navy-deep: #232d15;
  --blue: #55702f;
  --blue-bright: #6b8f3f;
  --bg-wash: #f5f3e8;
  --card: #fffdf7;
  --text: #2f3324;
  --text-muted: #74795f;
  --border: #ded9c2;
  --green: #3f7d4a;
  --green-bg: #e3f1e0;
  --red: #b5482a;
  --red-bg: #f7e4dd;
  --amber: #c48a2e;
  --shadow: 0 8px 24px rgba(51,66,31,0.12);
  --shadow-sm: 0 2px 8px rgba(51,66,31,0.08);
}

/* Dim — monochrome late-night mode: true black background, grayscale chrome.
   Correct/incorrect keep a whisper of green/red because that color carries
   real meaning in a qbank; everything else is black & white. */
[data-theme="dim"] {
  --navy: #3a3a3a;
  --navy-deep: #161616;
  --blue: #9a9a9a;
  --blue-bright: #c9c9c9;
  --bg-wash: #000000;
  --card: #121212;
  --text: #cfcfcf;
  --text-muted: #7a7a7a;
  --border: #2a2a2a;
  --green: #9fbfa8;
  --green-bg: #17201a;
  --red: #c99494;
  --red-bg: #221818;
  --amber: #b0a487;
  --shadow: 0 8px 24px rgba(0,0,0,0.6);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-wash);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--font-size-base);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }
h1,h2,h3,h4 { font-family: inherit; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

#app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  border: none; cursor: pointer;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 1em; font-weight: 600;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue-bright), var(--navy));
  color: #fff;
  box-shadow: 0 6px 18px rgba(11,61,110,0.28);
  width: 100%;
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--blue-bright);
  color: var(--blue);
  width: 100%;
}
[data-theme="dark"] .btn-outline, [data-theme="dim"] .btn-outline { color: var(--blue-bright); }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  padding: 8px 12px;
}
.btn-sm { padding: 8px 14px; font-size: 0.85em; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }

/* ---------- Header ---------- */
.topbar {
  background: linear-gradient(135deg, var(--blue-bright), var(--navy) 70%);
  color: #fff;
  padding: 18px 20px 26px;
  padding-top: calc(18px + env(safe-area-inset-top));
  border-radius: 0 0 26px 26px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.icon-btn {
  background: rgba(255,255,255,0.16); border: none; border-radius: 50%;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Logo-mark buttons sit on card/wash backgrounds, not the navy topbar, so the
   default .icon-btn white would be invisible in light & olive. Brand color instead. */
.icon-btn.logo-btn { color: var(--navy); }
[data-theme="dark"] .icon-btn.logo-btn, [data-theme="dim"] .icon-btn.logo-btn { color: var(--blue-bright); }
.hello { font-size: 1.3em; font-weight: 700; margin-top: 14px; }
.hello-sub { opacity: 0.85; font-size: 0.9em; margin-top: 2px; }
.sub-badge {
  display: inline-block; font-size: 0.72em; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; background: rgba(255,255,255,0.18); color: #fff; margin-top: 6px;
}
.sub-badge-urgent { background: var(--red); }
.sub-badge-trial { background: var(--amber); }

.toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 999; pointer-events: none;
}
.toast {
  max-width: 90vw; padding: 12px 18px; border-radius: 12px; font-size: 0.88em; font-weight: 600;
  color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease; text-align: center;
}
.toast-in { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }
.toast-info { background: var(--navy); }

.skeleton { background: linear-gradient(90deg, var(--bg-wash) 25%, var(--border) 50%, var(--bg-wash) 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.3s ease-in-out infinite; border-radius: 10px; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 78px; margin-bottom: 10px; }
.skeleton-line { height: 14px; margin-bottom: 8px; }

.theme-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; border: 1px solid rgba(0,0,0,0.15); }
.continue-card-icon svg { width: 20px; height: 20px; stroke: var(--blue); fill: none; stroke-width: 2; }
[data-theme="dark"] .continue-card-icon svg, [data-theme="dim"] .continue-card-icon svg { stroke: var(--blue-bright); }

.ptr-indicator {
  position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 998;
  background: var(--navy); color: #fff; font-size: 0.78em; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow);
  transition: opacity 0.15s ease; pointer-events: none; opacity: 0;
  transform: translateX(-50%);
}

.page-header {
  padding: 22px 20px 8px;
  padding-top: calc(22px + env(safe-area-inset-top));
}
.page-title { font-size: 1.4em; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 0.92em; margin-top: 4px; }

.content { padding: 16px 20px 30px; }

/* ---------- Legal doc (Terms / Privacy) typography ---------- */
.legal-doc { font-size: 0.94em; line-height: 1.65; color: var(--text); }
.legal-doc h3 { font-size: 1.05em; margin: 26px 0 8px; color: var(--navy); }
[data-theme="dark"] .legal-doc h3, [data-theme="dim"] .legal-doc h3 { color: var(--blue-bright); }
.legal-doc h3:first-of-type { margin-top: 4px; }
.legal-doc p { margin: 0 0 12px; color: var(--text-muted); }
.legal-doc ul { margin: 0 0 12px; padding-left: 20px; color: var(--text-muted); }
.legal-doc li { margin-bottom: 4px; }
.legal-doc a { color: var(--blue-bright); }
.legal-doc b { color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-flat { border: 1px solid var(--border); box-shadow: none; }

/* ---------- Dashboard ---------- */
.stat-donut-row { display: flex; gap: 16px; }
.donut-block { flex: 1; text-align: center; }
.donut {
  width: 108px; height: 108px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--green) 0deg, var(--green) var(--a1,0deg), var(--red) var(--a1,0deg), var(--red) var(--a2,0deg), var(--border) var(--a2,0deg));
}
.donut-inner {
  width: 76px; height: 76px; border-radius: 50%; background: var(--card);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.05em;
}
.legend { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 0.8em; color: var(--text-muted); text-align: left; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.feature-row { display: flex; gap: 10px; margin-top: 4px; }
.feature-chip {
  flex: 1; background: var(--bg-wash); border-radius: var(--radius-md);
  padding: 14px 10px; text-align: center; font-size: 0.78em; color: var(--text-muted); font-weight: 600;
}
.feature-chip svg { width: 24px; height: 24px; stroke: var(--blue); fill: none; stroke-width: 1.8; margin-bottom: 6px; }

/* ---------- Topic tree (create quiz) ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-wash); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 14px;
}
.search-box input { border: none; background: transparent; outline: none; flex: 1; color: var(--text); font-size: 0.95em; }
.search-box svg { width: 18px; height: 18px; stroke: var(--text-muted); fill: none; stroke-width: 2; }

.system-group { margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.system-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; cursor: pointer; font-weight: 700; color: var(--blue);
  background: var(--bg-wash);
}
[data-theme="dark"] .system-head, [data-theme="dim"] .system-head { color: var(--blue-bright); }
.system-head .count { color: var(--text-muted); font-weight: 500; font-size: 0.82em; }
.chev { transition: transform .15s ease; width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.chev.open { transform: rotate(180deg); }
.topic-list { max-height: 0; overflow: hidden; transition: max-height .2s ease; }
.topic-list.open { max-height: 900px; }
.topic-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-top: 1px solid var(--border); font-size: 0.92em;
}
.topic-row label { flex: 1; display: flex; justify-content: space-between; cursor: pointer; }
.topic-row .t-count { color: var(--text-muted); font-size: 0.85em; }
input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--blue-bright); flex-shrink: 0; }
.select-all-row { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-weight: 600; font-size: 0.9em; }

/* ---------- form fields ---------- */
.field { margin-bottom: 18px; }
.field label.field-label { display: block; font-weight: 700; color: var(--blue); margin-bottom: 8px; font-size: 0.95em; }
[data-theme="dark"] .field-label, [data-theme="dim"] .field-label { color: var(--blue-bright); }
.pill-toggle { display: flex; gap: 10px; }
.pill-toggle.wrap { flex-wrap: wrap; }
.pill-toggle.wrap button { flex: 1 1 30%; min-width: 92px; }

/* ---------- Subscription pricing cards ---------- */
.plan-box {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 18px 16px; text-align: left; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius-md);
  background: var(--card); color: var(--text); font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.plan-box.selected { border-color: var(--blue-bright); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-bright) 22%, transparent); }
.plan-box-highlight { border-color: var(--blue-bright); background: var(--bg-wash); }
.plan-box-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.plan-box-label { font-weight: 800; font-size: 1.1em; }
.plan-box-sub { font-size: 0.76em; color: var(--text-muted); line-height: 1.35; }
.plan-box-right { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.plan-was { font-size: 0.78em; color: var(--text-muted); text-decoration: line-through; }
.plan-price { font-weight: 800; font-size: 1.45em; line-height: 1.1; }
.plan-cur { font-size: 0.55em; font-weight: 700; color: var(--text-muted); }
.plan-badge {
  position: absolute; top: -9px; right: 12px;
  font-size: 0.66em; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--amber); color: #fff;
}
.plan-badge-best { background: var(--green); }
[data-theme="dim"] .plan-badge, [data-theme="dim"] .plan-badge-best { color: #121212; }
.pill-toggle button {
  flex: 1; border: 1.5px solid var(--border); background: var(--card); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px; font-weight: 600; cursor: pointer; font-size: 0.92em;
}
.pill-toggle button.active { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.checkrow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.checkrow { display: flex; align-items: center; gap: 8px; font-size: 0.88em; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 0.95em; background: var(--card); color: var(--text); outline: none;
}
.pw-toggle-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
input[type="text"]:focus, input[type="number"]:focus { border-color: var(--blue-bright); }
.hint { font-size: 0.78em; color: var(--text-muted); margin-top: 5px; }
.step-progress { height: 6px; background: var(--border); border-radius: 4px; margin: 14px 0 22px; overflow: hidden; }
.step-progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue-bright), var(--navy)); border-radius: 4px; transition: width .2s ease; }

/* ---------- Quiz runner ---------- */
.quiz-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; position: sticky; top: 0; z-index: 5;
  padding-top: calc(16px + env(safe-area-inset-top));
  background: var(--bg-wash);
}
.quiz-header .back-btn { background: none; border: none; cursor: pointer; color: var(--text); display: flex; }
.quiz-header .back-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.quiz-title { font-weight: 700; }
.quiz-progress { font-size: 0.9em; color: var(--text-muted); }
.quiz-progress b { color: var(--blue-bright); }

.timer-badge {
  display: flex; align-items: center; gap: 5px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-weight: 700; font-size: 0.85em; color: var(--navy);
}
[data-theme="dark"] .timer-badge, [data-theme="dim"] .timer-badge { color: var(--blue-bright); }
.timer-badge.low { color: var(--red); border-color: var(--red); }

.flag-btn { background: none; border: none; cursor: pointer; padding: 4px; }
.flag-btn svg { width: 22px; height: 22px; stroke: var(--text-muted); fill: none; stroke-width: 2; }
.flag-btn.active svg { stroke: var(--blue-bright); fill: var(--blue-bright); }

.question-wrap { padding: 4px 20px 20px; }
.question-meta { font-size: 0.78em; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.question-stem { font-size: 1.08em; font-weight: 600; line-height: 1.5; margin-bottom: 18px; }
.question-stem mark { padding: 0 1px; border-radius: 2px; color: #1a2634; }

.options { display: flex; flex-direction: column; gap: 12px; }
.option-row {
  display: flex; align-items: stretch; gap: 4px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  transition: border-color .12s ease, background .12s ease;
}
.option-row:hover { border-color: var(--blue-bright); }
.option-select {
  flex: 1; display: flex; align-items: flex-start; gap: 12px;
  background: none; border: none; padding: 14px 16px; cursor: pointer;
  text-align: left; font-size: 0.98em; line-height: 1.4; color: inherit; font-family: inherit;
}
.option-select .label { font-weight: 700; color: var(--blue); flex-shrink: 0; }
.option-row.selected { border-color: var(--blue-bright); background: rgba(41,171,226,0.08); }
.option-row.correct { border-color: var(--green); background: var(--green-bg); }
.option-row.correct .label { color: var(--green); }
.option-row.incorrect { border-color: var(--red); background: var(--red-bg); }
.option-row.incorrect .label { color: var(--red); }
.option-row.struck .opt-text { text-decoration: line-through; opacity: 0.5; }
.option-row.struck .label { opacity: 0.5; }
.option-select:disabled, .option-row.locked .option-select { cursor: default; }
.option-pct-badge {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 48px; font-size: 0.78em; font-weight: 700; color: var(--text-muted);
  border-left: 1px solid var(--border);
}
.option-row.correct .option-pct-badge { color: var(--green); }
.option-row.incorrect .option-pct-badge { color: var(--red); }
.strike-toggle {
  flex-shrink: 0; width: 40px; margin: 8px 8px 8px 0; border-radius: 10px;
  background: var(--bg-wash); border: 1.5px solid var(--border); color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.strike-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.strike-toggle.active { background: var(--red-bg); border-color: var(--red); color: var(--red); }

.toolbar { display: flex; gap: 6px; margin: 16px 0 4px; flex-wrap: wrap; }
.tool-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 0.82em; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.tool-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.tool-btn.active { border-color: var(--blue-bright); color: var(--blue-bright); }
.tag-chip.active { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.swatches { display: flex; gap: 8px; align-items: center; padding: 10px 2px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.selected { border-color: var(--text); }
.note-box textarea {
  width: 100%; min-height: 80px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: inherit; font-size: 0.92em; resize: vertical; background: var(--card); color: var(--text);
}

.explanation-panel {
  margin-top: 18px; background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px; font-size: 0.92em; line-height: 1.65;
}
.explanation-panel p { margin-bottom: 12px; }
.explanation-panel p:last-child { margin-bottom: 0; }
.explanation-panel h4 { color: var(--blue); font-size: 0.98em; margin: 18px 0 8px; }
.explanation-panel h4:first-child { margin-top: 0; }
[data-theme="dark"] .explanation-panel h4, [data-theme="dim"] .explanation-panel h4 { color: var(--blue-bright); }
.why-list { margin: 0 0 12px; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; }
.why-list li { line-height: 1.55; }
.why-list strong { color: var(--text); }
.explanation-badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.85em;
  padding: 7px 14px; border-radius: 14px; margin-bottom: 10px;
  max-width: 100%; line-height: 1.35; text-align: left;
}
.explanation-badge.correct { background: var(--green-bg); color: var(--green); }
.explanation-badge.incorrect { background: var(--red-bg); color: var(--red); }

.nav-footer {
  position: sticky; bottom: calc(88px + env(safe-area-inset-bottom)); display: flex; gap: 10px; padding: 14px 20px 0;
  background: linear-gradient(to top, var(--bg-wash) 60%, transparent);
}
.nav-footer .btn { flex: 1; }
.sticky-cta-footer {
  position: sticky; bottom: calc(88px + env(safe-area-inset-bottom));
  padding: 14px 0 0; margin-top: 8px;
  background: linear-gradient(to top, var(--bg-wash) 65%, transparent);
}

/* ---------- Font size control ---------- */
.fontsize-row { display: flex; align-items: center; gap: 14px; justify-content: center; }
.fontsize-row button {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text); font-weight: 700; cursor: pointer; font-size: 1.1em;
}

/* ---------- Results ---------- */
.result-hero { text-align: center; padding: 10px 0 6px; }
.result-score { font-size: 2.6em; font-weight: 800; color: var(--blue); }
[data-theme="dark"] .result-score, [data-theme="dim"] .result-score { color: var(--blue-bright); }
.result-breakdown { display: flex; justify-content: center; gap: 22px; margin-top: 14px; }
.result-breakdown div { text-align: center; }
.result-breakdown .num { font-size: 1.3em; font-weight: 700; }
.result-breakdown .lbl { font-size: 0.75em; color: var(--text-muted); }

.review-item { border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.review-item .rq { font-size: 0.9em; font-weight: 600; margin-bottom: 6px; }
.review-item .status-badge { font-size: 0.72em; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.status-badge.correct { background: var(--green-bg); color: var(--green); }
.status-badge.incorrect { background: var(--red-bg); color: var(--red); }
.status-badge.omitted { background: var(--border); color: var(--text-muted); }

/* Results screen — review filter chips (All / Incorrect / Flagged / Omitted) */
.review-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.review-filter-chip {
  padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text); font-size: 0.82em; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.review-filter-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
[data-theme="dark"] .review-filter-chip.active, [data-theme="dim"] .review-filter-chip.active { background: var(--blue-bright); border-color: var(--blue-bright); color: #0c1a2b; }
.review-flag-dot svg { width: 14px; height: 14px; stroke: var(--red); fill: var(--red); stroke-width: 2; display: block; }

/* ---------- History list ---------- */
.history-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-item .h-title { font-weight: 700; font-size: 0.95em; }
.history-item .h-date { font-size: 0.78em; color: var(--text-muted); margin-top: 2px; }
.history-score { font-weight: 800; font-size: 1.1em; color: var(--blue); }
[data-theme="dark"] .history-score, [data-theme="dim"] .history-score { color: var(--blue-bright); }

/* ---------- Tabbar (floating glass) ---------- */
.tabbar {
  position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); left: 14px; right: 14px;
  max-width: 692px; margin: 0 auto;
  background: rgba(255,255,255,0.62);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 26px;
  box-shadow: 0 10px 32px rgba(11,61,110,0.2), 0 2px 8px rgba(11,61,110,0.08);
  display: flex; z-index: 20;
  padding: 5px;
  /* iOS Safari can visually detach fixed + backdrop-filter elements from the
     viewport during scroll, especially right after navigating between pages of
     very different heights. Forcing this onto its own compositing layer is the
     standard fix. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  will-change: transform;
}
[data-theme="dark"] .tabbar, [data-theme="dim"] .tabbar {
  background: rgba(20,44,70,0.62);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 10px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 7px; margin: 1px; border-radius: 18px;
  color: var(--text-muted); font-size: 0.68em; font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.tab svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 2; }
.tab.active { color: var(--blue-bright); background: rgba(41,171,226,0.14); }

/* ---------- Brand logo (Blades & Beyond mark) ---------- */
.brand-logo { display: block; }
.brand-logo svg { display: block; width: 100%; height: auto; }
.brand-logo-ondark { color: #ffffff; }
.brand-logo-onlight { color: var(--navy); }
[data-theme="dark"] .brand-logo-onlight, [data-theme="dim"] .brand-logo-onlight { color: var(--blue-bright); }

/* ---------- Branded loading screen ---------- */
.brand-loading {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--bg-wash);
}
.brand-loading .brand-word { font-weight: 800; font-size: 1.15em; color: var(--navy); letter-spacing: -0.01em; }
[data-theme="dark"] .brand-loading .brand-word, [data-theme="dim"] .brand-loading .brand-word { color: var(--blue-bright); }
.brand-loading .brand-sub { font-size: 0.82em; color: var(--text-muted); }

/* ---------- Skeleton shimmer (loading screen + deck lists) ---------- */
.skel-line, .skel-box, .skel-circle {
  background: linear-gradient(100deg, var(--border) 20%, var(--card) 40%, var(--border) 60%);
  background-size: 250% 100%;
  animation: skelShimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
.skel-stats-row { display: flex; gap: 10px; margin-bottom: 14px; }
.skel-stats-row .skel-box { flex: 1; height: 46px; border-radius: 10px; }
.skel-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card); }
.skel-circle { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skel-row-item { padding: 14px 4px; border-bottom: 1px solid var(--border); }
.skel-row-item:last-child { border-bottom: none; }
@keyframes skelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel-line, .skel-box, .skel-circle { animation-duration: 2.6s; }
}

/* ---------- Page transitions ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
#app.page-anim > * { animation: pageIn 0.22s ease both; }
@media (prefers-reduced-motion: reduce) {
  #app.page-anim > * { animation: none; }
}
/* ---------- Resources page (glass blocks) ---------- */
.resources-bg-decor {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
}
.resources-bg-decor span {
  position: absolute; border-radius: 50%; filter: blur(50px); opacity: 0.35;
}
.resources-bg-decor span:nth-child(1) { width: 260px; height: 260px; background: var(--blue-bright); top: -60px; left: -60px; }
.resources-bg-decor span:nth-child(2) { width: 300px; height: 300px; background: var(--navy); top: 40vh; right: -100px; }
.resources-bg-decor span:nth-child(3) { width: 220px; height: 220px; background: var(--green); top: 75vh; left: -60px; opacity: 0.18; }

.resource-list { display: flex; flex-direction: column; gap: 14px; }
.resource-card {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.55);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 20px;
  padding: 16px;
  text-decoration: none; color: var(--text);
  box-shadow: 0 8px 24px rgba(11,61,110,0.1);
  transition: transform .12s ease, box-shadow .12s ease;
}
.resource-card:active { transform: scale(0.98); }
[data-theme="dark"] .resource-card, [data-theme="dim"] .resource-card {
  background: rgba(20,44,70,0.55);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.resource-icon {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--blue-bright), var(--navy));
  display: flex; align-items: center; justify-content: center;
}
.resource-icon svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.resource-text { flex: 1; min-width: 0; }
.resource-title { font-weight: 700; font-size: 0.95em; line-height: 1.3; }
.resource-sub { font-size: 0.78em; color: var(--text-muted); margin-top: 2px; }
.resource-chevron { flex-shrink: 0; opacity: 0.5; }
.resource-chevron svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 56px; height: 56px; stroke: var(--border); fill: none; stroke-width: 1.5; margin-bottom: 14px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,20,35,0.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--card); width: 100%; max-width: 720px; border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
}
.modal-sheet h3 { margin-bottom: 16px; }
.modal-close-row { display: flex; justify-content: flex-end; margin-bottom: -6px; }

/* ---------- Side drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(8,20,35,0.5); z-index: 60;
  display: flex; justify-content: flex-start;
}
.drawer-panel {
  width: 78%; max-width: 300px; height: 100%; background: var(--card);
  display: flex; flex-direction: column; padding: 18px 0;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  animation: drawerIn .18s ease;
}
@keyframes drawerIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.drawer-header {
  background: linear-gradient(135deg, var(--blue-bright), var(--navy) 70%);
  color: #fff; padding: 18px 20px; margin-bottom: 10px;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.drawer-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 14px 20px; font-size: 0.95em; font-weight: 600; color: var(--text);
}
.drawer-item:active { background: var(--bg-wash); }
.drawer-item svg { width: 20px; height: 20px; stroke: var(--blue); fill: none; stroke-width: 2; flex-shrink: 0; }
[data-theme="dark"] .drawer-item svg, [data-theme="dim"] .drawer-item svg { stroke: var(--blue-bright); }
.drawer-contact { padding: 14px 20px 4px; border-top: 1px solid var(--border); margin-top: 6px; }
.drawer-contact-label { font-size: 0.72em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 8px; }
.drawer-contact-link {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  color: var(--text); text-decoration: none; font-size: 0.85em;
}
.drawer-contact-link svg { width: 16px; height: 16px; stroke: var(--blue); fill: none; stroke-width: 2; flex-shrink: 0; }
[data-theme="dark"] .drawer-contact-link svg, [data-theme="dim"] .drawer-contact-link svg { stroke: var(--blue-bright); }

@media (min-width: 760px) {
  #app { box-shadow: var(--shadow); min-height: 100vh; }
}

/* =========================================================
   LANDING PAGE — mobile-first, scales to tablet & desktop
   ========================================================= */
#app.landing { max-width: none; padding-bottom: 0; }
.lp { background: var(--bg-wash); color: var(--text); overflow-x: hidden; }
.lp section, .lp header, .lp footer { padding-left: 20px; padding-right: 20px; }

/* --- nav --- */
.lp-nav { background: linear-gradient(135deg, var(--blue-bright), var(--navy) 70%); padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: 14px; }
.lp-nav-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lp-nav-logo { width: 190px; max-width: 46vw; }
.lp-nav-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.lp-link-btn { background: none; border: none; color: #fff; font-weight: 600; font-size: 0.9em; cursor: pointer; padding: 8px 6px; font-family: inherit; }
.lp-cta-light { background: #fff; color: var(--navy); font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,0.18); }

/* --- hero --- */
.lp-hero { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%); color: #fff; padding-top: 44px; padding-bottom: 56px; }
.lp-hero-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lp-eyebrow { display: inline-block; font-size: 0.78em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25); padding: 6px 14px; border-radius: 999px; margin-bottom: 18px; }
.lp-h1 { font-size: clamp(2.1em, 6vw, 3.4em); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 16px; }
.lp-lead { font-size: clamp(1em, 2.2vw, 1.15em); line-height: 1.6; opacity: 0.92; max-width: 560px; margin: 0 auto 26px; }
.lp-hero-ctas { display: flex; flex-direction: column; gap: 10px; max-width: 400px; margin: 0 auto; }
.lp-btn-wide { width: 100%; }
.lp-btn-ghost { background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.35); color: #fff; width: 100%; }
.lp-hero-note { font-size: 0.8em; opacity: 0.75; margin-top: 14px; }

/* --- phone mockup (pure CSS, no screenshots) --- */
/* --- stats strip --- */
.lp-stats { background: var(--card); border-bottom: 1px solid var(--border); padding-top: 26px; padding-bottom: 26px; }
.lp-stats-inner { max-width: 900px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.lp-stat-num { font-size: clamp(1.4em, 4vw, 2em); font-weight: 800; color: var(--blue); }
.lp-stat-lbl { font-size: 0.78em; color: var(--text-muted); margin-top: 2px; }

/* --- generic section --- */
.lp-section { max-width: 1080px; margin: 0 auto; padding-top: 56px; padding-bottom: 56px; }
.lp-h2 { font-size: clamp(1.5em, 4vw, 2.1em); letter-spacing: -0.02em; text-align: center; margin-bottom: 12px; }
.lp-section-sub { text-align: center; color: var(--text-muted); max-width: 520px; margin: 0 auto 34px; font-size: 0.95em; }

/* --- features --- */
.lp-features { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 34px; }
.lp-feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px 22px; }
.lp-feature-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--bg-wash); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.lp-feature-icon svg { width: 24px; height: 24px; stroke: var(--blue); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-feature h3 { font-size: 1.05em; margin-bottom: 8px; }
.lp-feature p { font-size: 0.88em; color: var(--text-muted); line-height: 1.55; }

/* --- quote band --- */
.lp-quote { background: linear-gradient(135deg, var(--blue-bright), var(--navy) 75%); color: #fff; padding-top: 52px; padding-bottom: 52px; text-align: center; }
.lp-quote-inner { max-width: 640px; margin: 0 auto; }
.lp-quote-mark { width: 54px; height: 54px; margin: 0 auto 16px; opacity: 0.9; }
.lp-quote blockquote { font-size: clamp(1.25em, 3.4vw, 1.7em); font-weight: 800; letter-spacing: -0.01em; margin: 0 0 12px; }
.lp-quote p { opacity: 0.88; font-size: 0.95em; line-height: 1.6; }

/* --- pricing --- */
.lp-pricing { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 420px; margin: 0 auto; }
.lp-price-card { position: relative; background: var(--card); border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 28px 22px 22px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.lp-price-best { border-color: var(--blue-bright); box-shadow: var(--shadow); }
.lp-price-label { font-weight: 800; font-size: 1.1em; }
.lp-price-amount { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.lp-price-amount .plan-price { font-size: 2em; }
.lp-price-sub { font-size: 0.8em; color: var(--text-muted); min-height: 2.4em; }
.lp-price-cta { width: 100%; margin-top: 6px; }
.lp-btn-outline { background: transparent; border: 1.5px solid var(--blue-bright); color: var(--blue); }
.lp-pricing-note { text-align: center; color: var(--text-muted); font-size: 0.82em; max-width: 520px; margin: 26px auto 0; line-height: 1.55; }

/* --- FAQ --- */
.lp-faq-section { padding-top: 0; }
.lp-faq { max-width: 640px; margin: 30px auto 0; display: flex; flex-direction: column; gap: 10px; }
.lp-faq details { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; }
.lp-faq summary { font-weight: 700; cursor: pointer; font-size: 0.95em; }
.lp-faq p { margin-top: 10px; font-size: 0.88em; color: var(--text-muted); line-height: 1.55; }

/* --- final CTA + footer --- */
.lp-final { background: var(--navy-deep); text-align: center; padding-top: 56px; padding-bottom: 56px; }
.lp-final .lp-btn-wide { max-width: 340px; margin: 22px auto 0; }
.lp-footer { background: var(--navy-deep); border-top: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); padding-top: 22px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); font-size: 0.82em; }
.lp-footer-inner { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.lp-footer-links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.lp-footer a { color: rgba(255,255,255,0.85); text-decoration: none; }

/* --- tablet: 720px+ --- */
@media (min-width: 720px) {
  .lp-features { grid-template-columns: 1fr 1fr; }
  .lp-hero-ctas { flex-direction: row; }
  .lp-pricing { max-width: none; grid-template-columns: repeat(3, 1fr); align-items: stretch; }
  .lp-footer-inner { flex-direction: row; justify-content: space-between; }
}

/* --- desktop: 1000px+ --- */
@media (min-width: 1000px) {
  .lp-features { grid-template-columns: repeat(4, 1fr); }
  .lp-price-best { transform: scale(1.05); }
}
