:root {
  color-scheme: dark;
  --bg: #080e19; --bg-soft: #0b1321; --side: #0c1524;
  --card: #121f32; --card-hover: #17273e; --card-soft: #0f1a2b;
  --line: #23344a; --line-soft: #1b293c;
  --ink: #ebf3fa; --muted: #92a6bc; --dim: #76899f;
  --teal: #2dd4bf; --green: #34d399; --amber: #f5b041; --red: #f87171;
  --button-ink: #051e1e; --nav-hover: #111d2e;
  --accent: var(--teal);
  --accent-ink: var(--accent);
  --radius: 16px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f8fc; --bg-soft: #ecf3f9; --side: #ffffff;
  --card: #ffffff; --card-hover: #f7fbfe; --card-soft: #f7fafd;
  --line: #d5e1ed; --line-soft: #e7eef5;
  --ink: #162535; --muted: #52677c; --dim: #62778c;
  --teal: #0d9488; --green: #0b7a58; --amber: #92610a; --red: #c23a3a;
  --button-ink: #06201e; --nav-hover: #eef5fa;
  --accent-ink: color-mix(in srgb, var(--accent) 58%, #000);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-ink); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 14px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
.pre { white-space: pre-line; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 22px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: var(--button-ink); font-weight: 700; font-size: 15px;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.big { min-height: 52px; font-size: 17px; padding: 10px 28px; }

/* Public pages */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1120px; margin: 0 auto; padding: 16px 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 18px; text-decoration: none; }
.brand img { width: 32px; height: 32px; display: block; }
.top-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page { max-width: 1120px; margin: 0 auto; padding: 0 20px 56px; }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding: 40px 0 56px; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.1; letter-spacing: -.01em; margin-bottom: 16px; }
.hero p { font-size: 18px; color: var(--muted); margin-bottom: 24px; max-width: 34em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 28px 0 0; padding: 0; list-style: none; }
.facts b { display: block; font-size: 26px; line-height: 1.2; }
.facts span { font-size: 14px; color: var(--muted); }
.section-title { font-size: 26px; line-height: 1.25; margin: 0 0 18px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 56px; }
.feature { padding: 22px; }
.feature h3 { font-size: 18px; margin-bottom: 6px; }
.footer { border-top: 1px solid var(--line-soft); margin-top: 8px; padding: 20px; color: var(--dim); font-size: 14px; }
.footer-in { max-width: 1120px; margin: 0 auto; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* Forms */
.form-page { min-height: 70vh; display: grid; place-items: center; padding: 16px 0; }
.form-card { width: 100%; max-width: 440px; padding: 28px; }
.form-card h1 { font-size: 26px; line-height: 1.2; margin-bottom: 6px; }
.form-card > p { color: var(--muted); margin-bottom: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  background: var(--card-soft); border: 1px solid var(--line);
}
.input:focus { border-color: var(--accent-ink); outline: 1px solid var(--accent-ink); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.alert { border-radius: 12px; padding: 10px 14px; font-size: 15px; margin-bottom: 14px; border: 1px solid; }
.alert.error { color: var(--red); border-color: var(--red); }
.alert.ok { color: var(--green); border-color: var(--green); }
.alert.warn { color: var(--amber); border-color: var(--amber); }
.form-links { margin-top: 14px; font-size: 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn.wide { width: 100%; }

/* App frame */
.frame { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line-soft); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 2px 8px 16px; }
.nav-link { display: block; padding: 10px 14px; border-radius: 11px; color: var(--muted); text-decoration: none; font-size: 15px; }
.nav-link:hover { background: var(--nav-hover); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--nav-hover); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--teal); }
.side-foot { margin-top: auto; }
.streak { padding: 12px 14px; border-radius: 14px; background: var(--card-soft); border: 1px solid var(--line-soft); margin-bottom: 8px; }
.streak b { display: block; font-size: 20px; line-height: 1.2; }
.main { padding: 24px 28px 48px; min-width: 0; max-width: 1200px; width: 100%; }
.title { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.2; margin-bottom: 4px; }
.lead { color: var(--muted); margin-bottom: 20px; }

/* Dashboard */
.continue { padding: 24px; margin-bottom: 18px; display: flex; gap: 20px; justify-content: space-between; align-items: center; flex-wrap: wrap; background: linear-gradient(100deg, color-mix(in srgb, var(--card) 86%, var(--accent)), var(--card)); }
.continue h2 { font-size: 24px; line-height: 1.2; margin: 6px 0 4px; }
.continue .btn { margin-top: 14px; }
.ring { font-size: 28px; font-weight: 700; color: var(--accent-ink); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat { padding: 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; }
.stat span { font-size: 14px; color: var(--muted); }
.notice { margin-bottom: 18px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notice .btn { min-height: 36px; padding: 4px 14px; font-size: 14px; }

/* Course map */
.section { margin-bottom: 30px; }
.section-head { margin-bottom: 12px; }
.section-head h2 { font-size: 21px; line-height: 1.25; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; color: var(--ink); text-decoration: none; border-radius: 15px; background: var(--card); border: 1px solid var(--line-soft); min-width: 0; }
a.tile:hover { background: var(--card-hover); border-color: var(--accent); }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: var(--dim); }
.tile-num { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 16%, transparent); font-size: 14px; }
.tile h3 { font-size: 17px; line-height: 1.3; }
.tile p { font-size: 14px; color: var(--muted); flex: 1; }
.tile.done .tile-status { color: var(--green); }
.tile.going .tile-status { color: var(--amber); }
.tile-foot { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.course-note { font-size: 14px; color: var(--dim); margin-top: 8px; }

/* Achievements */
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ach-item { padding: 16px; display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: start; }
.ach-glyph { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font-weight: 700; font-size: 15px; background: var(--card-soft); color: var(--dim); }
.ach-item.on .ach-glyph { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.ach-item h3 { font-size: 16px; line-height: 1.3; }
.ach-item:not(.on) h3 { color: var(--muted); }
.ach-item p { font-size: 14px; color: var(--muted); }
.ach-count { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--dim); }

/* Program */
.prog-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.prog-head > div { flex: 1; min-width: 200px; }
.prog-head h1 { font-size: clamp(20px, 2.6vw, 26px); line-height: 1.2; }
.pill { font-size: 12px; font-weight: 700; padding: 5px 14px; border-radius: 999px; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 14%, transparent); white-space: nowrap; }
.pill.fix { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.pill.end { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.prog-bar { margin-bottom: 16px; }
.prog-bar.bar { height: 4px; }
.prog-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.step { padding: 24px 26px; min-height: 340px; }
.step.fix { border-color: var(--amber); }
.outcome { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.outcome.good { color: var(--green); }
.outcome.bad { color: var(--amber); }
.step h2 { font-size: 22px; line-height: 1.3; margin-bottom: 10px; outline: none; }
.step-text { white-space: pre-line; margin-bottom: 14px; max-width: 46em; }
.formula { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-weight: 700; color: var(--accent-ink); background: var(--card-soft); border-radius: 10px; padding: 12px 16px; text-align: center; margin-bottom: 14px; overflow-x: auto; }
.prompt { font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--accent-ink); margin: 4px 0 14px; outline: none; max-width: 40em; }
.options { display: grid; gap: 8px; max-width: 46em; }
.option {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; width: 100%; min-height: 50px;
  padding: 10px 14px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--card-soft); border: 1px solid var(--line);
}
.option:hover { background: var(--card-hover); border-color: var(--accent); }
.option[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.option-key { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--dim); border: 1px solid var(--line); }
.option[aria-checked="true"] .option-key { background: var(--accent); color: var(--button-ink); border-color: var(--accent); }
.answer-input { max-width: 460px; }
.reveal { border-left: 3px solid var(--green); padding: 4px 0 4px 14px; margin-top: 10px; white-space: pre-line; max-width: 46em; }
.reveal b { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--green); }
.terms { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 14px; max-width: 46em; }
.terms dt { font-weight: 700; margin-top: 10px; }
.terms dd { margin: 0; color: var(--muted); font-size: 15px; }
.rail { padding: 14px; font-size: 14px; }
.scene { color: var(--ink); background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.scene svg { display: block; width: 100%; height: auto; }
.scene .l, .scene .a { fill: none; stroke-width: 2.500; stroke-linecap: round; stroke-linejoin: round; }
.scene .l { stroke: currentColor; opacity: .75; }
.scene .a { stroke: var(--accent-ink); }
.scene .f { fill: var(--accent); }
.scene .t { fill: var(--accent); opacity: .45; }
.scene .t.b { opacity: .22; }
.scene .d { fill: currentColor; }
.scene .x { fill: currentColor; font-size: 13px; font-weight: 700; }
.scene .x.big { font-size: 30px; }
.scene .x.inv { fill: var(--button-ink); }
.scene .ph { fill: url(#ph-grad); }
.rail-stat { margin-bottom: 10px; }
.rail-stat span { display: block; font-size: 12px; color: var(--dim); font-weight: 600; }
.rail-stat b { font-size: 18px; }
.rail-stat b.good { color: var(--green); }
.rail-stat b.warn { color: var(--amber); }
.rail-note { font-size: 13px; color: var(--dim); }
.prog-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-top: 14px; align-items: center; }
.prog-actions > div { display: flex; gap: 10px; flex-wrap: wrap; }
.keys { font-size: 13px; color: var(--dim); margin-top: 8px; }

/* Account */
.account { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.panel { padding: 22px; }
.panel h2 { font-size: 18px; margin-bottom: 12px; }
.panel .btn { margin-top: 2px; }
.theme-switch { display: flex; gap: 8px; }
.theme-switch .btn[aria-pressed="true"] { background: var(--teal); color: var(--button-ink); border-color: var(--teal); }

/* Text pages */
.doc { max-width: 720px; }
.doc h1 { font-size: 30px; line-height: 1.2; margin-bottom: 14px; }
.doc h2 { font-size: 19px; margin: 22px 0 6px; }
.doc p, .doc li { color: var(--muted); }
.loading, .empty { padding: 40px 0; color: var(--muted); }

/* Demo question on the landing page */
.demo { padding: 22px; }
.demo .prompt { margin-top: 8px; }
.demo-result { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card-soft); font-size: 15px; }
.demo-result.good { border-left: 3px solid var(--green); }
.demo-result.bad { border-left: 3px solid var(--amber); }

@media (max-width: 1000px) {
  .prog-grid { grid-template-columns: minmax(0, 1fr); }
  .rail { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 12px; align-items: center; }
  .rail .scene, .rail .rail-stat { margin-bottom: 0; }
  .rail-note { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 20px; }
  .features { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 6px 10px; gap: 2px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .side .brand { padding: 0 6px 0 0; }
  .side .brand span, .side-foot { display: none; }
  .side nav { display: flex; gap: 2px; }
  .nav-link { padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  .nav-link[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--teal); }
  .main { padding: 16px 16px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .step { padding: 18px 16px; min-height: 0; }
  .tiles, .ach, .account { grid-template-columns: minmax(0, 1fr); }
  .rail { grid-template-columns: 84px 1fr 1fr; padding: 10px; }
  .prog-actions .btn { flex: 1; }
  .prog-actions, .prog-actions > div { width: 100%; }
  .keys { display: none; }
  .form-card { padding: 20px; }
}
