:root {
  --bg: #f6f7f4; --surface: #ffffff; --surface2: #eef1ec; --text: #1c2420; --muted: #55625b;
  --primary: #0f766e; --primary-d: #0b5a54; --on-primary: #ffffff; --accent: #d97706;
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2; --warn-bg: #fef3c7; --tip-bg: #e0f2fe;
  --border: #d5dbd6; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
  --radius: 14px; --fs: 1;
}
:root[data-theme="dark"] {
  --bg: #0f1613; --surface: #18221e; --surface2: #202d28; --text: #e8efeb; --muted: #a2b1a9;
  --primary: #2dd4bf; --primary-d: #5eead4; --on-primary: #06201c; --accent: #fbbf24;
  --ok: #4ade80; --ok-bg: #12351f; --bad: #f87171; --bad-bg: #3b1616; --warn-bg: #3a2e0b; --tip-bg: #0f2a3b;
  --border: #2f3f38; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1613; --surface: #18221e; --surface2: #202d28; --text: #e8efeb; --muted: #a2b1a9;
    --primary: #2dd4bf; --primary-d: #5eead4; --on-primary: #06201c; --accent: #fbbf24;
    --ok: #4ade80; --ok-bg: #12351f; --bad: #f87171; --bad-bg: #3b1616; --warn-bg: #3a2e0b; --tip-bg: #0f2a3b;
    --border: #2f3f38; --shadow: none;
  }
}
:root.contrast { --text: #000; --muted: #222; --border: #000; --primary: #00424a; --primary-d: #00282d; --bg: #fff; --surface: #fff; --surface2: #f0f0f0; }
:root.contrast[data-theme="dark"], :root.contrast[data-theme="auto"] { --text: #fff; --muted: #eee; --border: #fff; --bg: #000; --surface: #000; --surface2: #111; --primary: #ffe600; --primary-d: #fff27a; --on-primary: #000; }
@media (prefers-color-scheme: light) { :root.contrast[data-theme="auto"] { --text: #000; --muted: #222; --border: #000; --bg: #fff; --surface: #fff; --surface2: #f0f0f0; --primary: #00424a; --primary-d: #00282d; --on-primary: #fff; } }

* { box-sizing: border-box; }
html { font-size: calc(100% * var(--fs)); scroll-behavior: smooth; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--on-primary); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

header.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand span.logo { background: var(--primary); color: var(--on-primary); border-radius: 10px; padding: .1rem .5rem; }
nav.main { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
nav.main a { text-decoration: none; color: var(--text); padding: .45rem .75rem; border-radius: 999px; font-weight: 600; font-size: .95rem; }
nav.main a:hover { background: var(--surface2); }
nav.main a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
main:focus, h1:focus { outline: none; }
article.lesson > :first-child { margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.crumbs { font-size: .9rem; margin-bottom: .75rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 2px solid var(--primary); background: var(--primary); color: var(--on-primary); padding: .65rem 1.15rem; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: var(--surface2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { padding: .9rem 1.5rem; font-size: 1.1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.hero { background: linear-gradient(135deg, var(--primary), var(--primary-d)); color: var(--on-primary); border-radius: var(--radius); padding: 1.5rem; }
.hero h1 { margin-bottom: .25rem; }
.hero .btn { background: var(--on-primary); color: var(--primary-d); border-color: var(--on-primary); }
.stat { text-align: center; }
.stat .n { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat .l { font-size: .9rem; color: var(--muted); }

.mod { display: flex; flex-direction: column; gap: .5rem; text-decoration: none; color: inherit; border-top: 6px solid var(--c, var(--primary)); transition: transform .12s; }
.mod:hover { transform: translateY(-2px); }
.mod .ic { font-size: 2rem; }
.bar { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--c, var(--primary)); width: 0; transition: width .3s; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list a { display: flex; gap: .75rem; align-items: center; padding: .85rem .25rem; text-decoration: none; color: inherit; }
.list a:hover { background: var(--surface2); }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex: none; font-weight: 800; }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }

article.lesson { font-size: 1.1rem; max-width: 760px; }
article.lesson p, article.lesson li { margin: .5em 0; }
article.lesson ul, article.lesson ol { padding-left: 1.3rem; }
article.lesson h3 { margin-top: 1.5rem; color: var(--primary); }
.note { border-left: 6px solid; padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0; }
.note.tip { background: var(--tip-bg); border-color: #0284c7; }
.note.warn { background: var(--warn-bg); border-color: var(--accent); }
.note b.t { display: block; }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 1rem; background: var(--surface); }
th, td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; vertical-align: top; }
th { background: var(--surface2); }
.tablewrap { overflow-x: auto; }

.qcard { max-width: 760px; margin: 0 auto; }
.qtext { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.opt { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; border: 2px solid var(--border); border-radius: 12px; margin: .5rem 0; cursor: pointer; background: var(--surface); font-size: 1.05rem; }
.opt:hover { border-color: var(--primary); }
.opt input { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.missed { border-color: var(--ok); border-style: dashed; }
.numin { font: inherit; font-size: 1.3rem; padding: .6rem .8rem; border: 2px solid var(--border); border-radius: 12px; width: 10rem; background: var(--surface); color: var(--text); }
.fb { padding: .85rem 1rem; border-radius: 12px; margin-top: 1rem; font-weight: 600; }
.fb.ok { background: var(--ok-bg); color: var(--ok); }
.fb.no { background: var(--bad-bg); color: var(--bad); }
.fb .ex { display: block; font-weight: 400; color: var(--text); margin-top: .25rem; }

.flash { max-width: 560px; margin: 1rem auto; min-height: 260px; display: grid; place-items: center; text-align: center; cursor: pointer; font-size: 1.4rem; padding: 2rem; border: 2px solid var(--primary); }
.flash .side { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: block; margin-bottom: .5rem; }
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); font-size: .9rem; margin: .2rem; }
.badge.off { opacity: .45; filter: grayscale(1); }
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: var(--surface2); font-size: .8rem; font-weight: 700; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }

input[type=text], input[type=date], textarea, select, input[type=search] { font: inherit; padding: .6rem .8rem; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; }
textarea { min-height: 120px; resize: vertical; }
label.f { display: block; font-weight: 700; margin: .75rem 0 .25rem; }
dl.gl dt { font-weight: 800; margin-top: 1rem; color: var(--primary); }
dl.gl dd { margin: .1rem 0 0; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7rem 1.2rem; border-radius: 999px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-block; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); text-decoration: none; font-size: .9rem; }
.chip:hover { border-color: var(--primary); }
.chip.done { background: var(--ok-bg); border-color: var(--ok); }
a.pill { text-decoration: none; color: var(--text); }
.plansec summary { cursor: pointer; padding: .25rem 0; font-size: 1.1rem; }
.plansec .bar { margin: .5rem 0; }
.plansec h3 { color: var(--primary); margin-top: 1.1rem; }
.planlist { list-style: none; padding: 0; margin: 0; }
.planlist li { display: flex; flex-direction: column; gap: .35rem; padding: .6rem 0; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  h1 { font-size: 1.55rem; }
  nav.main { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .25rem; }
  nav.main a { white-space: nowrap; }
}
@media print {
  header.top, .noprint, .skip, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
