/* Rough Sheet: the CAT 2026 study app.
   The idea: the exam is won on the rough sheet. Pages sit on squared paper, shortcuts are swiped with a yellow
   highlighter, traps are written in red pen in the margin. Everything else stays quiet. */
:root {
  --paper: #f7f9fc; --card: #ffffff; --ink: #172b4d; --muted: #5b6b85; --line: #d5deeb; --grid: #e7edf6;
  --pen: #2557d6; --pen-soft: #e8efff; --hl: #ffe14d; --hl-ink: #4a3b00; --red: #c8372d; --red-soft: #fdecea;
  --green: #17804f; --green-soft: #e3f4ea; --amber: #a86400;
  --f-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
  --f-hand: "Kalam", "Segoe Print", cursive;
  --r-s: 6px; --r-m: 10px;
  --shadow: 0 1px 0 rgba(23, 43, 77, .06), 0 6px 18px -10px rgba(23, 43, 77, .25);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #142033; --card: #1b2a40; --ink: #e6ecf5; --muted: #9fb0c8; --line: #2b3d58; --grid: #1a2a42;
    --pen: #7aa2ff; --pen-soft: #22345a; --hl: #c9a92a; --hl-ink: #1b1600; --red: #ff7a6e; --red-soft: #3a2330;
    --green: #4fd18b; --green-soft: #1d3a31; --amber: #f0b45a; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #142033; --card: #1b2a40; --ink: #e6ecf5; --muted: #9fb0c8; --line: #2b3d58; --grid: #1a2a42;
  --pen: #7aa2ff; --pen-soft: #22345a; --hl: #c9a92a; --hl-ink: #1b1600; --red: #ff7a6e; --red-soft: #3a2330;
  --green: #4fd18b; --green-soft: #1d3a31; --amber: #f0b45a; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink); font: 16.5px/1.6 var(--f-body);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-attachment: fixed;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--pen); }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--f-head); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); padding: 18px 14px 40px; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 6px 14px; text-decoration: none; color: var(--ink); }
.brand b { font: 800 22px var(--f-head); letter-spacing: -.02em; }
.brand span { font: 15px var(--f-hand); color: var(--red); transform: rotate(-3deg); display: inline-block; }
.count { margin: 0 6px 14px; padding: 10px 12px; border: 1.5px dashed var(--line); border-radius: var(--r-m); }
.count b { font: 800 28px var(--f-head); display: block; line-height: 1; }
.count span { color: var(--muted); font-size: 14px; }
.nav a, .nav button.navb { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-s); color: var(--ink); text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; }
.nav a:hover, .nav button.navb:hover { background: var(--pen-soft); }
.nav a.on { background: var(--pen-soft); color: var(--pen); font-weight: 700; }
.nav .grp { margin: 16px 0 4px; padding: 0 10px; font: 700 15px var(--f-head); display: flex; justify-content: space-between; align-items: baseline; }
.nav .grp small { font: 13px var(--f-body); color: var(--muted); }
.nav .ch { font-size: 14.5px; padding: 5px 10px; }
.nav .ch .cd { color: var(--muted); font-size: 12.5px; width: 30px; flex: none; }
.nav .ch .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .ch .pb { width: 34px; height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; flex: none; }
.nav .ch .pb i { display: block; height: 100%; background: var(--green); }
.nav details > summary { list-style: none; cursor: pointer; }
.nav details > summary::-webkit-details-marker { display: none; }
.nav details > summary .grp::after { content: "+"; color: var(--muted); font-weight: 400; }
.nav details[open] > summary .grp::after { content: "−"; }
.railfoot { margin-top: 20px; padding: 12px 10px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; }
.btn.menu { display: none; }
main { min-width: 0; padding: 26px 34px 80px; }
.wrap { max-width: 1180px; margin: 0 auto; }

