/* Revision — monochrome desk. Colour is reserved for marks:
   green got it, amber partly, red not yet. Everything else is ink and paper. */

:root {
  --bg: #fcfcfc; --side: #f5f5f6; --raise: #ffffff; --sunk: #f1f1f3;
  --rule: #e5e6e9; --rule-strong: #cfd1d6;
  --ink: #16171a; --ink-2: #4a4d55; --muted: #80848d;
  --inv: #16171a; --inv-ink: #ffffff;
  --got: #1f8a4c; --part: #b9770e; --miss: #cc3a2f;
  --got-soft: #e3f3e9; --part-soft: #f8eedb; --miss-soft: #fbe5e3;
  --heat-1: #d9dbe0; --heat-2: #a9adb6; --heat-3: #6b7079; --heat-4: #16171a;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
  --sans: Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* the logo's tick, in the inverse ink, for checked boxes */
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141518; --side: #18191d; --raise: #1d1f23; --sunk: #111215; --rule: #2a2c31; --rule-strong: #3b3e45;
    --ink: #e8e9ec; --ink-2: #b4b7be; --muted: #7d818a; --inv: #e8e9ec; --inv-ink: #141518;
    --got: #46c17a; --part: #e0a13c; --miss: #ef6b5f; --got-soft: #16291e; --part-soft: #2b2416; --miss-soft: #2e1a18;
    --heat-1: #2c2f35; --heat-2: #4c5059; --heat-3: #8a8f99; --heat-4: #e8e9ec;
    --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23141518' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='%23141518' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141518; --side: #18191d; --raise: #1d1f23; --sunk: #111215; --rule: #2a2c31; --rule-strong: #3b3e45;
  --ink: #e8e9ec; --ink-2: #b4b7be; --muted: #7d818a; --inv: #e8e9ec; --inv-ink: #141518;
  --got: #46c17a; --part: #e0a13c; --miss: #ef6b5f; --got-soft: #16291e; --part-soft: #2b2416; --miss-soft: #2e1a18;
  --heat-1: #2c2f35; --heat-2: #4c5059; --heat-3: #8a8f99; --heat-4: #e8e9ec;
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23141518' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='%23141518' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
[hidden] { display: none !important; }
kbd, .mono { font-family: var(--mono); font-size: 12px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--raise); padding: 6px 10px; z-index: 9; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background: var(--side); border-right: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 4px; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 500; font-size: 15px; text-decoration: none; padding: 2px 8px; }
/* The logo: a rounded square with a tick. Every checkbox and tick on the
   site is drawn the same way, so the mark and the controls read as one. */
.mark { width: 20px; height: 20px; flex: none; }
.mark rect { fill: var(--ink); }
.mark path { fill: none; stroke: var(--bg); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 16px; height: 16px; margin: 0; cursor: pointer;
  border: 1.5px solid var(--rule-strong); border-radius: 4px; background: var(--raise) center / 12px 12px no-repeat;
  transition: background-color .12s, border-color .12s;
}
input[type="checkbox"]:hover { border-color: var(--ink-2); }
input[type="checkbox"]:checked { background-color: var(--ink); border-color: var(--ink); background-image: var(--tick); }
input[type="checkbox"]:indeterminate { background-color: var(--ink); border-color: var(--ink); background-image: var(--dash); }
input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }
.side-toggle {
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 5px;
  font: 15px/1 var(--sans); opacity: .55;
}
.side-toggle:hover { color: var(--ink); background: var(--raise); opacity: 1; }
.side-show {
  display: none; position: fixed; left: 12px; top: 12px; z-index: 6; width: 34px; height: 34px;
  align-items: center; justify-content: center; border: 1px solid var(--rule-strong); border-radius: 7px;
  background: var(--raise); color: var(--ink-2); cursor: pointer; font-size: 16px; line-height: 1;
}
.side-show:hover { color: var(--ink); border-color: var(--ink-2); }
:root[data-sidebar="hidden"] .sidebar { display: none; }
:root[data-sidebar="hidden"] .shell { grid-template-columns: minmax(0, 1fr); }
:root[data-sidebar="hidden"] .markbar { left: 0; }
:root[data-sidebar="hidden"] .side-show { display: inline-flex; }
/* Before setup there is no meaningful subject list, so the welcome and setup
   pages run without the sidebar (or the phone's tab bar). */
