/* The tutor page (tutor_page.html): a calm study space. Warm paper, near-black ink, the board as the one dark object. */
@font-face { font-family: "Instrument Sans"; src: url(/static/fonts/InstrumentSans-Latin.woff2) format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Newsreader; src: url(/static/fonts/Newsreader-Latin.woff2) format("woff2"); font-weight: 400 600; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --page: #f6f5f1; --side: #efede7; --surface: #fff; --raised: #fbfaf7; --bubble: #eae7e0;
  --ink: #17191c; --ink-2: #3b4048; --muted: #5b616b;
  --line: #e3e0d8; --line-2: #d8d4ca; --line-3: #b9b4a8; --hover: #e6e3db; --selected: #e0ddd5;
  --accent: #2f5bd3; --accent-ink: #22459f; --accent-soft: #e4eafa; --accent-wash: #f1f4fd;
  --primary: #17191c; --primary-hover: #000; --on-primary: #fff;
  --good: #0b7a5e; --bad: #b3261e; --focus: #2f5bd3; --board: #0f2033;
  --shadow: 0 1px 2px rgb(23 25 28 / 4%), 0 10px 30px rgb(23 25 28 / 6%);
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --serif: Newsreader, Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #131417; --side: #17191d; --surface: #1c1e22; --raised: #202328; --bubble: #26292e;
    --ink: #ecedef; --ink-2: #c7cbd1; --muted: #a4aab3;
    --line: #2b2e34; --line-2: #363a41; --line-3: #50555e; --hover: #23262b; --selected: #2b2e34;
    --accent: #9db3f2; --accent-ink: #c9d6fa; --accent-soft: #22304f; --accent-wash: #1a2238;
    --primary: #ecedef; --primary-hover: #fff; --on-primary: #131417;
    --good: #5cc9a7; --bad: #ff8a80; --focus: #9db3f2;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.55 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, select, label { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.grow { flex: 1; }
.stack { display: grid; gap: 16px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.mark { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--on-primary); font: 500 21px/1 var(--serif); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.message { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.message:empty { display: none; }
.message.error { color: var(--bad); }
.boot { padding: 20px 24px; }

/* Controls */
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14.5px; }
.primary { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.secondary { border: 1px solid var(--line-2); background: var(--raised); color: var(--ink); font-weight: 500; }
.secondary:hover:not(:disabled) { background: var(--surface); border-color: var(--line-3); }
.wide { width: 100%; min-height: 52px; border-radius: 14px; font-size: 16px; }
.text-button { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--accent); font-weight: 500; font-size: 14px; }
.text-button.small { min-height: 32px; font-size: 13px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); }
.icon-button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-button.small { width: 32px; height: 32px; border-radius: 9px; }
.icon-button.tiny { width: 28px; height: 28px; border-radius: 50%; color: inherit; }
.round-button { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); }
.round-button:hover { border-color: var(--line-3); color: var(--ink); }
button:disabled { opacity: .55; cursor: default; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field label { font-size: .9rem; font-weight: 600; }
.field small { font-size: .8rem; color: var(--muted); }
.input { width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); }
textarea.input { min-height: 84px; resize: vertical; }
.input:hover { border-color: var(--line-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }

/* Before sign-in */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.gate-card { width: 100%; max-width: 460px; display: grid; gap: 16px; justify-items: start; }
.gate-card h1 { font: 500 2rem/1.1 var(--serif); letter-spacing: -.02em; }
.welcome { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 440px); gap: clamp(32px, 7vw, 104px); max-width: 1160px; margin: 0 auto; }
.welcome h1 { font: 500 clamp(2.4rem, 5vw, 3.7rem)/1.04 var(--serif); letter-spacing: -.025em; margin: 32px 0 18px; max-width: 620px; }
.lede { font-size: 1.12rem; line-height: 1.6; color: var(--ink-2); max-width: 520px; }
.welcome-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: var(--ink-2); font-size: .95rem; }
.welcome-points li { display: flex; gap: 12px; align-items: baseline; }
.welcome-points li::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); transform: translateY(-2px); }
/* The app: lessons and account beside the conversation */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 16px 12px 12px; background: var(--side); border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 2px 0 6px; }
.new-question { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; }
.new-question:hover { border-color: var(--line-3); }
.side-section { display: grid; gap: 2px; min-width: 0; }
.side-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 2px 10px; }
.side-heading h2 { font-size: 12px; font-weight: 600; color: var(--muted); }
.side-empty { font-size: 13px; color: var(--muted); padding: 0 10px; }
.history { display: grid; gap: 1px; min-width: 0; }
.history-item { display: grid; gap: 1px; width: 100%; min-width: 0; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; }
.history-item:hover { background: var(--hover); }
.history-item[aria-current="true"] { background: var(--selected); }
.history-item strong { font-size: 14px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-item[aria-current="true"] strong { font-weight: 600; }
.history-item small { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 2px 0 6px; border-top: 1px solid var(--line); }
.account-initial { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 600; text-transform: uppercase; }
#account-email { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: none; }

/* Home: the question first */
.home { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: clamp(48px, 13vh, 128px) 24px 48px; display: flex; flex-direction: column; }
.greeting { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.home h1 { font: 500 clamp(2.1rem, 4.4vw, 3rem)/1.06 var(--serif); letter-spacing: -.02em; margin-bottom: 28px; }
.composer { background: var(--surface); border: 1px solid var(--line-2); border-radius: 22px; box-shadow: var(--shadow); padding: 16px 12px 12px 18px; transition: border-color .15s; }
.composer:focus-within { border-color: var(--line-3); }
.composer textarea { display: block; width: 100%; min-height: 76px; max-height: 40vh; padding: 0 6px 0 0; border: 0; outline: 0; resize: none; background: transparent; font-size: 17px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--muted); opacity: .85; }
.composer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip, .chip-select select { height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--page); color: var(--ink-2); font-size: 13.5px; font-weight: 500; max-width: 100%; }
.chip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip:hover, .chip-select select:hover { border-color: var(--line-3); color: var(--ink); }
.chip-select select { appearance: none; padding-right: 30px; background: var(--page) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868b93' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center; }
.send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); }
.send:hover:not(:disabled) { background: var(--primary-hover); }
.photo-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin-top: 10px; padding: 3px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; }
.photo-thumb { flex: none; height: 48px; max-width: 96px; object-fit: contain; border-radius: 9px; background: var(--surface); }
#photo-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer-status { margin: 10px 6px 0; }
.composer-note { margin: 8px 6px 0; font-size: 12.5px; color: var(--muted); }
.check-ins { margin-top: 48px; }
.check-ins h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.counts { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
#check-ins ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
#check-ins li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 13.5px; color: var(--ink-2); }
#check-ins li strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 14.5px; }
#check-ins > p { font-size: 14px; }
.fine { margin-top: 12px; font-size: 12.5px; color: var(--muted); }

/* A lesson: the question, then the tutor's answer */
.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: var(--page); }
.thread-head h1 { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-head .text-button { flex: none; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.tag:empty { display: none; }
.thread-body { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 28px 32px; display: flex; flex-direction: column; gap: 26px; }
.turn-user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bubble { max-width: min(640px, 88%); padding: 13px 18px; border-radius: 20px 20px 6px 20px; background: var(--bubble); font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn-meta { font-size: 12px; color: var(--muted); }
.turn-tutor { display: flex; gap: 14px; align-items: flex-start; }
.tutor-avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 500 19px/1 var(--serif); }
.reply { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.reply-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.prep-steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.prep-steps:empty { display: none; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(250px, 1fr); gap: 16px; align-items: start; }
.lesson-video { min-width: 0; }
video { display: block; width: 100%; height: auto; background: var(--board); border-radius: 14px; }
.board-svg { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--board); border-radius: 14px; }
.board-svg path { stroke-linecap: round; stroke-linejoin: round; }
.board-say { min-height: 1.55em; margin: 10px 2px 0; font-size: 15px; }
.steps { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 0; }
.steps button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--raised); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; }
.steps button:hover:not(:disabled) { border-color: var(--line-3); background: var(--surface); }
.steps button:disabled { opacity: .45; cursor: default; }
.steps span { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.playback { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.playback label { display: flex; gap: 8px; align-items: center; }
.playback select { height: 36px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); }
.lesson-notes { min-width: 0; padding: 6px 14px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.notes-head h2 { font-size: 14px; font-weight: 600; }
.notes-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.notes-tabs [role="tab"] { height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.notes-tabs [aria-selected="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px var(--accent); }
.notes-panel { max-height: 420px; overflow: auto; overscroll-behavior: contain; padding: 4px 0; }
.notes-list { list-style: none; margin: 0; padding: 0; }
.note-entry { margin: 6px 0; padding: 10px 12px; border-radius: 10px; overflow-wrap: anywhere; }
.note-entry[aria-current="true"] { background: var(--accent-soft); }
.note-entry p { white-space: pre-wrap; margin: 4px 0 6px; font-size: 14px; }
.note-image { max-width: 100%; overflow-x: auto; }
.note-entry img { display: block; max-width: none; height: auto; border-radius: 6px; }
.note-entry details { margin-top: 6px; }
.note-entry summary, .note-time { font-size: 12px; color: var(--muted); font-weight: 500; }
.note-math { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; font: 16px/1.5 var(--serif); }
#notes-status { margin-top: 8px; }
.answer { padding: 14px 18px; border: 1px solid var(--accent-soft); border-radius: 14px; background: var(--accent-wash); font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer:empty, .warnings:empty { display: none; }
.warnings { font-size: 12.5px; color: var(--muted); }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.feel { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 12px; background: var(--side); }
.feel button { min-height: 38px; padding: 0 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.feel button:hover { color: var(--ink); }
.feel button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.more-feedback { padding-top: 12px; border-top: 1px solid var(--line); }
.more-feedback summary { min-height: 32px; font-size: 14px; font-weight: 600; }
.more-feedback summary::marker { color: var(--muted); }
#feedback { max-width: 660px; margin-top: 12px; }
#video-turn { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#video-turn[data-streaming] .lesson-layout { grid-template-columns: minmax(0, 1fr); }
#video-turn[data-streaming] :is(#answer, .lesson-notes, #feedback-panel, .reply-actions, #playback-controls) { display: none; }

/* A conversation's turns, and a written answer */
.turn { display: flex; flex-direction: column; gap: 18px; }
.turn + .turn { padding-top: 26px; border-top: 1px solid var(--line); }
.turn-reply { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.writing { color: var(--muted); font-size: 15px; }
.writing::after { content: "…"; display: inline-block; width: 1.2em; animation: writing 1.2s steps(4, end) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes writing { from { width: 0; } to { width: 1.2em; } }
.written { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.written p { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; }
.written-prose { color: var(--ink-2); }
.written-step { font: 18px/1.55 var(--serif); }
.step-number { flex: none; width: 22px; font: 12px/1 var(--sans); color: var(--muted); text-align: right; }
.written-step > span:nth-child(2), .written-prose > span:first-child { flex: 1; min-width: 0; }
.mark-tags { display: inline-flex; gap: 4px; flex: none; }
.mark-tag { padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font: 700 12px/1.4 var(--sans); }
.written-final { margin-top: 8px; padding: 12px 16px !important; border: 1px solid var(--accent-soft); border-radius: 14px; background: var(--accent-wash); font-size: 16.5px; }
.written-label { flex: none; font-weight: 700; }
.written sup { font-size: .7em; line-height: 0; }
.video-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.video-card-text { flex: 1; min-width: 200px; color: var(--ink-2); white-space: pre-wrap; }
.wait-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.wait-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

/* Is this your question? A photo's question read back before it is solved */
.photo-check { padding: 22px 24px 20px; }
.photo-check h2 { margin: 0 0 14px; font-size: 20px; }
.photo-check-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
#photo-check-image { width: 100%; max-height: 50dvh; object-fit: contain; border-radius: 12px; background: var(--side); }
.photo-unsure { margin: 10px 0 0; padding-left: 20px; color: var(--accent-ink); font-size: 14px; }
.photo-unsure:empty { display: none; }
.photo-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* The question box stays at the foot of a lesson */
.dock { position: sticky; bottom: 0; z-index: 4; padding: 14px 28px 18px; background: linear-gradient(to bottom, transparent, var(--page) 30%); }
.dock:empty { display: none; }
.dock:has(> .message:empty) { display: none; }
.dock > .message { max-width: 820px; margin: 0 auto; }   /* a study view's status line, docked alone */
.dock .composer-wrap { max-width: 820px; margin: 0 auto; }
.dock .composer textarea { min-height: 0; height: 28px; }
.dock .composer-note { display: none; }

/* Settings */
.sheet { width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(0 0 0 / 30%); }
.sheet::backdrop { background: rgb(23 25 28 / 45%); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sheet-head h2 { flex: 1; font: 500 1.75rem/1.1 var(--serif); }
.sheet-head .message { font-size: .8rem; max-width: 50%; }
.sheet-section { display: grid; gap: 14px; padding: 18px 24px 20px; border-bottom: 1px solid var(--line); }
.sheet-section h3 { font-size: 13px; font-weight: 600; color: var(--muted); }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 16px 24px 20px; }
.sheet-foot > :first-child { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.switch-row { display: flex; gap: 16px; align-items: flex-start; }
.switch-row > div { flex: 1; display: grid; gap: 2px; }
.switch { position: relative; flex: none; width: 52px; height: 30px; padding: 0; border: 0; border-radius: 999px; background: var(--line-3); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: var(--on-primary); }

/* First-run questions */
.onboarding { min-height: 100vh; min-height: 100dvh; max-width: 580px; margin: 0 auto; display: flex; flex-direction: column; }
.ob-head { display: flex; align-items: center; gap: 10px; padding: 12px; }
.ob-progress { flex: 1; display: flex; gap: 4px; }
.ob-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line-2); }
.ob-progress span.done { background: var(--ink); }
.ob-body { flex: 1; padding: 16px 22px 12px; }
.ob-count { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.ob-body h1 { font: 500 clamp(1.85rem, 5vw, 2.35rem)/1.12 var(--serif); letter-spacing: -.015em; margin-bottom: 10px; }
.ob-body h1:focus { outline: none; }
.ob-why { font-size: 15px; line-height: 1.5; color: var(--muted); margin-bottom: 22px; }
.ob-sub { display: block; font-size: 15px; font-weight: 600; margin: 24px 0 10px; }
.ob-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 10px 0 6px; }
.ob-cards { display: grid; gap: 10px; }
.ob-card, .ob-chip { position: relative; display: flex; align-items: center; border: 1.5px solid var(--line); background: var(--surface); }
.ob-card { gap: 12px; padding: 14px 16px; border-radius: 16px; }
.ob-card:hover, .ob-chip:hover { border-color: var(--line-3); }
.ob-card:has(:checked) { border-color: var(--ink); }
.ob-card:focus-within, .ob-chip:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.ob-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ob-text { flex: 1; display: grid; gap: 2px; }
.ob-text strong { font-size: 16px; font-weight: 600; }
.ob-text small { font-size: 13px; color: var(--muted); }
.ob-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-3); background: var(--surface); }
.ob-card:has(:checked) .ob-mark { border: 7px solid var(--ink); }
.ob-card.multi .ob-mark { border-radius: 7px; }
.ob-chips { display: grid; gap: 6px; }
.ob-chips.wrap { display: flex; flex-wrap: wrap; }
.ob-chip { justify-content: center; min-height: 46px; padding: 0 14px; border-radius: 12px; font-weight: 600; text-align: center; }
.ob-chip:has(:checked) { background: var(--ink); border-color: var(--ink); color: var(--page); }
.ob-note-field { margin-top: 14px; }
.ob-summary { margin: 0 0 8px; padding: 2px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.ob-summary div { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ob-summary div:last-child { border-bottom: 0; }
.ob-summary dt { flex: none; width: 116px; font-size: 13px; color: var(--muted); }
.ob-summary dd { margin: 0; font-size: 15px; font-weight: 500; }
.ob-foot { display: grid; gap: 4px; padding: 12px 16px 22px; }

/* Tutors: one colour each, for their face, their name and their notes */
.area-algebra { --tutor: #2f5bd3; --tutor-soft: #e4eafa; --tutor-ink: #22459f; }
.area-geometry { --tutor: #0b7a5e; --tutor-soft: #ddf0e8; --tutor-ink: #085c47; }
.area-statistics { --tutor: #a9520f; --tutor-soft: #f6e6d7; --tutor-ink: #7f3c08; }
.area-calculus { --tutor: #7a4cc2; --tutor-soft: #ece4f8; --tutor-ink: #5c3597; }
@media (prefers-color-scheme: dark) {
  .area-algebra { --tutor: #9db3f2; --tutor-soft: #22304f; --tutor-ink: #c9d6fa; }
  .area-geometry { --tutor: #6fd0b0; --tutor-soft: #183a31; --tutor-ink: #a7e6d1; }
  .area-statistics { --tutor: #f0a868; --tutor-soft: #3a2a1c; --tutor-ink: #f6c9a0; }
  .area-calculus { --tutor: #c3a6f0; --tutor-soft: #2e2445; --tutor-ink: #dccaf7; }
}
.tutor-face { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--tutor-soft); color: var(--tutor); font: 500 17px/1 var(--serif); }
.tutor-face.small { width: 24px; height: 24px; font-size: 14px; }
.tutor-face.turn-face { width: 32px; height: 32px; font-size: 19px; }
.tutor-face.large { width: 76px; height: 76px; font-size: 42px; }
.reply-name[class*="area-"] { color: var(--tutor-ink); }

/* The sidebar's places */
.side-nav, .side-list { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; font-size: 14px; }
.nav-item > svg { flex: none; color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="true"] { background: var(--selected); }
.nav-text { display: grid; min-width: 0; line-height: 1.25; }
.nav-text strong { font-weight: 600; }
.side-nav .nav-text strong { font-weight: 500; }
.nav-text small { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Home: what to do next, and the tutors */
.home-label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.picked { margin-top: 44px; }
.picked-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-align: left; }
.pick:hover { border-color: var(--line-3); box-shadow: var(--shadow); }
.pick-who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--tutor-ink); }
.pick-name { font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.pick-why { font-size: 13px; line-height: 1.45; color: var(--muted); }
.home-tutors { margin-top: 28px; }
.home-tutor-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tutor-chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); color: var(--ink); font-size: 13.5px; font-weight: 500; }
.tutor-chip:hover { border-color: var(--line-3); background: var(--surface); }

/* Study views: a tutor's page, practice, progress */
.study-view { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 44px 32px 56px; display: flex; flex-direction: column; gap: 28px; }
.study-view:focus { outline: none; }
.view-title { font: 500 clamp(2rem, 4vw, 2.75rem)/1.05 var(--serif); letter-spacing: -.02em; }
.study-view h2 { margin-bottom: 12px; font-size: 17px; font-weight: 600; }
.tutor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.tutor-words { flex: 1; min-width: 240px; display: grid; gap: 4px; }
.tutor-words h1 { font: 500 44px/1.05 var(--serif); letter-spacing: -.02em; }
.tutor-words h1:focus { outline: none; }
.tutor-role { font-size: 13px; font-weight: 600; color: var(--tutor-ink, var(--accent)); }
.tutor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tutor-note { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 24px 26px; border-radius: 20px; background: var(--tutor-soft); }
.tutor-note-text { flex: 1 1 380px; min-width: 0; display: grid; gap: 8px; }
.tutor-says { font: 22px/1.35 var(--serif); }
.stands { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.stand { padding: 18px 18px 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stand h2 { margin: 0 0 2px; font-size: 15px; }
.stand-row { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.stand-empty { padding: 10px 0 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.topics { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.topics h2 { padding: 16px 20px 0; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px 20px; border-top: 1px solid var(--line); font-size: 14.5px; }
.topic-evidence { font-size: 13px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.status::before, .swatch { content: ""; display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }
.status-strong::before, .swatch.status-strong, .bar-part.status-strong, .dot.right { background: #2f5bd3; }
.status-learning::before, .swatch.status-learning, .bar-part.status-learning { background: #a9bef0; }
.status-needs_work::before, .swatch.status-needs_work, .bar-part.status-needs_work, .dot.missed { background: #d9822b; }
.status-none::before, .swatch.status-none { border: 1.5px solid var(--line-3); }
.tutor-recent { display: grid; gap: 2px; }
.recent-link { min-height: 40px; padding: 8px 0; border: 0; background: none; color: var(--accent); font-size: 14.5px; text-align: left; overflow-wrap: anywhere; }
.recent-link:hover { text-decoration: underline; }
.practice-view { max-width: 760px; }
.practice-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.practice-title { flex: 1; min-width: 160px; font-weight: 600; text-align: center; }
.practice-dots { display: flex; gap: 5px; }
.dot { width: 22px; height: 6px; border-radius: 3px; background: var(--line-2); }
.practice-wait { display: grid; gap: 12px; padding: 40px 0; }
.practice-wait h1 { font: 500 2rem/1.1 var(--serif); }
.practice-wait h1::after { content: "…"; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; animation: writing 1.2s steps(4, end) infinite; }
.practice-card { display: flex; flex-direction: column; gap: 16px; }
.practice-question { font: 400 clamp(1.6rem, 3.6vw, 2.2rem)/1.3 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.practice-question sup { font-size: .65em; }
.practice-form { display: grid; gap: 10px; }
.practice-input { min-height: 58px; font: 22px/1.3 var(--serif); }
.practice-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.key { min-width: 44px; height: 40px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--raised); color: var(--ink); font: 17px var(--serif); }
.key:hover { border-color: var(--line-3); background: var(--surface); }
.practice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.practice-feedback { display: grid; gap: 12px; }
.practice-say { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; font-size: 15px; line-height: 1.55; }
.practice-say strong { flex: none; }
.say-hint { background: #fff6e6; color: #4a3a1c; }
.say-wrong { background: #f8e6d5; color: #5a2c05; }
.say-right { background: var(--accent-soft); color: var(--accent-ink); }
@media (prefers-color-scheme: dark) {
  .say-hint { background: #3a3020; color: #f3dfb4; }
  .say-wrong { background: #3a2a1c; color: #f6c9a0; }
}
.remember-note { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 14px; background: var(--accent-wash); }
.remember-note p { flex: 1 1 300px; }
.progress-body { display: flex; flex-direction: column; gap: 28px; }
.week { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stat { flex: 1 1 180px; display: grid; gap: 4px; padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-value { font: 34px/1.1 var(--serif); }
.stat-extra { font: 14px var(--sans); color: var(--ink-2); }
.next-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.next-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line); }
.next-row:first-child { border-top: 0; }
.next-text { flex: 1; min-width: 220px; display: grid; gap: 2px; }
.by-tutor { display: grid; gap: 8px; }
.by-tutor h2 { margin-bottom: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; font-size: 12.5px; color: var(--ink-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.tutor-row { display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 18px; align-items: center; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-align: left; }
.tutor-row:hover { border-color: var(--line-3); }
.tutor-row-who { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.bar { display: flex; gap: 2px; height: 12px; overflow: hidden; border-radius: 6px; background: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Narrow screens: the lessons list slides in */
@media (min-width: 861px) { .only-narrow { display: none; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw); height: 100%; transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; }
  .app[data-menu] .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 40px rgb(0 0 0 / 25%); }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 35%); }
  .topbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 6px 8px; background: var(--page); }
  .thread-head { top: 56px; min-height: 52px; padding: 8px 16px; }
  .thread-body { padding: 18px 14px 24px; gap: 20px; }
  .home { padding: 28px 18px 32px; }
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .study-view { padding: 24px 16px 40px; gap: 22px; }
  .topic-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; padding: 10px 16px; }
  .topic-row .status { grid-column: 1; }
  .topic-evidence { grid-column: 1 / -1; }
  .tutor-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .tutor-avatar, .tutor-face.turn-face { display: none; }
  .bubble { max-width: 92%; }
  .dock { padding: 10px 10px 12px; }
  .welcome { grid-template-columns: minmax(0, 1fr); place-items: start stretch; gap: 28px; }
  .welcome h1 { margin-top: 24px; }
}
@media (max-width: 560px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 22px; }
  .composer { padding: 14px 10px 10px 14px; }
  #lesson-style { display: none; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .photo-check-grid { grid-template-columns: minmax(0, 1fr); }
  #photo-check-image { max-height: 30dvh; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
