/* 7517 — calm, serious, exam-paper. Tokens first; light is the base, dark overrides. */
@font-face { font-family: 'Cascadia Mono'; src: url(/fonts/CascadiaMono-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cascadia Mono'; src: url(/fonts/CascadiaMono-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --desk: #eeede9; --sheet: #ffffff; --raise: #f7f6f3; --ink: #18181a; --ink2: #3d3d42; --muted: #6e6d72; --faint: #a3a2a7;
  --line: #dddcd7; --rule: #cfd3dc; --accent: #2345b8; --accent-ink: #ffffff; --accent-soft: #e6ebfa; --focus: #2345b8;
  --ok: #1c7a45; --ok-soft: #e3f3e9; --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #9a5b00; --warn-soft: #fbf0dc;
  --st-new: #a3a2a7; --st-learning: #c27c0e; --st-ready: #2345b8; --st-mastered: #1c7a45; --st-slipped: #b3261e;
  --code-bg: #ffffff; --code-ink: #000000; --con-bg: #0c0c0c; --con-ink: #cccccc;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 2px 10px rgba(20, 20, 30, .05);
  --ui: 'Segoe UI', system-ui, Inter, 'Helvetica Neue', Arial, sans-serif;
  --paper: Arial, 'Liberation Sans', Arimo, Helvetica, sans-serif;
  --mono: 'Cascadia Mono', Consolas, 'DejaVu Sans Mono', monospace;
  --r: 6px; --bar: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #0d0d0f; --sheet: #17171a; --raise: #1e1e22; --ink: #e9e7e3; --ink2: #c9c7c3; --muted: #94939a; --faint: #5f5e66;
    --line: #2b2b31; --rule: #34363f; --accent: #8aa4ff; --accent-ink: #0d0d0f; --accent-soft: #1d2440; --focus: #8aa4ff;
    --ok: #5cc98a; --ok-soft: #13291d; --bad: #ff8a80; --bad-soft: #321615; --warn: #f0b24a; --warn-soft: #2e2311;
    --st-new: #5f5e66; --st-learning: #f0b24a; --st-ready: #8aa4ff; --st-mastered: #5cc98a; --st-slipped: #ff8a80;
    --code-bg: #1f1f1f; --code-ink: #cccccc; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #0d0d0f; --sheet: #17171a; --raise: #1e1e22; --ink: #e9e7e3; --ink2: #c9c7c3; --muted: #94939a; --faint: #5f5e66;
  --line: #2b2b31; --rule: #34363f; --accent: #8aa4ff; --accent-ink: #0d0d0f; --accent-soft: #1d2440; --focus: #8aa4ff;
  --ok: #5cc98a; --ok-soft: #13291d; --bad: #ff8a80; --bad-soft: #321615; --warn: #f0b24a; --warn-soft: #2e2311;
  --st-new: #5f5e66; --st-learning: #f0b24a; --st-ready: #8aa4ff; --st-mastered: #5cc98a; --st-slipped: #ff8a80;
  --code-bg: #1f1f1f; --code-ink: #cccccc; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--desk); color: var(--ink); font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
code, pre, .mono { font-family: var(--mono); font-size: 13.5px; }
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
html, body { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
textarea.input { scrollbar-width: none; overflow: hidden; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sheet); color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); background: var(--raise); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn kbd, .kbd { font: 11px var(--mono); color: inherit; opacity: .7; border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; line-height: 15px; }
.iconbtn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r); border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.iconbtn:hover { color: var(--ink); background: var(--raise); }
.iconbtn.on { color: var(--accent); }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; height: var(--bar); display: flex; align-items: center; gap: 18px; padding: 0 14px 0 18px; background: var(--desk); border-bottom: 1px solid var(--line); }
.brand { font: 700 15px var(--mono); letter-spacing: .02em; color: var(--ink); }
.brand span { color: var(--muted); font-weight: 400; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: var(--r); font-weight: 500; }
.nav a:hover { color: var(--ink); text-decoration: none; background: var(--raise); }
.nav a.on { color: var(--ink); background: var(--sheet); box-shadow: var(--shadow); }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.clock { font: 13px var(--mono); color: var(--muted); padding: 0 8px; }
.who { color: var(--muted); font-size: 13px; padding: 0 6px; }
body.focus .top { display: none; }
body.focus .sesshead .plan { display: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: calc(100vh - var(--bar)); }
body.focus .shell { min-height: 100vh; }
main { flex: 1; min-width: 0; padding: 28px 24px 120px; }
.col { max-width: 840px; margin: 0 auto; }
.col.wide { max-width: 1180px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- the paper sheet ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); padding: 30px 40px 30px 64px; position: relative; font: 16px/1.55 var(--paper); }
.sheet + .sheet { margin-top: 16px; }
.qnum { position: absolute; left: 18px; top: 28px; width: 36px; text-align: center; font-weight: 700; font-size: 15px; }
.qnum.box { border: 1.5px solid var(--ink); border-radius: 2px; padding: 2px 0; font-size: 14px; }
.stem { margin: 0 0 6px; }
.stem p { margin: 0 0 10px; }
.stem pre, .codeblock { font: 14px/1.5 var(--mono); background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--line); border-radius: 3px; padding: 10px 14px; overflow-x: auto; margin: 10px 0; }
.stem table, .lb table { border-collapse: collapse; margin: 10px 0; font-size: 15px; }
.stem td, .stem th, .lb td, .lb th { border: 1px solid var(--ink2); padding: 4px 10px; text-align: center; }
.stem th, .lb th { font-weight: 700; }
.marks { display: flex; justify-content: flex-end; font-weight: 700; font-size: 15px; margin: 4px 0 10px; }
.meta { display: flex; gap: 10px; align-items: center; font: 12px var(--ui); color: var(--muted); margin: -12px 0 14px; }
.lvl { display: inline-flex; gap: 2px; }
.lvl i { width: 6px; height: 6px; border-radius: 1px; background: var(--line); }
.lvl i.on { background: var(--ink2); }
.answer { margin-top: 10px; }
.ruled { width: 100%; border: 0; resize: vertical; background: transparent; outline: none; font: 16px/32px var(--paper); padding: 0 2px; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule) 31px, var(--rule) 32px); background-attachment: local; min-height: 96px; }
.ruled:focus { background-color: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.lineinput { width: 100%; height: 40px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; outline: none; font: 16px var(--paper); padding: 0 2px; }
.lineinput:focus { border-bottom: 2px solid var(--accent); }
.lineinput.mono { font: 15px var(--mono); }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-family: var(--ui); font-size: 15px; }
.actions .note { color: var(--muted); font-size: 13px; }