:root[data-onboarding="1"] .sidebar { display: none; }
:root[data-onboarding="1"] .shell { grid-template-columns: minmax(0, 1fr); }
:root[data-onboarding="1"] .side-show { display: none; }
:root[data-onboarding="1"] .tabbar { display: none; }
:root[data-sidebar="hidden"] .page, :root[data-sidebar="hidden"] .practice { margin-left: auto; margin-right: auto; }
:root[data-sidebar="hidden"] .practice { padding-top: 56px; }
:root[data-sidebar="hidden"] .page { padding-top: 62px; }
.wordmark::after { content: "_"; color: var(--muted); animation: caret 1.1s steps(1) 3; }
@keyframes caret { 50% { opacity: 0; } }
/* Sidebar: Home and Plan, then each subject; the open one lists its sections. */
.subjects { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--rule); }
/* Small labels speak in the wordmark's lowercase monospace. */
.side-label, .lib-group, .steps-bar li, .start-label {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.01em; text-transform: lowercase;
}
.side-label { margin: 0 8px 4px; color: var(--muted); }
.subj-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-size: 14px;
}
.subj-head span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.subj-head:hover { background: var(--raise); color: var(--ink); }
.subj.open .subj-head { color: var(--ink); font-weight: 500; }
.subj-head.on { background: var(--raise); box-shadow: inset 0 0 0 1px var(--rule); }
.subj-nav { display: grid; gap: 1px; margin: 2px 0 8px 10px; padding-left: 8px; border-left: 1px solid var(--rule); }
.subj-nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
}
.subj-nav a:hover { background: var(--raise); color: var(--ink); }
.subj-nav a.on { background: var(--raise); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.subj-nav .count { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: auto; }
.subj-nav .tag { font-size: 10px; }
.subj-edit { margin: 6px 8px 0; font-size: 12px; color: var(--muted); }
.subj-edit:hover { color: var(--ink); }
.nav { display: grid; gap: 1px; }
.nav a, .side-foot > a, .side-foot > button {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--ink-2);
  text-decoration: none; font-size: 14px; text-align: left; cursor: pointer;
}
.nav a .count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.nav a:hover, .side-foot > a:hover, .side-foot > button:hover { color: var(--ink); background: var(--raise); }
.nav a.on, .side-foot > a.on { color: var(--ink); background: var(--raise); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.side-foot { margin-top: auto; display: grid; gap: 1px; }
.side-foot > a, .side-foot > button { font-size: 13px; color: var(--muted); }
.account-line { display: grid !important; gap: 0; margin-bottom: 6px; padding: 8px !important; border: 1px solid var(--rule) !important; }
.account-line strong { font-weight: 500; color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-line span { font-size: 12px; color: var(--muted); }
.sync-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.sync-dot.synced { background: var(--got); }
.sync-dot.syncing { background: var(--part); }
.sync-dot.error { background: var(--miss); }
.sources { margin: 10px 8px 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 12px; line-height: 1.5; color: var(--muted); }
.sources a { color: var(--ink-2); }
.main { min-width: 0; outline: none; }
.tabbar { display: none; }

/* ---------- pages ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 44px 40px 96px; }
.page-head { margin-bottom: 26px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 62ch; }
.section { margin-top: 36px; }
.section > h2, .section-head { margin-bottom: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head a { font-size: 13px; color: var(--muted); }
.empty { padding: 18px 0; color: var(--ink-2); max-width: 58ch; }
.loading { padding: 60px 40px; color: var(--muted); }
.notice { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 8px; color: var(--ink-2); font-size: 14px; background: var(--raise); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: 6px;
  border: 1px solid var(--rule-strong); background: var(--raise); color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--inv); border-color: var(--inv); color: var(--inv-ink); }
.btn.primary:hover { opacity: .9; }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); background: var(--sunk); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn kbd { opacity: .6; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--raise); font-size: 14px;
}
textarea { resize: vertical; line-height: 1.5; }
.form { display: grid; gap: 16px; max-width: 560px; }
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.form .lab span { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.form textarea { min-height: 140px; }
.error { color: var(--miss); font-size: 13px; }
.trap { position: absolute; left: -9999px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--raise); cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.chip:hover { border-color: var(--rule-strong); color: var(--ink); }
.chip[aria-pressed="true"], .chip:has(input:checked) { border-color: var(--ink); color: var(--ink); }
.chip input { margin: 0; accent-color: var(--ink); }
.chip kbd { color: var(--muted); }

/* ---------- lists ---------- */
.list { border-top: 1px solid var(--rule); }
.list-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--rule); text-decoration: none;
}
a.list-row:hover, button.list-row:hover { background: var(--raise); }
button.list-row { width: 100%; border-width: 0 0 1px; background: none; text-align: left; cursor: pointer; }
.list-row .what { min-width: 0; }
.list-row .what > span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .end { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.tag { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--rule); color: var(--muted); }
.res { font-family: var(--sans); font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 4px; }
.res.got { background: var(--got-soft); color: var(--got); }
.res.partly { background: var(--part-soft); color: var(--part); }
.res.not { background: var(--miss-soft); color: var(--miss); }
.more-row { padding: 14px 0; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-bottom: 1px solid var(--rule); }
.set-row .list-row { border-bottom: 0; }
.set-row .set-del { padding: 0 8px; color: var(--muted); opacity: 0; }
.set-row:hover .set-del, .set-row .set-del:focus-visible { opacity: 1; }
@media (hover: none) { .set-row .set-del { opacity: 1; } }
.list-row.numbered { grid-template-columns: 28px minmax(0, 1fr) auto; }
.list-row .num { color: var(--muted); }
.pick {
  width: 20px; height: 20px; padding: 0; border: 1.5px solid var(--rule-strong);
  border-radius: 5px; background: var(--raise) center / 14px 14px no-repeat; cursor: pointer; font-size: 0;
}
.pick:hover { border-color: var(--ink-2); }
.pick[aria-pressed="true"] { background-color: var(--ink); border-color: var(--ink); background-image: var(--tick); }
.pick[disabled] { opacity: .5; cursor: default; }
.pick-tray {
  position: fixed; left: 236px; right: 0; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 12px;
  justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent); border-top: 1px solid var(--rule); backdrop-filter: blur(6px);
}
.pick-tray > span { margin-right: auto; font-size: 14px; color: var(--ink-2); }
:root[data-sidebar="hidden"] .pick-tray { left: 0; }
.builder-filters { margin-top: 16px; align-items: flex-end; }
.builder-filters label { flex: 1 1 180px; display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.mini-strip { display: inline-flex; gap: 2px; margin-right: 4px; }
.mini-strip i { width: 6px; height: 10px; border-radius: 1px; background: var(--rule-strong); }
.mini-strip i.got { background: var(--got); }
.mini-strip i.partly { background: var(--part); }
.mini-strip i.not { background: var(--miss); }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }
.set-summary { display: flex; gap: 40px; flex-wrap: wrap; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.set-summary div { display: grid; gap: 2px; }
.set-summary .mono { font-size: 22px; font-weight: 500; color: var(--ink); }
.set-summary span:last-child { font-size: 13px; color: var(--muted); }

/* ---------- today ---------- */
.next {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 20px 22px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise);
}
.next p { color: var(--ink-2); margin-top: 2px; }
.focus-add { display: flex; gap: 8px; margin-top: 10px; }
.focus-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--rule); }
.focus-item input { margin-top: 4px; accent-color: var(--ink); }
.focus-item.done span { color: var(--muted); text-decoration: line-through; }
.focus-item .spacer + button { opacity: 0; }
.focus-item:hover .spacer + button { opacity: 1; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); grid-auto-columns: 11px; justify-content: start; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 11px; height: 11px; border-radius: 2px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.heat i.h1 { background: var(--heat-1); box-shadow: none; }
.heat i.h2 { background: var(--heat-2); box-shadow: none; }
.heat i.h3 { background: var(--heat-3); box-shadow: none; }
.heat i.h4 { background: var(--heat-4); box-shadow: none; }
.bar { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--ink-2); }