/* ---------------------------------------------------------------- common pieces */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--r-s); border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 700; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--pen-soft); }
.btn.pri { background: var(--pen); border-color: var(--pen); color: #fff; }
:root[data-theme="dark"] .btn.pri { color: #0c1730; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri { color: #0c1730; } }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ghost { border-color: var(--line); font-weight: 600; }
.btn.sm { padding: 5px 11px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 13px; font-weight: 700; border: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.chip.E { color: var(--green); border-color: currentColor; }
.chip.M { color: var(--amber); border-color: currentColor; }
.chip.H { color: var(--red); border-color: currentColor; }
.chip.tita { color: var(--pen); border-color: currentColor; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }
.kbd { display: inline-block; min-width: 22px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font-size: 12.5px; text-align: center; color: var(--muted); background: var(--card); }

/* rich text */
.rt p { margin: 0 0 .62em; }
.rt p:last-child { margin-bottom: 0; }
.rt ul, .rt ol { margin: .2em 0 .7em; padding-left: 1.3em; }
.rt li { margin: .15em 0; }
.rt table, table.dt { border-collapse: collapse; margin: .5em 0 .9em; font-size: 15px; background: var(--card); max-width: 100%; display: block; overflow-x: auto; }
.rt th, .rt td, table.dt th, table.dt td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; vertical-align: top; }
.rt th, table.dt th { background: var(--pen-soft); font-weight: 700; }
.rt b, .rt strong { font-weight: 700; }
.rt .lead { font-weight: 700; color: var(--pen); }

/* figures */
figure.fig { margin: 14px 0; padding: 14px 14px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); }
figure.fig figcaption { margin-top: 8px; color: var(--muted); font-size: 14px; text-align: center; }
figure.fig.sol { border-color: var(--pen); }
.qcard figure.fig { max-width: 560px; }
.qcard figure.fig svg.dg { max-width: 440px; max-height: 340px; }

/* the highlighter: the one loud thing */
.hlr { background: linear-gradient(100deg, transparent .4em, var(--hl) .5em, var(--hl) calc(100% - .5em), transparent calc(100% - .4em)) 0 62%/100% 74% no-repeat;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; color: var(--hl-ink); padding: 0 .3em; margin: 0 -.15em; }
.fast { position: relative; margin: 16px 0; padding: 14px 18px 14px 20px; border-radius: var(--r-m); background: var(--card); border: 2px solid var(--hl); }
.fast .tag { position: absolute; top: -14px; left: 14px; font: 700 15px var(--f-head); padding: 1px 10px 1px 8px; background: var(--hl); color: var(--hl-ink); border-radius: 4px 12px 12px 4px; transform: rotate(-1.5deg); display: inline-flex; gap: 6px; align-items: center; }
.fast .rt p { line-height: 1.85; }
.fast .rt p > span.hlr { font-weight: 600; }

/* red pen */
.trap { margin: 16px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--red); }
.trap .tag, .pen { font: 700 20px var(--f-hand); color: var(--red); display: inline-block; transform: rotate(-2deg); }
.trap .rt { margin-top: 2px; }
.remember { margin: 16px 0; padding: 12px 16px; border-radius: var(--r-m); background: var(--green-soft); }
.remember .tag { font: 700 15px var(--f-head); color: var(--green); margin-bottom: 4px; display: block; }
.note { margin: 14px 0; padding: 12px 16px; border-radius: var(--r-m); border: 1.5px dashed var(--amber); }
.note .tag { font: 700 15px var(--f-head); color: var(--amber); display: block; margin-bottom: 4px; }

