:root {
  --bg: #f4f7f5; --card: #ffffff; --text: #1d2a24; --muted: #5e6e66; --line: #dfe7e2;
  --brand: #16874f; --brand-d: #0f6a3d; --brand-l: #e3f4ea;
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2; --warn: #b45309; --warn-bg: #fef3c7;
  --chem: #2563eb; --phy: #c2410c; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101714; --card: #18221d; --text: #e6efe9; --muted: #9db0a6; --line: #2a3a32;
    --brand: #34d399; --brand-d: #10b981; --brand-l: #153326;
    --ok: #4ade80; --ok-bg: #123b22; --bad: #f87171; --bad-bg: #431818; --warn: #fbbf24; --warn-bg: #3d2f0a;
    --chem: #60a5fa; --phy: #fb923c; --shadow: 0 1px 3px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #101714; --card: #18221d; --text: #e6efe9; --muted: #9db0a6; --line: #2a3a32;
  --brand: #34d399; --brand-d: #10b981; --brand-l: #153326;
  --ok: #4ade80; --ok-bg: #123b22; --bad: #f87171; --bad-bg: #431818; --warn: #fbbf24; --warn-bg: #3d2f0a;
  --chem: #60a5fa; --phy: #fb923c; --shadow: 0 1px 3px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { max-width: 920px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 800; font-size: 18px; color: var(--brand); cursor: pointer; display: flex; align-items: center; gap: 8px; flex: 1; }
.logo small { font-weight: 600; color: var(--muted); font-size: 12px; display: block; line-height: 1.1; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 38px; height: 38px; font-size: 18px; }
main { max-width: 920px; margin: 0 auto; padding: 16px 16px 90px; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
.nav-in { max-width: 920px; margin: 0 auto; display: grid; grid-template-columns: repeat(7, 1fr); }
code { background: var(--brand-l); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.nav button { border: 0; background: none; padding: 8px 2px 10px; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav button span { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--brand); font-weight: 700; }
h1 { font-size: 24px; margin: 4px 0 6px; line-height: 1.25; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.hero { background: linear-gradient(135deg, var(--brand), #0e5e8a); color: #fff; border: 0; }
.hero h1 { color: #fff; } .hero .muted { color: rgba(255,255,255,.85); }
.bar { height: 9px; background: rgba(0,0,0,.14); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: #fff; border-radius: 99px; transition: width .4s; }
.bar.g { background: var(--line); } .bar.g > i { background: var(--brand); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile b { display: block; font-size: 16px; } .tile .em { font-size: 26px; display: block; margin-bottom: 4px; }
.tile .muted { font-size: 13px; }
.btn { border: 0; background: var(--brand); color: #fff; border-radius: 10px; padding: 11px 18px; font-weight: 700; }
.btn:hover { background: var(--brand-d); }
.btn.sec { background: var(--brand-l); color: var(--brand-d); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.sec { color: var(--brand); } }
:root[data-theme="dark"] .btn.sec { color: var(--brand); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.lesson-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.lesson-row:hover { border-color: var(--brand); }
.num { min-width: 42px; height: 42px; border-radius: 12px; background: var(--brand-l); color: var(--brand-d); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .num { color: var(--brand); } }
:root[data-theme="dark"] .num { color: var(--brand); }
.chip { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
ul.pts { padding-left: 20px; margin: 8px 0; } ul.pts li { margin-bottom: 10px; }
.formula { background: var(--brand-l); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 14px; margin: 8px 0; }
.formula small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.formula div { font-size: 17px; font-weight: 600; margin-top: 2px; }
sub, sup { line-height: 0; }
.qtext { font-size: 18px; font-weight: 600; margin: 4px 0 14px; }
.opt { display: flex; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 9px; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt .k { min-width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
.opt.sel { border-color: var(--brand); background: var(--brand-l); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); } .opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; }
.expl { background: var(--warn-bg); border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 15px; }
.flash { perspective: 900px; margin: 12px 0; }
.flash-in { position: relative; min-height: 220px; transition: transform .45s; transform-style: preserve-3d; cursor: pointer; }
.flash-in.flip { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 22px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); font-size: 19px; font-weight: 600; }
.face.back { transform: rotateY(180deg); background: var(--brand-l); font-weight: 500; }
.face small { position: absolute; top: 12px; color: var(--muted); font-size: 12px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; padding: 4px 12px; border-radius: 99px; background: var(--brand-l); color: var(--brand-d); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .timer { color: var(--brand); } }
:root[data-theme="dark"] .timer { color: var(--brand); }
.timer.low { background: var(--bad-bg); color: var(--bad); }
input[type=text], input[type=number], select { font: inherit; padding: 11px 14px; border-radius: 10px; border: 2px solid var(--line); background: var(--card); color: var(--text); width: 100%; }
input:focus { outline: none; border-color: var(--brand); }
.score { font-size: 54px; font-weight: 800; color: var(--brand); line-height: 1; }
label.chk { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; }
label.chk input { width: 20px; height: 20px; accent-color: var(--brand); }
.crumbs { margin-bottom: 8px; }
.crumbs button { background: none; border: 0; color: var(--brand); font-weight: 700; padding: 4px 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 8px 14px; font-weight: 600; }
.seg button.on { background: var(--brand); color: #fff; }
.tag-c { color: var(--chem); } .tag-p { color: var(--phy); }
.formula .fl { display: block; overflow-wrap: anywhere; padding: 2px 0; }
.formula .fl-note { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }
@media (max-width: 420px) { .nav button { font-size: 10px; } .nav button span { font-size: 18px; } }
.mt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; }
.mt-grid > div { display: flex; flex-direction: column; gap: 8px; }
.mt { min-height: 64px; width: 100%; text-align: left; padding: 8px 10px; font-size: 14px; line-height: 1.35; background: var(--card); border: 2px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.mt.sel { border-color: var(--brand); background: var(--brand-l); }
.mt.ok { border-color: var(--ok); background: var(--ok-bg); opacity: .75; }
.mt.bad { border-color: var(--bad); background: var(--bad-bg); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.mem-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mm { min-height: 92px; padding: 6px; font-size: 12.5px; line-height: 1.3; font-weight: 600; background: var(--brand); color: #fff; border: 2px solid transparent; border-radius: 12px; overflow-wrap: anywhere; display: flex; align-items: center; justify-content: center; text-align: center; font-size-adjust: none; }
.mm:not(.up) { font-size: 26px; }
.mm.up { background: var(--card); color: var(--text); border-color: var(--line); }
.mm.up.q { border-color: var(--brand); }
.mm.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }
