:root {
  --bg: #f6f7fb; --card: #ffffff; --ink: #1d2433; --muted: #5d6679; --line: #e2e6ef;
  --brand: #3456d1; --brand-ink: #ffffff; --brand-soft: #e8edff;
  --good: #1f8a4c; --good-soft: #e3f5ea; --bad: #c0392b; --bad-soft: #fdecea; --warn: #a86a00; --warn-soft: #fff4dc;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
  --maths: #3456d1; --french: #c2410c; --biology: #15803d; --chemistry: #7c3aed; --physics: #0e7490; --english: #b91c5c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151d; --card: #1a202b; --ink: #e8ecf4; --muted: #9aa4b8; --line: #2a3242;
    --brand: #7b93ff; --brand-ink: #0d1020; --brand-soft: #232c4a; --good: #4ccb82; --good-soft: #17301f;
    --bad: #ff7b6e; --bad-soft: #3a1c1a; --warn: #f0b545; --warn-soft: #3a2c10; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.wrap { max-width: 880px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 680px; }

/* top bar */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); margin-right: auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.nav a.on, .nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.nav form { display: inline; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; padding: 7px 12px; cursor: pointer; }

/* cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); text-decoration: none; }
.tile .icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; margin-bottom: 10px; }
.tile .name { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hero { background: linear-gradient(135deg, var(--brand), #6a4fd1); color: #fff; border: 0; }
.hero h1 { margin: 0 0 .3rem; }
.hero p { margin: 0 0 1rem; opacity: .92; }
.hero .btn { background: #fff; color: #2c3e9e; }
.stat { font-size: 1.5rem; font-weight: 700; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn.big { min-height: 54px; font-size: 1.05rem; padding: 12px 22px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }

/* progress */
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.good > i { background: var(--good); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.grey { background: var(--line); color: var(--muted); }

/* topic lists */
.unit { margin-bottom: 18px; }
.topic-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--ink); }
.topic-row:first-of-type { border-top: 0; }
.topic-row:hover { background: var(--brand-soft); text-decoration: none; }
.topic-row .t { flex: 1; min-width: 0; }
.topic-row .bar { width: 90px; }
.topic-row.missing { opacity: .55; pointer-events: none; }

/* questions */
.qhead { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i.done { background: var(--brand); }
.dots i.ok { background: var(--good); }
.dots i.no { background: var(--bad); }
.prompt { font-size: 1.2rem; line-height: 1.5; white-space: pre-line; margin: 6px 0 16px; }
.options { display: grid; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--card); font-size: 1.05rem; }
.option:hover { border-color: var(--brand); }
.option input { width: 20px; height: 20px; accent-color: var(--brand); }
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.answer-input { width: 100%; font: inherit; font-size: 1.2rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.answer-input:focus { outline: none; border-color: var(--brand); }
textarea.answer-input { min-height: 140px; font-size: 1.05rem; resize: vertical; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.keys button { min-width: 42px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 1.05rem; cursor: pointer; }
.keys button:hover { border-color: var(--brand); }
.hintbox { margin-top: 12px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
table.data { border-collapse: collapse; margin: 8px 0 16px; width: 100%; font-size: .95rem; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
table.data th { background: var(--brand-soft); }
.scroll-x { overflow-x: auto; }
.diagram { width: 100%; max-width: 340px; color: var(--ink); font-size: 15px; display: block; margin: 4px 0 14px; }
.diagram text { fill: currentColor; }

/* feedback */
.verdict { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.verdict.ok { background: var(--good-soft); border: 1px solid var(--good); }
.verdict.no { background: var(--bad-soft); border: 1px solid var(--bad); }
.verdict.part, .verdict.pending { background: var(--warn-soft); border: 1px solid var(--warn); }
.verdict h2 { margin: 0 0 4px; }
.steps { margin: 6px 0 0; padding-left: 1.2rem; }
.steps li { margin: 3px 0; }
.model { background: var(--bg); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 8px; white-space: pre-line; }

/* lesson */
.lesson p { margin: .5rem 0; }
.lesson .takeaway { background: var(--brand-soft); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.lesson .tip { background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; }
.lesson img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.keypoints li { margin: 6px 0; }

.flash { background: var(--warn-soft); border: 1px solid var(--warn); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.notice { background: var(--brand-soft); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
label.field { display: block; margin: 10px 0; }
label.field input[type=text], label.field input[type=password], label.field input[type=number], label.field textarea, label.field select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .muted { font-size: .85rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.35rem; }
  .prompt { font-size: 1.1rem; }
  .topic-row .bar { width: 60px; }
  .card { padding: 14px; }
}
@media print {
  .top, .noprint { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

.qimage { max-width: 100%; max-height: 360px; height: auto; display: block; margin: 0 0 14px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.matchrow { justify-content: space-between; flex-wrap: wrap; }
.matchrow .t { flex: 1 1 160px; }
.option select { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 100%; }
.matchrow select { flex: 1 1 220px; }
dl.kw { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
dl.kw dt { font-weight: 600; }
dl.kw dd { margin: 0; }
@media (max-width: 560px) { dl.kw { grid-template-columns: 1fr; } dl.kw dd { margin-bottom: 6px; } }
.viewbar { background: var(--warn-soft); border-bottom: 1px solid var(--warn); font-size: .92rem; }
.viewbar .wrap { padding-top: 8px; padding-bottom: 8px; }
.nav form { display: inline; }