/* ---------------------------------------------------------------- today */
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.today-h { font-size: clamp(30px, 4vw, 44px); font-weight: 800; letter-spacing: -.025em; margin-bottom: 6px; }
.today-h + p { margin: 0 0 18px; color: var(--muted); font-size: 18px; }
.daycard { padding: 22px 24px; }
.daycard .kind { font: 700 19px var(--f-hand); color: var(--red); transform: rotate(-2deg); display: inline-block; }
.daycard h2 { font-size: 28px; margin: 2px 0 12px; }
.task { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.task .sec { font: 800 16px var(--f-head); }
.task .sec small { display: block; font: 13px var(--f-body); color: var(--muted); }
.task a.chl { display: inline-flex; margin: 0 6px 6px 0; padding: 4px 10px; border-radius: var(--r-s); border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--paper); font-size: 15px; }
.task a.chl:hover { border-color: var(--pen); color: var(--pen); }
.task a.chl b { color: var(--muted); margin-right: 6px; font-weight: 700; }
.task a.chl.done { border-color: var(--green); }
.stats { display: grid; gap: 12px; }
.stat { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 14px 16px; }
.ring { width: 64px; height: 64px; }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: var(--grid); }
.ring .fg.zero { display: none; }
.ring .fg { stroke: var(--green); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.stat b { font: 800 20px var(--f-head); }
.stat .muted { font-size: 14px; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; }
.dayb { flex: none; width: 54px; padding: 6px 0; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); text-align: center; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.dayb b { display: block; font: 800 17px var(--f-head); color: var(--ink); }
.dayb.test { border-color: var(--red); }
.dayb.on { background: var(--ink); color: var(--paper); }
.dayb.on b { color: var(--paper); }
.dayb.past { opacity: .55; }
.weak li { margin: 6px 0; }

/* ---------------------------------------------------------------- chapter */
.chh { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.chh .code { font: 700 18px var(--f-hand); color: var(--red); transform: rotate(-2deg); display: inline-block; }
.chh h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 800; letter-spacing: -.025em; }
.chh .sub { color: var(--muted); margin-top: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 9px 16px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--ink); border-color: var(--pen); }
.tabs a .n { font-weight: 400; font-size: 13.5px; margin-left: 4px; }

/* learn */
.learn { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 30px; }
.toc { position: sticky; top: 20px; align-self: start; font-size: 14.5px; }
.toc a { display: block; padding: 5px 10px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--pen); border-color: var(--pen); }
.nsec { margin-bottom: 26px; max-width: 76ch; }
.nsec > h2 { font-size: 23px; margin-bottom: 10px; }
.nsec.card-like { padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); }
.nsec.sc > h2 .hlr { padding: 0 .35em; }
.nsec.tr > h2 { font: 700 26px var(--f-hand); color: var(--red); }
.nsec.tr { border-left: 3px solid var(--red); padding-left: 18px; }
.learnend { margin: 30px 0 0; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }

/* practice */
.pbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 14px; }
.filters button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.qmap { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 18px; }
.qmap button { width: 34px; height: 30px; border-radius: 5px; border: 1px solid var(--line); background: var(--card); font-size: 13px; cursor: pointer; color: var(--muted); padding: 0; }
.qmap button.ok { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 700; }
.qmap button.no { background: var(--red-soft); border-color: var(--red); color: var(--red); font-weight: 700; }
.qmap button.cur { outline: 2.5px solid var(--pen); outline-offset: 1px; color: var(--ink); }
.qmap button.fl::after { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin: -4px auto 0; position: relative; top: 7px; }
.qmap button.sv { opacity: .45; }
.saved { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--r-m); border: 1.5px dashed var(--line); font-size: 15px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }

.qwrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.qwrap.split { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
.ctxpane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px 22px; }
.ctxpane .rt { max-width: 72ch; }
.ctxpane.passage .rt { font-family: Georgia, "Source Serif 4", serif; font-size: 17px; line-height: 1.75; }
.ctxpane h3 { font-size: 20px; margin-bottom: 4px; }
.ctxpane .adv { margin: 8px 0 14px; padding: 8px 12px; border-radius: var(--r-s); background: var(--pen-soft); font-size: 15px; }
.qcard { padding: 20px 22px; scroll-margin-top: 16px; }
.qcard + .qcard { margin-top: 18px; }
.qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.qmeta .src { font-weight: 700; color: var(--ink); }
.qmeta .clock { margin-left: auto; font: 700 15px var(--f-head); font-variant-numeric: tabular-nums; color: var(--ink); padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); }
.qmeta .clock.over { color: var(--red); border-color: var(--red); }
.stem { font-size: 17.5px; max-width: 72ch; }
.pre { margin-bottom: 12px; padding: 12px 14px; background: var(--paper); border-radius: var(--r-s); font-size: 16px; }
.opts { display: grid; gap: 8px; margin: 16px 0 4px; max-width: 72ch; }
.opt { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; width: 100%; text-align: left; padding: 10px 14px; border-radius: var(--r-m); border: 1.5px solid var(--line); background: var(--card); cursor: pointer; transition: border-color .12s, background-color .12s; }
.opt:hover:not(:disabled) { border-color: var(--pen); }
.opt .k { width: 30px; height: 30px; border-radius: 7px; border: 1.5px solid var(--line); display: grid; place-items: center; font-weight: 800; font-family: var(--f-head); }
.opt .tx { padding-top: 3px; }
.opt .mk { font: 700 18px var(--f-hand); padding-top: 2px; }
.opt.pick { border-color: var(--pen); background: var(--pen-soft); }
.opt.pick .k { border-color: var(--pen); background: var(--pen); color: var(--card); }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.right .k { border-color: var(--green); background: var(--green); color: var(--card); }
.opt.right .mk { color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .k { border-color: var(--red); background: var(--red); color: var(--card); }
.opt.wrong .mk { color: var(--red); }
.opt:disabled { cursor: default; }
.opt .why { grid-column: 2 / 4; font-size: 14.5px; color: var(--muted); padding-top: 4px; border-top: 1px dashed var(--line); margin-top: 4px; }
.opt.right .why { color: var(--ink); }
.tita { display: flex; gap: 10px; align-items: center; margin: 16px 0 4px; flex-wrap: wrap; }
.tita input { width: 200px; padding: 9px 12px; font-size: 18px; font-weight: 700; border-radius: var(--r-s); border: 1.5px solid var(--line); background: var(--card); }
.tita input:focus { border-color: var(--pen); outline: none; box-shadow: 0 0 0 3px var(--pen-soft); }
.tita input.right { border-color: var(--green); background: var(--green-soft); }
.tita input.wrong { border-color: var(--red); background: var(--red-soft); }
.qact { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.qact .sp { flex: 1; }
.flag[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }

.sol-only .tests { margin: 0 0 4px; font-size: 17px; }
.sol-only .qact { margin-top: 12px; }
.sol-only .answer { margin-top: 14px; }
.okk { color: var(--green); } .nok { color: var(--red); }
.qact.self { padding-top: 12px; border-top: 1px dashed var(--line); }

/* verdict stamp: the moment after "Check" */
.verdict { display: flex; align-items: center; gap: 16px; margin: 18px 0 6px; padding: 12px 16px; border-radius: var(--r-m); flex-wrap: wrap; }
.verdict .stamp { font: 700 30px var(--f-hand); transform: rotate(-4deg); padding: 0 12px; border: 3px solid currentColor; border-radius: 8px; line-height: 1.25; }
.verdict.ok { background: var(--green-soft); color: var(--green); }
.verdict.no { background: var(--red-soft); color: var(--red); }
.verdict.seen { background: var(--pen-soft); color: var(--pen); }
.verdict .vt { color: var(--ink); font-size: 15.5px; }
.verdict .vt b { font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .verdict .stamp { animation: stamp .32s cubic-bezier(.2, 1.6, .4, 1) both; }
  @keyframes stamp { from { transform: rotate(-12deg) scale(1.7); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
  .step.new { animation: rise .25s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* solution */
.solution { margin-top: 8px; }
.sol-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 22px 0 8px; flex-wrap: wrap; }
.sol-h h3 { font-size: 20px; }
.idea { margin: 4px 0 12px; padding: 10px 14px; border-radius: var(--r-s); background: var(--pen-soft); max-width: 76ch; }
.idea b.lab { color: var(--pen); margin-right: 6px; }
ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; max-width: 76ch; }
ol.steps > li.step { position: relative; padding: 0 0 14px 46px; counter-increment: st; }
ol.steps > li.step::before { content: counter(st); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--pen); color: var(--pen); background: var(--card); display: grid; place-items: center; font: 800 14px var(--f-head); }
ol.steps > li.step::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; background: var(--line); }
ol.steps > li.step:last-child::after { display: none; }
ol.steps > li.step .rt { padding-top: 3px; }
.stepnext { margin: 2px 0 10px 46px; }
.answer { display: inline-flex; gap: 10px; align-items: baseline; margin: 10px 0 4px; padding: 8px 16px; border-radius: var(--r-m); border: 2px solid var(--green); background: var(--green-soft); font-size: 17px; }
.answer b { font: 800 20px var(--f-head); color: var(--green); }
.check { margin: 10px 0; color: var(--muted); font-size: 15px; max-width: 76ch; }
.check b.lab { color: var(--ink); }
.setup { margin-top: 18px; }
.setup .head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
details.fold { margin: 14px 0; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); }
details.fold > summary { padding: 12px 16px; cursor: pointer; font: 700 17px var(--f-head); list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "Show"; font: 600 14px var(--f-body); color: var(--pen); }
details.fold[open] > summary::after { content: "Hide"; }
details.fold > .in { padding: 0 16px 16px; }
.nextbar { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* revise */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.flash { position: relative; min-height: 150px; padding: 18px 18px 52px; cursor: pointer; text-align: left; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); box-shadow: var(--shadow); }
.flash .front { font-weight: 700; font-size: 17px; }
.flash .back { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.flash .back.hid { filter: blur(6px); user-select: none; }
.flash .src { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.flash .rate { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; gap: 8px; }
.flash.known { border-color: var(--green); }
.flash.again { border-color: var(--amber); }

/* plan / guide */
.guide { max-width: 82ch; }
.guide h2 { font-size: 22px; margin: 24px 0 8px; }
.guide h3 { font-size: 18px; margin: 16px 0 6px; }
.guide p { margin: 0 0 .7em; }
.guide .bx { margin: 14px 0; padding: 12px 16px; border-radius: var(--r-m); background: var(--card); border: 1px solid var(--line); }
.guide .bx .bx-h { font: 700 16px var(--f-head); margin-bottom: 4px; }
.guide .bx.sc { border: 2px solid var(--hl); }
.guide .bx.tr { border: 0; border-left: 3px solid var(--red); border-radius: 0; background: none; }
.guide .bx.tr .bx-h { font: 700 20px var(--f-hand); color: var(--red); }
.guide .bx.tk { background: var(--green-soft); border: 0; }
.guide .bx.nt { border: 1.5px dashed var(--amber); }
.guide .day { margin: 12px 0; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); }
.guide .day .dk { font-size: 14px; color: var(--muted); }
.guide .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.guide .lg { color: var(--muted); font-size: 15px; }
.glist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.glist a { display: block; padding: 16px 18px; text-decoration: none; color: var(--ink); }
.glist a:hover { border-color: var(--pen); }
.glist a .c { font: 700 16px var(--f-hand); color: var(--red); }
.glist a h3 { font-size: 19px; margin: 2px 0 4px; }
.glist a p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* error log */
table.log { width: 100%; border-collapse: collapse; background: var(--card); font-size: 15px; }
table.log th, table.log td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.log th { font-family: var(--f-head); background: var(--pen-soft); }
table.log select { padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--card); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.empty .pen { font-size: 24px; display: block; margin-bottom: 6px; }

/* search */
.search { display: flex; gap: 10px; margin-bottom: 18px; }
.search input { flex: 1; padding: 10px 14px; border-radius: var(--r-m); border: 1.5px solid var(--line); background: var(--card); font-size: 17px; }
.hit { display: block; padding: 12px 16px; text-decoration: none; color: var(--ink); margin-bottom: 8px; }
.hit:hover { border-color: var(--pen); }
.hit .m { font-size: 13.5px; color: var(--muted); }
mark { background: var(--hl); color: var(--hl-ink); border-radius: 2px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1100px) { .qwrap.split { grid-template-columns: minmax(0, 1fr); } .ctxpane { position: static; max-height: none; } .hero { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 300px; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .btn.menu { display: inline-flex; position: sticky; top: 8px; z-index: 20; margin: -6px 0 10px; }
  main { padding: 18px 16px 70px; }
  .learn { grid-template-columns: minmax(0, 1fr); } .toc { display: none; }
  .guide .two { grid-template-columns: 1fr; }
  .task { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .qcard, .ctxpane { padding: 16px; }
}
@media print { .rail, .menu, .qact, .filters, .qmap { display: none !important; } .shell { display: block; } body { background: #fff; } }

/* ================================================================== motion, depth and 3D
   Motion answers an action (open, check, flip, drag). The one staged moment is the home page arriving. */
.burst { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.ring .fg { stroke-dashoffset: var(--o, 0); }
.btn { transition: transform .08s ease-out, box-shadow .08s ease-out, background-color .12s; }
.btn.pri { box-shadow: 0 3px 0 color-mix(in srgb, var(--pen) 62%, #000); }
.btn.pri:active { transform: translateY(3px); box-shadow: 0 0 0 transparent; }
.opt { box-shadow: 0 3px 0 var(--line); transition: transform .08s ease-out, box-shadow .08s ease-out, border-color .12s, background-color .12s; }
.opt:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 var(--line); }
.opt:active:not(:disabled), .opt.pick { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.opt:disabled { box-shadow: none; transform: none; }
[data-tilt] { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transform-style: preserve-3d; transition: transform .22s ease-out, box-shadow .22s ease-out; position: relative; will-change: transform; }
[data-tilt].tilting { transition: transform .06s linear; box-shadow: 0 14px 30px -14px rgba(23, 43, 77, .45); }
[data-tilt]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .2s; background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .28), transparent 55%); }
[data-tilt].tilting::after { opacity: 1; }
[data-tilt] > * { transform: translateZ(12px); }

/* hints: pencil notes that appear above the buttons */
.hints { display: grid; gap: 8px; margin-top: 12px; max-width: 72ch; }
.hints:empty { display: none; }
.hintn { padding: 9px 14px; border-radius: var(--r-s); border: 1.5px dashed var(--amber); background: var(--card); font-size: 15.5px; }
.hintn b { font: 700 17px var(--f-hand); color: var(--amber); margin-right: 6px; }
.streak { margin-left: 8px; font-size: 19px; color: var(--green); }

/* the fastest route as moves */
ol.moves { list-style: none; margin: 4px 0 0; padding: 0; counter-reset: mv; display: grid; gap: 7px; }
ol.moves .mv { position: relative; padding-left: 34px; counter-increment: mv; cursor: pointer; line-height: 1.8; }
ol.moves .mv::before { content: counter(mv); position: absolute; left: 0; top: 4px; width: 22px; height: 22px; border-radius: 6px; background: var(--hl); color: var(--hl-ink); font: 800 13px/22px var(--f-head); text-align: center; transform: rotate(-4deg); }
.mvnote { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }

/* flash cards that really flip */
.flash3 { perspective: 1100px; cursor: pointer; border-radius: var(--r-m); }
.flash3 .fl-in { display: grid; min-height: 170px; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, 1.3, .5, 1); }
.flash3.flip .fl-in { transform: rotateY(180deg); }
.flash3 .fl-f, .flash3 .fl-b { grid-area: 1 / 1; padding: 18px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; gap: 8px; }
.flash3 .fl-b { transform: rotateY(180deg); border-color: var(--pen); }
.flash3 .src { font-size: 13px; color: var(--muted); }
.flash3 .front { font-weight: 700; font-size: 18px; }
.flash3 .tap { margin-top: auto; align-self: flex-end; font: 700 16px var(--f-hand); color: var(--red); transform: rotate(-3deg); }
.flash3 .back { font-size: 16px; }
.flash3 .rate { margin-top: auto; display: flex; gap: 8px; }
.flash3.known .fl-f, .flash3.known .fl-b { border-color: var(--green); }
.flash3.again .fl-f, .flash3.again .fl-b { border-color: var(--amber); }
.flash3:focus-visible { outline: 3px solid var(--pen); outline-offset: 3px; }

/* shortcut labs */
div.lab { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); padding: 20px 22px; }
.lab-h h3 { font-size: 22px; margin: 0 0 6px; }
.lab-h .say { margin: 0 0 14px; font-size: 17.5px; font-weight: 600; line-height: 1.9; max-width: 70ch; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.lab-fig { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px; text-align: center; }
.lab-fig .play { margin: 6px 0 4px; }
.lab-side { display: grid; gap: 12px; }
.ctl { display: grid; gap: 4px; font-size: 15px; }
.ctl .val { font: 800 16px var(--f-head); color: var(--pen); margin-left: 6px; font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { width: 100%; accent-color: var(--pen); height: 26px; }
.ctl .rng { margin-left: 8px; font-size: 13px; color: var(--muted); }
.ctl.off { opacity: .5; }
/* words in a lab picture keep a paper-coloured edge, so a line passing behind never cuts through them */
.lab-fig svg.dg text.halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--line); border-radius: 18px; padding: 3px; gap: 3px; justify-self: start; }
.seg button { border: 0; background: none; padding: 5px 13px; border-radius: 99px; cursor: pointer; font-size: 14.5px; color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--paper); }
.lab-out { padding: 12px 14px; border-radius: var(--r-s); background: var(--pen-soft); font-size: 15.5px; }
.lab-out p { margin: 0 0 6px; } .lab-out p:last-child { margin: 0; }
.lab-out .lk { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; font-weight: 700; color: var(--pen); }
.lab-more { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; align-items: start; }
.lab-more details.fold { margin: 0; }
.lab-quiz { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-m); border: 2px solid var(--hl); }
.lab-quiz .qh { display: flex; justify-content: space-between; align-items: baseline; font: 700 17px var(--f-head); }
.lab-quiz .qh .sc { font: 14px var(--f-body); }
.lab-quiz .qq { margin: 6px 0 0; max-width: 72ch; }
.lab-quiz .tita { margin: 10px 0 0; }
.lab-quiz .tita input { width: 150px; padding: 7px 10px; font-size: 17px; }
.lab-quiz .qa { margin: 10px 0 0; min-height: 1.4em; }
.lab-quiz .qa.ok b { color: var(--green); } .lab-quiz .qa.no b { color: var(--red); }
.labcard .chip { margin-top: 10px; }
.labtease { display: block; text-decoration: none; color: var(--ink); border: 2px solid var(--hl); }
.labtease .pen { font-size: 17px; margin-right: 8px; }
.toc a.tlab { color: var(--pen); font-weight: 700; }

/* the 3D box */
.scene3d { height: 320px; perspective: 800px; display: grid; place-items: center; position: relative; touch-action: none; cursor: grab; border-radius: var(--r-s); outline-offset: 2px; }
.scene3d:active { cursor: grabbing; }
.scene3d .turn { position: absolute; right: 10px; bottom: 6px; font: 700 16px var(--f-hand); color: var(--red); transform: rotate(-3deg); }
.box3d { position: relative; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, -22deg)) rotateY(var(--ry, -34deg)); }
.box3d .f { position: absolute; border: 2px solid var(--ink); background: color-mix(in srgb, var(--pen) 16%, transparent); transition: background-color .15s; }
.box3d .fr, .box3d .bk { width: calc(var(--l) * 1px); height: calc(var(--h) * 1px); margin: calc(var(--h) * -.5px) 0 0 calc(var(--l) * -.5px); }
.box3d .fr { transform: translateZ(calc(var(--b) * .5px)); }
.box3d .bk { transform: rotateY(180deg) translateZ(calc(var(--b) * .5px)); }
.box3d .lf, .box3d .rt { width: calc(var(--b) * 1px); height: calc(var(--h) * 1px); margin: calc(var(--h) * -.5px) 0 0 calc(var(--b) * -.5px); }
.box3d .rt { transform: rotateY(90deg) translateZ(calc(var(--l) * .5px)); }
.box3d .lf { transform: rotateY(-90deg) translateZ(calc(var(--l) * .5px)); }
.box3d .tp, .box3d .bt { width: calc(var(--l) * 1px); height: calc(var(--b) * 1px); margin: calc(var(--b) * -.5px) 0 0 calc(var(--l) * -.5px); }
.box3d .tp { transform: rotateX(90deg) translateZ(calc(var(--h) * .5px)); }
.box3d .bt { transform: rotateX(-90deg) translateZ(calc(var(--h) * .5px)); }
.box3d .diag { position: absolute; height: 0; border-top: 3px solid var(--red); top: 0; left: 0; }
.box3d.hi-tp .tp, .box3d.hi-tp .bt, .box3d.hi-lf .lf, .box3d.hi-lf .rt, .box3d.hi-fr .fr, .box3d.hi-fr .bk { background: color-mix(in srgb, var(--hl) 80%, transparent); }

