/* Classroom Daily: a printed-paper product interface, with native controls. */
:root {
  color-scheme: light;
  --paper: #fdfcf8;
  /* A translucent white paper layer softens the original yellow fiber tile. */
  --paper-surface: linear-gradient(#fdfcf8e8, #fdfcf8e8), url('assets/newspaper/paper-fibers.webp');
  --ink: #302d25;
  --muted: #58554e;
  --line: #c5c1b7;
  --accent: #904330;
  --reveal-height: 340px;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-height: 100%; scrollbar-gutter: stable; background: #deddd6; }
body { margin: 0; padding: 14px 0 20px; color: var(--ink); font-size: 14px; line-height: 1.65; min-height: 100dvh; background: radial-gradient(ellipse at 40% 0, #eeede8, #dad9d3); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 42px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 2px; background: transparent; cursor: pointer; transition: background .16s, color .16s, transform .16s; }
button:hover { background: #edece7; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:disabled:active { transform: none; }
input, select, textarea { min-height: 42px; min-width: 0; border: 1px solid #aaa69d; border-radius: 1px; padding: 9px 12px; background: #ffffff66; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; accent-color: var(--accent); flex-shrink: 0; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input::-webkit-inner-spin-button { appearance: none; }
textarea { resize: vertical; line-height: 1.9; }
::placeholder { color: #68645c; opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
::selection { background: #963d2f26; }
.primary-button { background: var(--accent) url('assets/newspaper/paper-fibers.webp') repeat; background-size: 512px; background-blend-mode: multiply; border-color: var(--accent); color: #fff9ec; box-shadow: inset 0 0 0 1px #fff9ec20; }
.primary-button:hover { background-color: #773024; border-color: #773024; }
.quiet-button, .text-button { border-color: transparent; }
.text-button { font-size: 12px; padding-inline: 8px; }
.danger { color: var(--accent); }
.app-shell {
  position: relative; isolation: isolate; width: calc(100% - 24px);
  min-height: calc(100dvh - 34px);
  padding: 0 clamp(20px, 2.8vw, 48px); margin: auto;
  background: var(--paper); background-image: var(--paper-surface);
  background-size: 720px;
  box-shadow: 0 0 0 1px #77736a30, 0 2px 4px #554f4430, 0 13px 35px #554f441c;
}
/* Named rows keep notices in normal flow and give spare page height to the main
   content. Long lists and short screens still grow the sheet naturally. */
body:not(.presenting) .app-shell {
  display: grid;
  grid-template-areas: "masthead" "navigation" "notice" "context" "content" "footer";
  grid-template-rows: auto auto auto auto minmax(min-content, 1fr) auto;
}
body:not(.presenting) .app-shell > .masthead { grid-area: masthead; }
body:not(.presenting) .app-shell > .nav-line { grid-area: navigation; }
body:not(.presenting) .app-shell > .message { grid-area: notice; }
body:not(.presenting) .app-shell > .class-context { grid-area: context; }
body:not(.presenting) .app-shell > main { grid-area: content; min-width: 0; }
body:not(.presenting) .app-shell > footer { grid-area: footer; }
/* Material lives below content: no fixed overlay over names, inputs or dialogs. */
.app-shell::before, .app-shell::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.app-shell::before {
  background:
    radial-gradient(ellipse at 0 8%, #9e681808, transparent 25%),
    radial-gradient(ellipse at 100% 38%, #b27c2407, transparent 23%),
    radial-gradient(ellipse at 8% 100%, #a0742208, transparent 26%),
    radial-gradient(ellipse at 97% 98%, #8c651b07, transparent 21%),
    radial-gradient(ellipse at 48% 25%, #ffffff45, transparent 53%);
  box-shadow: inset 0 0 3px 1px #8c652414, inset 0 0 22px #936b2609, inset 0 0 80px #9c792c04;
}
.app-shell::after {
  background:
    linear-gradient(90deg, transparent 49.45%, #8f774405 49.84%, #7c633708 49.96%, #ffffff66 50.08%, #ffffff11 50.5%, transparent 51.25%),
    linear-gradient(0deg, transparent 55.1%, #8a704b03 55.6%, #826a3908 55.92%, #ffffff54 56.05%, #ffffff16 56.6%, transparent 57.5%);
}
.masthead { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 20px; padding: 16px 0 14px; border-bottom: 5px double var(--ink); }
.brand { display: block; text-align: center; font-family: var(--serif); font-size: clamp(44px, 4.5vw, 62px); line-height: 1.08; font-weight: 900; letter-spacing: .12em; text-indent: .12em; white-space: nowrap; }
.brand span { display: block; color: var(--ink); -webkit-text-fill-color: var(--ink); font: 11px/1.7 var(--sans); letter-spacing: .25em; margin-top: 7px; }
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .brand, .stage-heading h1, .page-heading h1 {
    background: var(--ink) url('assets/newspaper/ink-grain.png') repeat;
    background-size: 512px; background-clip: text; -webkit-background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
  }
}
.masthead-side { font-size: 11px; color: var(--muted); }
.edition-label { display: block; color: var(--ink); letter-spacing: .1em; padding-bottom: 8px; }
.masthead-side p { font-family: var(--serif); margin: 0; line-height: 1.9; }
.masthead-right { display: flex; justify-content: end; align-items: center; gap: 18px; font-size: 10px; }
#edition-date { max-width: 112px; text-align: right; }
.edition-seal { display: inline-block; flex-shrink: 0; border: 2px solid var(--accent); outline: 1px solid var(--accent); outline-offset: -5px; color: var(--accent); padding: 7px 10px; font: 18px/1.2 var(--serif); letter-spacing: .1em; transform: rotate(-5deg); opacity: .86; mix-blend-mode: multiply; }
.nav-line { min-height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--ink); gap: 14px; }
.nav-edition { font-size: 11px; letter-spacing: .15em; }
nav { display: flex; gap: 18px; }
.nav-link { position: relative; border: 0; padding: 6px 9px; min-height: 46px; font-size: 12px; }
.nav-link.active { color: var(--accent); font-weight: 650; }
.nav-link.active::after { content: ""; height: 2px; background: var(--accent); position: absolute; bottom: -1px; left: 10px; right: 10px; }
#presentation { justify-self: end; font-size: 11px; padding-right: 0; }
#presentation span { margin-left: 12px; }
.class-context { display: flex; justify-content: space-between; align-items: center; gap: 15px; min-height: 56px; border-bottom: 1px solid var(--line); }
.class-picker { display: flex; gap: 12px; align-items: center; min-width: 0; }
.class-picker > label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.class-picker select { font-weight: 650; font-size: 15px; border: 0; padding-left: 0; max-width: 190px; background: transparent; }
.class-picker .text-button { color: var(--muted); font-size: 11px; white-space: nowrap; }
.round-context { display: flex; align-items: center; gap: 14px; font-size: 11px; font-variant-numeric: tabular-nums; }
#round-label { color: var(--accent); font-weight: 650; white-space: nowrap; }
progress { appearance: none; width: 64px; height: 3px; border: 0; background: #d7cebe; }
progress::-webkit-progress-bar { background: #d7cebe; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
main:focus { outline: none; }
.front-page { display: grid; grid-template-columns: minmax(0, 1fr) clamp(220px, 20vw, 310px); align-items: start; gap: 28px; padding: 20px 0; }
.lead-story { min-width: 0; position: relative; text-align: center; display: grid; grid-template-rows: 38px var(--reveal-height) 70px 36px; gap: 8px; }
.stage-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.story-kicker { color: var(--accent); font-size: 11px; font-weight: 650; letter-spacing: .16em; white-space: nowrap; }
.stage-heading h1 { font: 900 clamp(22px, 2.2vw, 28px)/1.3 var(--serif); margin: 0; letter-spacing: -.02em; }
/* One paper viewport throughout idle, reveal and result; names scroll inside it. */
.reveal-region { position: relative; height: var(--reveal-height); flex: 0 0 var(--reveal-height); display: grid; grid-template-rows: 20px minmax(0, 1fr) 20px; gap: 8px; padding: 12px 8px; border-block: 1px solid var(--line); overflow: hidden; }
.result-caption { margin: 0; font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.draw-results { display: flex; min-height: 0; height: 100%; overflow: auto; scrollbar-width: thin; justify-content: center; flex-wrap: wrap; align-items: safe center; align-content: safe center; gap: 10px 20px; }
.draw-results:empty::before { content: "虚位以待"; font: 700 clamp(54px, 6.5vw, 100px)/1.4 var(--serif); color: #bdb29f; letter-spacing: .1em; }
.student-result { display: flex; flex-direction: column; min-width: 0; align-items: center; max-width: 100%; }
.student-result strong { font: 900 clamp(64px, 8vw, 116px)/1.3 var(--serif); letter-spacing: .055em; overflow-wrap: anywhere; }
.student-result small { color: var(--muted); font: 10px/1.7 ui-monospace, monospace; overflow-wrap: anywhere; max-width: 100%; }
.draw-results:has(.student-result:nth-child(2)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.draw-results:has(.student-result:nth-child(2)) strong { font-size: clamp(32px, 4.3vw, 60px); }
.draw-results.many { padding: 2px 8px; }
.draw-results.many:has(.student-result:nth-child(2)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.draw-results.many strong { font-size: clamp(24px, 2.5vw, 34px) !important; }
.result-detail { margin: 0; color: var(--muted); font-size: 10px; min-height: 0; overflow: auto; }
.draw-console { display: grid; grid-template-columns: 115px minmax(0, 1fr) 80px; gap: 12px; align-items: end; align-self: center; width: min(100%, 800px); margin: 0 auto; text-align: left; }
.count-control > label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 5px; }
.stepper { display: flex; height: 46px; border: 1px solid #b2a792; }
.stepper button { border: 0; width: 36px; min-width: 32px; padding: 4px 0; font-size: 20px; }
.stepper input { width: 41px; padding: 0; border: 0; text-align: center; font-size: 18px; background: transparent; }
.draw-button { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; white-space: nowrap; padding: 9px 18px; font-size: 14px; letter-spacing: .12em; }
.draw-button span { font-size: 21px; }
.undo-button { min-height: 46px; font-size: 11px; padding: 8px 4px; color: var(--muted); }
.count-hint { grid-row: 4; grid-column: 1; align-self: center; font-size: 11px; color: var(--muted); margin: 0; line-height: 1.7; }
.milestone { grid-row: 4; grid-column: 1; align-self: stretch; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0 8px; margin: 0; font-size: 12px; color: var(--accent); overflow: auto; }
.milestone .text-button { min-height: 28px; padding: 2px 8px; }
.lead-story:has(.milestone:not([hidden])) .count-hint { visibility: hidden; }
.briefs-column { min-width: 0; border-left: 1px solid var(--line); padding-left: 22px; }
.brief-item { padding: 14px 0; border-top: 1px solid var(--line); }
.brief-item h2 { font: 700 15px/1.6 var(--serif); margin-bottom: 6px; }
.brief-item p { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.9; }
.collection-teaser { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; padding: 0; border: 0; border-top: 1px solid var(--line); text-align: left; }
.editorial-art { grid-column: 1 / -1; display: block; height: 62px; margin-bottom: 8px; background-image: radial-gradient(#302d2559 .6px, transparent .9px), url('assets/newspaper/mountains-print.png'); background-size: 3px 3px, cover; background-position: center, 52% 58%; background-blend-mode: multiply; filter: grayscale(1) sepia(.18) contrast(1.3); mix-blend-mode: multiply; opacity: .82; }
.collection-teaser strong { font: 700 19px/1.5 var(--serif); }
.collection-teaser .teaser-link { align-self: center; color: var(--accent); font-size: 10px; }
.recent-section { padding-bottom: 8px; }
.section-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.section-line h2 { font: 700 18px/1.4 var(--serif); margin: 0; }
.section-line > span { font-size: 10px; color: var(--muted); white-space: nowrap; }
.recent-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.recent-item { display: flex; flex-direction: column; gap: 3px; padding: 9px 0; min-width: 0; }
.recent-item + .recent-item { border-top: 1px solid var(--line); }
.recent-item time { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.recent-item > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; width: 100%; }
.recent-item p { min-width: 0; font: 700 17px/1.7 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.recent-item small { flex-shrink: 0; font-size: 10px; color: var(--muted); }
.recent-item.undone p { color: var(--muted); text-decoration: line-through; }
.recent-more { width: 100%; min-height: 34px; padding: 5px 0; text-align: left; color: var(--accent); font-size: 11px; }
.recent-list .empty-note { font: 16px/1.8 var(--serif); margin: 0; padding: 30px 0; }
footer { border-top: 1px solid var(--ink); display: flex; justify-content: space-between; gap: 20px; align-items: center; font-size: 10px; color: var(--muted); padding: 6px 0 14px; }
footer .text-button { font-size: 10px; }
.workspace-view { min-height: 440px; padding: 24px 0 36px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; border-bottom: 3px double var(--ink); padding-bottom: 18px; margin-bottom: 20px; }
.eyebrow { font-size: 11px; color: var(--accent); letter-spacing: .08em; }
.page-heading h1 { font: 900 38px/1.4 var(--serif); margin: 7px 0; }
.page-heading p { font-size: 13px; color: var(--muted); margin-bottom: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.download-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 2px; font-size: 14px; white-space: nowrap; }
.download-link:hover { background: #edece7; }
.template-help { padding: 14px 16px; border-left: 2px solid var(--line); background: #fffdf329; color: var(--muted); font-size: 12px; line-height: 1.9; }
.template-help strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.template-help span { display: block; }
.source-note, .dialog-note { font-size: 12px; color: var(--muted); line-height: 1.9; }
.roster-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 25px 0 20px; }
.search-field { display: flex; flex-direction: column; gap: 7px; font-size: 12px; }
.search-field input { width: min(320px, 100%); }
.student-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 28px; }
.student-row { display: grid; grid-template-columns: minmax(42px, auto) minmax(0, 1fr) auto; align-items: baseline; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.student-row strong { font: 700 20px/1.5 var(--serif); overflow-wrap: anywhere; }
.student-id { font-size: 10px; color: var(--muted); max-width: 90px; overflow-wrap: anywhere; }
.student-status { font-size: 10px; color: var(--muted); }
.student-row.is-drawn .student-status { color: var(--accent); }
.history-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 15px; margin-bottom: 18px; font-size: 12px; }
.history-toolbar label { display: flex; flex-direction: column; gap: 6px; }
#history-summary { margin-left: auto; align-self: center; color: var(--muted); }
.history-entry { display: grid; grid-template-columns: 180px minmax(0, 1fr) 100px; gap: 24px; border-bottom: 1px solid var(--line); padding: 20px 0; }
.history-entry time { font-size: 12px; }
.history-entry small { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }
.history-names { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.history-name { font: 700 22px/1.4 var(--serif); overflow-wrap: anywhere; max-width: 100%; }
.history-name span { display: block; font: 10px/1.8 var(--sans); color: var(--muted); }
.status-mark { color: var(--accent); font-size: 11px; text-align: right; }
.history-entry.undone .history-name { text-decoration: line-through; color: var(--muted); }
.collection-mark { color: var(--accent); border: 3px double var(--accent); font: 22px/1.2 var(--serif); padding: 10px; transform: rotate(-5deg); }
.print-collection { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; margin-bottom: 24px; }
.print-card { position: relative; border: 1px solid var(--line); border-top: 3px solid var(--ink); padding: 22px 20px 16px; background: #fffdf329; min-height: 285px; display: flex; flex-direction: column; }
.print-card-number { font: italic 40px/1 Georgia, serif; color: var(--accent); padding-bottom: 8px; }
.print-card-title { font: 700 30px/1.3 var(--serif); margin: 15px 0 8px; }
.print-card-subtitle { font-size: 10px; color: var(--muted); }
.print-card-copy { font: 16px/1.8 var(--serif); margin: 18px 0 10px; }
.print-card-prompt { font-size: 11px; color: var(--muted); }
.print-card-round { font-size: 10px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; color: var(--accent); }
.print-card.locked { border-top-color: #b5aa95; background: transparent; }
.print-card.locked .print-card-number, .print-card.locked .print-card-title, .print-card.locked .print-card-round { color: var(--muted); }
.print-card.locked .print-card-copy { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.message { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 15px; border: 1px solid var(--accent); border-left-width: 4px; margin-top: 14px; color: var(--accent); background: #fffaf0; }
.message.success { color: var(--ink); border-color: #7f8169; }
.message button { flex-shrink: 0; border: 0; }
.empty-note, .page-status { padding: 25px 0; font-size: 13px; color: var(--muted); }
dialog { width: min(550px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow: auto; padding: 26px 30px; border: 3px double var(--ink); background: var(--paper); background-image: var(--paper-surface); background-size: 720px; color: var(--ink); box-shadow: 0 20px 80px #29282033; }
dialog::backdrop { background: #29282080; backdrop-filter: blur(3px); }
dialog.wide-dialog { width: min(780px, calc(100% - 32px)); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding-bottom: 13px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.dialog-header h2 { font: 700 29px/1.5 var(--serif); margin: 3px 0 0; }
.dialog-header button { flex-shrink: 0; }
dialog > p { font-size: 13px; line-height: 1.8; }
.field-label { display: flex; flex-direction: column; gap: 7px; margin: 16px 0; font-size: 12px; }
.check-label { display: flex; align-items: center; gap: 10px; margin: 20px 0; font-size: 13px; }
#settings-dialog { width: min(780px, calc(100% - 32px)); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; margin: 24px 0; }
.settings-group { min-width: 0; border: 0; padding: 0; margin: 0; }
.settings-group legend { padding: 0 0 12px; font: 700 20px/1.5 var(--serif); }
.settings-group .check-label { margin: 0 0 18px; }
.settings-group .dialog-note { margin: 13px 0 0; }
.audio-settings { border-left: 1px solid var(--line); padding-left: 28px; }
.scene-preview-button { width: 100%; display: flex; justify-content: space-between; border-color: var(--ink); margin: 20px 0 0; }
.settings-data { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--ink); padding-top: 18px; }
.settings-data h3 { font: 700 20px/1.5 var(--serif); margin: 0 0 3px; }
.settings-data .dialog-note { margin: 0; }
.settings-data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#online-account-slot:empty { display: none; }
.audio-volume { display: grid; grid-template-columns: auto minmax(0, 1fr) 3.5em; align-items: center; gap: 12px; font-size: 13px; }
.audio-volume input { width: 100%; min-width: 0; padding: 0; accent-color: var(--ink); }
.audio-volume output { font-variant-numeric: tabular-nums; text-align: right; }
.audio-auditions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.audio-auditions button { flex: 1 1 100px; font-size: 12px; padding: 9px 10px; }
.audio-settings .dialog-note { margin-bottom: 0; }
.dialog-footer { display: flex; justify-content: end; gap: 12px; margin-top: 22px; }
.form-error { color: var(--accent); white-space: pre-wrap; font-size: 12px; }
.import-class { padding: 15px 0; border-bottom: 1px solid var(--line); }
.import-class label { display: flex; align-items: center; gap: 10px; }
.import-class input[type="text"] { flex: 1; }
.import-class small { white-space: nowrap; }
.import-class p { margin: 9px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 30; padding: 12px 18px; background: var(--ink); color: var(--paper); }
.skip-link:focus { top: 12px; }
.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; }
#paper-stage { position: absolute; inset: 0; z-index: 2; pointer-events: none; perspective: 900px; visibility: hidden; }
#paper-stage.is-printing { visibility: visible; }
.paper-fold { position: absolute; inset-block: 0; width: 50%; background: var(--paper); background-image: var(--paper-surface); background-size: 720px; border: 1px solid #bbb6aa; backface-visibility: hidden; box-shadow: inset 0 0 28px #907b5010; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.paper-fold-left { left: 0; transform-origin: left center; }
.paper-fold-right { right: 0; transform-origin: right center; }
.paper-fold > span { font: 900 clamp(30px, 4vw, 50px)/1.3 var(--serif); letter-spacing: .12em; }
.paper-fold i { height: 2px; background: #b9aa8d; width: 75%; margin-top: 10px; }
.paper-fold i:last-child { width: 55%; }
.print-stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); background: var(--paper); color: var(--accent); border: 3px double var(--accent); padding: 7px 16px; font: 700 20px/1.5 var(--serif); white-space: nowrap; }
@media (prefers-reduced-motion: no-preference) {
  .is-printing .paper-fold-left { animation: paper-left 1.4s cubic-bezier(.25,.65,.25,1) both; }
  .is-printing .paper-fold-right { animation: paper-right 1.4s cubic-bezier(.25,.65,.25,1) both; }
  .is-printing .print-stamp { animation: stamp-in 1.4s ease both; }
  .student-result { animation: ink-arrive .35s ease both; }
}
@keyframes paper-left { 0%, 38% { transform: rotateY(0); } 95%, 100% { transform: rotateY(-105deg); } }
@keyframes paper-right { 0%, 38% { transform: rotateY(0); } 95%, 100% { transform: rotateY(105deg); } }
@keyframes stamp-in { 0% { opacity: 0; transform: translate(-50%,-50%) rotate(-12deg) scale(1.3); } 18%, 38% { opacity: 1; transform: translate(-50%,-50%) rotate(-12deg) scale(1); } 60%, 100% { opacity: 0; } }
@keyframes ink-arrive { from { opacity: .2; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
body.plain .briefs-column { display: none; }
body.plain .front-page { grid-template-columns: minmax(0, 1fr); }
body.plain .student-result { animation: none; }
body.plain .app-shell::before, body.plain .app-shell::after { opacity: .35; }
@media (min-width: 1024px) and (max-height: 900px) {
  :root { --reveal-height: 300px; }
}
@media (min-width: 1024px) and (max-height: 780px) {
  :root { --reveal-height: 280px; }
  body { padding-bottom: 8px; }
  .app-shell { min-height: calc(100dvh - 22px); }
  .masthead { padding-block: 6px; }
  .brand { font-size: 44px; }
  .brand span { font-size: 10px; margin-top: 4px; }
  .nav-line, .nav-link { min-height: 42px; }
  .class-context { min-height: 52px; }
  .front-page { padding-block: 10px; }
  .lead-story { grid-template-rows: 32px var(--reveal-height) 70px 28px; gap: 6px; }
  .recent-item { gap: 1px; padding-block: 5px; }
  .recent-item p { font-size: 16px; line-height: 1.6; }
  .brief-item { padding-block: 10px; }
  .editorial-art { height: 52px; }
  footer { padding-block: 6px; }
  .draw-results:has(.student-result:nth-child(2)) { padding-inline: 8px; }
}
@media (max-width: 1100px) {
  .front-page { grid-template-columns: minmax(0, 1fr) 195px; gap: 22px; }
  .briefs-column { padding-left: 18px; }
  .masthead-side p { display: none; }
  .masthead-right { flex-direction: column; gap: 5px; }
  .edition-seal { display: none; }
  .collection-teaser { grid-template-columns: minmax(0, 1fr); }
  .collection-teaser .teaser-link { padding-top: 4px; }
  .print-collection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .front-page { grid-template-columns: minmax(0, 1fr); }
  .briefs-column { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 0 24px; padding: 18px 0 0; border-left: 0; border-top: 3px double var(--ink); }
  .recent-section { grid-row: span 2; }
  .brief-item { padding-top: 0; border: 0; }
}
@media (max-width: 700px) {
  :root { --reveal-height: 280px; }
  body { padding: 7px 0; }
  .app-shell { width: calc(100% - 14px); min-height: calc(100dvh - 14px); padding-inline: 16px; background-size: 620px; }
  .app-shell::before { opacity: .65; }
  .app-shell::after { opacity: .4; }
  .masthead { grid-template-columns: 1fr; padding: 18px 0 13px; }
  .brand { font-size: 48px; }
  .brand span { font-size: 10px; letter-spacing: .15em; }
  .masthead-side { display: none; }
  .nav-line { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
  .nav-edition { display: none; }
  nav { justify-content: space-between; gap: 0; }
  .nav-link { font-size: 11px; padding-inline: 4px; }
  #presentation { font-size: 10px; padding-left: 7px; }
  #presentation span { display: none; }
  .class-context { flex-direction: column; gap: 3px; align-items: stretch; padding: 9px 0 13px; }
  .class-picker { gap: 10px; }
  .class-picker select { max-width: 160px; margin-right: auto; }
  .round-context { justify-content: space-between; font-size: 10px; gap: 9px; }
  progress { width: 50px; }
  .front-page { padding-block: 16px 20px; gap: 24px; }
  .lead-story { grid-template-rows: 34px var(--reveal-height) 70px 46px; }
  .stage-heading { justify-content: center; align-items: center; }
  .stage-heading h1 { font-size: clamp(20px, 6vw, 26px); }
  .story-kicker { display: none; }
  .reveal-region { padding-inline: 0; grid-template-rows: 20px minmax(0, 1fr) 32px; }
  .student-result strong { font-size: clamp(48px, 14vw, 74px); }
  .draw-console { grid-template-columns: 97px minmax(0, 1fr) 64px; gap: 7px; }
  .stepper button { width: 29px; min-width: 28px; }
  .stepper input { width: 37px; }
  .draw-button { padding-inline: 12px; font-size: 13px; letter-spacing: 0; }
  .undo-button { font-size: 10px; padding-inline: 0; }
  .count-hint { text-align: left; font-size: 10px; }
  .milestone { font-size: 11px; }
  .draw-results.many:has(.student-result:nth-child(2)) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .briefs-column { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .recent-section { grid-row: auto; }
  .recent-item { flex-direction: row; align-items: baseline; gap: 16px; padding: 10px 0; }
  .recent-item time { flex-shrink: 0; }
  .recent-item > div { flex: 1; }
  .brief-item { padding: 12px 0 0; border-top: 1px solid var(--line); }
  .collection-teaser { grid-template-columns: minmax(0, 1fr) auto; }
  .editorial-art { height: 80px; }
  .collection-teaser .teaser-link { padding-top: 0; }
  footer { flex-wrap: wrap; gap: 0 12px; padding-block: 9px; }
  .footer-rule { display: none; }
  footer > div { margin-left: auto; }
  .page-heading { align-items: start; flex-direction: column; gap: 13px; }
  .page-heading h1 { font-size: 32px; }
  .page-actions { width: 100%; gap: 6px; }
  .page-actions button, .page-actions .download-link { font-size: 12px; padding-inline: 11px; }
  .roster-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-field input { width: 100%; }
  .roster-toolbar > div { display: flex; justify-content: space-between; }
  .student-grid { grid-template-columns: 1fr; }
  .student-row { padding-block: 12px; }
  .history-entry { grid-template-columns: minmax(0,1fr) 83px; gap: 12px; }
  .history-entry > div:first-child { grid-column: 1/-1; }
  .history-names { gap: 14px 20px; }
  #history-summary { margin-left: 0; width: 100%; }
  .collection-mark { display: none; }
  .print-collection { gap: 13px; }
  .print-card { padding: 16px 12px 12px; min-height: 270px; }
  .print-card-title { font-size: 25px; }
  .print-card-copy { font-size: 14px; }
  dialog { padding: 20px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .audio-settings { border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
  .settings-group legend { font-size: 19px; padding-bottom: 10px; }
  .settings-data { align-items: stretch; }
  .settings-data-actions { width: 100%; }
  .settings-data-actions button { flex: 1; }
  .message { font-size: 12px; padding: 8px 10px; }
}
/* Desktop names take the height left by the masthead and controls. Size
   containment prevents the old/new batch from changing the grid's geometry. */
@media (min-width: 801px) {
  body:not(.presenting) main:has(.classroom-view:not([hidden])),
  body:not(.presenting) .classroom-view { display: grid; }
  body:not(.presenting) .front-page { align-items: stretch; }
  body:not(.presenting) .lead-story { grid-template-rows: 38px minmax(var(--reveal-height), 1fr) 70px 36px; }
  body:not(.presenting) .briefs-column { align-self: start; }
  body:not(.presenting) .reveal-region { height: auto; min-height: 0; container-type: size; }
  body:not(.presenting) .draw-results:empty::before { font-size: clamp(54px, min(14cqw, 26cqh), 160px); }
  body:not(.presenting) .student-result strong { font-size: clamp(64px, min(18cqw, 34cqh), 240px); }
  body:not(.presenting) .draw-results:has(.student-result:nth-child(2)) strong { font-size: clamp(32px, min(9cqw, 22cqh), 130px); }
  body:not(.presenting) .draw-results:has(.student-result:nth-child(3)) strong { font-size: clamp(32px, min(9cqw, 19cqh), 110px); }
  body:not(.presenting) .draw-results:has(.student-result:nth-child(5)) strong { font-size: clamp(32px, min(8.6cqw, 13cqh), 100px); }
  body:not(.presenting) .draw-results.many strong { font-size: clamp(24px, min(5cqw, 10cqh), 56px) !important; }
  body:not(.presenting) .paper-fold > span { font-size: clamp(30px, min(8cqw, 18cqh), 100px); }
}
@media (min-width: 1024px) and (max-height: 780px) {
  body:not(.presenting) .lead-story { grid-template-rows: 32px minmax(var(--reveal-height), 1fr) 70px 28px; }
}
/* Projection has a definite viewport grid: names use the space left by controls,
   never the intrinsic height of the current batch. Keep these overrides last. */
body.presenting { padding-block: 8px; }
body.presenting .app-shell {
  width: calc(100% - 16px); height: calc(100dvh - 16px); min-height: 460px;
  padding: 0 clamp(16px, 2.5vw, 48px) 8px;
  display: grid; grid-template-rows: 56px minmax(0, 1fr);
}
body.presenting .app-shell::before, body.presenting .app-shell::after { opacity: .25; }
body.presenting .masthead, body.presenting .nav-edition, body.presenting nav,
body.presenting .briefs-column,
body.presenting .recent-section, body.presenting footer,
body.presenting .story-kicker, body.presenting .stage-heading { display: none; }
body.presenting .nav-line { position: absolute; top: 6px; right: clamp(16px, 2.5vw, 48px); display: flex; min-height: 42px; border: 0; }
body.presenting #presentation { min-height: 42px; padding: 8px 0 8px 12px; }
body.presenting .class-context { grid-row: 1; min-height: 0; padding: 0 100px 0 0; }
body.presenting main { grid-row: 2; min-height: 0; }
body.presenting .classroom-view { height: 100%; }
body.presenting .front-page { display: block; max-width: none; height: 100%; padding: 8px 0 0; margin: 0; }
body.presenting .lead-story { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) 70px 32px; gap: 8px; }
body.presenting .reveal-region {
  grid-row: 1; height: auto; min-height: 0; flex: none; padding: 12px 16px;
  grid-template-rows: 24px minmax(0, 1fr) 22px;
  border-top: 0; container-type: size;
}
body.presenting .result-caption { font-size: 14px; }
body.presenting .result-detail { font-size: 11px; }
body.presenting .draw-results {
  --projection-columns: 1;
  --projection-name-size: clamp(64px, min(22cqw, 45cqh), 340px);
  display: grid; grid-template-columns: repeat(var(--projection-columns), minmax(0, 1fr));
  grid-auto-rows: minmax(min-content, 1fr); gap: 12px 24px; padding: 4px 12px;
}
body.presenting .draw-results:has(.student-result:nth-child(2)) {
  --projection-columns: 2; --projection-name-size: clamp(56px, min(11cqw, 38cqh), 200px);
  grid-template-columns: repeat(var(--projection-columns), minmax(0, 1fr));
}
body.presenting .draw-results:has(.student-result:nth-child(3)) { --projection-name-size: clamp(44px, min(10.5cqw, 21cqh), 150px); }
body.presenting .draw-results:has(.student-result:nth-child(3)):not(:has(.student-result:nth-child(4))) .student-result:last-child { grid-column: 1 / -1; }
body.presenting .draw-results:has(.student-result:nth-child(5)) { --projection-columns: 3; --projection-name-size: clamp(40px, min(7.3cqw, 22cqh), 120px); }
body.presenting .draw-results:has(.student-result:nth-child(7)) { --projection-name-size: clamp(36px, min(7cqw, 13cqh), 100px); }
body.presenting .draw-results:has(.student-result:nth-child(13)) { --projection-columns: 4; --projection-name-size: clamp(32px, min(5cqw, 9cqh), 76px); }
body.presenting .draw-results:has(.student-result:nth-child(25)) { --projection-columns: 5; --projection-name-size: clamp(30px, min(4cqw, 6.4cqh), 56px); }
body.presenting .draw-results:has(.student-result:nth-child(37)) { --projection-columns: 8; --projection-name-size: clamp(30px, min(2.6cqw, 9cqh), 64px); gap: 8px 12px; }
body.presenting .draw-results .student-result strong,
body.presenting .draw-results.many .student-result strong { font-size: var(--projection-name-size) !important; line-height: 1.12; letter-spacing: .035em; }
body.presenting .student-result small { font-size: 13px; line-height: 1.5; margin-top: 8px; }
body.presenting .draw-results.many .student-result small { font-size: 11px; margin-top: 5px; }
body.presenting .draw-results:has(.student-result:nth-child(37)) .student-result small { font-size: 10px; line-height: 1.4; margin-top: 3px; }
body.presenting .draw-results:empty::before { font-size: clamp(44px, min(16cqw, 30cqh), 220px); }
body.presenting .paper-fold > span { font-size: clamp(44px, min(12cqw, 24cqh), 160px); }
body.presenting .draw-console { grid-row: 2; grid-column: 1; align-self: center; max-width: 800px; width: 100%; margin: 0 auto; }
body.presenting .count-hint { grid-row: 3; grid-column: 1; align-self: center; margin: 0; text-align: center; font-size: 11px; }
body.presenting .milestone { grid-row: 3; grid-column: 1; margin: 0; padding: 0; border: 0; background: none; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0 8px; line-height: 1.5; overflow: auto; }
body.presenting .milestone .text-button { min-height: 28px; padding: 2px 8px; }
body.presenting .lead-story:has(.milestone:not([hidden])) .count-hint { visibility: hidden; }
body.presenting .message { position: absolute; top: 56px; left: 24px; right: 24px; z-index: 4; }
@media (max-width: 700px) {
  body.presenting .app-shell { padding-inline: 14px; grid-template-rows: 88px minmax(0, 1fr); }
  body.presenting .nav-line { right: 14px; }
  body.presenting .class-context { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; }
  body.presenting .class-picker { padding-right: 76px; gap: 8px; }
  body.presenting .class-picker > label { display: none; }
  body.presenting .class-picker select { max-width: 130px; font-size: 13px; }
  body.presenting .class-picker .text-button { padding-inline: 0; font-size: 10px; }
  body.presenting .lead-story { grid-template-rows: minmax(0, 1fr) 70px 48px; }
  body.presenting .reveal-region { padding-inline: 0; grid-template-rows: 22px minmax(0, 1fr) 32px; }
  body.presenting .draw-results { padding-inline: 4px; gap: 10px 12px; }
  body.presenting .draw-results:has(.student-result:nth-child(2)) { --projection-columns: 1; --projection-name-size: clamp(48px, min(21cqw, 20cqh), 90px); }
  body.presenting .draw-results:has(.student-result:nth-child(3)) { --projection-columns: 2; --projection-name-size: clamp(32px, min(10.5cqw, 17cqh), 68px); }
  body.presenting .draw-results:has(.student-result:nth-child(5)) { --projection-columns: 2; --projection-name-size: clamp(28px, min(9.5cqw, 12cqh), 56px); }
  body.presenting .draw-results:has(.student-result:nth-child(13)) { --projection-columns: 3; --projection-name-size: 26px; }
  body.presenting .draw-results:has(.student-result:nth-child(25)) { --projection-columns: 3; --projection-name-size: 24px; }
  body.presenting .student-result small { font-size: 11px; margin-top: 5px; }
  body.presenting .count-hint { font-size: 10px; }
  body.presenting .milestone { font-size: 11px; }
  body.presenting .message { top: 88px; left: 14px; right: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) {
  .brand, .brand span, .stage-heading h1, .page-heading h1 { background: none; color: CanvasText; -webkit-text-fill-color: CanvasText; }
  .app-shell::before, .app-shell::after { display: none; }
}
