
:root {
  color-scheme: light;
  --page: #FFFFFF;
  --panel: #F1F1F1;
  --sheet: #FAFAFA;
  --ink: #222222;
  --muted: #55555B;
  --line: #C9C9CE;
  --red: #D9301F;
  --purple: #85589B;
  --lime: #D2E76A;
  --salmon: #F09A85;
  --on-block: #FFFFFF;
  --head: "Rubik", "Segoe UI", Arial, sans-serif;
  --hand: "Caveat", "Comic Sans MS", cursive;
  --brush: "Amatic SC", "Caveat", Impact, sans-serif;
  --body: "Onest", "Segoe UI", Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #151517; --panel: #202024; --sheet: #2A2A2F; --ink: #F1F1F3;
  --muted: #B4B4BC; --line: #46464D; --red: #F0503F; --purple: #C4A2D8;
  --lime: #B9CF56; --salmon: #E8907C; --on-block: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #151517; --panel: #202024; --sheet: #2A2A2F; --ink: #F1F1F3;
    --muted: #B4B4BC; --line: #46464D; --red: #F0503F; --purple: #C4A2D8;
    --lime: #B9CF56; --salmon: #E8907C; --on-block: #FFFFFF;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: 20px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 12px 12px 48px; }
.topbar { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; padding: 8px 4px 22px; }
.eyebrow { font-family:var(--hand); color:var(--red); font-weight:700; font-size:1.45rem; line-height:1; margin-bottom:7px; }
h1,h2 { font-family:var(--head); font-weight:700; color:var(--purple); margin:0; letter-spacing:-.01em; }
h1 { font-size:clamp(1.65rem,7vw,2.5rem); line-height:1.08; }
h2 { font-size:1.3rem; line-height:1.2; }
.panel { background:var(--panel); border-radius:12px; padding:18px 14px; }
.theme-btn { border:2px solid var(--ink); background:transparent; color:var(--ink); width:44px; height:44px; border-radius:50%; font-size:1.1rem; }
.hero { display:grid; grid-template-columns:minmax(0,1fr); gap:28px; align-items:end; padding-bottom:16px; border-bottom:1px solid var(--line); }
.hero > div:first-child { display:none; }
.brush { font-family:var(--brush); font-size:2.7rem; font-weight:700; line-height:.9; text-transform:uppercase; color:var(--ink); }
.lead { margin:14px 0 0; max-width:32em; font-size:1.06rem; }
.progress-card { background:var(--sheet); border:1px solid var(--line); border-radius:10px; padding:12px; }
.progress-head { display:flex; justify-content:space-between; gap:12px; font-family:var(--head); }
.progress-head strong { color:var(--purple); }
.progress { height:11px; background:var(--line); border-radius:99px; overflow:hidden; margin:10px 0 13px; }
.progress span { display:block; width:0; height:100%; background:var(--purple); transition:width .25s ease; }
.stats { display:flex; flex-wrap:wrap; gap:4px 12px; color:var(--muted); font-size:.8rem; }
.stats b { color:var(--ink); }
.trainer { margin-top:18px; }
.topic-row { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:8px 10px; margin-bottom:18px; }
.topic-row > div { display:contents; }
.topic-row .topic-code { grid-column:1; grid-row:1; align-self:center; }
.topic-row h2 { grid-column:1 / -1; grid-row:2; }
#topicsBtn { grid-column:2; grid-row:1; }
.topic-code { display:inline-block; font-family:var(--hand); font-weight:700; font-size:1.25rem; color:var(--red); margin-bottom:3px; }
.outline-btn { background:transparent; border:2px solid var(--purple); color:var(--purple); border-radius:10px; padding:9px 14px; font-weight:600; min-height:44px; }
.task-card { background:var(--sheet); border:1px solid var(--line); border-top:6px solid var(--lime); border-radius:10px; padding:16px 12px; }
.task-type { font-family:var(--brush); font-size:2rem; line-height:1; font-weight:700; color:var(--muted); overflow-wrap:anywhere; max-width:100%; }
.question { min-height:110px; display:grid; place-items:center; text-align:center; padding:20px 0; font-family:var(--head); font-size:1.2rem; line-height:1.4; overflow-wrap:anywhere; }
.question p { margin:0; }
.equation { font-size:clamp(1.9rem,5vw,3.5rem); line-height:1.25; margin-top:16px; }
.equation:empty { display:none; }
.task-meta { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.difficulty { border:1px solid var(--line); border-radius:20px; padding:3px 12px; font-size:.85rem; color:var(--muted); }
.progress-caption { color:var(--muted); font-size:.8rem; margin:0 0 8px; }
.task-visual { max-width:580px; margin:0 auto 20px; }
.task-visual svg { display:block; width:100%; height:auto; color:var(--ink); }
.answer-options { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.answer-options button { min-width:48px; min-height:44px; padding:6px 14px; border:2px solid var(--line); border-radius:8px; background:var(--page); color:var(--ink); }
.answer-options button[aria-pressed="true"] { border-color:var(--purple); background:var(--panel); }
.input-error { color:var(--red); font-size:.9rem; margin:6px 0 0; }
.input-error:empty { display:none; }
.feedback ol { margin:10px 0; padding-left:24px; }
.feedback li { margin:8px 0; overflow-wrap:anywhere; }
.feedback .outline-btn { margin-top:12px; }
button:disabled { cursor:default; opacity:.65; }
.theme-btn,.outline-btn { flex-shrink:0; }
.topbar > div,.topic-row > div,.hero > div { min-width:0; }
.topbar h1,.topic-row h2 { overflow-wrap:anywhere; }
:root[data-theme="dark"] .check-btn { color:#222; }
:root[data-theme="dark"] .feedback.good .feedback-title { color:var(--lime); }
@media (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) .check-btn { color:#222; }
  :root:not([data-theme="light"]) .feedback.good .feedback-title { color:var(--lime); }
}
.answer-form { max-width:640px; margin:0 auto; }
.answer-form label { display:block; font-weight:600; margin-bottom:7px; }
.answer-line { display:flex; flex-direction:column; gap:10px; }
.answer-line input { flex:1; min-width:0; min-height:52px; border:2px solid var(--line); border-radius:10px; background:var(--page); color:var(--ink); padding:10px 14px; font-size:1.25rem; }
.check-btn,.next-btn { min-height:52px; border:0; border-radius:10px; padding:10px 20px; font-family:var(--head); font-weight:700; }
.check-btn { background:var(--purple); color:#fff; width:100%; }
.next-btn { background:var(--ink); color:var(--page); margin-top:18px; }
.answer-help { color:var(--muted); font-size:.85rem; margin-top:6px; }
.feedback { margin:22px auto 0; max-width:640px; padding:16px 12px; border-radius:10px; background:var(--panel); border:1px solid var(--line); }
.feedback.good { border-color:var(--lime); }
.feedback.bad { border-color:var(--salmon); }
.feedback-title { font-family:var(--head); font-weight:700; font-size:1.25rem; margin-bottom:8px; }
.feedback.bad .feedback-title { color:var(--red); }
.feedback.good .feedback-title { color:#4e7410; }
.feedback p { margin:6px 0; }
.tip { display:flex; gap:14px; align-items:flex-start; background:var(--ink); color:var(--page); border-radius:10px; margin-top:20px; padding:18px 14px; }
.tip-mark { width:34px; height:34px; border-radius:50%; background:var(--lime); color:#222; display:grid; place-items:center; font-weight:700; flex:none; }
.tip p { margin:3px 0 0; color:var(--page); opacity:.88; }
.topics-panel { margin-top:20px; background:var(--sheet); border:1px solid var(--line); border-radius:10px; padding:16px 12px; }
.topics-head { display:flex; justify-content:space-between; gap:10px; align-items:center; margin-bottom:18px; }
.topics-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; }
.topics-filter { margin-bottom:18px; }
.topics-filter label { display:block; margin-bottom:6px; font-size:.9rem; color:var(--muted); }
.select-wrap { position:relative; min-width:0; }
.select-wrap::after { content:""; position:absolute; right:18px; top:50%; width:9px; height:9px; border-right:2px solid var(--purple); border-bottom:2px solid var(--purple); transform:translateY(-70%) rotate(45deg); pointer-events:none; }
.topics-filter select { appearance:none; -webkit-appearance:none; display:block; width:100%; min-width:0; max-width:100%; min-height:48px; padding:10px 42px 10px 12px; border:2px solid var(--line); border-radius:8px; background:var(--page); color:var(--ink); font-size:1rem; cursor:pointer; }
.topics-filter option { background:var(--page); color:var(--ink); }
.data-table { width:100%; border-collapse:collapse; font-size:1rem; }
.data-table caption { font-weight:600; margin-bottom:8px; }
.data-table th,.data-table td { border:1px solid var(--line); padding:8px 12px; text-align:center; }
.data-table thead { background:var(--panel); }
.disclaimer { margin-top:18px; padding-top:12px; border-top:1px solid var(--line); color:var(--muted); font-size:.85rem; }
.disclaimer summary { cursor:pointer; min-height:44px; padding:10px 0; }
.disclaimer p { margin:8px 0; }
.source-links { display:flex; flex-wrap:wrap; gap:8px 16px; }
.source-links a { display:inline-flex; align-items:center; min-height:44px; color:var(--purple); }
.topic-item { text-align:left; border:1px solid var(--line); background:var(--page); color:var(--ink); border-radius:9px; padding:12px 14px; min-height:64px; }
.topic-item.active { border:3px solid var(--purple); padding:10px 12px; background:var(--panel); }
.topic-item.active strong { text-decoration:underline; text-decoration-color:var(--purple); text-underline-offset:4px; text-decoration-thickness:2px; }
.topic-item small { display:block; color:var(--red); font-family:var(--hand); font-weight:700; font-size:1.05rem; }
.topic-item strong { display:block; line-height:1.25; }
.topic-item .mini { color:var(--muted); font-size:.78rem; margin-top:4px; }
.footer { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-top:22px; color:var(--muted); font-size:.85rem; }
.text-btn { background:none; border:0; padding:8px 0; min-height:44px; color:var(--red); text-decoration:underline; text-underline-offset:3px; }
[hidden] { display:none !important; }
/* Mobile first: the base layout supports a 320px viewport. */
@media (min-width:561px) {
  body { font-size:17px; }
  .wrap { padding:20px 20px 64px; }
  .topbar { gap:20px; }
  h1 { font-size:clamp(2.3rem,6vw,4rem); }
  h2 { font-size:clamp(1.55rem,3.6vw,2.35rem); line-height:1.12; }
  .panel { padding:32px 28px; }
  .hero { padding-bottom:28px; }
  .hero > div:first-child { display:block; }
  .progress-card { padding:18px; }
  .stats { gap:8px 18px; font-size:.9rem; }
  .trainer { margin-top:28px; }
  .topic-row { display:flex; flex-wrap:nowrap; gap:20px; }
  .topic-row > div { display:block; }
  .answer-line { flex-direction:row; }
  .check-btn { width:auto; }
  .task-card { padding:30px; }
  .question { min-height:120px; padding:20px 10px; font-size:clamp(1.25rem,2.6vw,1.7rem); }
  .tip { padding:20px 24px; }
  .feedback { padding:18px 20px; }
  .topics-panel { padding:24px; }
  .topics-head { gap:20px; }
  .topics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (min-width:861px) {
  .hero { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .panel { padding:40px 44px; }
}
@media (prefers-reduced-motion:reduce) {
  .progress span { transition:none; }
}
