/* Library, My progress, My flashcards, XP, subject colours, question groups and quick mark. */

:root { --navy: #213372; --turq: #58c7d4; --xp: #f2a20c; --right: #1c8f3f; --wrong: #f3c5cc; }
@media (prefers-color-scheme: dark) {
  :root { --navy: #9fb2ff; --xp: #ffc24d; --right: #5fd98a; --wrong: #5b2a36; }
}

/* ---------- top bar: XP chip, Create, Settings ---------- */
.nav-settings { margin-left: 0; }
.xp-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(242, 162, 12, 0.14); color: #9a5f00; font: 800 14px/1 var(--font-head); text-decoration: none; white-space: nowrap;
}
.xp-chip svg { color: var(--xp); }
.xp-chip:hover { background: rgba(242, 162, 12, 0.24); }
@media (prefers-color-scheme: dark) { .xp-chip { color: var(--xp); } }
.create-wrap { position: relative; }
.create-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 0;
  background: var(--orange); color: #fff; font: 800 14px/1 var(--font-head); cursor: pointer; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}
.create-btn:hover { filter: brightness(1.06); }
.create-menu { right: 0; left: auto; top: calc(100% + 8px); min-width: 280px; z-index: 50; }
.create-menu .menu-item { display: grid; gap: 1px; text-decoration: none; padding: 10px 12px; }
.create-menu .menu-item small { font-weight: 400; color: var(--text-2); font-size: 13px; }
@media (max-width: 860px) {
  .create-btn span { display: none; }
  .create-btn { padding: 9px; }
  .xp-chip { padding: 6px 9px; }
}

/* ---------- subject badges ---------- */
.subj-badge {
  flex: none; display: inline-grid; place-items: center; border-radius: 14px; color: #fff;
  background: var(--subj, var(--accent)); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.14);
}

