/* BECE Tutor — design tokens, then layout, then components. */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #eef1ed;
  --ink: #17201b;
  --ink-2: #3d4a43;
  --muted: #66736c;
  --line: #e2e6e1;
  --line-strong: #cfd6cf;
  --brand: #0b5d45;
  --brand-2: #0f7a5a;
  --brand-soft: #e5f2ec;
  --brand-ink: #ffffff;
  --gold: #a87f00;
  --gold-soft: #fbf3d6;
  --red: #b42318;
  --red-soft: #fdecea;
  --blue: #1d4f91;
  --blue-soft: #e8f0fb;
  --ok: #0f7a5a;
  --ok-soft: #e3f4ec;
  --board: #183d30;
  --board-2: #12302a;
  --chalk: #f3f1e8;
  --chalk-dim: #a9bdb2;
  --chalk-accent: #f2c94c;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .06);
  --shadow: 0 1px 3px rgba(16, 24, 20, .08), 0 8px 24px rgba(16, 24, 20, .06);
  --focus: 0 0 0 3px rgba(15, 122, 90, .28);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #161d1a;
    --surface-2: #1b2420;
    --surface-3: #222c27;
    --ink: #e8eee9;
    --ink-2: #c3cec7;
    --muted: #93a39a;
    --line: #26312c;
    --line-strong: #34413a;
    --brand: #2fa37b;
    --brand-2: #3cb88d;
    --brand-soft: #173329;
    --brand-ink: #06140f;
    --gold: #e0b43a;
    --gold-soft: #2e2711;
    --red: #f07a6e;
    --red-soft: #3a1c19;
    --blue: #8ab4f0;
    --blue-soft: #18263a;
    --ok: #4cc497;
    --ok-soft: #14302a;
    --board: #14322a;
    --board-2: #0f2620;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --focus: 0 0 0 3px rgba(60, 184, 141, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: none; box-shadow: var(--focus); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.icon svg { width: 100%; height: 100%; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
.note { margin: 0; font-size: .82rem; color: var(--muted); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidenav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-size: 1.25rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.02rem; }
.brand-text small { color: var(--muted); font-size: .78rem; }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tabs button {
  display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 550;
}
.tabs button .icon { font-size: 1.15rem; color: var(--muted); }
.tabs button:hover { background: var(--surface-3); }
.tabs button.active { background: var(--brand-soft); color: var(--brand); }
.tabs button.active .icon { color: var(--brand); }
.sidenav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line); }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.online::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status.offline::before { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 30px; height: 18px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--gold); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

