:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --ink: #24211a;
  --muted: #635d50;
  --line: #dcd1b8;
  --accent: #765009;
  --soft: #f3e9cd;
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(calc(100% - 2 * clamp(20px, 5vw, 72px)), 1100px); margin-inline: auto; }
.reading { max-width: 680px; }
.reading, .workspace { padding-block: clamp(32px, 6vw, 68px); }
.site-header { border-bottom: 1px solid var(--line); }
.topbar, .nav-links, .actions { display: flex; align-items: center; gap: 12px 20px; }
.topbar { justify-content: space-between; min-height: 60px; padding-block: 8px; }
.topbar a { font-size: 14px; }
.topbar .brand { font-size: 17px; font-weight: 750; white-space: nowrap; }
.nav-links { flex-wrap: wrap; justify-content: flex-end; }
.topbar a:hover, .text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.teacher-topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  min-height: 60px; padding-block: 9px; gap: 9px 18px; font-size: 14px;
}
.teacher-back, .teacher-public { white-space: nowrap; color: var(--accent); font-weight: 700; }
.teacher-back { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; }
.teacher-public { justify-self: end; }
.teacher-topbar a:hover { text-decoration: underline; text-underline-offset: 4px; }
.teacher-breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 2px 8px; margin: 0; padding: 0; list-style: none; }
.teacher-breadcrumbs li { display: flex; align-items: baseline; gap: 8px; color: var(--muted); }
.teacher-breadcrumbs li + li::before { content: "/"; color: #8e8676; }
.teacher-breadcrumbs [aria-current] { color: var(--ink); font-weight: 650; }
@media (max-width: 690px) {
  .teacher-topbar { grid-template-columns: auto 1fr; gap: 2px 12px; }
  .teacher-breadcrumbs { grid-column: 1 / -1; grid-row: 2; font-size: 13px; }
}

h1, h2, p { margin: 0 0 12px; overflow-wrap: anywhere; }
h1 { font: 700 clamp(32px, 5vw, 52px)/1.25 var(--serif); margin-bottom: 18px; }
h2 { font: 700 clamp(20px, 3vw, 25px)/1.35 var(--serif); }
.eyebrow { color: var(--accent); font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); }
.help { font-size: 14px; }
.text-link { color: var(--accent); font-size: inherit; font-weight: 650; }
button.text-link { border: 0; background: transparent; padding: 0; cursor: pointer; }
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 8px 16px; border: 1px solid var(--accent); border-radius: 4px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.button:hover { background: var(--ink); }
.button.secondary { background: transparent; color: var(--accent); border-color: var(--line); }
.button.secondary:hover { background: var(--soft); }
.section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.back { display: inline-block; margin-top: 22px; }
.actions { flex-wrap: wrap; }
.field { margin-bottom: 22px; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; overflow-wrap: anywhere; }
.field .help { margin-bottom: 8px; }
input, textarea {
  width: 100%; padding: 10px 12px; min-height: 46px; border: 1px solid #b7a989;
  border-radius: 4px; background: var(--surface); color: var(--ink);
}
input[type="file"] { background: transparent; }
textarea { display: block; resize: vertical; }
.errorlist { margin: 6px 0; padding-left: 20px; color: #9d261c; }
.notice { padding: 12px 15px; margin-bottom: 18px; border-left: 3px solid var(--accent); background: var(--soft); }
.receipt { font-size: 20px; font-weight: 750; }
.result-summary { padding: 16px 18px; border-inline-start: 3px solid var(--accent); background: var(--soft); }
.result-summary p { margin: 0; }
.result-summary strong { color: var(--accent); font-size: 1.35em; }
.result-questions { margin-top: 24px; }
.result-questions .case summary { font-weight: 700; cursor: pointer; }
.result-questions .case[open] summary { margin-bottom: 8px; }
.result-question { padding: 16px 0; border-bottom: 1px solid var(--line); }
.result-question header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.result-question h3 { margin: 6px 0 12px; font-size: 1rem; }
.result-question dl { margin: 0; }
.result-question dl > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 8px; padding-block: 4px; }
.result-question dt { color: var(--muted); }
.result-question dd { margin: 0; overflow-wrap: anywhere; }
.result-grade { padding: 1px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 14px; }
.result-grade[data-grade="correct"] { background: var(--soft); color: var(--accent); }
.result-grade[data-grade="incorrect"] { color: #922e24; }
.case { padding: 18px 20px; background: var(--soft); margin-block: 24px; }
.case p { margin-bottom: 0; }
.multiline { white-space: pre-wrap; }
.join-form { max-width: 390px; margin-top: 24px; }
.join-form .button { width: 100%; }
.answer-form { margin-top: 24px; }
.answer-form .field + .field { padding-top: 20px; border-top: 1px solid var(--line); }
.choice-field { min-width: 0; margin-inline: 0; padding: 0; border: 0; }
.choice-field legend { margin-bottom: 8px; padding: 0; font-weight: 700; }
.choice-field label {
  display: flex; align-items: baseline; gap: 10px; min-height: 44px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); font-weight: 400; cursor: pointer;
}
.choice-field label:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.choice-field input[type="radio"] { flex: 0 0 auto; width: 17px; height: 17px; min-height: 0; margin: 0; accent-color: var(--accent); }
.disclosure { border-bottom: 1px solid var(--line); padding-inline: 4px; }
.disclosure summary { padding: 15px 0; cursor: pointer; font-weight: 700; }
.disclosure[open] { padding-bottom: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); }
td[data-state="submitted"] { color: var(--accent); font-weight: 700; }
.questions { padding-inline-start: 26px; }
.questions li { margin-bottom: 14px; overflow-wrap: anywhere; }
.questions li::marker { color: var(--accent); font-weight: 700; }
.questions h2 { font-family: inherit; font-size: 1rem; line-height: 1.55; }