/* ---------- library ---------- */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.board-card {
  display: grid; gap: 4px; padding: 22px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  color: inherit; text-decoration: none; box-shadow: var(--shadow); border-top: 6px solid var(--bc, var(--accent));
}
.board-card:hover { border-color: var(--bc, var(--accent)); }
.board-title { font: 900 24px/1.15 var(--font-head); }
.board-aqa { --bc: #7a1fa2; }
.board-edexcel { --bc: #0f75bc; }
.board-ocr { --bc: #e2001a; }
.board-eduqas { --bc: #82bc00; }
.board-mine { --bc: var(--orange); }
.board-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 6px; scrollbar-width: thin; }
.board-tab {
  flex: none; display: grid; gap: 0; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; min-width: 130px;
}
.board-tab .board-name { font: 800 16px/1.2 var(--font-head); }
.board-tab .board-count { font-size: 13px; color: var(--text-2); }
.board-tab.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.board-tab.on .board-count { color: inherit; opacity: 0.8; }
.board-note { margin: 4px 0 18px; }
.subj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.subj-tile {
  display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 16px; background: var(--surface); color: inherit;
  text-decoration: none; border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.subj-tile::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--subj); }
.subj-tile:hover { border-color: var(--subj); }
.subj-tile .name { font: 800 16px/1.25 var(--font-head); }
.subj-added { color: var(--subj); font-weight: 700; }
.subject-hero {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 20px 22px; margin: 6px 0 18px; border-radius: 18px;
  background: color-mix(in srgb, var(--subj) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--subj) 30%, var(--border));
}
.subject-hero h1 { margin-bottom: 4px; }
.subject-hero .lead { margin: 0; }
.grow { flex: 1; min-width: 0; }

/* ---------- home: your subjects ---------- */
.my-subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 22px; }
.my-subject, .mini-subject {
  display: grid; justify-items: center; gap: 6px; padding: 14px 8px 12px; border-radius: 16px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.my-subject:hover, .mini-subject:hover { border-color: var(--subj); transform: translateY(-1px); }
.ms-name { font: 800 14px/1.2 var(--font-head); }
.ms-board { font-size: 12px; color: var(--text-2); }

/* ---------- XP ---------- */
.xp-card { display: block; }
.xp-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.xp-title { font: 800 13px/1 var(--font-head); color: var(--text-2); margin-bottom: 4px; }
.xp-big { font: 900 30px/1.1 var(--font-head); color: var(--text); }
.xp-side { display: grid; gap: 6px; text-align: right; }
.xp-side div { display: grid; }
.xp-side strong { font: 800 15px/1.2 var(--font-head); }
.xp-side span { font-size: 12px; color: var(--text-2); }
.xp-ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.xp-ring svg { position: absolute; inset: 0; }
.ring-track { fill: none; stroke: var(--grid); stroke-width: 6; }
.ring-fill { fill: none; stroke: var(--xp); stroke-width: 6; stroke-linecap: round; }
.ring-level { font: 900 19px/1 var(--font-head); }
.xp-bars { width: 100%; max-height: 130px; margin-top: 10px; display: block; }
.xp-bar { fill: var(--xp); }
.xp-bar.empty { fill: var(--grid); }
.xp-day { font-size: 11px; fill: var(--text-2); }
.xp-day.today { font-weight: 800; fill: var(--text); }
.xp-val { font-size: 10px; font-weight: 700; fill: var(--text-2); }

/* ---------- my progress ---------- */
.progress-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 760px) { .progress-top { grid-template-columns: 1fr; } }
a.points-mini { display: block; color: inherit; text-decoration: none; }
.grade-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grade-strip .gs { display: inline-flex; align-items: center; gap: 4px; }
.grade-strip .subj-badge { border-radius: 8px; }
.fold { padding: 0; }
.fold > summary {
  list-style: none; display: flex; align-items: center; gap: 12px; padding: 18px 20px; cursor: pointer;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold-title { flex: 1; display: grid; gap: 2px; }
.fold-title strong { font: 800 18px/1.25 var(--font-head); }
.fold .chev, .q-group .chev { transition: transform 0.2s; flex: none; }
.fold[open] > summary .chev, .q-group[open] > summary .chev { transform: rotate(180deg); }
.fold-body { padding: 0 20px 20px; }

/* school results */
.school-top { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.school-figure { flex: 1; min-width: 170px; display: grid; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--wash); }
.school-figure strong { font: 900 32px/1.1 var(--font-head); color: var(--navy); }
.school-chart h3 { margin-top: 4px; }
.school-bars { display: flex; gap: 18px; align-items: flex-end; height: 190px; padding: 18px 4px 0; border-bottom: 1px solid var(--axis); margin: 8px 0 10px; }
.sb-year { flex: 1; display: grid; justify-items: center; gap: 6px; height: 100%; grid-template-rows: 1fr auto; }
.sb-pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; }
.sb-bar { width: 26px; border-radius: 6px 6px 0 0; position: relative; min-height: 2px; }
.sb-bar.school { background: var(--navy); }
.sb-bar.england { background: var(--turq); }
.sb-bar.none { background: transparent; }
.sb-bar em { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font: 700 11px/1 var(--font-body); font-style: normal; color: var(--text-2); white-space: nowrap; }
.sb-label { font-size: 12px; color: var(--text-2); }

/* ---------- my flashcards ---------- */
.card-chart-wrap { margin-bottom: 8px; }
.cc-svg { width: 100%; max-height: 190px; display: block; }
.cc-right { fill: var(--right); }
.cc-wrong { fill: var(--wrong); }
.cc-none { fill: var(--grid); }
.cc-val { font-size: 10px; font-weight: 700; fill: var(--text-2); }
.cc-day { font-size: 10px; fill: var(--text-2); }
.swatch.cc-right-sw { background: var(--right); }
.swatch.cc-wrong-sw { background: var(--wrong); }
.chart-pick { max-width: 260px; }
.deck-top { display: flex; gap: 10px; align-items: center; }
.deck-top .subj-badge { border-radius: 10px; }
.deck-card { border-top: 4px solid var(--subj, var(--border)); }