.main { min-width: 0; }
.page { max-width: 980px; margin: 0 auto; padding: 28px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
.page-wide { max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.55rem; font-weight: 700; }
.page-head h1.title-sm { font-size: 1.25rem; margin-top: 6px; }
.lede { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
.eyebrow { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }

/* ---------- surfaces & controls ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.chip, .pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.chip-gold, .pill.sample, .chip.pace-slow { background: var(--gold-soft); color: var(--gold); }
.pill.mine { background: var(--blue-soft); color: var(--blue); }
.pill.tocheck { background: var(--red-soft); color: var(--red); }
.chip.pace-steady { background: var(--surface-3); color: var(--ink-2); }
.chip.pace-fast { background: var(--ok-soft); color: var(--ok); }

.btn, .offer-buttons > button, .pq-controls button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: .92rem; transition: background .15s, border-color .15s;
}
.btn:hover, .offer-buttons > button:hover:not(:disabled), .pq-controls button:hover:not(:disabled) { background: var(--surface-3); }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--brand); font-weight: 600; }
.btn-primary, .primary, .offer-buttons > button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover, .primary:hover:not(:disabled), .offer-buttons > button.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.primary:disabled, .btn:disabled, .pq-controls button:disabled { opacity: .45; }
.btn-secondary, .offer-buttons > button:not(.primary):not(.link-btn) { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); color: var(--brand); background: var(--surface); }
.btn-secondary:hover, .offer-buttons > button:not(.primary):not(.link-btn):hover { background: var(--brand-soft); }
.btn-ghost, .pq-controls button { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.link-btn { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--red); }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 1.1rem;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); }
.icon-btn:disabled { opacity: .4; }
.icon-btn.listening { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(180, 35, 24, .18); } }

select, .field input, .field textarea, .ask-form input, .question input, textarea.written {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background-color: var(--surface); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366736c' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.select-field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.select-field select { font-size: .95rem; font-weight: 500; color: var(--ink); min-width: 200px; }
.select-field.compact { flex-direction: row; align-items: center; gap: 8px; }
.voice-field select { min-width: 0; width: 100%; }
.select-field.compact select { min-width: 0; padding-top: 6px; padding-bottom: 6px; }
.lesson-picker select { font-size: 1.2rem; font-weight: 650; border: 0; padding: 2px 32px 2px 0; background-color: transparent; background-position: right 4px center; max-width: min(640px, 80vw); }
.lesson-picker select:focus { box-shadow: none; text-decoration: underline; }

/* ---------- chalkboard ---------- */
.board {
  position: relative; overflow: hidden; color: var(--chalk); border-radius: var(--radius-lg); padding: 26px 30px 32px; min-height: 290px;
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(255, 255, 255, .06), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 28px),
    linear-gradient(160deg, var(--board), var(--board-2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), var(--shadow);
}
.board::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: linear-gradient(90deg, #8a6d3b, #a6844a, #8a6d3b); opacity: .55; }
.board .board-title { font-size: 1rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--chalk-accent); margin-bottom: 16px; }
.board-lines { display: flex; flex-direction: column; gap: 10px; }
.board-line { font-size: clamp(1.1rem, 2.3vw, 1.6rem); line-height: 1.35; overflow-wrap: anywhere; font-weight: 500; }
.board-line.fresh { animation: chalk-in .5s ease-out; }
.board-line .rule { display: inline-block; margin-left: 12px; font-size: .62em; font-weight: 400; color: var(--chalk-dim); }
.board-line.wrong-line { color: #ffb4a6; }
.board.gotcha { box-shadow: inset 0 0 0 2px var(--chalk-accent), var(--shadow); }
.board.gotcha .board-title { color: #ffb4a6; }
.board.small { min-height: 0; padding: 18px 22px 24px; }
.board.small .board-line { font-size: clamp(1rem, 2vw, 1.3rem); }
@keyframes chalk-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.lesson { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.caption { margin: 0; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 1.05rem; line-height: 1.6; color: var(--ink); min-height: 3.4em; box-shadow: var(--shadow-sm); }

.offer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.offer-label { font-weight: 600; color: var(--brand); font-size: .92rem; }
.offer-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }

.player { display: flex; align-items: center; gap: 16px; padding: 10px 14px; flex-wrap: wrap; }
.player-buttons { display: flex; align-items: center; gap: 6px; }
.play-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-size: 1.2rem; box-shadow: var(--shadow-sm); }
.play-btn:hover { background: var(--brand-2); }
.player-progress { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress { flex: 1; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s; }
.step-count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- side panel & chat ---------- */
.side-panel { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 10px; padding: 16px; height: calc(100vh - 40px); max-height: 760px; min-height: 420px; }
.side-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.side-head h3 { font-size: 1rem; }
.side-head .muted { font-size: .84rem; }
.sheet-only, .fab { display: none; }
.resume-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--gold-soft); font-size: .88rem; font-weight: 600; }

.chat-panel { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.page-chat { height: 100vh; padding-bottom: 20px; }
.page-chat .chat-panel { padding: 16px; flex: 1; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 140px; padding: 4px 4px 4px 0; scroll-behavior: smooth; }
.bubble { padding: 10px 14px; border-radius: 14px; line-height: 1.55; max-width: 88%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.bubble.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.bubble.tutor { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.thinking { color: var(--muted); font-style: italic; }
.bubble .source { display: block; font-size: .72rem; color: var(--muted); margin-top: 6px; font-style: normal; }
.bubble.me .source { color: inherit; opacity: .8; }
.bubble-photo { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; white-space: normal; }
.chips button { font-size: .8rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2); border-radius: 999px; padding: 4px 12px; }
.chips button:hover { border-color: var(--brand); color: var(--brand); }
.lesson-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: .84rem; font-weight: 600; background: var(--brand-soft); border: 1px solid transparent; color: var(--brand); border-radius: var(--radius-sm); padding: 6px 10px; white-space: normal; text-align: left; }
.lesson-link:hover { border-color: var(--brand); }
.lesson-link.soon { background: var(--surface-3); color: var(--muted); cursor: default; font-weight: 500; }
.ask-form { display: flex; gap: 8px; align-items: center; }
.ask-form input[type="text"] { flex: 1; min-width: 0; height: 44px; }
.ask-form .primary { height: 44px; }
.photo-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-preview img { max-height: 72px; border-radius: 8px; border: 1px solid var(--line); }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.examples-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin-right: 2px; }
.examples button { font-size: .85rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 14px; color: var(--ink-2); }
.examples button:hover { border-color: var(--brand); color: var(--brand); }

em.twi { font-style: italic; font-weight: 600; color: var(--brand); }
.bubble.me em.twi { color: inherit; }

/* ---------- questions ---------- */
.question { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.q-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-bottom: 8px; }
.q-text { font-size: 1.15rem; line-height: 1.55; margin-bottom: 14px; white-space: pre-wrap; font-weight: 500; }
.q-images { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.q-image { max-width: 100%; max-height: 340px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; }
.check-note { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--gold-soft); color: var(--gold); font-size: .88rem; }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.question input[type="text"] { flex: 1; min-width: 160px; font-size: 1.1rem; height: 46px; }
.question textarea.written { width: 100%; resize: vertical; margin-bottom: 8px; line-height: 1.5; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.choice { display: flex; align-items: center; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); text-align: left; font-size: 1.02rem; transition: border-color .15s, background .15s; }
.choice:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.choice.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.choice.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.choice:disabled:not(.right):not(.wrong) { opacity: .6; }
.feedback { margin: 12px 0 0; min-height: 1.4em; font-size: .95rem; }
.feedback.ok { color: var(--ok); font-weight: 600; }
.feedback.bad { color: var(--red); }
.q-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.explain-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); line-height: 1.6; white-space: pre-line; }
.explain-box.alt { background: var(--brand-soft); border-color: transparent; }
.watch-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--red-soft); color: var(--red); line-height: 1.55; display: flex; gap: 8px; align-items: flex-start; }
.model-answer { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.model-answer pre { margin: 6px 0 0; font: inherit; white-space: pre-wrap; }
.marks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.marks li { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.marks li.met { background: var(--ok-soft); border-color: transparent; }
.marks li.not-met { background: var(--red-soft); border-color: transparent; }
.mark-comment { font-size: .86rem; color: var(--muted); margin-top: 2px; }
.question-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- past questions ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pq-subject { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.pq-subject h3 { font-size: 1rem; }
.pq-set { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, transform .15s; }
.pq-set:hover { border-color: var(--brand); transform: translateY(-1px); }
.pq-set strong { font-size: .98rem; }
.pq-set > span { font-size: .84rem; color: var(--muted); }
.pq-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.pq-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pq-num { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: .88rem; font-variant-numeric: tabular-nums; }
.pq-num:hover { border-color: var(--brand); }
.pq-num.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.pq-num.done { background: var(--gold-soft); border-color: var(--gold); }
.pq-num.current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.pq-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.pq-controls #pqNext { margin-left: auto; }
.pq-done { margin: 0; }

/* ---------- check my questions ---------- */
.subject-grid.compact { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.check-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.check-head h3 { font-size: 1.05rem; }
.toggle { display: inline-flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--muted); cursor: pointer; }
.check-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.check-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-card .offer-buttons { margin-left: 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select { font-size: .98rem; font-weight: 400; color: var(--ink); }
.field textarea { resize: vertical; line-height: 1.5; }

/* ---------- small screens ---------- */
@media (max-width: 1024px) {
  .split { grid-template-columns: 1fr; }
  .side-panel:not(#learnAside) { position: static; height: 70vh; }
  /* Learn: the tutor chat becomes a sheet opened from the "Ask" button. */
  #learnAside {
    position: fixed; z-index: 40; left: auto; right: 0; bottom: 0; top: auto; width: min(480px, 100%); height: 78vh; max-height: none; min-height: 0;
    border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .25s ease; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
  }
  #learnAside.open { transform: none; }
  #view-learn .page { padding-bottom: 96px; }
  .sheet-only { display: inline-grid; }
  #view-learn .fab {
    display: inline-flex; align-items: center; gap: 8px; position: fixed; z-index: 35; right: 20px; bottom: 20px;
    padding: 12px 18px; border-radius: 999px; border: 0; background: var(--brand); color: var(--brand-ink); font-weight: 700; box-shadow: var(--shadow);
  }
}
/* ---------- write ---------- */
.write-task .write-prompt { font-size: .86rem; color: var(--ink); line-height: 1.45; }
.write-page { max-width: 880px; }
.write-task-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.write-question { font-size: 1.02rem; line-height: 1.5; font-weight: 500; }
.write-include summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.write-include ul { margin: 8px 0 0 18px; display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
.write-own-prompt { width: 100%; resize: vertical; font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.write-examples { padding: 14px 18px; }
.write-examples > summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.write-ex-tabs { display: flex; gap: 6px; margin: 12px 0 10px; }
.write-ex-tabs button { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: .88rem; }
.write-ex-tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.write-ex-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.write-paper { background: #fffdf6; color: #1d2420; border: 1px solid var(--line-strong); border-radius: 6px; padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1.6; box-shadow: var(--shadow-sm); }
.write-ex-part { white-space: pre-line; border-radius: 4px; transition: background .2s; }
.write-ex-part.right { align-self: flex-end; text-align: left; }
.write-ex-part.reading { background: #fdf0c2; box-shadow: 0 0 0 4px #fdf0c2; }
.write-ex-notes { margin-top: 12px; font-size: .92rem; }
.write-ex-notes ul { margin: 6px 0 0 18px; display: flex; flex-direction: column; gap: 4px; }
.write-text { width: 100%; min-height: 380px; resize: vertical; font: 1rem/1.6 inherit; font-family: inherit; padding: 16px 18px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); white-space: pre-wrap; }
.write-text:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.write-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.write-actions { display: flex; gap: 8px; }
.write-result { display: flex; flex-direction: column; gap: 10px; }
.write-result h3 { font-size: 1.02rem; margin-top: 8px; }
.write-result h4 { font-size: .92rem; color: var(--muted); margin-top: 4px; }
.write-note { background: var(--gold-soft); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; }
.write-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.write-score, .write-total { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .86rem; }
.write-total strong { font-size: 1.4rem; }
.write-score strong { font-size: 1.05rem; }
.write-summary { font-size: 1rem; line-height: 1.5; }
.write-checks { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.write-checks li { display: grid; grid-template-columns: 22px minmax(120px, auto) 1fr; gap: 8px; align-items: start; font-size: .92rem; padding: 6px 0; border-bottom: 1px solid var(--line); }
.write-checks li.ok .icon { color: var(--ok); }
.write-checks li.bad .icon { color: var(--red); }
.write-checks li.bad span:last-child { color: var(--red); }
.write-problems { margin-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.write-problems li { display: flex; flex-direction: column; gap: 3px; font-size: .94rem; line-height: 1.45; }
.write-problems q { background: var(--red-soft); color: var(--red); border-radius: 6px; padding: 1px 6px; align-self: flex-start; font-style: normal; }
.write-problems .fix { color: var(--ok); }
.write-rewrite { background: var(--ok-soft); border-radius: var(--radius); padding: 12px 14px; line-height: 1.6; white-space: pre-wrap; }
@media (max-width: 520px) { .status { font-size: 0; gap: 0; } .write-checks li { grid-template-columns: 22px 1fr; } .write-checks li span:last-child { grid-column: 2; } }
@media (max-width: 860px) {
  .app { display: block; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .sidenav { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-text small { display: none; }
  .brand-text strong { white-space: nowrap; }
  .brand-mark { width: 32px; height: 32px; font-size: 1.05rem; }
  .sidenav-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 12px; }
  .switch > span:last-child { display: none; }
  .voice-field > span { display: none; }
  .voice-field select { width: auto; max-width: 150px; padding-top: 6px; padding-bottom: 6px; font-size: .85rem; }
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; flex-direction: row; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .72rem; text-align: center; }
  .tabs button .icon { font-size: 1.3rem; }
  .page { padding: 18px 16px 28px; gap: 14px; }
  .page-head h1 { font-size: 1.3rem; }
  .split { grid-template-columns: 1fr; }
  .board { padding: 20px 20px 26px; min-height: 220px; }
  .page-chat { height: calc(100vh - 56px - 64px); }
  .select-field select { min-width: 0; width: 100%; }
  .offer-buttons { margin-left: 0; }

  #learnAside { width: 100%; }
  #view-learn .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .player { gap: 10px; }
}