/* mcq: AQA lozenges */
.opts { display: grid; gap: 8px; margin: 8px 0; font-family: var(--paper); }
.opt { display: flex; gap: 14px; align-items: center; padding: 6px 8px; border-radius: 4px; cursor: pointer; border: 1px solid transparent; }
.opt:hover { background: var(--raise); }
.opt .lz { width: 30px; height: 18px; border: 1.5px solid var(--ink2); border-radius: 9px; flex: none; display: grid; place-items: center; }
.opt.on .lz { background: var(--ink); border-color: var(--ink); }
.opt .ltr { font-weight: 700; width: 16px; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opts.locked .opt { cursor: default; }

/* tables to fill in (truth, trace) */
table.fill { border-collapse: collapse; margin: 10px 0; font: 15px var(--paper); }
table.fill th, table.fill td { border: 1.5px solid var(--ink2); min-width: 46px; height: 34px; text-align: center; padding: 0; }
table.fill th { padding: 4px 10px; font-weight: 700; background: var(--raise); }
table.fill td.given { color: var(--ink); padding: 0 10px; }
table.fill td input { width: 100%; min-width: 60px; height: 34px; border: 0; background: transparent; text-align: center; font: 15px var(--mono); outline: none; }
table.fill td input:focus { background: var(--accent-soft); }
table.fill td.tog { cursor: pointer; font: 16px var(--mono); user-select: none; }
table.fill td.tog:hover { background: var(--raise); }
table.fill td.wrongc { background: var(--bad-soft); }
table.fill td.rightc { background: var(--ok-soft); }
table.fill td.sep, table.fill th.sep { border-left-width: 3px; }

/* code */
.ide { margin-top: 12px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; font-family: var(--ui); }
.ide .bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--raise); border-bottom: 1px solid var(--line); font-size: 13px; }
.ide .bar .file { color: var(--muted); font: 12.5px var(--mono); padding: 0 6px; }
.ide .ed { height: 340px; background: var(--code-bg); }
.ide .ed textarea { width: 100%; height: 100%; border: 0; resize: none; padding: 10px; background: var(--code-bg); color: var(--code-ink); font: 14px/1.5 var(--mono); outline: none; tab-size: 4; }
.console { background: var(--con-bg); color: var(--con-ink); font: 13.5px/1.45 var(--mono); padding: 8px 12px; height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console .err { color: #f48771; }
.console .sys { color: #7f7f7f; }
.console .in { color: #9cdcfe; }
.console input { background: transparent; border: 0; outline: none; color: #9cdcfe; font: inherit; width: 60%; }
.ide .resize { height: 6px; cursor: ns-resize; background: var(--raise); border-top: 1px solid var(--line); }
.cases { margin-top: 10px; display: grid; gap: 6px; font: 13px var(--mono); }
.case { border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; background: var(--raise); }
.case.pass { border-color: var(--ok); }
.case.fail { border-color: var(--bad); }
.case pre { margin: 4px 0 0; white-space: pre-wrap; }

/* Boolean expression lines */
.blines { display: grid; gap: 4px; margin-top: 6px; }
.bline { display: grid; grid-template-columns: 28px 1fr 1fr 28px; gap: 10px; align-items: center; }
.bline .eq { color: var(--muted); text-align: right; font-family: var(--paper); }
.bline .pv { min-height: 28px; font-size: 17px; color: var(--ink2); }
.bline .pv.err { font: 13px var(--ui); color: var(--bad); }
.kbdhelp { font: 12.5px var(--ui); color: var(--muted); margin-top: 6px; }

/* order */
.order { display: grid; gap: 6px; margin: 8px 0; }
.ordl { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); padding: 6px 8px; font: 14px var(--mono); cursor: grab; }
.ordl.drag { opacity: .4; }
.ordl .grip { color: var(--faint); }
.ordl .mv { margin-left: auto; display: flex; gap: 2px; }

/* circuits */
.circ { border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); margin: 10px 0; position: relative; }
.circ svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.circ .pal { display: flex; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--raise); flex-wrap: wrap; font: 13px var(--ui); align-items: center; }
.circ .pal .btn { height: 28px; padding: 0 10px; font-size: 13px; }
.gate path, .gate circle.bub { fill: var(--sheet); stroke: var(--ink); stroke-width: 2; }
.gate.sel path, .gate.sel circle.bub { stroke: var(--accent); }
.gate text { font: 10px var(--ui); fill: var(--muted); }
.pin { fill: var(--sheet); stroke: var(--ink2); stroke-width: 1.5; cursor: crosshair; }
.pin:hover, .pin.hot { fill: var(--accent); stroke: var(--accent); }
.wire { stroke: var(--ink); stroke-width: 2; fill: none; }
.wire.hit { stroke: transparent; stroke-width: 12; cursor: pointer; }
.wire.hit:hover + .wire, .wire.sel { stroke: var(--accent); }
.wire.ghost { stroke: var(--accent); stroke-dasharray: 5 4; }
.wire:not(.hit), .term text, .gate text { pointer-events: none; }
.term text { font: 600 15px var(--paper); fill: var(--ink); }
.glabel { font: 600 13px var(--paper); fill: var(--ink); }
.term circle { fill: var(--ink); }

/* ---------- results ---------- */
.result { margin-top: 18px; border-top: 2px solid var(--ink); padding-top: 14px; font-family: var(--ui); font-size: 14.5px; }
.score { display: flex; align-items: baseline; gap: 10px; }
.score b { font: 700 22px var(--paper); }
.score.full b { color: var(--ok); }
.score.zero b { color: var(--bad); }
.score.part b { color: var(--warn); }
.pts { margin: 10px 0; display: grid; gap: 6px; }
.pt { display: grid; grid-template-columns: 22px 1fr auto; gap: 2px 8px; align-items: baseline; }
.pt .ptext p { margin: 0; }
.pt .mk { font-weight: 700; }
.pt .mk.y { color: var(--ok); }
.pt .mk.n { color: var(--bad); }
.pt .why { grid-column: 2 / 4; color: var(--muted); font-size: 13px; margin-top: -4px; }
.model { margin-top: 10px; padding: 10px 14px; background: var(--raise); border: 1px solid var(--line); border-radius: 4px; }
.model h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.improve { margin-top: 8px; color: var(--ink2); }
.marking { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 16px; font-family: var(--ui); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

/* ---------- session chrome ---------- */
.sesshead { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.sesshead .kind { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sesshead h1 { font-size: 20px; }
.sesshead .prog { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.timer { font: 600 20px var(--mono); color: var(--ink); }
.timer.low { color: var(--bad); }
.pips { display: flex; gap: 3px; margin-top: 4px; justify-content: flex-end; }
.pips i { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.pips i.done { background: var(--ink2); }
.pips i.cur { background: var(--accent); }
.plan { margin-top: 22px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.plan .step { padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; padding: 26px 30px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.bigcard { text-align: left; max-width: 640px; margin: 40px auto; }
.lede { font-size: 16px; color: var(--ink2); }

/* lesson blocks */
.lb { font: 16px/1.6 var(--paper); }
.lb .kind { font: 600 12px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.lb h3 { font: 600 17px var(--ui); margin: 0 0 8px; }
.steps { display: grid; gap: 10px; margin-top: 12px; }
.wstep { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.wstep .why { color: var(--ink2); font-size: 14.5px; background: var(--raise); border-radius: 4px; padding: 8px 12px; }
.diagram { margin: 12px 0; text-align: center; }
.diagram svg { max-width: 100%; height: auto; }

/* ---------- topics / group ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 1px 9px 1px 7px; border-radius: 10px; border: 1px solid var(--line); white-space: nowrap; }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--st-new)); }
.chip.new { --c: var(--st-new); } .chip.learning { --c: var(--st-learning); } .chip.ready { --c: var(--st-ready); }
.chip.mastered { --c: var(--st-mastered); } .chip.slipped { --c: var(--st-slipped); }
.tsec { margin-top: 26px; }
.tsec h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.tlist { background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.trow { display: grid; grid-template-columns: 76px 1fr 120px 80px 150px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink); }
.trow:first-child { border-top: 0; }
.trow:hover { background: var(--raise); text-decoration: none; }
.trow .code { font: 13px var(--mono); color: var(--muted); }
.trow .t { font-weight: 500; }
.trow .r { font: 13px var(--mono); text-align: right; color: var(--ink2); }
.trow .g { font-size: 12.5px; color: var(--muted); text-align: right; }
.trow.off { opacity: .55; }
.bar100 { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar100 i { display: block; height: 100%; background: var(--ink2); }
.grid { overflow-x: auto; background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; }
.grid table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.grid th, .grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid th.v { font: 500 11.5px var(--mono); color: var(--muted); padding: 8px 2px; text-align: center; white-space: nowrap; cursor: help; }
.grid table { width: auto; min-width: 0; }
.grid td.cell { text-align: center; padding: 4px; }
.dot { display: inline-block; width: 22px; height: 22px; border-radius: 4px; background: var(--c); color: var(--sheet); font: 600 10px/22px var(--mono); text-align: center; }
.dot.new { --c: var(--line); color: var(--muted); } .dot.learning { --c: var(--st-learning); } .dot.ready { --c: var(--st-ready); }
.dot.mastered { --c: var(--st-mastered); } .dot.slipped { --c: var(--st-slipped); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

/* forms */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input { height: 38px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sheet); outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { width: min(340px, 100%); }
.auth h1 { font: 700 20px var(--mono); margin-bottom: 18px; }
.err { color: var(--bad); font-size: 13.5px; min-height: 20px; }
.flash { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--desk); padding: 8px 16px; border-radius: 6px; font-size: 14px; z-index: 60; }
.list { display: grid; gap: 8px; }
.li { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pacegrid { columns: 2 340px; column-gap: 24px; }
.pacegrid label { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; break-inside: avoid; font-size: 14px; }
.pacegrid .sec { font-weight: 600; margin: 12px 0 4px; break-after: avoid; font-size: 13px; color: var(--muted); }
.copy { font: 12.5px var(--mono); background: var(--raise); padding: 4px 8px; border-radius: 4px; user-select: all; word-break: break-all; }

/* ---------- tutor sidebar ---------- */
.tutor { width: var(--tw, 400px); flex: none; border-left: 1px solid var(--line); background: var(--sheet); display: flex; flex-direction: column; position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); }
body.focus .tutor { top: 0; height: 100vh; }
.tutor .grab { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.tutor header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.tutor .ctx { font-weight: 400; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; font-size: 14.5px; }
.msg.user { justify-self: end; max-width: 85%; background: var(--raise); border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; }
.msg.ai { line-height: 1.6; }
.msg.ai p { margin: 0 0 8px; }
.msg.ai pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; overflow-x: auto; font-size: 13px; }
.msg.ai code { background: var(--raise); padding: 0 3px; border-radius: 3px; }
.msg.ai pre code { background: none; padding: 0; }
.msg .by { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.tutor form { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.tutor textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: var(--r); background: var(--desk); padding: 8px 10px; max-height: 160px; min-height: 38px; outline: none; }
.tutor textarea:focus { border-color: var(--accent); }
.tutor .quick { display: flex; gap: 6px; padding: 0 10px 8px; flex-wrap: wrap; }
.tutor .quick .btn { height: 28px; font-size: 12.5px; padding: 0 10px; }

@media (max-width: 860px) {
  .sheet { padding: 22px 18px 22px 48px; }
  .qnum { left: 8px; }
  .trow { grid-template-columns: 64px 1fr 100px; }
  .trow .r, .trow .g:last-child { display: none; }
  .tutor { position: fixed; right: 0; z-index: 30; width: min(100vw, 420px); }
  .wstep { grid-template-columns: 1fr; }
  .nav a { padding: 6px 6px; }
}

/* static C# highlighting in Visual Studio's colours */
.cm-keyword { color: #0000ff; } .cm-string, .cm-string-2 { color: #a31515; } .cm-comment { color: #008000; }
.cm-number { color: #098658; } .cm-variable-3, .cm-type, .cm-def { color: #2b91af; } .cm-meta { color: #808080; } .cm-atom { color: #0000ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cm-keyword, :root:not([data-theme="light"]) .cm-atom { color: #569cd6; } :root:not([data-theme="light"]) .cm-string, :root:not([data-theme="light"]) .cm-string-2 { color: #d69d85; } :root:not([data-theme="light"]) .cm-comment { color: #57a64a; } :root:not([data-theme="light"]) .cm-number { color: #b5cea8; } :root:not([data-theme="light"]) .cm-variable-3, :root:not([data-theme="light"]) .cm-type, :root:not([data-theme="light"]) .cm-def { color: #4ec9b0; } }
:root[data-theme="dark"] .cm-keyword, :root[data-theme="dark"] .cm-atom { color: #569cd6; } :root[data-theme="dark"] .cm-string, :root[data-theme="dark"] .cm-string-2 { color: #d69d85; } :root[data-theme="dark"] .cm-comment { color: #57a64a; } :root[data-theme="dark"] .cm-number { color: #b5cea8; } :root[data-theme="dark"] .cm-variable-3, :root[data-theme="dark"] .cm-type, :root[data-theme="dark"] .cm-def { color: #4ec9b0; }