/* ---------- mini mock ---------- */
.mini-subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.mini-subject { cursor: pointer; font: inherit; }
.mini-subject.on { border: 2px solid var(--subj); background: color-mix(in srgb, var(--subj) 12%, var(--surface)); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.preset { display: grid; gap: 2px; padding: 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.preset strong { font: 800 17px/1.2 var(--font-head); }
.preset span { font-size: 13px; color: var(--text-2); }
.preset.on { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 560px) { .presets { grid-template-columns: 1fr; } }
.more-options { border-top: 1px solid var(--border); margin-top: 6px; }
.more-options > summary { cursor: pointer; padding: 16px 0; font: 800 16px/1.2 var(--font-head); }

/* ---------- question groups and quick mark ---------- */
.q-group { margin-bottom: 12px; border-radius: 14px; background: var(--wash); }
.q-group > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); position: sticky; top: 0; z-index: 2;
}
.q-group > summary::-webkit-details-marker { display: none; }
.q-group[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.qg-title { font: 900 17px/1.2 var(--font-head); }
.qg-status { display: inline-flex; align-items: center; gap: 6px; }
.qg-body { padding: 12px; display: grid; gap: 12px; }
.qg-body .card.question { margin: 0; }
.qg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.qm { display: flex; gap: 12px; align-items: flex-start; margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--accent-soft); }
.qm-text p { margin: 0 0 6px; }
.qm-text p:last-child { margin: 0; }
.quick-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; cursor: pointer; }
.mini-subject { white-space: normal; min-width: 0; }
.ms-name { overflow-wrap: anywhere; hyphens: auto; }
.cc-svg { max-height: 160px; }
@media (max-width: 560px) {
  .nav-my { display: none; }
  .topbar nav a { padding: 8px 6px; letter-spacing: 0.04em; }
  .xp-chip .xp-chip-val { font-size: 13px; }
}
/* Phones: the four main tabs move to a bar along the bottom. */
@media (max-width: 560px) {
  .topbar nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); overflow: visible;
  }
  .topbar nav a { text-align: center; padding: 10px 2px; font-size: 12px; }
  .topbar nav a::after { left: 22%; right: 22%; bottom: 3px; }
  .nav-my { display: none; }
  #app { padding-bottom: 64px; }
  .topbar .xp-chip { margin-left: 0; }
  .topbar { justify-content: flex-end; }
  .brand { display: inline-flex !important; margin-right: auto; }
  .brand-name { display: none; }
}
body.study .topbar nav { display: none; }

/* ---------- thumbs up/down ratings ---------- */
.rate { margin-top: 12px; display: grid; gap: 8px; }
.rate-stack { display: grid; gap: 0; margin-top: 6px; border-top: 1px dashed var(--border); }
.rate-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rate-label { font-size: 13px; font-weight: 700; color: var(--text-2); margin-right: 2px; }
.thumb {
  display: inline-grid; place-items: center; width: 34px; height: 30px; padding: 0; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.thumb:hover { color: var(--text); border-color: var(--axis); }
.thumb.up.on { background: rgba(28, 143, 63, 0.14); border-color: var(--good); color: var(--good); }
.thumb.down.on { background: rgba(212, 33, 61, 0.12); border-color: var(--critical); color: var(--critical); }
.rate-done { font-size: 13px; color: var(--text-2); }
.rate-why { display: grid; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--wash); }
.rate-why .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rate-note { display: flex; gap: 8px; align-items: center; }
.rate-note input { flex: 1; min-width: 0; }
.qm .rate { margin-top: 10px; }

/* ---------- answer boxes sized to the answer ---------- */
.question .ans { width: 100%; font: inherit; }
.question input.ans-word { width: min(100%, 280px); }
.question textarea.ans { resize: vertical; min-height: 0; overflow: hidden; }
.question textarea.ans-lines { min-height: 84px; }
.question textarea.ans-code { overflow: auto; }
.ans-parts { display: grid; gap: 12px; }
.ans-part { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--wash); }
.part-head { display: flex; gap: 8px; align-items: baseline; }
.part-label { font: 900 16px/1.3 var(--font-head); color: var(--accent); flex: none; }
.part-text { white-space: pre-wrap; }
.ans-table-wrap { overflow-x: auto; margin-top: 4px; }
.ans-table { border-collapse: collapse; min-width: 100%; }
.ans-table th, .ans-table td { border: 1px solid var(--axis); padding: 6px 8px; text-align: left; vertical-align: middle; }
.ans-table th { background: var(--wash); font: 800 14px/1.3 var(--font-head); }
.ans-table td.fixed { font-weight: 600; }
.ans-table td input[type="text"] { width: 100%; min-width: 90px; border-radius: 6px; padding: 6px 8px; }
.ans-table td.tick { text-align: center; }
.ans-table td.tick input { width: 22px; height: 22px; cursor: pointer; }
.ans-match { display: grid; gap: 8px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); align-items: center; gap: 8px; }
.match-left { padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--wash); font-weight: 600; }
.match-line { height: 2px; background: var(--axis); border-radius: 2px; }
@media (max-width: 560px) {
  .match-row { grid-template-columns: 1fr; gap: 4px; }
  .match-line { display: none; }
}