@media (max-width: 620px) {
  .topbar, .nav-links { gap: 6px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.management-list { max-width: 850px; margin: 24px 0 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.management-list li { border-bottom: 1px solid var(--line); }
.management-list a { display: flex; align-items: center; gap: 14px; min-height: 65px; padding: 12px 8px; }
.management-list a:hover { background: var(--soft); }
.management-list strong { font-size: 18px; }
.management-list small { display: block; color: var(--muted); }
.management-list a > :last-child { color: var(--accent); }
.management-list a > :nth-child(2):last-child { margin-inline-start: auto; }
.management-meta { margin-inline-start: auto; color: var(--muted); white-space: nowrap; }
.management-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 18px; }
.management-heading > * { margin: 0; }
.management-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.management-counts > div { border-top: 2px solid var(--line); padding: 8px 4px; }
.management-counts dt { color: var(--muted); font-size: 14px; }
.management-counts dd { margin: 0; font-size: clamp(24px, 4vw, 40px); line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.management-trend { border-top: 1px solid var(--line); padding-top: 16px; }
.trend-chart {
  list-style: none; padding: 24px 0 0; margin: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 7px;
}
.trend-point { text-align: center; min-width: 0; }
.trend-column { display: grid; align-items: end; justify-items: center; height: 76px; border-bottom: 1px solid var(--line); }
.trend-bar {
  position: relative; width: min(58%, 38px); height: var(--bar-height); min-height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; animation: bar-rise 240ms ease-out both;
  transform-origin: bottom;
}
@keyframes bar-rise { from { transform: scaleY(.3); opacity: .65; } }
.trend-bar span { position: absolute; bottom: 100%; inset-inline: 0; font-size: 12px; font-weight: 700; }
.trend-point time { display: block; margin-top: 5px; color: var(--muted); font-size: clamp(10px, 1.2vw, 13px); overflow-wrap: anywhere; }

.projection-page {
  --screen: var(--paper);
  --screen-panel: #fbf3df;
  --screen-line: #d8c59c;
  --screen-text: var(--ink);
  --screen-muted: var(--muted);
  --phase-submitted: #765009;
  --phase-started: #865719;
  --meter-fill: #b17a16;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  background: var(--screen);
  color: var(--screen-text);
}
.projection-page .site-header { border-color: var(--screen-line); }
.projection-page .topbar { min-height: 48px; }
.projection-page :focus-visible { outline-color: var(--phase-submitted); }
.projection-page .notice { background: var(--screen-panel); border-color: var(--phase-submitted); }
.projection-page .wrap { width: min(calc(100% - 2 * clamp(14px, 4vw, 68px)), 1620px); }
.projection, .projection-content { display: flex; flex: 1; flex-direction: column; }
.projection { padding-block: clamp(12px, 2vw, 28px) 12px; }
.projection-heading {
  display: flex; align-items: end; justify-content: space-between; gap: 8px 20px;
  padding-bottom: clamp(10px, 1.4vw, 22px);
}
.projection-heading .eyebrow { color: var(--phase-submitted); margin-bottom: 4px; }
.projection-heading h1 { margin: 0; font-size: clamp(24px, 3.5vw, 58px); }
.projection-status {
  padding: 4px 10px; border: 1px solid var(--screen-line); border-radius: 20px;
  color: var(--phase-submitted); font-size: 14px; font-weight: 700; white-space: nowrap;
}
.projection-heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.projection-grid {
  flex: 1; min-height: 380px; display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
  border: 1px solid var(--screen-line);
}
.projection-scan {
  min-width: 0; min-height: 0; padding: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: clamp(8px, 2vh, 20px); background: var(--screen-panel);
}
.projection-scan h2 { margin: 0; font-family: inherit; font-size: clamp(24px, 3.3vw, 51px); line-height: 1.15; }
.projection-scan a { display: block; max-width: 100%; }
.projection-scan .qr {
  display: block; width: clamp(150px, min(38vw, calc(100svh - 390px)), 470px);
  max-width: 100%; height: auto; border-radius: 4px; background: white; image-rendering: pixelated;
}
.projection-summary {
  display: grid; grid-template-rows: 1.35fr 1fr 1fr; min-width: 0;
  border-inline-start: 1px solid var(--screen-line);
}
.projection-stat { display: grid; align-content: center; gap: 5px; padding: 12px clamp(14px, 2.5vw, 42px); }
.projection-stat + .projection-stat { border-top: 1px solid var(--screen-line); }
.projection-stat-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.projection-stat h2 { margin: 0; font-family: inherit; font-size: clamp(18px, 2.8vw, 42px); line-height: 1.18; white-space: nowrap; }
.projection-stat-heading p { margin: 0; font-size: clamp(35px, 5.5vw, 91px); line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.projection-stat-heading small { margin-inline-start: .14em; font-size: .40em; color: var(--screen-muted); }
.projection-submitted strong { color: var(--phase-submitted); }
.projection-started strong { color: var(--phase-started); }
.projection-meter { height: 8px; border-radius: 999px; overflow: hidden; background: var(--screen-line); }
.projection-meter::before { content: ''; display: block; height: 100%; width: var(--submitted-end); background: var(--meter-fill); transition: width 220ms ease; }
.projection-ratio { margin: 2px 0 0; color: var(--screen-muted); font-size: clamp(14px, 1.7vw, 26px); font-weight: 700; }
.projection-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding-top: 10px; }
.projection-footer p { margin: 0; color: var(--screen-muted); font-size: 13px; }
.projection-footer .actions { flex-wrap: wrap; gap: 8px 14px; }
.projection-page .button.secondary { border-color: var(--screen-line); color: var(--screen-text); }
.projection-page .button.secondary:hover { background: var(--screen-panel); }
html:fullscreen .projection-page .site-header { display: none; }
html:fullscreen .projection-page { height: 100svh; min-height: 0; }
html:fullscreen .projection, html:fullscreen .projection-content { min-height: 0; }
html:fullscreen .projection { padding-block: 12px; }
html:fullscreen .projection-grid { flex: 1; min-height: 0; }
html:fullscreen .projection-scan .qr { width: clamp(140px, min(43vw, calc(100svh - 280px)), 530px); }

.analysis { padding-block: clamp(12px, 2vh, 24px) 40px; }
.analysis-section + .analysis-section { margin-top: clamp(24px, 4vh, 42px); }
.analysis-section h2 { margin: 0 0 12px; font: inherit; font-size: clamp(21px, 2.15vw, 36px); font-weight: 750; line-height: 1.2; }
.analysis-section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }
.analysis-section-heading h2, .analysis-section-heading p { margin: 0; }
.analysis-section-heading p { color: var(--screen-muted); font-size: clamp(13px, 1.1vw, 17px); }
.analysis-metrics {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 16px;
  border-block: 1px solid var(--screen-line);
}
.analysis-metrics > div { padding: 10px clamp(8px, 2vw, 24px); }
.analysis-metrics > div + div { border-inline-start: 1px solid var(--screen-line); }
.analysis-metrics dt { color: var(--screen-muted); font-size: clamp(14px, 1.7vw, 25px); font-weight: 700; line-height: 1.25; }
.analysis-metrics dd { margin: 0; font-size: clamp(32px, 4.8vw, 76px); font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.analysis-overall [data-grade-percent], .question-completion-heading strong { color: var(--phase-submitted); }
.analysis-metrics .analysis-note { margin-top: 3px; color: var(--screen-muted); font-size: clamp(11px, 1.15vw, 16px); line-height: 1.35; }
.question-completion-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 10px;
}
.question-completion { padding: 12px clamp(12px, 1.35vw, 23px); border: 1px solid var(--screen-line); background: var(--screen-panel); }
.question-completion-heading, .question-completion-counts { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 3px 12px; }
.question-completion-heading h3 { margin: 0; font: inherit; font-size: clamp(18px, 1.8vw, 27px); font-weight: 750; }
.question-completion-heading a:hover { color: var(--phase-submitted); }
.question-completion-heading a span { color: var(--phase-submitted); font-size: .75em; }
.question-completion-heading p, .question-completion-counts { margin: 0; color: var(--screen-muted); font-size: clamp(13px, 1.15vw, 18px); font-variant-numeric: tabular-nums; }
.question-completion-heading strong { font-size: clamp(23px, 2.45vw, 41px); line-height: 1; }
.question-completion .projection-meter { margin-block: 8px; }
.question-completion-counts b { color: var(--screen-text); }
.ai-study-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px;
  padding: 10px clamp(12px, 2vw, 26px); margin-bottom: 12px; background: var(--screen-panel);
  border-inline-start: 3px solid var(--phase-submitted);
}
.ai-study-summary h3 { margin: 0 0 3px; color: var(--phase-submitted); font: inherit; font-weight: 700; }
.ai-study-summary p { margin: 0; font-size: clamp(14px, 1.35vw, 19px); line-height: 1.4; }
.analysis button:disabled { opacity: .58; cursor: default; }
.analysis-ai-error { margin-top: 5px; color: var(--phase-started); font-size: 14px; }
.analysis-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 15px; margin-top: 12px; color: var(--screen-muted); font-size: 13px; }
.analysis-footer p { margin: 0; }
.analysis-footer [data-sync-status] { margin-inline-start: auto; }
.review-case, .review-question { padding: clamp(12px, 2vw, 30px); border: 1px solid var(--screen-line); }
.review-case { margin-bottom: 12px; }
.review-case p, .review-prompt { white-space: pre-wrap; }
.review-question { scroll-margin-top: 12px; background: var(--screen-panel); }
.review-question + .review-question { margin-top: 12px; }
.review-question:target { border-color: var(--phase-submitted); }
.review-question-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.review-question-heading h3 { margin: 0; color: var(--phase-submitted); font: inherit; font-size: clamp(19px, 1.8vw, 28px); font-weight: 750; }
.review-question-score { margin: 0 0 0 auto; color: var(--screen-muted); text-align: end; font-size: clamp(13px, 1.3vw, 20px); font-variant-numeric: tabular-nums; }
.review-question-score strong { color: var(--phase-submitted); font-size: clamp(18px, 2vw, 32px); }
.review-prompt { margin: 0; font-size: clamp(19px, 2.15vw, 34px); line-height: 1.45; }
.review-options { list-style: none; margin: 12px 0 0; padding: 0; font-size: clamp(17px, 1.7vw, 27px); }
.review-options li + li { margin-top: 4px; }
.answer-distribution { margin-top: 16px; padding-block: 10px; border-block: 1px solid var(--screen-line); }
.answer-distribution summary { width: fit-content; cursor: pointer; font-weight: 750; color: var(--phase-submitted); }
.answer-distribution ul { margin: 10px 0 0; padding: 0; list-style: none; }
.answer-distribution li { padding: 8px 0; }
.answer-distribution li + li { border-top: 1px solid var(--screen-line); }
.answer-distribution-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; font-size: clamp(15px, 1.4vw, 22px); }
.answer-distribution-row > span { overflow-wrap: anywhere; }
.answer-distribution-row small { color: var(--phase-submitted); font-weight: 650; }
.answer-distribution .projection-meter { height: 5px; margin-top: 5px; }
.answer-distribution li[data-reference="true"] .projection-meter::before { background: var(--phase-submitted); }
.answer-distribution p { margin: 7px 0 0; }
.answer-diagnostic { color: var(--screen-muted); font-size: clamp(14px, 1.2vw, 20px); }
.review-actions { display: flex; align-items: start; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; }
.review-case summary, .review-reference summary, .review-explanation summary { cursor: pointer; font-weight: 700; }
.review-reference summary { padding-block: 7px; }
.review-case p, .review-reference p, .review-explanation p { margin: 8px 0 0; }
.review-case, .review-reference, .review-explanation { font-size: clamp(16px, 1.55vw, 25px); line-height: 1.5; }
.review-explanation { margin-top: 8px; padding: 12px 16px; border-inline-start: 3px solid var(--phase-submitted); background: var(--screen); }
.review-explanation ol { margin: 8px 0; padding-inline-start: 1.5em; }
.review-explanation li + li { margin-top: 6px; }
.review-explanation strong { color: var(--phase-started); }
html:fullscreen .analysis-page .analysis { max-height: 100svh; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 681px) and (max-height: 820px) {
  .analysis { padding-top: 12px; }
  .analysis .projection-heading { padding-bottom: 12px; }
  .analysis-metrics { margin-bottom: 10px; }
  .analysis-metrics > div { padding-block: 7px; }
  .analysis-metrics dd:not(.analysis-note) { font-size: clamp(32px, 4.2vw, 64px); }
  .ai-study-summary { padding-block: 7px; }
}
.grading-form .questions > li { padding-block: 12px; border-bottom: 1px solid var(--line); }
.grading-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.grading-field label { color: var(--muted); font-size: 14px; }
.grading-field select { font: inherit; color: var(--ink); padding: 6px 9px; }

