:root {
  color-scheme: light;
  --paper: #eff3ef;
  --surface: #fff;
  --soft: #e8efea;
  --line: #d7e3db;
  --ink: #172f2a;
  --muted: #506961;
  --primary: #245c4c;
  --primary-hover: #19493b;
  --on-primary: #fff;
  --coral: #ff9a83;
  --good: #24654b;
  --good-bg: #e8f5ed;
  --bad: #9c362e;
  --bad-bg: #fff0ec;
  --focus: #a64634;
  --shadow: 0 12px 30px #213c2910;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font: 16px/1.5 "Segoe UI", "Arial", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #141e20;
  --surface: #202e30;
  --soft: #2a3d3b;
  --line: #38514b;
  --ink: #e9f4ed;
  --muted: #b0c6be;
  --primary: #9addbc;
  --primary-hover: #b2ebce;
  --on-primary: #152920;
  --good: #9ae4b9;
  --good-bg: #253f35;
  --bad: #ffb1a1;
  --bad-bg: #492d2d;
  --focus: #ff9a83;
  --shadow: 0 12px 30px #0002;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --paper: #141e20;
    --surface: #202e30;
    --soft: #2a3d3b;
    --line: #38514b;
    --ink: #e9f4ed;
    --muted: #b0c6be;
    --primary: #9addbc;
    --primary-hover: #b2ebce;
    --on-primary: #152920;
    --good: #9ae4b9;
    --good-bg: #253f35;
    --bad: #ffb1a1;
    --bad-bg: #492d2d;
    --focus: #ff9a83;
    --shadow: 0 12px 30px #0002;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: var(--paper); color: var(--ink); }
#app { position: fixed; inset: var(--viewport-top, 0px) 0 auto; height: 100vh; height: var(--viewport-height, 100dvh); display: grid; grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; }
#app, dialog { touch-action: manipulation; touch-action: pan-y; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 3.8vw, 3.3rem); line-height: 1.08; letter-spacing: -.038em; }
h2 { font-size: 1.37rem; line-height: 1.22; letter-spacing: -.018em; }
h3 { font-size: 1.08rem; line-height: 1.3; }
a { color: var(--primary); }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { position: fixed; z-index: 20; background: var(--surface); padding: 1rem; top: .4rem; left: .4rem; }
.boot { padding: 1.5rem; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 27px 18px; overflow-y: auto; overscroll-behavior: none; }
.brand { display: inline-flex; gap: .65rem; align-items: center; color: var(--ink); text-decoration: none; font-weight: 750; font-size: 1.13rem; white-space: nowrap; }
.sidebar .brand { margin: 0 6px 40px; }
.brand-icon { display: grid; place-items: center; background: #245c4c; color: #fff; width: 38px; height: 38px; border-radius: 12px; font-size: 1.36rem; font-weight: 750; }
.side-nav { display: grid; gap: 7px; }
.side-nav a, .mobile-nav a { display: flex; gap: .7rem; align-items: center; padding: .68rem .75rem; border-radius: 12px; color: var(--muted); font-weight: 650; text-decoration: none; }
.side-nav a:hover, .side-nav a[aria-current="page"], .mobile-nav a[aria-current="page"] { color: var(--primary); background: var(--soft); }
.nav-icon { display: inline-grid; place-items: center; width: 1.35rem; height: 1.4rem; font-size: 1.3rem; line-height: 1; }
.sidebar-bottom { margin: auto .55rem 0; border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 6px; font-size: .86rem; color: var(--muted); }
.sidebar-bottom a { text-decoration: none; }
.workspace { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.content-scroll { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; overflow-wrap: anywhere; scroll-padding-block: 0.8rem; }
.topbar { min-height: 70px; padding: .65rem clamp(1.25rem, 4vw, 3.3rem); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .7rem; align-items: center; }
.section-name { font-weight: 700; }
.mobile-brand, .mobile-nav { display: none; }
.offline { border: 1px solid var(--line); border-radius: 99px; display: inline-flex; align-items: center; gap: .45rem; padding: .31rem .72rem; color: var(--muted); font-size: .87rem; background: var(--surface); }
.offline i { width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.offline[data-status="ready"] { color: var(--good); }
.offline[data-status="failed"] { color: var(--bad); }
.offline[data-status="interrupted"] { color: var(--bad); }
.offline small { color: var(--muted); font-variant-numeric: tabular-nums; }
.offline small:empty { display: none; }
main { max-width: 1330px; margin: 0 auto; padding: 32px clamp(1.25rem, 4vw, 3.3rem) 46px; }
.dashboard { display: grid; grid-template-columns: minmax(0, 2.45fr) minmax(200px, 1fr); gap: 18px; }
.hero { position: relative; isolation: isolate; overflow: hidden; min-height: 290px; display: flex; align-items: center; padding: clamp(1.5rem, 4vw, 3.05rem); border-radius: 25px; background: linear-gradient(119deg,#133a34,#235649); color: #f5faf7; box-shadow: var(--shadow); }
.hero-copy { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.2rem, 4vw, 3.8rem); max-width: 12ch; }
.hero p { color: #d6ebe1; margin: .95rem 0 1.25rem; max-width: min(36ch, 100%); }
.hero-art { position: absolute; right: 0; bottom: 0; width: 42%; height: 100%; pointer-events: none; }
.orbit { position: absolute; width: min(25vw, 280px); aspect-ratio: 1; right: -15%; bottom: -6%; border: 1px solid #a8d7bf65; border-radius: 100%; box-shadow: 0 0 0 28px #9dc9b41c, 0 0 0 57px #9dc9b414, 0 0 0 86px #9dc9b40b; }
.art-ledger, .art-shadow { position: absolute; width: clamp(76px, 10vw, 142px); height: clamp(97px, 12vw, 168px); right: 22%; bottom: 22%; border-radius: 15px; transform: rotate(12deg); }
.art-shadow { background: #7bbba2; opacity: .7; transform: translate(-16px,-8px) rotate(-13deg); }
.art-ledger { display: grid; align-content: center; gap: 9px; background: #ccebd8; box-shadow: 6px 12px 23px #092d23a0; padding: 20%; padding: clamp(9px, 1.5vw, 19px); color: #1c5547; }
.art-ledger b { font-size: clamp(1.25rem, 3vw, 2.5rem); line-height: 1; }
.art-ledger i { height: 3px; width: 85%; border-radius: 6px; background: #659f8b; }
.art-ledger i:last-child { width: 62%; }
.art-coin { position: absolute; right: 12%; bottom: 20%; width: clamp(28px, 4.5vw, 56px); aspect-ratio: 1; border-radius: 50%; background: var(--coral); color: #592a21; display: grid; place-items: center; font-weight: 800; font-size: clamp(1rem, 2.35vw, 1.9rem); transform: rotate(-12deg); box-shadow: 0 6px 15px #1f382c55; }
.overview, .panel, .lesson-card { border: 1px solid var(--line); background: var(--surface); border-radius: 19px; box-shadow: var(--shadow); }
.overview { padding: clamp(1.15rem, 2.7vw, 2.05rem); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.overview .big-stat { margin: .7rem 0 .45rem; }
.overview > p:not(.big-stat) { color: var(--muted); margin: .55rem 0 .8rem; }
.big-stat { font-size: clamp(2.3rem, 4vw, 3.55rem); font-weight: 770; letter-spacing: -.05em; line-height: 1; }
.big-stat span { font-size: .55em; color: var(--muted); letter-spacing: -.025em; }
progress { display: block; width: 100%; height: 9px; appearance: none; border: 0; border-radius: 20px; overflow: hidden; background: var(--soft); accent-color: var(--primary); }
progress::-webkit-progress-bar { background: var(--soft); }
progress::-webkit-progress-value { background: var(--primary); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--primary); }
.text-link { font-weight: 700; text-underline-offset: .22em; }
.curriculum { margin-top: 32px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 15px; }
.section-heading span, .label { font-size: .88rem; color: var(--muted); }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
.levels a { padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 13px; display: grid; align-content: start; color: var(--ink); text-decoration: none; background: var(--surface); }
.levels a[aria-current="page"], .levels a:hover { border-color: var(--primary); background: var(--soft); }
.levels small { font-size: .87rem; color: var(--muted); }
.levels strong { line-height: 1.3; }
.lesson-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.lesson-card { display: flex; text-decoration: none; align-items: center; gap: .75rem; padding: .86rem; color: var(--ink); min-height: 76px; }
.lesson-card:hover { border-color: var(--primary); }
.lesson-index { width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; background: var(--soft); color: var(--primary); font-weight: 750; }
.lesson-text { display: grid; flex: 1; min-width: 0; gap: .16rem; }
.lesson-text strong { overflow-wrap: anywhere; line-height: 1.3; }
.lesson-text small, .lesson-state { color: var(--muted); font-size: .87rem; }
.lesson-state { text-align: right; }
.lesson-state.complete { color: var(--good); white-space: nowrap; }
.page-intro { margin: .45rem 0 1.2rem; }
.page-intro p { margin-top: .65rem; max-width: 62ch; color: var(--muted); }
.page-intro .label { margin-top: 0; margin-bottom: .45rem; }
.lesson-intro .button { margin-top: 1.12rem; }
.reading { max-width: 825px; margin: 0 auto; }
.panel { padding: clamp(1rem, 2.4vw, 1.6rem); margin-bottom: 14px; }
.theory p, .theory ul, .theory form, .theory .button, .theory ol { margin-top: .75rem; }
.theory > p { max-width: 74ch; }
.theory .example { padding: .8rem 1rem; background: var(--soft); border-radius: 12px; border-left: 3px solid var(--primary); }
.empty { padding: 1.35rem; }
.empty p { margin-top: .4rem; color: var(--muted); }
.feature-grid, .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 13px; margin-bottom: 14px; }
.feature-grid .panel, .stats .panel { margin-bottom: 0; }
.tool-card { display: block; color: var(--ink); text-decoration: none; }
.tool-card:hover { border-color: var(--primary); }
.tool-card b { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--soft); color: var(--primary); font-size: 1.23rem; margin-bottom: .7rem; }
.tool-card p { margin-top: .55rem; color: var(--muted); }
.stats .panel { display: grid; gap: .2rem; }
.stats strong { font-size: 1.9rem; letter-spacing: -.04em; }
.stats span { color: var(--muted); }
.trainer-list { columns: 2; padding-left: 1.5rem; }
.trainer-list li { margin-bottom: .5rem; break-inside: avoid; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .85rem 0; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .58rem 1rem; border: 1px solid transparent; border-radius: 11px; text-decoration: none; text-align: center; font-weight: 700; line-height: 1.25; }
.primary { background: var(--primary); color: var(--on-primary); }
.primary:hover { background: var(--primary-hover); }
.secondary { background: var(--surface); color: var(--primary); border-color: var(--line); }
.secondary:hover, .quiet:hover { background: var(--soft); }
.quiet { color: var(--primary); background: transparent; padding-left: .4rem; }
.accent { background: var(--coral); color: #42261f; }
.accent:hover { background: #ffaf9d; }
.button:disabled { opacity: .55; cursor: default; }
.alert, .feedback { border: 1px solid currentColor; border-radius: 12px; padding: .85rem 1rem; }
.alert { color: var(--bad); background: var(--bad-bg); margin-bottom: 1rem; }
.feedback { margin-top: 1rem; }
.correct { color: var(--good); background: var(--good-bg); }
.wrong, .form-error { color: var(--bad); }
.wrong { background: var(--bad-bg); }
.form-error:empty { display: none; }
.saved-answer { color: var(--muted); }
.sources, .plain-list { list-style: none; padding: 0; margin: 0; }
.sources li, .plain-list li, .glossary article { padding: .78rem 0; border-bottom: 1px solid var(--line); }
.sources li:last-child, .plain-list li:last-child, .glossary article:last-child { border-bottom: 0; }
.sources a, .sources span, .sources small, .plain-list strong, .plain-list span { display: block; }
.sources small, .calendar small { color: var(--muted); }
.score-list li { display: flex; justify-content: space-between; align-items: baseline; gap: .7rem; }
.score-list span { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.calendar li { display: flex; gap: 1rem; }
.calendar time { font-weight: 700; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters a { padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 650; }
.filters a[aria-current="page"] { background: var(--soft); border-color: var(--primary); }
.field { display: grid; max-width: 440px; gap: .35rem; margin: .7rem 0; font-weight: 650; }
input:not([type="radio"],[type="checkbox"]), select { width: 100%; min-width: 0; min-height: 44px; font-size: max(16px, 1rem); padding: .55rem .65rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; }
.glossary p { margin: .3rem 0; }
.calc-output { display: block; margin-top: .9rem; font-weight: 700; }
.exercise-top { display: flex; justify-content: space-between; margin: .7rem 0; gap: .5rem; font-weight: 700; }
.exercise-panel { margin-top: 1rem; }
.exercise h1 { font-size: clamp(1.45rem, 3.2vw, 2.4rem); line-height: 1.22; }
.exercise fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.choices { display: grid; gap: .5rem; }
.option { display: flex; align-items: flex-start; min-height: 45px; gap: .6rem; padding: .58rem .7rem; cursor: pointer; border: 1px solid var(--line); border-radius: 11px; }
.option:has(input:checked) { border-color: currentColor; }
.option:has(input:disabled) { cursor: default; }
.option input { flex-shrink: 0; width: 1.14rem; height: 1.14rem; accent-color: var(--primary); margin-top: .17rem; }
.option span:nth-child(2) { flex: 1; }
#answer-form input.correct { color: var(--good); background: var(--good-bg); border-color: var(--good); }
#answer-form input.wrong { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); }
.exercise-nav { justify-content: space-between; }
#notice { position: fixed; z-index: 5; bottom: max(1.1rem, var(--safe-bottom)); right: 1.1rem; max-width: min(32rem, calc(100vw - 2.2rem)); padding: .75rem 1rem; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow); pointer-events: none; }
#notice:empty { padding: 0; }
dialog { max-width: min(480px, calc(100% - 1.5rem)); max-height: calc(var(--viewport-height, 100dvh) - 1.5rem); overscroll-behavior: none; padding: 1.3rem; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); }
dialog p { margin-top: .65rem; }
dialog::backdrop { background: #12252691; }

@media (min-width: 801px) and (max-width: 1130px) {
  .hero-art { opacity: .62; }
  #app { grid-template-columns: 194px minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .sidebar, .section-name { display: none; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  :root[data-keyboard] { --safe-bottom: 0px; }
  .mobile-brand { display: inline-flex; }
  .topbar { min-height: 60px; padding: max(.6rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left)); }
  main { padding: 20px max(1rem, env(safe-area-inset-right)) 1.25rem max(1rem, env(safe-area-inset-left)); }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border-top: 1px solid var(--line); background: var(--surface); padding: .32rem env(safe-area-inset-right) max(.32rem, var(--safe-bottom)) env(safe-area-inset-left); }
  .mobile-nav a { display: grid; justify-items: center; gap: .12rem; padding: .3rem 0; min-height: 46px; font-size: .8rem; }
  #notice { bottom: calc(60px + var(--safe-bottom)); }
}
@media (max-width: 570px) {
  .dashboard, .lesson-grid { grid-template-columns: 1fr; gap: 10px; }
  .hero { border-radius: 18px; min-height: 260px; }
  .hero-art { opacity: .47; }
  .orbit { width: min(41vw, 146px); }
  .overview { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: .5rem; }
  .overview progress { grid-column: 1/-1; }
  .overview .big-stat { margin: .2rem 0 .55rem; }
  .overview > p:not(.big-stat), .overview .text-link { font-size: .87rem; margin: .5rem 0 0; }
  .curriculum { margin-top: 22px; }
  .section-heading { flex-wrap: wrap; }
  .levels { grid-template-columns: 1fr; gap: 5px; }
  .levels a { display: flex; align-items: baseline; gap: .5rem; padding: .53rem .65rem; }
  .levels small { flex-shrink: 0; }
  .trainer-list { columns: 1; }
}
@media (max-width: 390px) {
  .brand { font-size: 1rem; gap: .4rem; }
  .brand-icon { width: 31px; height: 31px; }
  .offline { font-size: .8rem; padding: .28rem .4rem; }
  .mobile-nav a { font-size: .71rem; }
  .calendar li { flex-direction: column; gap: .2rem; }
  .score-list span { white-space: normal; text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