/* ---------- my subjects picker ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.picker { margin-bottom: 22px; border: 2px solid var(--marker); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; margin: 14px 0; }
.pick-tile {
  position: relative; display: grid; justify-items: center; gap: 6px; padding: 14px 8px 12px; border-radius: 16px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); color: var(--text); font: inherit; white-space: normal; min-width: 0;
}
.pick-tile:hover { border-color: var(--subj); }
.pick-tile.on { border-color: var(--subj); background: color-mix(in srgb, var(--subj) 14%, var(--surface)); }
.pick-check {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border); color: #fff;
}
.pick-tile.on .pick-check { background: var(--subj); border-color: var(--subj); }
.picker-bar { position: sticky; bottom: 0; padding-top: 8px; background: inherit; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- subjects sidebar (left pop-out) ---------- */
.side-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; padding: 0;
}
.side-toggle:hover { border-color: var(--marker); }
.side-tab {
  position: fixed; left: 0; top: 50%; z-index: 30; transform: translateY(-50%) rotate(180deg); writing-mode: vertical-rl;
  padding: 16px 8px; border: 0; border-radius: 0 12px 12px 0; transform-origin: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font: 800 13px/1 var(--font-head); letter-spacing: 0.04em;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
.side-tab { transform: translateY(-50%); writing-mode: vertical-rl; border-radius: 0 12px 12px 0; }
body.side-open .side-tab, body.study .side-tab { display: none; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(340px, 88vw); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; animation: side-in 0.18s ease-out;
}
@keyframes side-in { from { transform: translateX(-16px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sidebar { animation: none; } }
.side-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(5, 10, 30, 0.45); }
@media (min-width: 1280px) {
  /* Wide screens: the sidebar sits beside the page instead of over it. */
  body.side-open .side-scrim { display: none; }
  body.side-open { padding-left: 340px; }
  .sidebar { box-shadow: none; }
}
.side-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font: 900 18px/1.2 var(--font-head); }
.side-edit { font: 700 14px/1 var(--font-body); }
.side-search { margin: 12px 16px 4px; width: auto; }
.side-list { padding: 8px 10px 24px; display: grid; gap: 8px; }
.side-subject { border-radius: 14px; border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.side-subject[open] { border-color: color-mix(in srgb, var(--subj) 55%, var(--border)); }
.side-subject > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.side-subject > summary::-webkit-details-marker { display: none; }
.side-subject[open] > summary { background: color-mix(in srgb, var(--subj) 12%, var(--surface)); }
.side-subject[open] > summary .chev { transform: rotate(180deg); }
.side-subject .chev { margin-left: auto; transition: transform 0.2s; flex: none; color: var(--text-2); }
.side-subject .subj-badge { border-radius: 10px; }
.side-subject-text { display: grid; min-width: 0; }
.side-subject-text strong { font: 800 15px/1.25 var(--font-head); }
.side-subject-text span { font-size: 12px; color: var(--text-2); }
.side-topics { list-style: none; margin: 0; padding: 4px 8px 8px; display: grid; gap: 2px; }
.side-topic { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px 8px; align-items: start; padding: 8px 6px; border-radius: 10px; }
.side-topic:hover { background: var(--wash); }
.topic-num {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font: 800 12px/1 var(--font-head);
  background: color-mix(in srgb, var(--subj) 16%, transparent); color: var(--subj);
}
.topic-main { display: grid; gap: 3px; min-width: 0; }
.topic-name { font-weight: 600; font-size: 14px; line-height: 1.35; }
.topic-progress { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); }
.tp-bar { width: 60px; height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.tp-bar span { display: block; height: 100%; background: var(--good); }
.topic-acts { grid-column: 2; display: flex; gap: 6px; }
.side-act {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font: 700 12px/1.2 var(--font-body);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.side-act:hover { border-color: var(--subj); color: var(--subj); }
.side-act:disabled { opacity: 0.5; cursor: progress; }
.side-papers { display: block; padding: 4px 16px 12px; font-size: 13px; font-weight: 700; }
.side-empty { padding: 4px 16px 10px; }
.side-none { padding: 16px; display: grid; gap: 10px; justify-items: start; }
@media (max-width: 560px) { .side-tab { display: none; } }
.sidebar input.side-search { width: calc(100% - 32px); box-sizing: border-box; }
@media (min-width: 1280px) and (max-width: 1680px) {
  /* Sidebar open beside the page: make room in the top bar. */
  body.side-open .brand-name, body.side-open .nav-settings span { display: none; }
  body.side-open .topbar { gap: 12px; }
  body.side-open .topbar nav a { padding: 8px 8px; }
}

/* ---------- sidebar chapters ---------- */
.side-subject-body { padding: 4px 6px 4px; }
.side-section { margin: 10px 8px 4px; font: 800 12px/1.3 var(--font-head); color: var(--subj); letter-spacing: 0.02em; }
.side-chapter { border-radius: 10px; margin: 2px 0; }
.side-chapter[open] { background: var(--wash); }
.side-chapter > summary { list-style: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px 6px; cursor: pointer; border-radius: 10px; }
.side-chapter > summary::-webkit-details-marker { display: none; }
.side-chapter > summary:hover { background: var(--wash); }
.side-chapter > summary .chev { transition: transform 0.2s; color: var(--text-2); margin-top: 2px; }
.side-chapter[open] > summary .chev { transform: rotate(180deg); }
.chap-code {
  min-width: 34px; padding: 3px 6px; border-radius: 7px; text-align: center; font: 800 12px/1.2 var(--font-head);
  background: var(--subj); color: #fff;
}
.chap-title { font: 700 14px/1.35 var(--font-head); }
.chap-count { font-size: 11px; color: var(--text-2); }
.chap-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 8px 6px 48px; }
.chap-acts .topic-acts { grid-column: auto; }
.side-chapter .side-topics { padding: 0 4px 8px 20px; }
.side-chapter .topic-num { width: auto; min-width: 24px; padding: 0 4px; font-size: 11px; }
.side-topic { grid-template-columns: auto minmax(0, 1fr); }
.topic-points { font-size: 11.5px; line-height: 1.4; color: var(--text-2); }

/* ---------- revision timetable ---------- */
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-back .modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.modal-wide { max-width: 720px; }
.plan-form { display: grid; gap: 14px; }
.plan-form .field { display: grid; gap: 6px; margin: 0; }
.plan-subjects { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-subject {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface); color: var(--text); font: 700 13px/1.2 var(--font-body);
}
.plan-subject .subj-badge { border-radius: 50%; }
.plan-subject.on { border-color: var(--subj); background: color-mix(in srgb, var(--subj) 14%, var(--surface)); }
.plan-topics { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; display: grid; gap: 4px; }
.plan-search { width: 100%; margin-bottom: 4px; }
.plan-chapter { display: grid; gap: 1px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.plan-chapter:last-child { border-bottom: 0; }
.topic-check { display: flex; align-items: flex-start; gap: 8px; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.topic-check:hover { background: var(--wash); }
.topic-check input { margin-top: 2px; flex: none; }
.topic-check.chapter { font-weight: 700; }
.topic-check.sub { margin-left: 22px; }
.tc-code { flex: none; font: 800 11px/1.6 var(--font-head); padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.plan-when { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.plan-topic-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.plan-topic-list li { display: flex; gap: 6px; align-items: baseline; }
.plan-actions { flex-wrap: wrap; }
.danger-text { color: var(--critical) !important; }
.exam-count { font: 900 26px/1.1 var(--font-head); margin: 0; color: var(--orange); }

.plan-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.plan-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; font-weight: 700; cursor: pointer; background: var(--surface); }
.filter-chip input { margin: 0; }
.filter-chip.f-mock { border-color: color-mix(in srgb, var(--orange) 60%, var(--border)); }
.filter-chip.f-gcse { border-color: color-mix(in srgb, var(--critical) 60%, var(--border)); }
.month-nav { gap: 6px; }
.month-name { min-width: 150px; text-align: center; font: 900 17px/1.2 var(--font-head); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.cal-dow { padding: 8px; font: 800 12px/1 var(--font-head); color: var(--text-2); text-align: center; border-bottom: 1px solid var(--border); background: var(--wash); }
.cal-day { min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n + 7) { border-right: 0; }
.cal-day:hover { background: var(--wash); }
.cal-day.other { opacity: 0.45; }
.cal-day.past .cal-num { color: var(--muted); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--marker); }
.cal-day.today .cal-num { background: var(--marker); color: var(--marker-ink); }
.cal-day.has-exam { background: color-mix(in srgb, var(--orange) 6%, var(--surface)); }
.cal-num { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; font: 800 13px/1 var(--font-head); }
.cal-evs { display: grid; gap: 3px; min-width: 0; }
.cal-more { font-size: 11px; color: var(--text-2); padding-left: 4px; }
.ev {
  display: flex; align-items: center; gap: 4px; min-width: 0; width: 100%; padding: 2px 6px; border-radius: 6px; cursor: pointer; text-align: left;
  font: 700 11.5px/1.35 var(--font-body); border: 0; color: var(--text);
  background: color-mix(in srgb, var(--subj, var(--accent)) 18%, var(--surface)); border-left: 3px solid var(--subj, var(--accent));
}
.ev .ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .ev-time { flex: none; color: var(--text-2); font-weight: 600; }
.ev .ev-icon { flex: none; display: inline-grid; color: var(--subj, var(--accent)); }
.ev.done { opacity: 0.6; }
.ev.done .ev-title { text-decoration: line-through; }
.ev-mock { background: color-mix(in srgb, var(--orange) 16%, var(--surface)); border-left-color: var(--orange); }
.ev-gcse { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); border-left-color: var(--critical); }
.ev-note { background: var(--wash); border-left-color: var(--muted); font-style: italic; }
@media (max-width: 760px) {
  .cal-day { min-height: 70px; padding: 3px; }
  .ev { padding: 1px 3px; font-size: 10px; }
  .ev .ev-time, .ev .ev-icon { display: none; }
  .month-name { min-width: 0; }
}

.agenda { display: grid; gap: 18px; }
.agenda-day h3 { margin: 0 0 8px; }
.agenda-list { display: grid; gap: 8px; }
.agenda-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--subj, var(--accent)); flex-wrap: wrap; }
.agenda-row.ev-mock { border-left-color: var(--orange); }
.agenda-row.ev-gcse { border-left-color: var(--critical); }
.agenda-time { min-width: 62px; font: 800 14px/1.2 var(--font-head); color: var(--text-2); }
.agenda-main { flex: 1; min-width: 180px; display: grid; gap: 2px; }
.agenda-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--wash); flex: none; }
.exam-list { display: grid; gap: 6px; margin-top: 10px; }
.exam-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.exam-row:hover { border-color: var(--subj, var(--accent)); }
.exam-row.past { opacity: 0.5; }
.exam-date { display: grid; justify-items: center; min-width: 44px; line-height: 1.1; }
.exam-date strong { font: 900 20px/1 var(--font-head); }
.exam-date span { font-size: 12px; color: var(--text-2); }
.exam-when { font: 800 13px/1.2 var(--font-head); color: var(--text-2); white-space: nowrap; }
.exam-when.soon { color: var(--orange); }

/* Home: today's revision and the next exam */
.today-card { display: grid; gap: 10px; }
.today-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.next-exam { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--orange) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--orange) 40%, var(--border)); }
.next-exam .exam-count { font-size: 22px; }