/* ---------- practise builder ---------- */
.group { border-top: 1px solid var(--rule); padding: 12px 0; }
.group-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 8px; }
.group-head p { font-size: 13px; color: var(--muted); }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.mode { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--raise); cursor: pointer; text-align: left; }
.mode span { font-size: 13px; color: var(--muted); }
.mode[aria-pressed="true"] { border-color: var(--ink); }
.startbar {
  position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 28px; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--rule);
}
.filters { display: grid; gap: 8px; margin-bottom: 18px; }
.filters .search { height: 42px; font-size: 15px; padding: 0 14px; }
.filters .selects { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .selects select { width: auto; min-width: 0; flex: 0 1 auto; }
select {
  appearance: none; -webkit-appearance: none; height: 34px; padding: 0 30px 0 11px; cursor: pointer; color: var(--ink-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2380848d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select:hover { border-color: var(--ink-2); color: var(--ink); }
.page.wide { max-width: 1120px; }
.lib { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; align-items: start; }
/* One column exactly the sidebar's width: long topic names wrap instead of
   pushing the subtopic arrow and count off the edge. */
.lib-side { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; padding-right: 4px; }
.lib-side button {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: none; padding: 5px 8px; border-radius: 6px;
  text-align: left; font-size: 13.5px; color: var(--ink-2); cursor: pointer;
}
.lib-side button .mono { font-size: 11px; color: var(--muted); }
.lib-side button:hover { background: var(--raise); color: var(--ink); }
.lib-side button.on { background: var(--raise); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.lib-side button.sub { padding-left: 20px; font-size: 13px; }
.lib-side button.none { opacity: .45; }
.tree-head { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tree-row {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
  padding: 5px 8px; border-radius: 6px; font-size: 13.5px; color: var(--ink-2); cursor: pointer;
}
.tree-row:hover { background: var(--raise); color: var(--ink); }
.tree-row.on { background: var(--raise); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.tree-row input { margin: 0; accent-color: var(--ink); flex: none; }
.tree-row > span:not(.mono) { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.tree-row input, .tree-row .mono { align-self: flex-start; margin-top: 2px; }
.tree-row .mono { font-size: 11px; color: var(--muted); }
.tree-row.none { opacity: .45; }
.lib-side .tree-caret { width: auto; flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 11px; line-height: 1; }
.lib-side .tree-caret:hover { color: var(--ink); background: none; }
.tree-subs { padding-left: 18px; }
.tree-row.sub { padding-left: 14px; font-size: 13px; }
.tree-row.all { border-bottom: 1px solid var(--rule); border-radius: 0; margin-bottom: 6px; padding-bottom: 9px; }
.lib-group { margin: 14px 8px 4px; color: var(--muted); }
.lib-main .search { width: 100%; height: 42px; font-size: 15px; padding: 0 14px; }
.lib-topic-select { display: none; }
.lib-filters { display: grid; gap: 8px; margin: 12px 0 18px; }
.lib-filters .row { gap: 16px; }
.lib-block { content-visibility: auto; contain-intrinsic-size: auto 600px; margin-bottom: 26px; }
.lib-topic { font-size: 16px; margin: 0 0 6px; display: flex; gap: 10px; align-items: baseline; }
.lib-topic .mono, .lib-sub .mono { font-size: 11px; color: var(--muted); font-weight: 400; }
.lib-sub { padding: 14px 6px 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
/* Start a set: at the top of Practise, under the search and filters. */
.start-panel {
  display: grid; gap: 10px; margin: 4px 0 20px; padding: 14px 16px;
  border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--raise);
}
.start-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.start-label { width: 74px; flex: none; color: var(--muted); }
.start-help { margin: -4px 0 0 84px; }
.count-input { width: 76px; height: 32px; padding: 0 8px; font-family: var(--mono); }
.start-go { margin-top: 2px; }
.start-name { flex: 1 1 180px; min-width: 0; max-width: 280px; height: 36px; }
.start-go .btn.primary { margin-left: auto; }
@media (max-width: 860px) {
  .start-label { width: 100%; }
  .start-help { margin-left: 0; }
  .start-go .btn.primary { width: 100%; margin-left: 0; }
  .start-name { max-width: none; }
}
.your-sets { margin: -6px 0 20px; }
.your-sets summary { cursor: pointer; font-size: 14px; color: var(--ink-2); padding: 6px 0; }
.your-sets summary .mono { font-size: 12px; color: var(--muted); margin-left: 4px; }
.your-sets[open] summary { margin-bottom: 8px; }
.your-sets .link { margin-top: 8px; }
.lib-more { display: flex; align-items: center; gap: 14px; padding: 18px 0 8px; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 10px; }
.startbar select { width: auto; }
.startbar input[type="text"] { width: 190px; max-width: 190px; }
.startbar .row { flex-wrap: nowrap; }
details.more summary { cursor: pointer; color: var(--ink-2); font-size: 14px; margin-top: 18px; }
details.more[open] summary { margin-bottom: 12px; }

/* ---------- practice ---------- */
.practice { max-width: 940px; margin: 0 auto; padding: 22px 32px 150px; }
.p-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.p-top > a { color: var(--muted); text-decoration: none; font-size: 14px; }
.p-top > a:hover { color: var(--ink); }
.strip { display: flex; gap: 4px; flex-wrap: wrap; max-width: 560px; justify-content: flex-end; }
.strip a {
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 4px; border: 1px solid var(--rule-strong);
  font: 500 10px/1 var(--mono); color: var(--muted); text-decoration: none;
}
.strip a.cur { border-color: var(--ink); color: var(--ink); }
.strip a.got { background: var(--got); border-color: var(--got); color: #fff; }
.strip a.partly { background: var(--part); border-color: var(--part); color: #fff; }
.strip a.not { background: var(--miss); border-color: var(--miss); color: #fff; }
.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 14px 0 2px; flex-wrap: wrap; }
.q-head h1 { font-size: 20px; }
.q-head .mono { color: var(--muted); }
.q-sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.sheet { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 14px; min-height: 96px; }
.sheet canvas { display: block; width: 100%; height: auto; cursor: zoom-in; }
.sheet canvas + canvas { margin-top: 8px; }
.sheet-state { color: #6b6f78; text-align: center; padding: 28px 12px; font-size: 14px; }
.sheet-state a { color: #16171a; }
.framed { position: relative; overflow: hidden; background: #fff; margin: 0 auto; }
.framed + .framed { margin-top: 8px; }
.framed iframe { position: absolute; border: 0; pointer-events: none; background: #fff; }
.frame-mask { position: absolute; background: #fff; }
.frame-cover { position: absolute; background: repeating-linear-gradient(135deg, #f4f4f6 0 10px, #fff 10px 20px); border: 1px dashed #cfd1d6; border-radius: 6px; }
.frame-veil { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: #fff; color: #6b6f78; font-size: 14px; }
.frame-veil p { margin: 0; }
.frame-bar { width: min(260px, 60%); min-width: 160px; height: 4px; border-radius: 2px; background: #e5e6e9; overflow: hidden; }
.frame-bar i { display: block; height: 100%; width: 0; background: #16171a; border-radius: 2px; transition: width .25s linear; }
.frame-note { margin-top: 8px; font-size: 13px; color: var(--muted); }
.frame-note a { color: var(--ink-2); }
.away {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; border: 1px dashed var(--rule-strong); border-radius: 10px;
}
.away p { color: var(--ink-2); max-width: 54ch; }
.panel { margin-top: 18px; }
.panel-label { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.panel textarea { min-height: 120px; font-family: var(--mono); font-size: 13px; }
.q-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.timer-bar { display: inline-flex; align-items: center; gap: 6px; }
.timer-btn.running { color: var(--ink); border-color: var(--rule-strong); }
.q-tools .credit { margin-left: auto; font-size: 13px; color: var(--muted); }
.q-tools .credit a { color: var(--ink-2); }
.similar { margin-top: 24px; }
.markbar {
  position: fixed; left: 236px; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-top: 1px solid var(--rule); backdrop-filter: blur(6px);
}
.markbar .btn { min-width: 118px; }
.markbar .m-got:hover, .markbar .m-got.chosen { border-color: var(--got); color: var(--got); }
.markbar .m-partly:hover, .markbar .m-partly.chosen { border-color: var(--part); color: var(--part); }
.markbar .m-not:hover, .markbar .m-not.chosen { border-color: var(--miss); color: var(--miss); }
.drawer-scrim { position: fixed; inset: 0; z-index: 6; background: rgba(0, 0, 0, .35); }
.practice-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 7; width: min(370px, 92vw);
  display: flex; flex-direction: column; background: var(--raise); border-left: 1px solid var(--rule);
  box-shadow: -10px 0 30px rgba(0, 0, 0, .12);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.drawer-list { overflow-y: auto; padding: 4px 0 20px; }
.drawer-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 16px; text-decoration: none; border-bottom: 1px solid var(--rule); color: var(--ink-2);
}
.drawer-row:hover { background: var(--sunk); }
.drawer-row.current { box-shadow: inset 3px 0 0 var(--ink); background: var(--sunk); color: var(--ink); }
.drawer-row .num { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.drawer-row .grow { min-width: 0; display: grid; gap: 1px; }
.drawer-row .name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-row .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-note { padding: 10px 16px; font-size: 12px; color: var(--muted); }
.why { display: grid; gap: 10px; justify-items: center; width: 100%; }
.why p { font-size: 14px; color: var(--ink-2); }

/* ---------- parts and the revealed two-column layout ---------- */
.p-body { min-width: 0; }
.p-right { min-width: 0; margin-top: 24px; }
.ms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.ms-head .panel-label { margin: 0; }
.ms-actions { display: flex; align-items: baseline; gap: 14px; }
.parts { display: grid; gap: 14px; margin-top: 18px; }
.part { border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); padding: 12px 14px; }
.part.focus { border-color: var(--ink-2); box-shadow: 0 0 0 1px var(--rule-strong); }
.part-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.part-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.part textarea { min-height: 84px; }
.part-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.scores { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; max-width: 100%; overflow-x: auto; }
.scores .score {
  min-width: 32px; height: 30px; padding: 0 8px; border: 0; background: var(--raise);
  cursor: pointer; font: 500 13px/1 var(--mono); color: var(--ink-2);
}
.scores .score + .score { border-left: 1px solid var(--rule); }
.scores .score:hover { background: var(--sunk); color: var(--ink); }
.scores .score.on { background: var(--ink); color: var(--inv-ink); }
.part-why { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule); display: grid; gap: 8px; }
.part-note { font-size: 13px; }
.earlier { margin: 16px 0; border: 1px solid var(--rule); border-radius: 8px; padding: 8px 12px; background: var(--sunk); }
.earlier summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.earlier p { white-space: pre-wrap; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.mark-total { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.mark-total .mono { font-size: 16px; font-weight: 500; }
#a-sheet { overflow-x: hidden; }
@media (min-width: 1100px) {
  .practice.revealed { max-width: 1680px; }
  .practice.revealed .p-body { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .practice.revealed.wide-ms .p-body { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .practice.revealed .p-right {
    position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow-y: auto; overscroll-behavior: contain;
    scrollbar-gutter: stable; margin-top: 0;
  }
  :root[data-sidebar="hidden"] .practice.revealed { max-width: 1750px; }
}
/* Split questions: one step per sub-question, its mark scheme beside it. */
.steps { display: grid; gap: 22px; }
.step.part { border: 0; background: none; padding: 0; box-shadow: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.step-main { border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); padding: 12px 14px; display: grid; gap: 10px; min-width: 0; }
.step.focus .step-main { border-color: var(--ink-2); box-shadow: 0 0 0 1px var(--rule-strong); }
.step .part-head { margin-bottom: 0; }
.step .part-foot { margin-top: 0; }
.step .part-why { margin-top: 0; }
.step .part-sheet { padding: 10px; min-height: 60px; }
.step textarea { min-height: 76px; }
.step-ms { min-width: 0; }
.step-ms .part-sheet { overflow-x: hidden; }
.step:not(.shown) .step-ms { display: none; }
.step.shown .step-ms-wait { display: none; }
.step-ms-wait { display: grid; place-items: center; min-height: 120px; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.practice.stepped .p-body { display: block; }
/* "Larger text": a crop drawn wider than its sheet scrolls sideways. */
.sheet.wide { overflow-x: auto; overscroll-behavior-x: contain; }
.text-size { display: none; }
@media (max-width: 700px) {
  .text-size { display: inline-flex; }
  .welcome { padding-top: 32px; }
  .welcome-card { padding: 24px 20px; }
  .welcome-card h1 { font-size: 25px; }
  /* Phones: question and mark-scheme sheets run edge to edge, with as
     little framing as possible, so the page is drawn as large as it can be. */
  .practice .sheet { padding: 4px; border-radius: 6px; }
  .practice > .p-body > .p-left > .sheet, .p-right .sheet { margin: 0 -12px; }
  .step-main { padding: 10px 14px; border-left: 0; border-right: 0; border-radius: 0; margin: 0 -16px; }
  .step-main > .part-sheet { margin: 0 -14px; border-left: 0; border-right: 0; border-radius: 0; }
  .step-ms { margin: 0 -16px; }
  .step-ms .part-sheet { border-left: 0; border-right: 0; border-radius: 0; }
}
@media (min-width: 1100px) {
  /* After revealing, the question keeps the larger share of the width: its
     text is what's being read closely; the mark scheme is checked against it. */
  .practice.stepped.revealed .step.part { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 20px; }
  .practice.stepped.revealed.wide-ms .step.part { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .practice.stepped.revealed .step:not(.shown) .step-ms { display: block; }
  .practice.stepped .step-ms { position: sticky; top: 18px; }
  .practice.stepped.revealed .step-reveal { display: none; }
}
.done-card { text-align: center; padding: 60px 20px; display: grid; gap: 14px; justify-items: center; }
.done-card .score { font-family: var(--mono); font-size: 40px; font-weight: 500; letter-spacing: -0.02em; }

/* ---------- progress ---------- */
.prog-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px 74px; gap: 14px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.prog-row .mono { color: var(--muted); text-align: right; }
.conf { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.conf button { border: 0; background: none; padding: 3px 9px; font-size: 12px; color: var(--muted); cursor: pointer; }
.conf button + button { border-left: 1px solid var(--rule); }
.conf button[aria-pressed="true"][data-level="not"] { background: var(--miss-soft); color: var(--miss); }
.conf button[aria-pressed="true"][data-level="unsure"] { background: var(--part-soft); color: var(--part); }
.conf button[aria-pressed="true"][data-level="confident"] { background: var(--got-soft); color: var(--got); }

.zoom { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: rgba(10, 10, 12, .93); }
.zoom-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.zoom-bar .btn { background: #fff; color: #16171a; border-color: #cfd1d6; }
.zoom-bar .btn[aria-pressed="true"] { background: #16171a; color: #fff; border-color: #16171a; }
.zoom-scroll { flex: 1; overflow: auto; padding: 0 14px 14px; display: grid; justify-items: center; align-content: start; }
.zoom-scroll img { background: #fff; display: block; }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 9; padding: 8px 14px; border-radius: 6px;
  background: var(--inv); color: var(--inv-ink); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.toast.show { opacity: 1; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .page { padding: 24px 16px 120px; }
  .practice { padding: 14px 16px 210px; }
  .markbar { left: 0; bottom: 57px; }
  .pick-tray { left: 0; bottom: 57px; }
  .markbar .btn { min-width: 0; flex: 1; padding: 6px 8px; }
  .markbar [data-action="reveal"] { flex-basis: 100%; }
  .markbar kbd { display: none; }
  .filters .selects select { flex: 1 1 calc(50% - 4px); }
  .lib { grid-template-columns: minmax(0, 1fr); }
  .lib-side { display: none; }
  .lib-topic-select { display: block; margin-top: 8px; width: 100%; }
  .lib-filters .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .lib-filters .chip { white-space: nowrap; }
  .prog-row { grid-template-columns: minmax(0, 1fr) auto; }
  .prog-row .mono { display: none; }
  .startbar { bottom: 57px; }
  .startbar .row { flex-wrap: wrap; }
  .startbar input[type="text"] { width: 100%; max-width: none; }
  .mobile-subject { display: block !important; margin-bottom: 18px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    background: var(--side); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { text-align: center; padding: 17px 4px; font-size: 13px; color: var(--muted); text-decoration: none; }
  .tabbar a.on { color: var(--ink); font-weight: 500; }
  .toast { bottom: 140px; }
}
.mobile-subject { display: none; }
/* ---------- home and plan ---------- */
.goal-card { display: grid; gap: 10px; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.goal-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.goal-num { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; }
.goal-num span { font-size: 18px; color: var(--muted); }
.goal-what { color: var(--ink-2); }
.goal-bar { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.goal-bar i { display: block; height: 100%; background: var(--ink); border-radius: 4px; transition: width .3s; }
.goal-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.goal-meta strong { color: var(--ink); font-size: 14px; }
.goal-meta a { color: var(--ink-2); margin-left: auto; }
.tasks { border-top: 1px solid var(--rule); }
.task { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--rule); }
.task .tick { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--rule-strong); font-size: 0; background: center / 14px 14px no-repeat; }
.task.done .tick { background-color: var(--ink); border-color: var(--ink); background-image: var(--tick); }
.task.done .what { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.task .what { min-width: 0; font-size: 14.5px; }
.task .what > span:last-child { display: block; font-size: 12.5px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .amount { font-size: 12px; color: var(--muted); white-space: nowrap; }
.task.stretch .tick { border-style: dashed; }
.subj-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: var(--sunk); color: var(--ink-2); font-size: 11.5px; font-weight: 500; vertical-align: 1px; }
.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.subject-card { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); text-decoration: none; }
.subject-card:hover { border-color: var(--rule-strong); }
.sc-grade { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.sc-grade .mono { font-size: 18px; font-weight: 500; color: var(--ink); }
.overview-stats { margin-top: -6px; }
.overview-stats a { color: inherit; }
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.week-day { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.week-day h3 { margin-bottom: 6px; }
.week-day ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.week-day li .mono { font-size: 11px; display: block; }
.goal-form .count-input, .exam-form input, .exam-form select { height: 36px; }

/* ---------- welcome and signing in ---------- */
.welcome { padding-top: 72px; max-width: 760px; }
.welcome-brand { display: inline-flex; align-items: center; gap: 12px; font: 500 30px/1 var(--mono); letter-spacing: -0.01em; margin-bottom: 40px; }
.welcome-brand .mark { width: 36px; height: 36px; }
.welcome-brand .mark rect { fill: var(--ink); }
.welcome-brand .mark path { stroke: var(--bg); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.welcome-brand i { font-style: normal; color: var(--muted); margin-left: -10px; animation: caret 1.1s steps(1) infinite; }
.welcome-title { font-size: clamp(30px, 5vw, 46px); line-height: 1.08; letter-spacing: -0.025em; }
.welcome-lede { margin-top: 18px; font-size: 17px; color: var(--ink-2); max-width: 54ch; }
.welcome-actions { margin-top: 28px; }
.welcome-actions .btn { padding: 10px 18px; font-size: 15px; }
.welcome-note { margin-top: 14px; }
.welcome-subjects { margin-top: 10px; font-size: 14px; color: var(--muted); }
@media (max-width: 700px) { .welcome { padding-top: 40px; } .welcome-brand { margin-bottom: 28px; font-size: 24px; } }
.welcome-card { max-width: 640px; padding: 34px 36px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raise); }
.welcome-card h1 { font-size: 30px; max-width: 18ch; }
.welcome-card > p { margin-top: 12px; color: var(--ink-2); max-width: 58ch; }
.welcome-actions { margin-top: 22px; flex-wrap: wrap; }
.auth-switch { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 20px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sunk); }
.auth-switch a { padding: 6px 14px; border-radius: 6px; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.auth-switch a.on { background: var(--inv); color: var(--inv-ink); font-weight: 500; }
.auth-switch a:not(.on):hover { color: var(--ink); }

/* ---------- setup ---------- */
.steps-bar { display: flex; gap: 6px; padding: 0; margin: 0 0 24px; list-style: none; flex-wrap: wrap; }
.steps-bar li { flex: 1 1 120px; padding: 8px 10px; border-top: 3px solid var(--rule); color: var(--muted); }
.steps-bar li.on { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.steps-bar li.done { border-color: var(--ink-2); color: var(--ink-2); }
.setup-body { display: grid; gap: 8px; max-width: 720px; }
.setup-body > p.muted { margin-bottom: 6px; }
.setup-subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 12px; }
.setup-subjects .build-kind { justify-content: space-between; text-align: left; font: inherit; color: inherit; }
.setup-subjects .build-kind[aria-pressed="true"] { border-color: var(--ink-2); box-shadow: 0 0 0 1px var(--rule-strong); }
.setup-subjects .check { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--rule-strong); font-size: 0; background: center / 14px 14px no-repeat; }
.setup-subjects [aria-pressed="true"] .check { background-color: var(--ink); border-color: var(--ink); background-image: var(--tick); }
.setup-nav { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); }
.cover { display: grid; gap: 2px; }
.cover-head { margin-bottom: 6px; }
.cover-topic { border-bottom: 1px solid var(--rule); }
.cover-topic summary { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; list-style: none; }
.cover-topic summary::-webkit-details-marker { display: none; }
.cover-topic summary::before { content: "▸"; color: var(--muted); font-size: 11px; width: 10px; }
.cover-topic[open] summary::before { content: "▾"; }
.cover-topic summary .mono { margin-left: auto; font-size: 11px; }
.cover-subs { display: grid; gap: 2px; padding: 0 0 10px 34px; }
.cover-row { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; min-width: 0; }
.cover-row input { accent-color: var(--ink); margin: 0; flex: none; }
.cover-row.sub { font-size: 13.5px; color: var(--ink-2); padding: 3px 0; }

/* ---------- progress: grade and coverage map ---------- */
.grade-card { display: grid; gap: 12px; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.grade-main { display: flex; gap: 18px; align-items: center; }
.grade-big { font-size: 40px; font-weight: 500; min-width: 64px; text-align: center; letter-spacing: -0.02em; }
.grade-card .row label { display: inline-flex; align-items: center; gap: 8px; }
.boundaries summary { cursor: pointer; color: var(--ink-2); }
.boundaries label { display: grid !important; gap: 2px; }
.boundaries .count-input { width: 62px; }
.lv { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--rule-strong); vertical-align: -1px; }
.lv.attention { background: var(--miss); box-shadow: none; }
.lv.rusty { background: var(--part-soft); box-shadow: inset 0 0 0 2px var(--part); }
.lv.developing { background: var(--part); box-shadow: none; }
.lv.strong { background: var(--got); box-shadow: none; }
.map-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; cursor: help; }
.map { display: grid; gap: 4px; }
.map-row { display: grid; grid-template-columns: minmax(120px, 240px) minmax(0, 1fr); gap: 12px; align-items: center; }
.map-name { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-cells { display: flex; gap: 3px; flex-wrap: wrap; }
.map-cells .lv { width: 18px; height: 18px; border: 0; padding: 0; cursor: pointer; border-radius: 4px; }
.map-cells .lv:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.map-cells .lv.uncovered { opacity: .35; }
.prog-topic { margin-top: 10px; }
.prog-row.head { border-bottom-color: var(--rule-strong); }
.prog-row .cover-row .lv { margin-right: 8px; }

/* ---------- difficulty ---------- */
.stars { font-family: var(--sans); font-size: 11px; letter-spacing: 1px; color: var(--ink-2); white-space: nowrap; }
.star-chips { align-items: center; }
.star-chips .chip { letter-spacing: 1px; font-size: 12px; }

/* ---------- flashcards ---------- */
.card-form textarea { min-height: 70px; }
.card-row .what > span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-review { max-width: 720px; }
.flashcard {
  margin-top: 30px; min-height: 260px; padding: 36px 32px; border: 1px solid var(--rule-strong); border-radius: 14px; background: var(--raise);
  display: grid; align-content: center; gap: 16px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .05);
}
.fc-front { font-size: 22px; line-height: 1.4; white-space: pre-wrap; }
.fc-back { font-size: 18px; line-height: 1.5; white-space: pre-wrap; color: var(--ink-2); }
.flashcard hr { border: 0; border-top: 1px dashed var(--rule-strong); width: 100%; margin: 0; }
.card-bar .btn { display: inline-grid; grid-auto-flow: column; gap: 6px; }
.card-bar .fc-again:hover { border-color: var(--miss); color: var(--miss); }
.card-bar .fc-hard:hover { border-color: var(--part); color: var(--part); }
.card-bar .fc-good:hover, .card-bar .fc-easy:hover { border-color: var(--got); color: var(--got); }
.inline-card { max-width: none; padding: 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); gap: 10px; }

/* ---------- practice additions ---------- */
.practice.no-answers .answer-panel, .practice.no-answers .part-answer, .practice.no-answers .earlier { display: none; }
.timer-btn .small { margin-left: 4px; }
.timer-btn.paused #timer-label { opacity: .6; }
.timer-btn.over #timer-label { color: var(--part); }
.mark-scores { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.mark-quick { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.markbar.asking { justify-content: center; }
.why { max-width: 760px; margin: 0 auto; }
.why-note { width: 100%; min-height: 54px; font-size: 14px; }
.mistake-item { border-bottom: 1px solid var(--rule); }
.mistake-item .list-row { border-bottom: 0; }
.mistake-note { margin: -4px 6px 12px; padding: 8px 10px; border-left: 3px solid var(--rule-strong); background: var(--sunk); font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.paper-row .as-link { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.paper-row .as-link:hover { text-decoration: underline; }
.paper-row .end a { font-family: var(--sans); }
.pdf-group { display: inline-flex; align-items: center; gap: 8px; }
.pdf-group input { accent-color: var(--ink); vertical-align: -1px; }
.build-topics summary { cursor: pointer; font-size: 14px; color: var(--ink-2); }
.weights { display: grid; gap: 2px; }
.weight-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid var(--rule); }
.weight-row .what { min-width: 0; font-size: 13.5px; }
.weight-row .what span { display: block; font-size: 12px; color: var(--muted); }
.weight-row .conf button[aria-pressed="true"] { background: var(--ink); color: var(--inv-ink); }

@media (max-width: 860px) {
  .task { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .task .amount { grid-column: 2; grid-row: 2; }
  .task .btn { grid-row: 1 / span 2; grid-column: 3; }
  .map-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .markbar .mark-scores { flex-basis: 100%; justify-content: center; }
  .markbar .mark-quick { flex-basis: 100%; }
  .markbar .mark-quick .btn { flex: 1; }
  .weight-row { flex-wrap: wrap; }
}

/* ---------- print ---------- */
.print-page { max-width: 820px; margin: 0 auto; padding: 22px 32px 80px; }
.print-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.print-bar > a { color: var(--muted); text-decoration: none; font-size: 14px; margin-right: 6px; }
.print-doc { background: #fff; color: #16171a; border: 1px solid var(--rule); border-radius: 10px; padding: 40px 44px; }
.mam-files { max-width: 820px; margin: 0 0 18px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.mam-files p { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.mam-load-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mam-progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.mam-progress .bar { width: 180px; height: 7px; }
.mam-progress .bar i { width: 0; transition: width .2s linear; }
.mam-fallback { margin-top: 12px; }
.mam-fallback summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.mam-file { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 7px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.mam-file:first-of-type { border-top: 0; }
.mam-file > span:first-child { flex: 1; min-width: 160px; }
.print-head { border-bottom: 1px solid #d0d2d7; padding-bottom: 14px; margin-bottom: 24px; }
.print-head .mono { color: #6b6f78; }
.print-head h1 { color: #16171a; font-size: 22px; margin: 6px 0 4px; }
.print-head p { color: #4a4d55; font-size: 13px; }
.p-item { padding: 10px 0 18px; border-bottom: 1px solid #ececef; break-inside: avoid; }
.p-item-head { display: flex; gap: 8px; align-items: baseline; font-size: 14px; color: #16171a; margin-bottom: 8px; }
.p-item-head span { margin-left: auto; font-family: var(--mono); font-size: 12px; color: #6b6f78; }
.p-crop canvas { display: block; width: 100%; height: auto; }
.p-crop canvas + canvas { margin-top: 6px; }
.p-away { font-size: 13px; color: #4a4d55; word-break: break-all; }
.p-space { height: 7cm; border: 1px dashed #d0d2d7; border-radius: 6px; margin-top: 10px; }
.p-space.lined, .p-space.squared { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-space.lined {
  border: 0; border-radius: 0;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, #d0d2d7 27px 28px);
}
.p-space.squared {
  border: 0; border-radius: 0;
  background-image: linear-gradient(#e0e2e6 1px, transparent 1px), linear-gradient(90deg, #e0e2e6 1px, transparent 1px);
  background-size: 6mm 6mm;
}
.print-doc.one-per-page .p-item { break-after: page; }
.print-doc.one-per-page .p-item:last-of-type { break-after: auto; }
.print-ms { color: #16171a; font-size: 18px; margin: 30px 0 10px; break-before: page; }
.print-foot { margin-top: 24px; font-size: 11px; color: #6b6f78; }

/* ---------- build a paper ---------- */
.build-form { display: grid; gap: 16px; margin-bottom: 30px; }
.build-kinds { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.build-kinds legend { margin-bottom: 6px; }
.build-kind {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--raise); cursor: pointer;
}
.build-kind:hover { border-color: var(--rule-strong); }
.build-kind:has(input:checked) { border-color: var(--ink-2); box-shadow: 0 0 0 1px var(--rule-strong); }
.build-kind input { accent-color: var(--ink); margin: 0; }
.build-kind .what { display: grid; gap: 2px; font-size: 14.5px; color: var(--ink); }
.build-kind .what span { font-size: 12.5px; color: var(--muted); }
.nav .tag, .page-head .tag { font-size: 10px; vertical-align: 1px; }
.home-nav { padding-bottom: 4px; }

/* A built paper on paper: cover sheet, numbered questions, answer lines. */
.paper-doc { font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; }
.pp-cover { display: grid; gap: 10px; break-after: page; padding-bottom: 20px; }
.pp-cand { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.pp-cand div { display: grid; gap: 4px; font-size: 11px; color: #4a4d55; }
.pp-cand i { display: block; height: 30px; border: 1px solid #16171a; }
.pp-maker { font-size: 12px; color: #4a4d55; text-transform: uppercase; letter-spacing: .06em; }
.pp-subject { font-size: 34px; font-weight: 700; color: #16171a; margin: 6px 0 0; }
.pp-level { font-size: 20px; color: #16171a; }
.pp-paper { font-size: 18px; font-weight: 700; color: #16171a; padding-bottom: 12px; border-bottom: 2px solid #16171a; }
.pp-meta { display: flex; gap: 28px; align-items: end; flex-wrap: wrap; font-size: 14px; color: #16171a; }
.pp-score { margin-left: auto; display: grid; gap: 4px; font-size: 11px; color: #4a4d55; }
.pp-score i { display: block; width: 110px; height: 40px; border: 1px solid #16171a; }
.pp-musthave { font-size: 13px; color: #16171a; }
.pp-notes { border: 1px solid #16171a; padding: 12px 16px; color: #16171a; font-size: 12.5px; }
.pp-notes h3 { font-size: 13px; margin: 8px 0 4px; color: #16171a; }
.pp-notes h3:first-child { margin-top: 0; }
.pp-notes ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.pp-built { font-size: 10.5px; color: #6b6f78; }
.pp-section { font-size: 15px; font-weight: 700; color: #16171a; margin: 18px 0 2px; break-after: avoid; }
.pp-answer-all { font-size: 13px; color: #16171a; margin-bottom: 8px; }
.pp-q { padding: 14px 0 6px; }
.pp-q.mc { padding: 8px 0 2px; break-inside: avoid; }
.pp-mc { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: #16171a; }
.pp-mc i { display: block; width: 34px; height: 30px; border: 1.5px solid #16171a; }
.pp-q-body { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; break-inside: avoid; }
.pp-num { font-weight: 700; font-size: 15px; color: #16171a; padding-top: 6px; }
.pp-crop canvas { display: block; width: 100%; height: auto; }
.pp-lines {
  height: calc(var(--lines) * 9mm); margin: 8px 0 0 34px; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(9mm - 1px), #9a9da4 calc(9mm - 1px) 9mm);
}
.pp-total { text-align: right; font-weight: 700; font-size: 13px; color: #16171a; margin-top: 6px; }
.pp-paper-total { text-align: right; font-weight: 700; font-size: 14px; color: #16171a; margin-top: 20px; padding-top: 8px; border-top: 2px solid #16171a; }
.pp-end { text-align: center; font-weight: 700; color: #16171a; margin: 26px 0 0; letter-spacing: .1em; }
.pp-ms { break-before: page; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #000; }
  .sidebar, .tabbar, .toast, .no-print, .markbar { display: none !important; }
  .shell { display: block; }
  .print-page { max-width: none; padding: 0; }
  .print-doc { border: 0; border-radius: 0; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.empty-day { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 16px 18px; border: 1px dashed var(--rule-strong); border-radius: 10px; background: var(--raise); }
.empty-day > div:first-child { flex: 1 1 280px; display: grid; gap: 4px; }

/* ---------- handwriting ---------- */
.pad-host { display: grid; gap: 6px; }
.pad-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pad-tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pad-tool { border: 1px solid var(--rule); background: var(--raise); color: var(--ink-2); border-radius: 6px; padding: 3px 9px; font-size: 12.5px; cursor: pointer; }
.pad-tool[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--sunk); }
.pad-colours { display: inline-flex; gap: 4px; margin: 0 4px; }
.pad-colour { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--raise); background: var(--c); box-shadow: 0 0 0 1px var(--rule-strong); cursor: pointer; }
.pad-colour[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.pad-paper { position: relative; border: 1px solid var(--rule-strong); border-radius: 8px; background: #fffef9; overflow: hidden; touch-action: none; }
.pad-paper.lined { background-image: linear-gradient(to bottom, transparent calc(var(--line, 32px) - 1px), #c9dcef calc(var(--line, 32px) - 1px)), linear-gradient(to right, transparent 7%, #efb6b6 7%, #efb6b6 calc(7% + 1px), transparent calc(7% + 1px)); background-size: 100% var(--line, 32px), 100% 100%; }
.pad-paper.pen-mode { touch-action: pan-y; }
.pad-paper canvas { display: block; cursor: crosshair; }
.answer-mode { display: inline-flex; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; }
.answer-mode button { border: 0; background: none; padding: 3px 10px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.answer-mode button[aria-pressed="true"] { background: var(--inv); color: var(--inv-ink); }
/* drawing over a question */
.annot-wrap { position: relative; }
.annot { position: absolute; inset: 0; pointer-events: none; }
.annot .pad-bar { position: absolute; top: 8px; right: 8px; z-index: 3; pointer-events: auto; background: var(--raise); padding: 4px; border-radius: 8px; border: 1px solid var(--rule); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.annot .pad-paper.overlay { position: absolute; inset: 0; border: 0; border-radius: 0; background: transparent; pointer-events: none; touch-action: auto; }
.annot .pad-paper.overlay.active { pointer-events: auto; touch-action: none; outline: 2px dashed var(--c, #cc3a2f); outline-offset: -2px; }
.annot .pad-paper.overlay.active.pen-mode { touch-action: pan-y; }

/* a multiple-choice answer read off the official key */
.key-answer { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; background: #fff; color: #16171a; border-radius: 6px; }
.key-answer strong { font-size: 56px; line-height: 1; font-weight: 600; }
.key-answer a { color: #4a4d55; }

/* ---------- history ---------- */
.history-summary { display: flex; flex-wrap: wrap; gap: 26px; margin-bottom: 16px; }
.history-summary div { display: grid; }
.history-summary .mono { font-size: 20px; }
.history-summary span:last-child { font-size: 12.5px; color: var(--muted); }
.history-tabs { margin-bottom: 14px; }
.history-row { position: relative; }
.history-row .again-btn { position: absolute; right: 8px; bottom: 4px; font-size: 12px; text-decoration: none; color: var(--muted); }
.history-row .again-btn[aria-pressed="true"] { color: var(--ink); font-weight: 500; }
.history-row .list-row { padding-bottom: 22px; }

/* ---------- profile and settings ---------- */
.plan-card { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.plan-card h2 { margin: 4px 0 2px; }
.plan-card.plus { border-color: var(--ink); }
.plus-offer { margin-top: 12px; padding: 16px 18px; border: 1px dashed var(--rule-strong); border-radius: 10px; display: grid; gap: 10px; }
.plus-offer ul { margin: 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 4px; }
.usage { display: grid; gap: 8px; max-width: 520px; }
.usage { max-width: 640px; }
.usage-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 150px; gap: 12px; align-items: center; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.usage-row .bar { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.usage-row .bar i { display: block; height: 100%; background: var(--ink); }
.notice.good { border-color: var(--got); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 520px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 14.5px; }
.setting-row select { width: auto; }

/* ---------- AI marking ---------- */
.ai-tools { margin-top: 12px; gap: 8px; }
#aimark-slot, #aichat-slot { margin-top: 12px; }
.aimark { display: grid; gap: 12px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raise); }
.aimark-head { display: flex; align-items: center; gap: 8px; }
.aimark-src { margin: 0; padding-left: 18px; }
.aimark-total { display: flex; align-items: baseline; gap: 12px; }
.aimark-total .mono { font-size: 28px; font-weight: 500; }
.aimark-img { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: #fff; }
.aimark-img canvas { display: block; }
.aimark-part { display: grid; gap: 6px; }
.aimark-part ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.aimark-part li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: 14px; }
.aimark-line { min-width: 62px; padding: 3px 8px; border-radius: 6px; border: 1px solid; font: 600 13px var(--mono); cursor: pointer; background: none; }
.aimark-part li.got .aimark-line { color: var(--got); border-color: var(--got); background: var(--got-soft); }
.aimark-part li.lost .aimark-line { color: var(--miss); border-color: var(--miss); background: var(--miss-soft); }
.aimark-actions { gap: 8px; }
.aimark-explain { margin-left: 6px; }

/* ---------- AI conversations ---------- */
.ai-plan { margin: 4px 0 14px; }
.aichat { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raise); }
.aichat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aichat-head strong { margin-right: auto; }
.aichat-pick { width: auto; max-width: 260px; padding: 4px 8px; font-size: 13px; }
.aichat-log { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; padding: 2px; }
.aichat-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; }
.aichat-msg p { margin: 0 0 6px; } .aichat-msg p:last-child { margin: 0; }
.aichat-msg ul { margin: 4px 0; padding-left: 20px; }
.aichat-msg.user { justify-self: end; background: var(--inv); color: var(--inv-ink); border-bottom-right-radius: 4px; }
.aichat-msg.assistant { justify-self: start; background: var(--sunk); border-bottom-left-radius: 4px; }
.aichat-msg .katex { font-size: 1.05em; }
.aichat-msg.thinking { display: flex; gap: 4px; }
.aichat-msg.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite alternate; }
.aichat-msg.thinking span:nth-child(2) { animation-delay: .2s; } .aichat-msg.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { from { opacity: .25; } to { opacity: 1; } }
.aichat-intro { display: grid; gap: 10px; }
.aichat-form { display: flex; gap: 8px; align-items: flex-end; }
.aichat-form textarea { flex: 1; min-height: 44px; resize: vertical; }
.aichat-note { margin: 0; }
.aichat-plan { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rule); }

/* ---------- setup: your week, when topics were taught ---------- */
.setup-week { display: grid; gap: 14px; margin-top: 12px; max-width: 520px; }
.setup-week label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.setup-week label .row { font-weight: 400; color: var(--muted); }
.setup-week input[type="time"] { width: auto; padding: 5px 8px; }
.learned-select { width: auto; margin-left: auto; padding: 2px 6px; font-size: 12.5px; }
.cover-topic summary { display: flex; align-items: center; gap: 10px; }

/* ---------- typed maths ---------- */
.math-preview { margin-top: 6px; padding: 8px 12px; border: 1px dashed var(--rule-strong); border-radius: 6px; background: var(--sunk); font-size: 15px; overflow-x: auto; }
.math-preview p { margin: 2px 0; min-height: 1.2em; }
.math-preview .katex { font-size: 1.12em; }
.math-help { margin-top: 10px; }
.math-help summary { cursor: pointer; color: var(--ink-2); }
.math-help-body { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--raise); }
.math-help table { border-collapse: collapse; width: 100%; }
.math-help td { padding: 3px 8px 3px 0; vertical-align: top; color: var(--ink-2); }
.math-help td.mono { color: var(--ink); white-space: nowrap; }
.math-help select { width: auto; padding: 3px 6px; font-size: 13px; }

/* ---------- timed paper sat offline ---------- */
.sit .steps-bar { margin-bottom: 22px; }
.sit h2 { margin-bottom: 6px; }
.sit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; align-items: start; }
.sit-how { padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.sit-side { padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.sit-qs { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 8px; font-size: 13.5px; }
.sit-qs-wide { grid-template-columns: repeat(auto-fill, minmax(70px, auto) minmax(30px, auto)); max-width: 720px; margin: 26px auto 0; }
.sit-clock { display: grid; justify-items: center; gap: 6px; margin: 30px auto 18px; max-width: 520px; }
.sit-time { font-size: clamp(56px, 13vw, 104px); line-height: 1; font-weight: 500; letter-spacing: -0.02em; }
.sit-time.low { color: var(--part); }
.sit-time.over { color: var(--miss); }
.sit-clock .goal-bar { width: 100%; }
.sit-clock-actions { justify-content: center; margin-bottom: 10px; }
.sit-pages { display: flex; flex-wrap: wrap; gap: 14px; }
.sit-thumb { margin: 0; padding: 8px; border: 1px solid var(--rule); border-radius: 8px; background: var(--raise); display: grid; gap: 6px; }
.sit-thumb canvas { border-radius: 4px; background: var(--sunk); }
.sit-thumb figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; }
.sit-thumb figcaption .link { text-decoration: none; padding: 0 3px; }
.sit-mark { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; margin-top: 14px; }
.sit-page-nav { margin-bottom: 8px; }
.sit-canvas-wrap { position: relative; cursor: crosshair; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--sunk); }
.sit-canvas-wrap canvas { display: block; }
/* a line across the page where an answer starts, with its label as a tab */
.sit-marker { position: absolute; left: 0; transform: translateY(-100%); padding: 2px 8px; border: 0; border-radius: 0 6px 0 0;
  background: #2f6bd6; color: #fff; font: 600 12px var(--sans); cursor: pointer; }
.sit-marker::after { content: ""; position: absolute; left: 0; top: 100%; width: var(--w, 2000px); max-width: 100vw; height: 2px; background: #2f6bd6; }
.sit-marker.on { background: #d4537e; }
.sit-marker.on::after { background: #d4537e; }
.sit-canvas-wrap { overflow: hidden; }
.sit-mark-side { position: sticky; top: 16px; display: grid; gap: 10px; }
.sit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sit-chips .chip.placed { border-color: var(--got); }
.sit-ai { display: grid; gap: 6px; padding: 12px; border: 1px dashed var(--rule-strong); border-radius: 8px; color: var(--ink-2); }
.sit-summary { display: flex; gap: 28px; margin-bottom: 20px; }
.sit-summary div { display: grid; }
.sit-summary .mono { font-size: 22px; }
.sit-summary span:last-child { font-size: 12.5px; color: var(--muted); }
.sit-choose { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sit-option { display: grid; gap: 8px; align-content: start; justify-items: start; padding: 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); }
.sit-option.paid { border-style: dashed; }
.sit-answers { display: grid; gap: 18px; margin-top: 14px; }
.sit-answer { display: grid; gap: 8px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }
.sit-crop, #sit-answer { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: #fff; }
.sit-crop canvas, #sit-answer canvas { display: block; }
.sit-answer-panel { margin-top: 14px; }
@media (max-width: 860px) {
  .sit-grid, .sit-mark, .sit-choose { grid-template-columns: minmax(0, 1fr); }
  .sit-mark-side { position: static; order: -1; }
}

/* ---------- timetable planner ----------
   Subjects are the one place colour means something other than a mark:
   each block carries its subject's colour in --c. */
.page.page-wide { max-width: 1180px; }
.subj-tag[style*="--c"], .tb-task .subj-tag { background: color-mix(in srgb, var(--c) 16%, var(--raise)); color: color-mix(in srgb, var(--c) 70%, var(--ink)); }
.tb-bar { flex-wrap: wrap; gap: 10px; }
.tb-bar h2 { display: inline; }
.tb-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 10px; font-size: 13px; color: var(--ink-2); }
.tb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.tb-wrap { border: 1px solid var(--rule); border-radius: 10px; background: var(--raise); overflow: hidden; }
.tb { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); max-height: 640px; overflow-y: auto; position: relative; }
.tb-corner, .tb-head { position: sticky; top: 0; z-index: 3; background: var(--raise); border-bottom: 1px solid var(--rule); }
.tb-head { display: grid; gap: 1px; padding: 8px 8px 6px; font-size: 13px; border-left: 1px solid var(--rule); }
.tb-head > span { font-size: 11px; color: var(--muted); }
.tb-head > span.met { color: var(--got); }
.tb-head.today strong { color: var(--inv-ink); background: var(--inv); border-radius: 4px; padding: 0 5px; justify-self: start; }
.tb-times { position: relative; }
.tb-times span { position: absolute; right: 6px; transform: translateY(-50%); font: 11px var(--mono); color: var(--muted); }
.tb-times span:first-child { transform: none; }
.tb-col { position: relative; border-left: 1px solid var(--rule); cursor: crosshair; touch-action: pan-y;
  background-image: repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px var(--hour)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) / 2), color-mix(in srgb, var(--rule) 45%, transparent) calc(var(--hour) / 2) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px) var(--hour)); }
.tb-col.today { background-color: color-mix(in srgb, var(--sunk) 60%, transparent); }
.tb-col.past { background-color: color-mix(in srgb, var(--sunk) 35%, transparent); }
.tb-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--miss); z-index: 2; pointer-events: none; }
.tb-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--miss); }
.tb-block { position: absolute; left: 3px; right: 3px; z-index: 1; overflow: hidden; display: grid; align-content: start; gap: 1px;
  padding: 4px 6px 6px 8px; border-radius: 6px; cursor: grab; user-select: none; font-size: 12px; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 17%, var(--raise)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-left: 4px solid var(--c); }
.tb-block:hover { background: color-mix(in srgb, var(--c) 24%, var(--raise)); }
.tb-block.dragging { cursor: grabbing; opacity: .85; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); z-index: 4; }
.tb-block.done { opacity: .6; }
.tb-block.short { display: flex; gap: 6px; align-items: center; padding-top: 1px; padding-bottom: 1px; }
.tb-block.short .tb-subj { flex: 0 1 auto; min-width: 0; }
.tb-block.short .tb-meta { flex: none; }
.tb-subj { font-weight: 600; color: color-mix(in srgb, var(--c) 72%, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-what { color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tb-meta { font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.tb-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.tb-ghost { position: absolute; left: 3px; right: 3px; z-index: 2; border-radius: 6px; border: 2px dashed var(--ink-2); background: color-mix(in srgb, var(--ink) 6%, transparent);
  font: 11px var(--mono); padding: 3px 6px; color: var(--ink-2); pointer-events: none; }
.tb-daytabs { display: none; margin-bottom: 8px; flex-wrap: nowrap; overflow-x: auto; }
.tb-daytabs .chip { white-space: nowrap; }
.tb-settings { margin-top: 10px; }
.tb-settings input[type="time"] { width: auto; padding: 4px 8px; }
.tb-suggest summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.tb-suggest summary::-webkit-details-marker { display: none; }
.tb-suggest summary h2::before { content: "▸ "; color: var(--muted); }
.tb-suggest[open] summary h2::before { content: "▾ "; }
.tb-task { border-left: 4px solid var(--c); padding-left: 10px; }
.tb-task .tick { border-color: color-mix(in srgb, var(--c) 60%, var(--rule-strong)); }
.tb-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--raise); color: var(--ink); }
.tb-dialog::backdrop { background: rgba(10, 11, 13, .35); }
.tb-form { padding: 18px 20px 20px; gap: 12px; max-width: none; border-top: 5px solid var(--c); }
.tb-form-head { display: flex; align-items: center; justify-content: space-between; }
.tb-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.tb-swatch { border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 12%, var(--raise)); color: var(--ink);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.tb-swatch[aria-pressed="true"] { background: var(--c); color: #fff; border-color: var(--c); }
.tb-times-row { gap: 10px; flex-wrap: nowrap; }
.tb-times-row label { flex: 1; min-width: 0; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.tb-actions { gap: 8px; }
@media (max-width: 860px) {
  .tb-daytabs { display: flex; }
  .tb { grid-template-columns: 46px minmax(0, 1fr); max-height: 70vh; }
  .tb-head:not(.focus), .tb-col:not(.focus) { display: none; }
  .tb-times-row { flex-wrap: wrap; }
  .tb-times-row label { flex: 1 1 40%; }
}
