/* Coached Stats. Plain CSS, no framework. Colors are roles (below), light and dark:
   dark by the system's setting, or by the header's switch (data-theme on <html>, which wins both ways). */

*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e9;
  --border-strong: #c5cbd5;
  --text: #14171c;
  --text-2: #475061;
  --muted: #6d7686;
  --primary: #2456c7;
  --primary-hover: #1b449f;
  --primary-soft: #e7eefc;
  --primary-ink: #1b3f8f;
  --on-primary: #ffffff;
  --good: #156c35;
  --good-soft: #e2f4e7;
  --bad: #b3261e;
  --bad-soft: #fdeaea;
  --warn: #8a5a00;
  --warn-soft: #fff3d1;
  --coach-bubble: #f0f2f5;
  --student-bubble: #2456c7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --radius: 10px;
  --radius-sm: 6px;
  /* Charts (ChartRenderer.cs): two series colors, checked for color-vision deficiency on these surfaces; the rest recedes */
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --viz-dim: #c9ced6;
  --viz-grid: #e6e8ec;
  --viz-axis: #b9bfc9;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1114;
    --surface: #181b20;
    --surface-2: #20242b;
    --border: #2c313a;
    --border-strong: #404754;
    --text: #eceef2;
    --text-2: #bcc2cd;
    --muted: #8e96a4;
    --primary: #7aa5f7;
    --primary-hover: #9dbcf9;
    --primary-soft: #1d2a45;
    --primary-ink: #c5d8fc;
    --on-primary: #0d1830;
    --good: #5fcf85;
    --good-soft: #14301f;
    --bad: #f28b82;
    --bad-soft: #3a1c1a;
    --warn: #f0c060;
    --warn-soft: #33290f;
    --coach-bubble: #20242b;
    --student-bubble: #2f5fc4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --viz-1: #3987e5;
    --viz-2: #d95926;
    --viz-dim: #414855;
    --viz-grid: #262a31;
    --viz-axis: #454c58;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1114;
  --surface: #181b20;
  --surface-2: #20242b;
  --border: #2c313a;
  --border-strong: #404754;
  --text: #eceef2;
  --text-2: #bcc2cd;
  --muted: #8e96a4;
  --primary: #7aa5f7;
  --primary-hover: #9dbcf9;
  --primary-soft: #1d2a45;
  --primary-ink: #c5d8fc;
  --on-primary: #0d1830;
  --good: #5fcf85;
  --good-soft: #14301f;
  --bad: #f28b82;
  --bad-soft: #3a1c1a;
  --warn: #f0c060;
  --warn-soft: #33290f;
  --coach-bubble: #20242b;
  --student-bubble: #2f5fc4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --viz-1: #3987e5;
  --viz-2: #d95926;
  --viz-dim: #414855;
  --viz-grid: #262a31;
  --viz-axis: #454c58;
}