@media (prefers-reduced-motion: no-preference) {
  #main.enter > .wrap { animation: pagein .32s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes pagein { from { opacity: 0; transform: translateY(12px); } }
  #stage[data-dir="f"] > .qwrap { animation: slidef .28s cubic-bezier(.2, .7, .2, 1) both; }
  #stage[data-dir="b"] > .qwrap { animation: slideb .28s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes slidef { from { opacity: 0; transform: translateX(28px); } }
  @keyframes slideb { from { opacity: 0; transform: translateX(-28px); } }
  /* the home page arrives as a small stack of sheets, once */
  #main.enter .hero .card { animation: deal .5s cubic-bezier(.2, .9, .3, 1.15) both; animation-delay: calc(var(--n, 0) * 70ms); transform-origin: 50% 100%; }
  #main.enter .hero .stats > :nth-child(1) { --n: 1; } #main.enter .hero .stats > :nth-child(2) { --n: 2; } #main.enter .hero .stats > :nth-child(3) { --n: 3; } #main.enter .hero .stats > :nth-child(4) { --n: 4; } #main.enter .hero .stats > :nth-child(5) { --n: 5; } #main.enter .hero .stats > :nth-child(6) { --n: 6; }
  @keyframes deal { from { opacity: 0; transform: perspective(900px) rotateX(-28deg) translateY(26px); } }
  .ring .fg { animation: ringin 1s .15s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes ringin { from { stroke-dashoffset: var(--c); } }
  .fast .hlr, .lab-h .hlr { background-size: 0% 74%; animation: swipe .7s .2s cubic-bezier(.3, .7, .2, 1) forwards; }
  @keyframes swipe { to { background-size: 100% 74%; } }
  ol.moves .mv { animation: rise .3s ease-out both; animation-delay: calc(var(--i) * 110ms + 120ms); }
  .fast { animation: rise .3s ease-out both; }
  .hintn { animation: rise .25s ease-out both; }
  .opt.right { animation: pop .38s cubic-bezier(.2, 1.6, .4, 1); }
  .opt.wrong { animation: shake .36s ease-in-out; }
  @keyframes pop { 40% { transform: scale(1.025); } }
  @keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
  ol.steps > li.step.new::after { animation: grow .35s ease-out both; transform-origin: top; }
  @keyframes grow { from { transform: scaleY(0); } }
}
@media (max-width: 900px) { .lab-grid, .lab-more { grid-template-columns: minmax(0, 1fr); } div.lab { padding: 16px; } .scene3d { height: 230px; } }
/* 11-14: a stacked fraction inside a highlighted line stuck out of the yellow band (numerator and denominator half off it).
   Give the fraction its own full-height yellow box with dark ink, so it reads as part of the highlight. */
.hlr .fx, .point[open] .ptt .fx { background: var(--hl); color: var(--hl-ink); border-radius: 4px; box-shadow: 0 0 0 1px var(--hl); }
.fast .hlr .fx { background: none; color: inherit; box-shadow: none; }

/* XAT: pictures from the question paper */
.qimg{margin:12px 0;padding:8px;background:#fff;border:1px solid var(--line,#ddd);border-radius:8px;overflow-x:auto}
.qimg img{display:block;max-width:100%;height:auto;margin:0 auto}
