:root {
  --bg: #0E1420; --surface: #172033; --surface-2: #1F2A42; --line: #2C3A58;
  --text: #EEF2FA; --muted: #9AA8C4; --accent: #FFC83D; --on-accent: #1A1405;
  --good: #3DD6A3; --bad: #FF7A7A; --info: #7FB2FF; --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #F4F6FB; --surface: #FFFFFF; --surface-2: #EDF1F8; --line: #D5DCEA;
    --text: #131A2A; --muted: #56627C; --accent: #E0A100; --on-accent: #1A1405;
    --good: #0E9F6E; --bad: #D64545; --info: #2F6FD6; color-scheme: light; }
}
* { 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; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 500; letter-spacing: .01em; }
.brand b { color: var(--accent); font-weight: 700; }
.streak { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak b { color: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 8px; outline: none; }
.pad { padding: 24px 0; }
.stack > * + * { margin-top: 16px; }
.h1 { font-size: clamp(26px, 6vw, 36px); line-height: 1.15; font-weight: 750; letter-spacing: -.01em; }
.h2 { font-size: 20px; font-weight: 700; }
.sub { color: var(--muted); }
.small { font-size: 14px; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 14px; white-space: nowrap; }
.chip b { color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 650; text-decoration: none; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.good { background: var(--good); color: #05261B; border-color: transparent; }
.btn.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid3 .btn { padding: 0 6px; }
@media (hover: none) { .keys { display: none; } }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar.good > span { background: var(--good); }

.topics { display: grid; gap: 10px; }
.topic { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; }
.topic:hover { border-color: var(--accent); }
.topic .name { font-weight: 650; }
.topic .meta { font-size: 13px; color: var(--muted); }
.topic .pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.topic .bar { grid-column: 1 / -1; margin-top: 6px; height: 6px; }
.part { margin-top: 26px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* Flashcard */
.scene { perspective: 1400px; }
.card { position: relative; width: 100%; min-height: 300px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.8,.2,1); border: 0; background: none; padding: 0; text-align: left; display: block; }
.card.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.face.back { transform: rotateY(180deg); border-color: var(--accent); }
.face .q { font-size: clamp(19px, 4.6vw, 24px); line-height: 1.35; font-weight: 650; margin: auto 0; }
.face .a { font-size: clamp(19px, 4.6vw, 23px); line-height: 1.35; font-weight: 700; color: var(--accent); }
.face .hint { margin-top: auto; font-size: 13px; color: var(--muted); text-align: center; }
.tag { align-self: flex-start; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ref { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.flag { font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--info); padding-left: 10px; }
.flag.src { border-color: var(--good); }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }

.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; min-height: 52px; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.choice:hover { border-color: var(--accent); }
.choice .k { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.choice.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.choice[disabled] { cursor: default; }
.explain { border-radius: 14px; padding: 14px 16px; background: var(--surface-2); }
.explain.ok { border-left: 4px solid var(--good); }
.explain.no { border-left: 4px solid var(--bad); }

.lesson li { margin: 10px 0; padding-left: 4px; }
.lesson ol { margin: 0; padding-left: 22px; }
.lesson li.new { animation: pop .35s; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.done-mark { color: var(--good); font-weight: 700; }

.timer { font-size: 44px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.big { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pass { color: var(--good); } .fail { color: var(--bad); }
input.num { width: 100%; min-height: 52px; font: inherit; font-size: 20px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.qnav button { height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-variant-numeric: tabular-nums; }
.qnav button.ans { background: var(--surface-2); border-color: var(--accent); }
.qnav button.cur { outline: 2px solid var(--accent); }
table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t td, table.t th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td:last-child, table.t th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.note { font-size: 13.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }
.note a, .stack p a { color: var(--info); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px 8px; font-size: 11.5px; text-decoration: none; color: var(--muted); }
.tabs a i { font-style: normal; font-size: 19px; line-height: 1; }
.tabs a.on { color: var(--accent); }
@media (min-width: 900px) { .tabs { left: 50%; right: auto; transform: translateX(-50%); bottom: 16px; width: 560px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; } }
.btn.two { flex-direction: column; gap: 0; padding: 12px 14px; line-height: 1.3; }
.btn.two span { font-weight: 500; font-size: 13.5px; opacity: .85; }