html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .85rem; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: var(--surface-2); padding: .08em .35em; border-radius: 4px; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.subtle { color: var(--text-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.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; }
[hidden] { display: none !important; }

/* ── Page frame ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.site-header-inner { display: flex; align-items: center; gap: 1.25rem; padding: .55rem 1.25rem; max-width: 1280px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 750; font-size: 1.08rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; flex-shrink: 0; }
.brand b { color: var(--primary); font-weight: 750; }
.site-nav { display: flex; gap: .25rem; align-items: center; flex: 1; min-width: 0; }
.site-nav a { padding: .35rem .7rem; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-size: .93rem; font-weight: 550; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); }
.site-header-right { display: flex; align-items: center; gap: .6rem; margin-left: auto; font-size: .9rem; color: var(--text-2); }
.who { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: block; }
  :root:not([data-theme="light"]) .theme-moon { display: none; }
}
.page { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page--narrow { max-width: 760px; }
.page--mid { max-width: 1000px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); margin: .2rem 0 0; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.site-footer { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 2rem; color: var(--muted); font-size: .85rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .93rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; border-radius: 6px; }
.btn-lg { padding: .7rem 1.3rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ── Forms ── */
label { font-weight: 600; font-size: .9rem; }
.field { margin-bottom: .9rem; }
.field > label { display: block; margin-bottom: .25rem; }
.field .hint, .hint { color: var(--muted); font-size: .84rem; font-weight: 400; margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
}
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input.mono, textarea.mono { font-size: .88rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500; }
.check input { margin-top: .25rem; width: 1rem; height: 1rem; flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem 1rem; }
.form-grid .field { margin: 0; }
.field-error, .validation-summary-errors, .field-validation-error { color: var(--bad); font-size: .87rem; }
.validation-summary-errors ul { margin: 0 0 .75rem; padding-left: 1.1rem; }

/* ── Cards, tables, badges, alerts ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .grid > .card-link + .card-link { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
a.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.card-link:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.empty { text-align: center; color: var(--text-2); padding: 2rem 1rem; }
.empty h3 { margin-bottom: .3rem; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; padding: .5rem .7rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.data td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data a.row-link { font-weight: 600; text-decoration: none; }
table.data a.row-link:hover { text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--primary { background: var(--primary-soft); color: var(--primary-ink); }
.alert { padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 1rem; font-size: .94rem; }
.alert--good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good); }
.alert--bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.alert--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.alert ul { margin: .3rem 0 0; padding-left: 1.15rem; }
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs a, .tabs button { padding: .55rem .9rem; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font: inherit; font-weight: 600; font-size: .93rem; text-decoration: none; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--primary-ink); border-bottom-color: var(--primary); }
.meter { height: 8px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; min-width: 70px; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); padding: 1.25rem; max-width: min(92vw, 720px); width: 100%; }
dialog::backdrop { background: rgba(10, 14, 22, .5); }

/* ── Writing: a problem's statement, the coach's messages, a solution (Markdown, with KaTeX) ── */
.prose { line-height: 1.65; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .7rem; }
.prose ul, .prose ol { margin: 0 0 .7rem; padding-left: 1.35rem; }
.prose li { margin-bottom: .2rem; }
.prose table { border-collapse: collapse; margin: 0 0 .8rem; font-variant-numeric: tabular-nums; }
.prose th, .prose td { border: 1px solid var(--border); padding: .3rem .65rem; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose blockquote { margin: 0 0 .7rem; padding: .1rem .9rem; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.prose .katex-display { margin: .6rem 0; overflow-x: auto; overflow-y: hidden; padding: .15rem 0; }

/* ── Charts ── */
.sc-figure { margin: 1rem 0; max-width: 520px; }
.sc-figure-title { font-weight: 650; font-size: .93rem; margin-bottom: .3rem; }
.sc-figure figcaption { color: var(--text-2); font-size: .86rem; margin-top: .3rem; }
.sc-figure-problem { color: var(--muted); font-style: italic; }
.sc-chart { display: block; width: 100%; height: auto; overflow: visible; font-family: inherit; }
.sc-chart text { fill: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sc-chart .sc-axis-label { fill: var(--text-2); font-size: 13px; font-weight: 550; }
.sc-chart .sc-tick--name { font-variant-numeric: normal; fill: var(--text); }
.sc-chart .sc-label { fill: var(--text); font-size: 13px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.sc-chart .sc-label--region { font-weight: 600; }
.sc-chart .sc-value { fill: var(--text); font-size: 12px; font-weight: 600; }
.sc-chart .sc-axis { stroke: var(--viz-axis); stroke-width: 1; fill: none; }
.sc-chart .sc-grid { stroke: var(--viz-grid); stroke-width: 1; fill: none; }
.sc-chart .sc-curve { stroke: var(--viz-1); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.sc-chart .sc-shade { fill: var(--viz-1); fill-opacity: .24; }
.sc-chart .sc-shade-edge { stroke: var(--viz-1); stroke-width: 1.25; }
.sc-chart .sc-marker { stroke: var(--text); stroke-width: 1.25; }
.sc-chart .sc-bar { fill: var(--viz-1); }
.sc-chart .sc-bar--2 { fill: var(--viz-2); }
.sc-chart .sc-bar--dim { fill: var(--viz-dim); }
.sc-chart .sc-dot { fill: var(--viz-1); stroke: var(--surface); stroke-width: 2; }
.sc-chart .sc-dot--plain { stroke-width: 1; }
.sc-chart .sc-hit { fill: transparent; stroke: none; }
.sc-chart .sc-fit { stroke: var(--viz-2); stroke-width: 2; stroke-linecap: round; }
.sc-chart .sc-box { fill: var(--viz-1); fill-opacity: .2; stroke: var(--viz-1); stroke-width: 1.5; }
.sc-chart .sc-whisker { stroke: var(--viz-1); stroke-width: 1.5; stroke-linecap: round; }
.sc-chart .sc-median { stroke: var(--viz-1); stroke-width: 3; stroke-linecap: round; }
.sc-chart [data-tip] { cursor: default; }
.sc-chart .sc-bar[data-tip]:hover, .sc-chart .sc-dot[data-tip]:hover { filter: brightness(1.15); }
.sc-tip {
  position: fixed; z-index: 100; pointer-events: none; padding: .25rem .55rem; border-radius: 6px; background: var(--text); color: var(--surface);
  font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 10px));
}
.sc-table-wrap { overflow: auto; max-height: 22rem; border: 1px solid var(--border); border-radius: 8px; display: inline-block; max-width: 100%; vertical-align: top; }
.sc-table { border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.sc-table th { position: sticky; top: 0; background: var(--surface-2); font-weight: 650; text-align: left; padding: .35rem .8rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.sc-table td { padding: .28rem .8rem; border-bottom: 1px solid var(--border); }
.sc-table tr:last-child td { border-bottom: 0; }
.sc-table .num { text-align: right; }
.sc-copy { display: block; margin-top: .35rem; background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: .84rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
@media (forced-colors: active) {
  .sc-chart .sc-shade { fill: Highlight; fill-opacity: .5; }
  .sc-chart .sc-bar--dim { fill: GrayText; }
}

/* ── Home and sign-in ── */
.hero { padding: 2.5rem 0 2rem; max-width: 46rem; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -.02em; margin-bottom: .8rem; }
.hero-sub { font-size: 1.1rem; color: var(--text-2); margin-bottom: 1.4rem; }
.coach-letters .card h3 { margin-top: .5rem; }
.coach-letter {
  display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary-ink); font-weight: 800; font-size: 1.05rem;
}
.coach-letter--sm { width: 1.5rem; height: 1.5rem; font-size: .8rem; border-radius: 6px; vertical-align: middle; margin-right: .3rem; }
.auth-card { margin-top: 6vh; padding: 1.6rem 1.7rem; }
.url-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .8rem; font-size: .93rem; }
.url-list dt { color: var(--text-2); }
.url-list dd { margin: 0; overflow-wrap: anywhere; }
.score-box { text-align: right; white-space: nowrap; }
.score-num { font-size: 1.6rem; font-weight: 750; }
.start-card { text-align: center; padding: 2rem 1.5rem; }
.start-card p { max-width: 36rem; margin-left: auto; margin-right: auto; color: var(--text-2); }
.filter-row { display: flex; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.filter-row input[type=search] { max-width: 20rem; }
.filter-row select { width: auto; }
.level { letter-spacing: .1em; color: var(--primary); font-size: .8rem; }
table.gradebook th.num { white-space: normal; min-width: 7rem; vertical-align: bottom; }
table.gradebook th a { color: inherit; text-decoration: none; text-transform: none; letter-spacing: 0; font-size: .86rem; }

/* ── The assignment editor ── */
.steps-mini { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .3rem; }
.steps-mini span { font-size: .7rem; padding: .05rem .4rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem; }
.mode-card { display: flex; gap: .55rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; font-weight: 400; }
.mode-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.mode-card input { margin-top: .25rem; }
.mode-card-body { display: flex; flex-direction: column; gap: .15rem; }
.sticky-actions { position: sticky; bottom: 0; padding: .7rem 0; background: linear-gradient(transparent, var(--bg) 30%); margin-top: .5rem; }
section.card + form, form + section.card, form > section.card + section.card { margin-top: 1rem; }
form > section.card:first-of-type { margin-top: 1rem; }
.picker-list { max-height: 50vh; overflow-y: auto; margin-top: .6rem; border: 1px solid var(--border); border-radius: 8px; }
.picker-topic { padding: .35rem .7rem; background: var(--surface-2); font-size: .8rem; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
.picker-row { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-top: 1px solid var(--border); font-weight: 400; cursor: pointer; }
.picker-row > span:first-of-type { flex: 1; }
.picker-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* ── The problem editor ── */
.editor-page { padding: 1rem 1.25rem 2rem; }
.editor-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.editor-bar h1 { margin: 0; font-size: 1.3rem; }
.editor-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.editor-side { position: sticky; top: 4.2rem; max-height: calc(100vh - 5rem); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.editor-side .tabs { margin: 0; padding: 0 .5rem; flex-shrink: 0; }
.side-pane { padding: 1rem 1.1rem; overflow-y: auto; min-height: 0; flex: 1; }
.side-pane[data-pane=assistant] { display: flex; flex-direction: column; padding: 0; }
.side-pane[data-pane=assistant][hidden] { display: none; }
.ed-section + .ed-section { margin-top: .9rem; }
.ed-section-head { margin-bottom: .7rem; }
.ed-section-head h2 { margin: 0; }
.ed-sub { font-size: .9rem; margin: 1rem 0 .15rem; }
.ed-card { border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; margin-bottom: .7rem; background: color-mix(in srgb, var(--surface-2) 35%, var(--surface)); }
.ed-card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.ed-card-head select { width: auto; padding: .25rem .5rem; font-size: .88rem; }
.ed-card-head .row-tools { margin-left: auto; }
.row-tools { display: flex; gap: .1rem; flex-shrink: 0; }
.row-tools .btn { padding: .15rem .45rem; }
.val-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .6rem; }
.val-row { display: grid; grid-template-columns: 7.5rem 9.5rem minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: .4rem; align-items: center; }
.val-row input, .val-row select, .list-row input, .mistake-row input { padding: .35rem .5rem; font-size: .88rem; }
.val-range { display: grid; grid-template-columns: 1fr auto 1fr auto .7fr; gap: .3rem; align-items: center; font-size: .82rem; color: var(--muted); }
.list-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.list-row input { flex: 1; min-width: 0; }
.list-n { width: 1.2rem; text-align: right; color: var(--muted); font-size: .85rem; }
.mistake-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: .4rem; margin-bottom: .35rem; }
.tol { display: grid; grid-template-columns: 1fr 3.6rem; gap: .3rem; }
.span-2 { grid-column: span 2; }
.editor-form .btn-row { margin-top: .4rem; }
.check-ok { color: var(--good); font-size: .88rem; margin-bottom: .6rem; }
.held-back { border: 1px dashed var(--border-strong); border-radius: 10px; padding: .5rem .7rem 0; margin: .7rem 0; }
.preview-part { border-top: 1px solid var(--border); padding: .7rem 0; }
.preview-part-prompt { display: flex; gap: .4rem; margin-bottom: .3rem; }
.part-letter { font-weight: 700; color: var(--text-2); flex-shrink: 0; }
.preview-options { list-style: none; padding: 0; margin: .2rem 0; }
.preview-options li { padding: .25rem .5rem; border-radius: 6px; display: flex; gap: .5rem; align-items: center; }
.preview-options li.is-correct { background: var(--good-soft); }
.preview-mistake { margin-top: .3rem; color: var(--text-2); }
.preview-solution, .preview-values { border-top: 1px solid var(--border); padding-top: .7rem; margin-top: .4rem; }
.preview-solution summary, .preview-values summary { font-weight: 650; cursor: pointer; margin-bottom: .5rem; }
.preview-values th { text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; position: static; }
.help h3 { margin-top: 1rem; }
.help ul { padding-left: 1.1rem; }
.help li { font-size: .88rem; margin-bottom: .3rem; }
.assistant { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.assistant-log { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .6rem; min-height: 12rem; }
.assistant-ideas { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem .7rem; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: .3rem .75rem; font: inherit; font-size: .84rem; cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.assistant-applied { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.assistant .chat-form { border-top: 1px solid var(--border); padding: .7rem 1.1rem; }
@media (max-width: 1000px) {
  .editor-cols { grid-template-columns: 1fr; }
  .editor-side { position: static; max-height: none; }
  .val-row { grid-template-columns: 1fr 1fr; }
}

/* ── Conversations ── */
.chat-log { display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; max-height: 52vh; min-height: 9rem; padding: .2rem .1rem .6rem; }
.chat-log--static { max-height: none; min-height: 0; overflow: visible; margin-bottom: .6rem; }
.chat-msg { max-width: 88%; padding: .6rem .85rem; border-radius: 14px; line-height: 1.55; font-size: .96rem; overflow-wrap: anywhere; }
.chat-msg--coach { align-self: flex-start; background: var(--coach-bubble); border-bottom-left-radius: 4px; }
.chat-msg--student { align-self: flex-end; background: var(--student-bubble); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-phase { align-self: center; font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: .3rem; }
.chat-phase:empty { display: none; }
.chat-typing { display: inline-flex; gap: .3rem; padding: .8rem .9rem; }
.chat-typing span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--muted); animation: sc-blink 1.2s infinite both; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes sc-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; opacity: .6; } }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 2.7rem; resize: none; }

/* ── The problem page ── */
.player { padding: .9rem 1.25rem 2.5rem; max-width: 1500px; margin: 0 auto; }
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .7rem; }
.player-where { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.player-where a { color: var(--text-2); text-decoration: none; }
.player-where a:hover { text-decoration: underline; }
.stepper { list-style: none; display: flex; gap: .3rem; padding: 0; margin: 0 0 .9rem; flex-wrap: wrap; }
.stepper-step { display: flex; align-items: center; gap: .45rem; padding: .3rem .75rem .3rem .35rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 600; }
.stepper-dot { display: inline-flex; align-items: center; justify-content: center; width: 1.55rem; height: 1.55rem; border-radius: 50%; background: var(--surface-2); font-size: .8rem; font-weight: 800; }
.stepper-step--done { color: var(--text-2); }
.stepper-step--done .stepper-dot { background: var(--good-soft); color: var(--good); }
.stepper-step--current { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.stepper-step--current .stepper-dot { background: var(--primary); color: var(--on-primary); }
.player-cols { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.player-cols > .card + .card { margin-top: 0; }
.player-step { position: sticky; top: 4.2rem; }
.statement { font-size: 1.04rem; }
.parts { margin-top: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.part { border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem; }
.part--right { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good-soft) 45%, transparent); }
.part--wrong { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.part-prompt { display: flex; gap: .45rem; margin-bottom: .45rem; font-weight: 550; }
.answer-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.answer-input { max-width: 13rem; font-variant-numeric: tabular-nums; font-size: 1.02rem !important; }
.unit { color: var(--text-2); }
.mark { font-weight: 650; font-size: .92rem; white-space: nowrap; }
.mark--right { color: var(--good); }
.mark--wrong { color: var(--bad); }
.part-feedback { margin-top: .45rem; padding: .45rem .7rem; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: .93rem; }
.part-key { margin-top: .4rem; font-size: .95rem; }
.options { display: flex; flex-direction: column; gap: .3rem; }
.option { display: flex; gap: .55rem; align-items: flex-start; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; font-weight: 400; cursor: pointer; }
.option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.option input { margin-top: .3rem; }
.calc { margin-top: 1.1rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.calc summary, .ask-coach summary, .first-read summary, .solution summary { cursor: pointer; font-weight: 650; }
.calc-form { margin-top: .5rem; }
.calc-text { font-size: 1.05rem; font-weight: 650; margin-top: .7rem; font-variant-numeric: tabular-nums; }
.step-head h2 { margin-bottom: .15rem; }
.step-head p { margin-bottom: .8rem; }
.step-actions { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .9rem; flex-wrap: wrap; }
.first-read, .ask-coach, .solution { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .8rem; margin-bottom: .7rem; }
.first-read[open] summary, .ask-coach[open] summary, .solution[open] summary { margin-bottom: .5rem; }
.qa { margin: .5rem 0; }
.qa-q { font-size: .86rem; color: var(--text-2); font-weight: 600; }
.qa-a { white-space: pre-wrap; padding: .35rem .7rem; border-left: 3px solid var(--primary-soft); margin-top: .2rem; }
.result { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .8rem; }
.result--right { background: var(--good-soft); color: var(--good); }
.result--partial { background: var(--warn-soft); color: var(--warn); }
.result--done { background: var(--surface-2); }
@media (max-width: 980px) {
  .player-cols { grid-template-columns: 1fr; }
  .player-step { position: static; }
  .stepper-name { display: none; }
  .stepper-step--current .stepper-name { display: inline; }
  .chat-log { max-height: 60vh; }
}

/* ── A student's work, for the instructor ── */
.work-problem + .work-problem { margin-top: 1rem; }
.work-step { margin: 1.1rem 0 .4rem; font-size: .98rem; }
.work-problem .chat-msg { font-size: .92rem; }

/* ── Small screens: the header keeps to one line ── */
@media (max-width: 720px) {
  .site-header-inner { gap: .5rem; padding: .5rem .75rem; }
  .site-nav { overflow-x: auto; scrollbar-width: none; }
  .site-nav a { padding: .3rem .5rem; font-size: .88rem; }
  .who { display: none; }
  .page, .player, .editor-page { padding-left: .75rem; padding-right: .75rem; }
  .player-top { gap: .4rem; }
}
@media (max-width: 460px) {
  .brand span { display: none; }
}
.calc-form .btn { margin-top: .6rem; }

/* A cell that holds a badge and its buttons: on one line when there's room, wrapping when there isn't (never off the edge) */
.cell-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.cell-actions form { margin: 0; }
.wrap-anywhere { overflow-wrap: anywhere; }
/* A second line in a cell (an address under a name): on one line when it's short, broken only when it's longer than this */
.cell-sub { display: block; max-width: 18rem; overflow-wrap: break-word; font-size: .87rem; color: var(--text-2); }
@media (max-width: 800px) { .hide-narrow { display: none; } }