@media (max-width: 680px) {
  .management-counts { grid-template-columns: repeat(2, 1fr); }
  .projection-heading { align-items: start; flex-wrap: wrap; }
  .projection-status { font-size: 12px; }
  .projection-grid, html:fullscreen .projection-grid { flex: 0 0 auto; grid-template-columns: 1fr; min-height: 0; }
  .projection-scan .qr, html:fullscreen .projection-scan .qr { width: min(100%, 63vw, 270px); }
  .projection-summary { border-inline-start: 0; border-top: 1px solid var(--screen-line); }
  .projection-stat h2 { white-space: normal; }
  .analysis-metrics dt { font-size: 14px; }
  .ai-study-summary { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .trend-bar { animation: none; }
}

.room-count { font-size: clamp(2rem, 8vw, 6rem); line-height: 1.2; }
.room-review { padding: clamp(16px, 3vw, 44px); }
.room-review h2 { white-space: pre-wrap; }
.room-review li { margin-block: .65em; }
.room-activities p { margin-bottom: 0; }

.teacher-tools { display: flex; justify-self: end; align-items: center; gap: 18px; white-space: nowrap; }
.roster-table { margin-top: 20px; max-height: 70vh; }
.roster-table thead th { position: sticky; top: 0; background: var(--paper, #faf8f2); z-index: 1; }
.roster-table th, .roster-table td { min-width: 135px; white-space: nowrap; vertical-align: top; }
table small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 5px; }

.roster-table th:first-child, .roster-table td:first-child { min-width: 85px; }
.roster-table th:nth-child(2), .roster-table td:nth-child(2) { min-width: 100px; }
