/* Chalk Talk v2. Tokens come from tokens.json (contrast-checked). Day is the default; 2 AM mode sets data-mode="night". */
:root {
  --bg: #FBF6EA; --surface: #FFFFFF; --surface2: #F3ECDA; --ink: #17140F; --ink2: #4E493F; --line: #E2D8C1;
  --accent: #2563EB; --on-accent: #FFFFFF; --brand: #FDDB25; --on-brand: #17140F;
  --ok: #157347; --warn: #9A5B00; --err: #B42318; --board: #121517;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --display: 'Dela Gothic One', 'Arial Black', system-ui, sans-serif;
  --body: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hand: 'Gochi Hand', 'Comic Sans MS', cursive;
  --shadow: 0 1px 0 rgba(23, 20, 15, .06), 0 8px 24px -12px rgba(23, 20, 15, .18);
  --tabbar-h: 64px;
  color-scheme: light;
}
:root[data-mode="night"] {
  --bg: #0E1013; --surface: #171A1F; --surface2: #1F232A; --ink: #F2F0EA; --ink2: #B4B0A6; --line: #2C313A;
  --accent: #6EA0FF; --on-accent: #0E1013; --ok: #5FD39A; --warn: #F2B84B; --err: #FF8A80;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--body); min-height: 100vh; -webkit-font-smoothing: antialiased; }
svg { width: 20px; height: 20px; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.h { font: 400 clamp(26px, 4vw, 34px)/1.05 var(--display); letter-spacing: -.01em; }
.sub { color: var(--ink2); margin: 4px 0 0; }
.small { font-size: 14px; }
.kicker { display: inline-block; font: 700 12px var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.empty { margin: 8px 0; padding: 18px; border: 2px dashed var(--line); border-radius: var(--r-md); color: var(--ink2); text-align: center; }
.empty.small { padding: 12px; font-size: 14px; }

/* logo: black lowercase wordmark with an electric-blue underline on yellow */
.logo { display: inline-grid; line-height: .86; padding: 6px 8px 8px; border-radius: 8px; background: var(--brand); color: var(--on-brand); font: 400 15px var(--display); letter-spacing: -.02em; text-decoration: none; }
.logo span:last-child { box-shadow: inset 0 -3px 0 #2563EB; padding-bottom: 2px; justify-self: start; }
.logo.big { font-size: 28px; padding: 10px 14px 14px; border-radius: 14px; justify-self: center; }
.logo.big span:last-child { box-shadow: inset 0 -5px 0 #2563EB; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; display: flex; }
.course { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.grow { flex: 1; }
.pill { font: 700 12px var(--body); padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--ink2); }
.streak { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 800; font-size: 14px; color: var(--ink); }
.streak svg { width: 18px; height: 18px; color: #E8590C; }
.credits { height: 36px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; white-space: nowrap; }
.credits.low { background: var(--err); color: #fff; }
.acct, .ib.round { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; }
.acct svg { width: 20px; height: 20px; }
#nightBtn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--ink2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.accent:hover:not(:disabled) { filter: brightness(1.08); }
.btn.brand { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.note { min-height: 0; margin: 8px 0 0; font-size: 14px; color: var(--ink2); }
.note:empty { margin: 0; }
.note.err { color: var(--err); font-weight: 600; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; color: var(--ink2); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 16px; }
textarea { resize: vertical; line-height: 1.45; }

/* progress ring */
.prog { display: inline-flex; align-items: center; gap: 10px; }
.ring { position: relative; width: 40px; height: 40px; flex: none; }
.ring svg { width: 40px; height: 40px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .trk { stroke: var(--line); }
.ring .val { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 106.8; transition: stroke-dashoffset .4s; }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.lbl { font-size: 14px; font-weight: 600; color: var(--ink2); }

/* layout */
.shell { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 60px); }
.side { border-right: 1px solid var(--line); padding: 20px 18px 40px; display: grid; align-content: start; gap: 22px; background: var(--surface); position: sticky; top: 61px; height: calc(100vh - 61px); overflow-y: auto; }
.sheet-grip, .sheet-head { display: none; }
.block { display: grid; gap: 10px; }
.block-head { display: flex; justify-content: space-between; align-items: center; }
.label { font: 800 12px var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); }
.drop { position: relative; display: flex; align-items: center; gap: 12px; padding: 18px; border: 2px dashed var(--line); border-radius: var(--r-md); background: var(--bg); cursor: pointer; font-weight: 500; color: var(--ink); }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .ico { width: 28px; height: 28px; color: var(--accent); }
.filelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.filelist li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface2); font-size: 14px; }
.filelist li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.filelist small { color: var(--ink2); }
.filelist .x { border: 0; background: none; font-size: 18px; width: 28px; height: 28px; color: var(--ink2); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks label { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 400; cursor: pointer; }
.checks input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.checks .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ink2); display: grid; place-items: center; flex: none; margin-top: 1px; }
.checks .box svg { width: 14px; height: 14px; opacity: 0; color: var(--on-accent); }
.checks input:checked + .box { background: var(--accent); border-color: var(--accent); }
.checks input:checked + .box svg { opacity: 1; }
.checks input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.checks .t { display: block; font-weight: 700; font-size: 15px; }
.checks small { display: block; color: var(--ink2); font-size: 13px; line-height: 1.35; }

.main { min-width: 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 60px 28px; }
.rail { display: flex; gap: 6px; margin-bottom: 18px; padding: 4px; background: var(--surface2); border-radius: 14px; width: fit-content; max-width: 100%; overflow-x: auto; }
.rail button { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 0; background: none; font-weight: 700; font-size: 15px; color: var(--ink2); white-space: nowrap; }
.rail button[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.rail svg { width: 18px; height: 18px; }
.pane { display: none; }
body[data-tab="learn"] [data-pane="learn"], body[data-tab="practice"] [data-pane="practice"], body[data-tab="tools"] [data-pane="tools"],
body[data-tab="progress"] [data-pane="progress"], body[data-tab="library"] [data-pane="library"] { display: block; }
.pane-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pane-head > div { min-width: 0; }
.m-hero { display: none; }

/* player */
.stage { max-width: 1040px; }
.screen { scroll-margin-top: 84px; position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--board); box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .55); aspect-ratio: 16 / 10; }
#board { display: block; width: 100%; height: 100%; }
.caption { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(8, 10, 12, .78); color: #F2F2EE; font-size: 16px; line-height: 1.4; max-height: 40%; overflow: auto; }
.caption:empty { display: none; }
.working { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(18, 21, 23, .88); color: #F2F2EE; }
.working .lbl, .working .pct { color: #F2F2EE; }
.working .trk { stroke: rgba(255, 255, 255, .2); }
.working .val { stroke: #FDDB25; }
.cover { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; background: linear-gradient(180deg, rgba(18, 21, 23, .25), rgba(18, 21, 23, .82)); color: #F2F2EE; }
.cover-btn { width: 76px; height: 76px; border-radius: 50%; border: 0; background: #FDDB25; color: #17140F; display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.cover-btn svg { width: 34px; height: 34px; margin-left: 4px; }
.cover-title { font: 400 clamp(20px, 3vw, 30px)/1.1 var(--display); max-width: 22ch; }
.cover-meta { font-size: 15px; color: #D5D8D4; }
.controls { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ib { width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; color: var(--ink); }
.ib.big { width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ib.big svg { width: 24px; height: 24px; }
.bar { flex: 1 1 120px; min-width: 80px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.status { font-size: 13px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
.ask { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--brand); color: var(--on-brand); font-weight: 800; font-size: 14px; }
.ask svg { width: 18px; height: 18px; }
.speed { width: auto; min-height: 42px; padding: 0 8px; font-weight: 700; }
.tabs-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.chapters { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.chapters button { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; text-align: left; }
.chapters button.on { border-color: var(--accent); color: var(--accent); }
.next-up { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; max-width: 1040px; }
.nu { text-align: left; padding: 14px 16px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); display: grid; gap: 2px; }
.nu b { font-size: 15px; } .nu small { color: var(--ink2); font-size: 13px; }
.nu:hover { border-color: var(--accent); }

/* practice */
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface2); gap: 4px; }
.seg button { height: 38px; padding: 0 14px; border-radius: 9px; border: 0; background: none; font-weight: 700; font-size: 14px; color: var(--ink2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.toolbar label { min-width: 120px; }
.toolbar label.grow { flex: 1 1 220px; }
.timer { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.timer span { font: 400 26px var(--display); font-variant-numeric: tabular-nums; }
.timer.low span { color: var(--err); }
.probs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-top: 16px; }
.prob { border-radius: var(--r-lg); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.prob .scenefig { display: block; background: #FFFFFF; border-bottom: 1px solid var(--line, #E2D8C1); }
.prob .scenefig svg { display: block; width: 100%; height: auto; }
.prob .fig { display: block; width: 100%; aspect-ratio: 16 / 10; background: var(--board); }
.prob .body { padding: 16px; display: grid; gap: 10px; flex: 1; align-content: start; }
.prob h3 { font-size: 18px; line-height: 1.25; }
.prob .q { margin: 0; line-height: 1.5; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ok); }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tag.unverified { color: var(--warn); }
details { border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; font-weight: 700; font-size: 14px; }
details p { margin: 8px 0 0; }
.mark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--ink2); }
.foot { margin-top: auto; }
.exam-result { margin-top: 16px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--accent); }
.exam-result h3 { font: 400 24px var(--display); }

/* tools */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.tcard { position: relative; text-align: left; padding: 16px; border-radius: var(--r-lg); border: 1.5px solid var(--line); background: var(--surface); display: grid; gap: 6px; align-content: start; min-height: 132px; }
.tcard:hover { border-color: var(--ink2); }
.tcard .ti { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--c, var(--brand)); color: #17140F; font: 400 18px var(--display); }
.tcard .ti svg { width: 22px; height: 22px; }
.tcard b { font-size: 16px; } .tcard small { color: var(--ink2); font-size: 13px; line-height: 1.4; }
.tcard .st { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
.tcard .st.live { color: var(--ok); }
.tcard.soon { background: var(--surface2); }
.section-title { font: 800 12px var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); margin: 22px 0 10px; }
.toolview { max-width: 860px; }
.backlink { margin-bottom: 8px; }
.tool-head { display: grid; gap: 6px; margin-bottom: 16px; }
.tool-head h2 { font: 400 clamp(24px, 4vw, 32px)/1.08 var(--display); }
.panel { padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: grid; gap: 12px; }
.panel + .panel { margin-top: 14px; }
.out { margin-top: 14px; display: grid; gap: 12px; }
.qa { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.qa h4 { margin: 0 0 6px; font-size: 16px; }
.qa .ans { font-weight: 800; color: var(--accent); }
.qa ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.sheet { columns: 2 280px; column-gap: 16px; }
.sheet .blk { break-inside: avoid; margin: 0 0 16px; padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.sheet h4 { margin: 0 0 6px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sheet ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.soonbox { padding: 22px; border-radius: var(--r-lg); background: var(--surface2); border: 2px dashed var(--line); display: grid; gap: 8px; }
.soonbox b { font-size: 15px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 800; letter-spacing: .04em; width: fit-content; }
.list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* flashcards */
.fc-wrap { display: grid; gap: 12px; justify-items: center; }
.fc { width: 100%; max-width: 560px; min-height: 240px; border-radius: var(--r-lg); border: 0; padding: 26px; display: grid; place-items: center; text-align: center; background: var(--board); color: #F2F2EE; font: 400 26px/1.25 var(--hand); box-shadow: var(--shadow); }
.fc.back { background: var(--surface); color: var(--ink); border: 2px solid var(--accent); font: 600 19px/1.45 var(--body); }
.fc-meta { font-size: 13px; color: var(--ink2); font-weight: 700; }
.fc-rate { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.fc-rate .btn { display: grid; justify-items: center; gap: 1px; min-width: 76px; }
.fc-rate .btn small { font-size: 11px; font-weight: 600; opacity: .7; }
.fc-prog, .fc-mast { width: 100%; max-width: 560px; height: 6px; border-radius: 99px; background: var(--line, rgba(127,127,127,.25)); overflow: hidden; }
.fc-mast { max-width: none; margin-top: 8px; }
.fc-prog span, .fc-mast span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }
.linkbtn { background: none; border: 0; color: var(--ink2); font: 600 13px var(--body); text-decoration: underline; cursor: pointer; padding: 4px; }

/* progress */
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: grid; gap: 12px; align-content: start; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h3 { font-size: 18px; }
.big-num { font: 400 52px/1 var(--display); }
.big-num small { font-size: 22px; }
.rows { display: grid; gap: 10px; }
.row .lab { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 14px; }
.row .lab span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 10px; border-radius: 5px; background: var(--surface2); overflow: hidden; margin-top: 4px; }
.track i { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width .8s; }
.track i.lo { background: var(--err); } .track i.mid { background: var(--warn); } .track i.hi { background: var(--ok); }
.callout { padding: 12px 14px; border-radius: var(--r-md); background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 15px; }
.xp-row { display: flex; gap: 18px; flex-wrap: wrap; }
.xp-row > div { min-width: 90px; }
.xp-row b { display: block; font: 400 30px var(--display); }
.xp-row span { font-size: 13px; color: var(--ink2); font-weight: 600; }
.days { display: flex; gap: 6px; }
.days i { width: 26px; height: 26px; border-radius: 7px; background: var(--surface2); display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 800; color: var(--ink2); }
.days i.on { background: #E8590C; color: #fff; }
.plan-days { display: grid; gap: 10px; }
.pday { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg); }
.pday h4 { margin: 0 0 6px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.pday.today { border-color: var(--accent); }
.pday label.task { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: 14px; }
.pday input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row label { flex: 1 1 140px; }
.grade-rows { display: grid; gap: 8px; }
.grow-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.grow-row input { min-height: 40px; }
.grow-row .x { width: 36px; height: 40px; border: 0; background: none; font-size: 20px; color: var(--ink2); }
.result { font: 400 22px/1.2 var(--display); }
.result.bad { color: var(--err); } .result.good { color: var(--ok); }

/* library */
.library { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.library li { display: flex; align-items: stretch; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.lib-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 10px 12px; display: grid; gap: 2px; }
.lib-open .kind { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.lib-open .lt { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-open small { color: var(--ink2); font-size: 12px; }
.lib-del { border: 0; background: none; width: 44px; font-size: 18px; color: var(--ink2); }
.lib-del.sure { width: auto; padding: 0 10px; color: var(--err); font-weight: 800; font-size: 13px; }

/* modals */
.modal { border: 0; border-radius: 22px; padding: 0; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.modal::backdrop { background: rgba(14, 16, 19, .6); backdrop-filter: blur(3px); }
.modal-body { padding: 24px; display: grid; gap: 12px; }
.modal-body h2 { font: 400 24px/1.12 var(--display); }
.perks { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.plans { display: grid; gap: 8px; }
.plan { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; text-align: left; padding: 12px 14px; border-radius: var(--r-md); border: 2px solid var(--line); background: var(--surface); }
.plan .pn { font-weight: 800; } .plan .pp { font-weight: 800; text-align: right; }
.plan small { grid-column: 1 / -1; color: var(--ink2); font-size: 12px; font-weight: 600; }
.plan[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.row-between { display: flex; justify-content: space-between; }
.col { display: grid; gap: 8px; }
.fine { font-size: 12px; color: var(--ink2); margin: 0; }
.danger summary { color: var(--err); }
.danger-btn { background: var(--err); border-color: var(--err); color: #fff; }
.quote { margin: 0; padding: 10px 12px; border-left: 4px solid var(--brand); background: var(--surface2); border-radius: 0 10px 10px 0; font-size: 14px; color: var(--ink2); max-height: 96px; overflow: auto; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.scrim { position: fixed; inset: 0; background: rgba(14, 16, 19, .5); z-index: 39; }
.tabbar { display: none; }

/* phone */
@media (max-width: 860px) {
  .shell { display: block; }
  .main { padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .rail { display: none; }
  .course { display: none; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; max-height: 86vh; z-index: 40; border-radius: 22px 22px 0 0; border: 0;
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -20px 60px rgba(0, 0, 0, .3);
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .side { visibility: hidden; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s .28s; }
  body.sheet-open .side { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
  .sheet-head { display: flex; justify-content: space-between; align-items: center; }
  .sheet-head h2 { font: 400 20px var(--display); }
  .lib-side { display: none !important; }
  .m-hero { display: grid; gap: 10px; margin-bottom: 14px; }
  .m-hi { margin: 0; font: 400 24px/1.1 var(--display); }
  .m-course { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); text-align: left; }
  .m-plus { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; flex: none; }
  .m-course-text { display: grid; min-width: 0; }
  .m-course-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-course-text small { color: var(--ink2); }
  .screen { border-radius: var(--r-md); aspect-ratio: auto; }
  #board { height: auto; aspect-ratio: 16 / 10; }
  .caption { position: static; border-radius: 0; background: #0B0D0F; font-size: 15px; padding: 10px 14px 12px; max-height: none; min-height: 62px; }
  .caption:empty { display: block; }
  .status { display: none; }
  .controls { gap: 6px; }
  .ib { width: 38px; height: 38px; }
  .ib.big { width: 48px; height: 48px; }
  .ask { height: 38px; padding: 0 12px; }
  .speed { min-height: 38px; padding: 0 2px; width: 56px; font-size: 14px; }
  .ask { padding: 0 10px; }
  .bar { order: 10; flex-basis: 100%; }
  .next-up { grid-template-columns: minmax(0, 1fr); }
  .pgrid { grid-template-columns: minmax(0, 1fr); }
  .timer { margin-left: 0; width: 100%; justify-content: space-between; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px)); }
  .tabbar button { display: grid; justify-items: center; gap: 2px; border: 0; background: none; padding: 6px 0; font-size: 11px; font-weight: 700; color: var(--ink2); min-width: 0; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
  .grow-row { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, .8fr) 32px; gap: 6px; }
}
@media (max-width: 420px) {
  .streak { padding: 0 8px; }
  .credits { padding: 0 10px; font-size: 13px; }
  .ask { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* illustrated problems get the full row so the scene reads like a textbook figure */
#probs .prob.scened { grid-column: 1 / -1; }


/* ---------- tutor chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: min(62vh, 640px); overflow-y: auto; padding: 4px 2px; }
.msg { max-width: min(680px, 92%); padding: 12px 14px; border-radius: 16px; display: grid; gap: 8px; min-width: 0; }
.msg p { margin: 0; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .btn { justify-self: start; }
.check { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface2); }
.check p { margin: 0; }
.choice { text-align: left; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); font-weight: 700; }
.choice.wrong { border-color: var(--err); background: color-mix(in srgb, var(--err) 12%, var(--surface)); }
.ok { color: var(--ok); } .bad { color: var(--err); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chatbar { display: flex; gap: 8px; align-items: flex-end; }
.chatbar textarea { flex: 1; min-width: 0; min-height: 46px; max-height: 160px; resize: vertical; padding: 12px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.attach { display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; flex: none; }
.attach.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.attach input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.attach .ico { width: 20px; height: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
/* ---------- grade my work ---------- */
.gradebox { display: grid; gap: 10px; margin: 6px 0 10px; }
.gradebox .drop.small { padding: 12px; }
.grade { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: var(--r-md); border: 1.5px solid var(--line); }
.grade .score { font: 400 34px/1 var(--display); }
.grade .score small { font: 700 13px var(--body); color: var(--ink2); }
.grade.good { border-color: var(--ok); } .grade.good .score { color: var(--ok); }
.grade.mid { border-color: var(--warn); } .grade.mid .score { color: var(--warn); }
.grade.bad { border-color: var(--err); } .grade.bad .score { color: var(--err); }
.steps { margin: 0; padding-left: 4px; list-style: none; display: grid; gap: 6px; }
.steps li.ok { color: var(--ink); } .steps li.ok::first-letter { color: var(--ok); }
.steps li.bad { color: var(--ink); font-weight: 600; }
.prob .foot { display: flex; flex-wrap: wrap; gap: 8px; }
.choice:disabled { opacity: 1; color: var(--ink); cursor: default; }

/* ---------- lab solver ---------- */
.tablewrap { overflow-x: auto; }
.tablewrap table { border-collapse: collapse; min-width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.tablewrap th, .tablewrap td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tablewrap th { font-weight: 800; color: var(--ink2); }
.chart { width: 100%; max-width: 640px; height: auto; display: block; }
.chart text { font: 600 12px var(--body); fill: var(--ink2); }
.chart .lab { font-weight: 800; fill: var(--ink); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--ink); stroke-width: 1.5; }
.chart .fit { stroke: var(--accent); stroke-width: 2.5; }
.chart .pt { fill: var(--brand); stroke: var(--ink); stroke-width: 1.5; }
.qa .btn.small { margin-top: 8px; }

.pday .task { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pday .task label { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--ink); }

/* ---------- lesson title cards ---------- */
.titlecard { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(37,99,235,.18), rgba(18,21,23,.0) 70%); pointer-events: none; animation: tcIn .5s cubic-bezier(.2,.8,.2,1) both; z-index: 3; }
.titlecard .tc-k { font: 400 clamp(16px, 2.6vw, 22px) var(--hand); color: #FFD43B; letter-spacing: .02em; }
.titlecard .tc-t { font: 400 clamp(24px, 5vw, 46px)/1.05 var(--display); color: #F2F2EE; max-width: 18ch; text-wrap: balance; text-shadow: 0 0 18px rgba(255,255,255,.18); }
.titlecard .tc-u { width: min(60%, 360px); height: 6px; border-radius: 6px; background: #5EC8FF; box-shadow: 0 0 14px #5EC8FF; transform-origin: left; animation: tcLine .7s .25s cubic-bezier(.2,.8,.2,1) both; }
.titlecard.out { animation: tcOut .35s ease both; }
@keyframes tcIn { from { opacity: 0; transform: scale(1.06); } to { opacity: 1; transform: none; } }
@keyframes tcLine { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes tcOut { to { opacity: 0; transform: scale(.97); } }
@media (prefers-reduced-motion: reduce) { .titlecard { animation: none; } }

/* Save as PDF */
.pdf-btn { display: inline-flex; align-items: center; gap: 6px; justify-self: start; margin: 0 0 12px; }
.pdf-btn[hidden] { display: none; }
.sheet-dlg { border: 0; border-radius: var(--r-lg, 14px); padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sheet-dlg::backdrop { background: rgba(10, 12, 16, .45); }
.pdf-form { display: grid; gap: 12px; padding: 20px; }
.pdf-form h3 { margin: 0; }
.pdf-form fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.pdf-form legend { font-weight: 700; font-size: 14px; margin-bottom: 6px; padding: 0; }
.pdf-form .opt { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.pdf-form .form-row { justify-content: flex-end; margin: 0; }

/* Answer key */
.akey { display: grid; gap: 0; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: 12px; overflow: hidden; margin-top: 10px; background: var(--surface); }
.akey-r { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px; padding: 10px 14px; border-top: 1px solid var(--line, rgba(127,127,127,.18)); }
.akey-r:first-child { border-top: 0; }
.akey-p { grid-row: span 2; align-self: start; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font: 800 12px/1 var(--body); text-transform: lowercase; margin-top: 1px; }
.akey-p.dot { background: none; border: 2px solid var(--accent); width: 12px; height: 12px; margin: 6px 6px 0; }
.akey-l { font: 600 16px/1.3 var(--body); color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.akey-v { font: 800 18px/1.2 var(--body); color: var(--ink); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.akey-v .u { font-weight: 600; color: var(--ink2); font-size: 15px; }
.akey-n { grid-column: 2 / -1; font-size: 13.5px; color: var(--ink2); line-height: 1.4; }
.akey-n.wide { grid-row: span 2; font-size: 15px; color: var(--ink); }
.akey-f { padding: 8px 14px; font-size: 12.5px; font-weight: 700; color: var(--ink2); background: var(--bg2, rgba(127,127,127,.07)); border-top: 1px solid var(--line, rgba(127,127,127,.18)); }
.akey.idea { padding: 12px 14px; display: block; }
.akey.idea p { margin: 4px 0 0; font-size: 15px; }
.akey-k { font: 800 11px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.akey-empty { color: var(--ink2); margin: 8px 0 0; }
.akey sub, .akey sup { font-size: .7em; }
/* the whole-set answer key */
.keypanel { border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: var(--r-lg, 14px); background: var(--surface); padding: 16px 18px; margin: 0 0 16px; }
.keypanel h3 { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.keypanel ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.keypanel li { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 4px 10px; }
.keypanel .kn { font: 800 20px/1.2 var(--body); color: var(--accent); }
.keypanel .kt { font: 700 15px/1.3 var(--body); }
.keypanel .akey { grid-column: 2; margin-top: 2px; }
.ptools[hidden], .keypanel[hidden] { display: none; }
.ptools { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.ptools .pdf-btn { margin: 0; }
@media (max-width: 520px) { .akey-r { grid-template-columns: 26px minmax(0,1fr); } .akey-v { grid-column: 2; text-align: left; } }
@media print { .akey { break-inside: avoid; } }

/* uploads */
.upbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.upbtns .btn { flex: 1 1 140px; }
.upbtns .btn[hidden] { display: none; }
.coursefiles { font-size: 13px; color: var(--ink2); }
.coursefiles summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.coursefiles ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.coursefiles li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ask about this problem */
.helpbox { display: grid; gap: 10px; margin: 12px 0 4px; padding: 14px; border-radius: var(--r-lg, 14px); border: 1.5px solid var(--accent); background: var(--surface); }
.helpbox[hidden] { display: none; }
.hb-head { display: grid; gap: 2px; }
.hb-chat { max-height: 420px; overflow: auto; }
.hb-chat[hidden] { display: none; }
.helpbox .chatbar { margin: 0; }

/* Problem statement layout */
.prob h3 { font-size: 20px; line-height: 1.2; letter-spacing: -.01em; }
.prob .q { display: grid; gap: 12px; }
.pstory p { margin: 0 0 8px; font-size: 15.5px; line-height: 1.6; color: var(--ink); }
.pstory p:last-child { margin-bottom: 0; }
.qv { font-weight: 700; white-space: nowrap; padding: 0 4px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); font-variant-numeric: tabular-nums; }
.qv sub, .pchip sub { font-size: .72em; }
.plab { display: block; font: 800 11px/1 var(--body); letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.pgiven { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface2); }
.pgiven .plab { width: 100%; margin-bottom: 2px; }
.pchip { font: 700 13.5px/1 var(--body); padding: 7px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pask { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.pparts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pparts li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; }
.pparts.one li { grid-template-columns: minmax(0, 1fr); }
.pnum { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font: 800 12px/1 var(--body); text-transform: lowercase; margin-top: 1px; }
.ptxt { font-size: 15.5px; line-height: 1.55; font-weight: 600; }

/* Your answer */
.myans { display: grid; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1.5px dashed var(--line); background: var(--surface); }
.ma-rows { display: grid; gap: 8px; }
.ma-row { display: grid; grid-template-columns: auto auto minmax(80px, 1fr) auto; align-items: center; gap: 8px; }
.ma-row:not(:has(.pnum)) { grid-template-columns: auto minmax(80px, 1fr) auto; }
.ma-l { font-weight: 700; white-space: nowrap; }
.ma-row input { font: 600 16px var(--body); padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg, #fff); color: var(--ink); min-width: 0; width: 100%; font-variant-numeric: tabular-nums; }
.ma-row input.ok { border-color: #1F9D55; background: color-mix(in srgb, #1F9D55 8%, transparent); }
.ma-row input.bad { border-color: #D9480F; }
.ma-u { color: var(--ink2); font-weight: 600; min-width: 2ch; }
.ma-r { grid-column: 1 / -1; font-size: 13.5px; font-weight: 700; }
.ma-r:empty { display: none; }
.ma-r.ok { color: #1F9D55; } .ma-r.no { color: #D9480F; } .ma-r.close { color: #B7791F; } .ma-r.none { color: var(--ink2); }
.ma-text { font: 500 15px/1.45 var(--body); padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg, #fff); color: var(--ink); resize: vertical; width: 100%; }
.ma-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.ma-note { margin: 0; }
.ma-note:empty { display: none; }
.ma-note .ok { color: #1F9D55; }

/* Hint */
.prob details.hint > summary, .prob details.ans > summary { cursor: pointer; font-weight: 700; }
.hint-text { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #F2B705 14%, transparent); border-left: 3px solid #F2B705; font: 500 15px/1.5 var(--body); color: var(--ink); }

/* Step-by-step written solution */
.stepsbox { display: grid; gap: 10px; padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.stepsbox[hidden] { display: none; }
.ws { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; counter-reset: none; }
.ws li { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ws li:last-child { border-bottom: 0; padding-bottom: 0; }
.ws-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15.5px; }
.ws-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent); font: 800 12px/1 var(--body); flex: none; }
.ws-part { font: 700 11px/1 var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); padding: 4px 7px; border-radius: 99px; background: var(--surface2); }
.ws-t { margin: 0 0 0 34px; font: 400 15.5px/1.55 Georgia, "Times New Roman", serif; color: var(--ink); }
.ws-m { margin: 2px 0 0 34px; padding: 10px 14px; border-radius: 10px; background: var(--surface2); display: grid; gap: 6px; font: 400 17px/1.45 "Cambria Math", "STIX Two Math", Georgia, "Times New Roman", serif; color: var(--ink); overflow-x: auto; }
.ws-m div { white-space: nowrap; }
.ws-m sub, .ws-m sup, .ws-al sub, .ws-al sup { font-size: .7em; }
.vec { font-weight: 800; }
.ws-ans { padding: 12px 14px; border-radius: 10px; border: 2px solid #1F9D55; background: color-mix(in srgb, #1F9D55 7%, transparent); }
.ws-ans .plab { color: #1F9D55; }
.ws-al { font: 700 17px/1.5 "Cambria Math", Georgia, serif; }
.ws-chk { margin: 0; font: 400 14.5px/1.5 Georgia, serif; color: var(--ink2); }
@media (max-width: 520px) { .ws-t, .ws-m { margin-left: 0; } }

/* Rich text everywhere (tutor, labs, grading, cheat sheets) */
.rich { display: grid; gap: 8px; }
.rich p { margin: 0; line-height: 1.6; }
.rich .rx-m, .ws-m { font: 400 17px/1.45 "Cambria Math", "STIX Two Math", Georgia, "Times New Roman", serif; }
.rich .rx-m { padding: 10px 14px; border-radius: 10px; background: var(--surface2); display: grid; gap: 6px; overflow-x: auto; color: var(--ink); }
.rich .rx-m div { white-space: nowrap; }
.rich sub, .rich sup, .cs-eq sub, .cs-eq sup { font-size: .7em; }
.rx-ol, .rx-ul { margin: 0; padding-left: 22px; display: grid; gap: 6px; line-height: 1.55; }
.rx-ol li::marker { font-weight: 800; color: var(--accent); }
.rx-key { padding: 10px 12px; border-radius: 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); line-height: 1.55; }
.rx-key .plab { margin-bottom: 4px; }
.rx-key.warn { border-color: #D9480F; background: color-mix(in srgb, #D9480F 8%, transparent); } .rx-key.warn .plab { color: #D9480F; }
.rx-key.ans { border-color: #1F9D55; background: color-mix(in srgb, #1F9D55 8%, transparent); font-weight: 700; } .rx-key.ans .plab { color: #1F9D55; }
.rich code { font: 600 .92em ui-monospace, Menlo, monospace; padding: 1px 5px; border-radius: 5px; background: var(--surface2); }
.msg.assistant .rich { gap: 10px; }
.qa h4 { display: flex; gap: 10px; align-items: flex-start; }
.qa h4 .ws-n { margin-top: 1px; }
details.work { margin-top: 8px; } details.work > summary { cursor: pointer; font-weight: 700; color: var(--accent); }
details.work .ws { margin-top: 10px; }
.cs-eq { font: 400 16px/1.4 "Cambria Math", Georgia, serif; }
ul.steps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
ul.steps li { display: grid; grid-template-columns: 24px minmax(0,1fr); gap: 8px; align-items: start; line-height: 1.5; }
.gs-i { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 12px; color: #fff; background: #1F9D55; }
ul.steps li.bad .gs-i { background: #D9480F; }
.fc .qv { background: transparent; padding: 0; }

/* live lesson */
.live { display: grid; gap: 14px; max-width: 760px; }
.lv-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lv-meta { display: grid; min-width: 0; } .lv-meta b { font-size: 18px; } .lv-meta span { font-size: 13px; color: var(--ink2); }
.lv-prog { height: 6px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.lv-prog i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 6px; transition: width .5s; }
.lv-feed { display: grid; gap: 14px; }
.lv-turn { display: grid; gap: 10px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.lv-turn.new { animation: lvIn .35s ease-out; }
@keyframes lvIn { from { opacity: 0; transform: translateY(8px); } }
.lv-fb { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface2); font-size: 15px; }
.lv-fb b { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.lv-fb.lv-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); } .lv-fb.lv-ok b { color: var(--ok); }
.lv-fb.lv-bad { background: color-mix(in srgb, var(--warn) 14%, transparent); } .lv-fb.lv-bad b { color: var(--warn); }
.lv-teach { font-size: 16px; line-height: 1.6; }
.lv-q { display: grid; gap: 6px; padding: 14px 16px; border-radius: 14px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); font-weight: 600; font-size: 16px; }
.lv-qk { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.lv-you { display: flex; justify-content: flex-end; } .lv-you span { max-width: 85%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--ink); color: var(--bg); }
.lv-answer { position: sticky; bottom: calc(var(--tabbar-h) + 8px); display: grid; gap: 8px; padding: 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
@media (min-width: 861px) { .lv-answer { bottom: 12px; } }
.lv-choices { display: grid; gap: 6px; } .lv-choices:empty { display: none; }
.lv-choices .choice { display: flex; gap: 10px; align-items: center; text-align: left; }
.lv-l { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--surface2); }
.lv-row { display: flex; gap: 8px; } .lv-row textarea { flex: 1; min-width: 0; resize: none; border-radius: 14px; padding: 10px 12px; border: 1px solid var(--line); background: var(--bg); }
.lv-done { display: grid; gap: 6px; padding: 16px; border-radius: 14px; background: color-mix(in srgb, var(--ok) 9%, transparent); }
.lv-done ul { margin: 0 0 6px; padding-left: 18px; } .lv-done li.lv-y::marker { color: var(--ok); }
.live-start .chips .chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
