/* Demo Assessment design system. One stylesheet for every page.
   Grammar: LeetCode's workspace and list rows; DOMjudge / HackerRank for Staff review.
   Served by the app; no external request (the classroom has no internet).
   Order follows DESIGN.md: tokens, base, shell, panels, tables, chips, buttons, forms,
   banners, login, student workspace, responsive. Each rule is declared once. */

:root {
  /* Layers */
  --canvas: #f0f0f0;
  --layer-1: #ffffff;
  --layer-2: #f7f7f8;
  --topbar: #ffffff;
  --raised: #ffffff; /* the current Question step on its track */

  /* Text ramp */
  --text-1: #1a1a1a;
  --text-2: rgb(0 0 0 / 0.68);
  --text-3: rgb(0 0 0 / 0.58); /* ≥4.5:1 on white and on --canvas */
  --text-on-fill: #ffffff;

  /* Lines and fills */
  --border-1: rgb(0 0 0 / 0.16);
  --border-2: rgb(0 0 0 / 0.1);
  --border-3: rgb(0 0 0 / 0.06);
  --border-hover: rgb(0 0 0 / 0.28);
  --fill-1: rgb(0 0 0 / 0.08);
  --fill-2: rgb(0 0 0 / 0.05);
  --fill-3: rgb(0 0 0 / 0.03);
  --fill-hover: rgb(0 0 0 / 0.12);
  --fill-active: rgb(0 0 0 / 0.16);
  --grip: rgb(0 0 0 / 0.2);
  --grip-active: rgb(0 0 0 / 0.45);
  --edge-shadow: rgb(0 0 0 / 0.14); /* a table's clipped edge */

  /* Brand and states */
  --brand: #ffa116;
  --brand-ink: #a85d00;
  --brand-tint: rgb(255 161 22 / 0.14);
  --selection: rgb(255 161 22 / 0.3);
  --primary: #1f8240;
  --primary-hover: #1c7a3c;
  --info: #007aff;
  --info-ink: #0059c2;
  --info-tint: rgb(0 122 255 / 0.1);
  --info-tint-strong: rgb(0 122 255 / 0.18);
  --ok: #01b328;
  --ok-ink: #0a7d25;
  --ok-tint: rgb(1 179 40 / 0.1);
  --warn-ink: #8a5a00;
  --warn-tint: rgb(255 184 0 / 0.16);
  --warn-tint-strong: rgb(255 184 0 / 0.26);
  --danger-ink: #c41f1f;
  --danger-tint: rgb(246 54 54 / 0.1);
  --danger-tint-strong: rgb(246 54 54 / 0.18);
  --mark: #fff0b3;

  /* Type */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", Helvetica, Arial,
    sans-serif;
  --font-mono:
    Menlo, Monaco, Consolas, "Liberation Mono", "PingFang TC",
    "Microsoft JhengHei", monospace;
  --fs-xs: 0.75rem; /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-base: 0.875rem; /* 14 */
  --fs-md: 1rem; /* 16 */
  --fs-lg: 1.25rem; /* 20 */
  --fs-xl: 1.5rem; /* 24 */
  --lh-tight: 1.35;
  --lh-base: 1.55;

  /* Geometry */
  /* One graded scale and no pills: 3px small marks, 4px controls, 6px sections. */
  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;
  --gutter: 10px;
  --row-h: 44px;
  --control-h: 32px;
  --control-sm: 28px; /* small buttons, one-line forms in a table cell */
  --panel-pad: 1rem;
  --topbar-h: 50px;
  --tool-h: 48px;
  --tabbar-h: 36px;

  --ring: 0 0 0 2px var(--layer-1), 0 0 0 4px var(--info);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light;
}

/* Dark: the system's, unless the `theme` cookie chose light (forms.theme), or the
   cookie's. Both blocks hold the same lines (tests/unit/test_theme_tokens.py); a token left out
   is the same in both themes. Screen only, so a printed page stays light. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #1b1d21;
    --layer-1: #24272c;
    --layer-2: #202227;
    --topbar: #24272c;
    --raised: rgb(255 255 255 / 0.12);
    --text-1: #e3e5e8;
    --text-2: rgb(255 255 255 / 0.7);
    --text-3: rgb(255 255 255 / 0.56);
    --border-1: rgb(255 255 255 / 0.16);
    --border-2: rgb(255 255 255 / 0.1);
    --border-3: rgb(255 255 255 / 0.07);
    --border-hover: rgb(255 255 255 / 0.28);
    --fill-1: rgb(255 255 255 / 0.08);
    --fill-2: rgb(255 255 255 / 0.05);
    --fill-3: rgb(255 255 255 / 0.03);
    --fill-hover: rgb(255 255 255 / 0.12);
    --fill-active: rgb(255 255 255 / 0.16);
    --grip: rgb(255 255 255 / 0.2);
    --grip-active: rgb(255 255 255 / 0.45);
    --edge-shadow: rgb(0 0 0 / 0.5);
    --brand-ink: #ffab4a;
    --brand-tint: rgb(255 161 22 / 0.16);
    --selection: rgb(255 161 22 / 0.35);
    --info: #4c9aff;
    --info-ink: #7dbaff;
    --info-tint: rgb(76 154 255 / 0.16);
    --info-tint-strong: rgb(76 154 255 / 0.26);
    --ok: #2ea043;
    --ok-ink: #5ccf7a;
    --ok-tint: rgb(46 191 85 / 0.16);
    --warn-ink: #f5bb4f;
    --danger-ink: #ff8783;
    --danger-tint: rgb(240 72 72 / 0.16);
    --danger-tint-strong: rgb(240 72 72 / 0.26);
    --mark: rgb(255 184 0 / 0.3);
    color-scheme: dark;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --canvas: #1b1d21;
    --layer-1: #24272c;
    --layer-2: #202227;
    --topbar: #24272c;
    --raised: rgb(255 255 255 / 0.12);
    --text-1: #e3e5e8;
    --text-2: rgb(255 255 255 / 0.7);
    --text-3: rgb(255 255 255 / 0.56);
    --border-1: rgb(255 255 255 / 0.16);
    --border-2: rgb(255 255 255 / 0.1);
    --border-3: rgb(255 255 255 / 0.07);
    --border-hover: rgb(255 255 255 / 0.28);
    --fill-1: rgb(255 255 255 / 0.08);
    --fill-2: rgb(255 255 255 / 0.05);
    --fill-3: rgb(255 255 255 / 0.03);
    --fill-hover: rgb(255 255 255 / 0.12);
    --fill-active: rgb(255 255 255 / 0.16);
    --grip: rgb(255 255 255 / 0.2);
    --grip-active: rgb(255 255 255 / 0.45);
    --edge-shadow: rgb(0 0 0 / 0.5);
    --brand-ink: #ffab4a;
    --brand-tint: rgb(255 161 22 / 0.16);
    --selection: rgb(255 161 22 / 0.35);
    --info: #4c9aff;
    --info-ink: #7dbaff;
    --info-tint: rgb(76 154 255 / 0.16);
    --info-tint-strong: rgb(76 154 255 / 0.26);
    --ok: #2ea043;
    --ok-ink: #5ccf7a;
    --ok-tint: rgb(46 191 85 / 0.16);
    --warn-ink: #f5bb4f;
    --danger-ink: #ff8783;
    --danger-tint: rgb(240 72 72 / 0.16);
    --danger-tint-strong: rgb(240 72 72 / 0.26);
    --mark: rgb(255 184 0 / 0.3);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-1);
  background: var(
    --layer-1
  ); /* one surface; the student workspace keeps the canvas */
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: var(--lh-tight);
  font-weight: 600;
  text-wrap: balance;
}
h1 {
  font-size: var(--fs-xl);
}
h2 {
  font-size: var(--fs-lg);
}
h3 {
  font-size: var(--fs-md);
}
h4 {
  font-size: var(--fs-base);
}

p {
  margin: 0 0 0.75em;
}
p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--info-ink);
  text-decoration: none;
  text-underline-offset: 0.2em;
}
a:hover {
  text-decoration: underline;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
:not(pre) > code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--fill-3);
  overflow-wrap: anywhere;
}
pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-2);
  margin: 1rem 0;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* A link has no corners of its own; the ring takes the small radius. A control keeps its own, a
   link-button too: :where() lets any class that sets a radius win. */
a:where(:focus-visible) {
  border-radius: var(--radius-sm);
}

/* An id (Student ID, Question, Slot, Demo Session, Assignment): mono, never broken. */
.id {
  font-family: var(--font-mono);
  font-size: 0.92em;
  white-space: nowrap;
}
/* An id in a heading: the mono fonts have no 600, so the heading weight would fall to Bold. */
:is(h1, h2, h3) .id {
  font-weight: 500;
}
.num,
time {
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}
.small {
  font-size: var(--fs-sm);
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The English half of a bilingual label: same line, quieter. */
.en {
  color: var(--text-2);
  font-weight: inherit;
}
/* In running sentences the English half starts its own line, so neither language breaks mid-phrase. */
.sub .en,
.hint .en,
.empty .en,
p.bi .en {
  display: block;
}
/* Staff pages show only the Chinese (ADR-0022): over every rule that shows an English half. */
.zh-only .en {
  display: none !important;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: -3px;
}

details > summary {
  cursor: pointer;
  color: var(--text-2);
  font-weight: 500;
}
details > summary:hover {
  color: var(--text-1);
}
details[open] > summary {
  margin-bottom: 0.5rem;
}

/* ---------- Staff shell: top bar, page, title row, crumbs, segmented chooser ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: var(--topbar);
  border-bottom: 1px solid var(--border-2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-1);
  font-weight: 600;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
/* The nav scrolls inside its own strip, so Log out keeps its place. */
.topnav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav a {
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: 0 0.7rem;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition:
    color 150ms var(--ease),
    border-color 150ms var(--ease);
}
.topnav a:hover {
  color: var(--text-1);
  text-decoration: none;
}
.topnav a[aria-current="page"] {
  color: var(--text-1);
  border-bottom-color: var(--brand);
}
.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}
.page-head h1 {
  font-size: var(--fs-xl);
}
.page-head .sub {
  margin-top: 0.25rem;
  color: var(--text-2);
}
/* The count after a page title: one pattern for every list page, a plain grey number. */
.tally {
  margin-left: 0.5rem;
  color: var(--text-3);
  font-size: var(--fs-md);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.crumbs a {
  color: var(--text-2);
}
.crumbs .sep {
  color: var(--text-3);
}
.crumbs .icon {
  width: 12px;
  height: 12px;
  color: var(--text-3);
}

/* In-page tabs (an Assignment chooser, the checklist's stages): links on a hairline, the current
   one underlined in text-1 (the top nav keeps the brand underline). */
.seg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: var(--gutter);
  border-bottom: 1px solid var(--border-2);
}
.seg-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}
.seg a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  margin-bottom: -1px;
  padding: 0 0.125rem;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-base);
  font-weight: 500;
  white-space: nowrap;
}
/* With nothing chosen yet the options are links to choose from, not a value beside the label. */
.seg:not(:has([aria-current])) a {
  color: var(--info-ink);
}
.seg a:hover {
  color: var(--text-1);
  text-decoration: none;
}
.seg a[aria-current="page"] {
  color: var(--text-1);
  border-bottom-color: var(--text-1);
}

/* ---------- Panels and content blocks ---------- */

.panel {
  background: var(--layer-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
}
.panel + .panel,
.panel + .stack,
.stack + .panel,
.seg-row + .banner,
.seg-row + .panel,
.banner + .banner,
.banner + .panel {
  margin-top: var(--gutter);
}
/* Side-by-side panels in a grid share one top edge. */
.grid-2 > .panel + .panel {
  margin-top: 0;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-height: 44px;
  padding: 0.5rem var(--panel-pad);
  border-bottom: 1px solid var(--border-3);
}
.panel-head h2,
.panel-head h3 {
  font-size: var(--fs-md);
}
.panel-body {
  padding: var(--panel-pad);
}
.panel-body > * + * {
  margin-top: 0.75rem;
}
.panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem var(--panel-pad);
  border-top: 1px solid var(--border-3);
  background: var(--layer-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  gap: var(--gutter);
  align-items: start;
}
.stack > * + * {
  margin-top: var(--gutter);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
/* A list of state words: a 16px gap, well past a space inside a word like "PDF 沒有文字層", so
   each item reads as one. */
.cluster:has(> .state) {
  column-gap: 1rem;
}
/* A detail page's facts under its title: the one status chip, then short items set apart by
   space alone. It sits 4px under the title, like a .sub line, in a .stack too. */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0.25rem 0 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.meta b {
  font-weight: 500;
  color: var(--text-1);
}
/* Row actions stay on one line (seat map); the table scrolls instead. */
.cluster.nowrap {
  flex-wrap: nowrap;
}

/* Inline count strip under a title or in a panel.
   Its margin follows the panel-body and stack spacing rules on purpose. */
.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0.375rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
}
.counts li {
  white-space: nowrap;
}
/* Long labels (overturn groups) wrap instead of clipping. */
.counts.wrap li {
  white-space: normal;
}
.counts b {
  margin-right: 0.3em;
  color: var(--text-1);
  font-size: var(--fs-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.counts .is-ok b {
  color: var(--ok-ink);
}
.counts .is-warn b {
  color: var(--warn-ink);
}
.counts .is-danger b {
  color: var(--danger-ink);
}

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-3);
}
.empty strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-2);
  font-size: var(--fs-md);
}

/* Read-only evidence: Response text, anchored content */
.evidence {
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius);
  background: var(--layer-2);
  border: 1px solid var(--border-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 28rem;
  overflow: auto;
}
.evidence.code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
/* The passage a Question asks about, above its prompt (ui.passage). */
.passage {
  margin-bottom: 0.75rem;
}
.passage > p {
  margin-bottom: 0.25rem;
}
.passage > pre {
  line-height: var(--lh-base); /* code, not the Demo page's looser prompt */
}
/* The Figure a Question asks about (ui.figure): a plot drawn for white keeps its axes; a whole
   report page fits the screen's height, so the prompt below it stays near. */
.q-figure {
  margin: 0 0 0.75rem;
}
.q-figure > figcaption {
  margin-bottom: 0.25rem;
}
.q-figure > img.figure {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: #fff;
  color: #1a1a1a; /* its alt text, if the picture fails after all, reads on the white */
}
/* A report page laid out as on paper: table columns stay aligned, wide rows scroll. */
.evidence.laid-out {
  white-space: pre;
  overflow-wrap: normal;
}
.prose {
  max-width: 72ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Key-value list for detail pages */
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.375rem 1.25rem;
  margin: 0;
}
dl.kv dt {
  color: var(--text-2);
  white-space: nowrap;
}
dl.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The Assignment checklist: numbered steps; the next one has a solid disc, a done
   one is a single line whose title links to its page. */
ol.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.step {
  display: flex;
  gap: 0.875rem;
  padding: var(--panel-pad);
}
.step + .step {
  border-top: 1px solid var(--border-3);
}
.step-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid var(--border-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  background: var(--layer-1);
}
.step.is-next .step-mark {
  background: var(--text-1);
  border-color: var(--text-1);
  color: var(--layer-1);
}
.step.is-done .step-mark {
  border-color: var(--ok-ink);
  color: var(--ok-ink);
  background: none;
}
.step.is-error .step-mark {
  border-color: var(--danger-ink);
  color: var(--danger-ink);
  background: var(--danger-tint);
}
.step.is-blocked {
  color: var(--text-2);
}
.step-body {
  flex: 1 1 auto;
  min-width: 0;
}
.step-body > * + * {
  margin-top: 0.5rem;
}
.step-body h2 {
  font-size: var(--fs-md);
}
.step-body h2 a {
  color: var(--text-1);
}
.stages .seg a {
  gap: 0.35em;
}
.stages .count {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* A version's changes: the old value struck through, the new one marked. */
.diff del {
  color: var(--danger-ink);
}
.diff ins {
  color: var(--ok-ink);
  text-decoration: none;
}
.diff del:empty,
.diff ins:empty {
  display: none;
}
legend.label {
  margin-bottom: 0.3rem;
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
}

/* A Job's progress: the native bar in the brand colour, its count beside it. */
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
/* The Generate step's test run: a few Student IDs, so a readable width. */
.test-run {
  max-width: 40rem;
}
.progress-row progress {
  flex: 1 1 auto;
  max-width: 24rem;
  height: 0.5rem;
  appearance: none;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: var(--fill-1);
}
.progress-row progress::-webkit-progress-bar {
  background: var(--fill-1);
}
.progress-row progress::-webkit-progress-value {
  background: var(--brand);
}
.progress-row progress::-moz-progress-bar {
  background: var(--brand);
}

/* ---------- Row-stack tables (LeetCode list grammar) ---------- */

/* Scrolls sideways inside a panel, keeping its corners; soft shadows show a clipped edge.
   position: relative keeps visually hidden labels inside the scroll box. */
.table-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: inherit;
  background:
    linear-gradient(to right, var(--layer-1) 30%, transparent) left / 32px 100%
      no-repeat local,
    linear-gradient(to left, var(--layer-1) 30%, transparent) right / 32px 100%
      no-repeat local,
    linear-gradient(to right, var(--edge-shadow), transparent) left / 10px 100%
      no-repeat scroll,
    linear-gradient(to left, var(--edge-shadow), transparent) right / 10px 100%
      no-repeat scroll;
}
/* A table at a panel's edge runs full width, its outer cells aligned with the panel's text.
   :where keeps these below the phone card rules. */
.panel > .table-wrap,
.panel > table.rows {
  padding: 0;
}
:where(.panel > .table-wrap, .panel) > table.rows :is(th, td):first-child {
  padding-left: var(--panel-pad);
}
:where(.panel > .table-wrap, .panel) > table.rows :is(th, td):last-child {
  padding-right: var(--panel-pad);
}
table.rows {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
table.rows th {
  height: 36px;
  padding: 0 0.75rem;
  text-align: left;
  vertical-align: middle;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-2);
}
table.rows td {
  height: var(--row-h);
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}
table.rows.top td {
  vertical-align: top;
}
/* Rows separate by a hairline, never by zebra fill or rounded strips. */
table.rows tbody tr + tr td,
:where(table.rows.grouped tbody + tbody) > tr:first-child > td {
  border-top: 1px solid var(--border-3);
}
/* Row fills, in cascade order: hover, attention (and the Live monitor's stale row). */
table.rows tbody tr:hover td {
  background: var(--fill-2);
}
table.rows tbody tr.is-attention td,
table.rows tbody tr.stale td {
  background: var(--warn-tint);
}
table.rows tbody tr.is-muted td {
  color: var(--text-3);
}
/* Score review: the Decided column layers a fill over any row fill above (they use the
   background shorthand, so the td selector must match their specificity and come after). */
table.rows .decided,
table.rows tbody tr td.decided {
  background-image: linear-gradient(var(--fill-2), var(--fill-2));
  font-weight: 600;
}
table.rows .decided .state {
  font-weight: 600;
}
table.rows th.num,
table.rows td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.rows a.id,
table.rows .id a {
  font-weight: 500;
}

/* A table whose cells hold forms: keeps its width and scrolls inside .table-wrap. */
table.rows.wide {
  min-width: 60rem;
}
/* Fairness report: one column grid, so each Direction's table lines up with the next. */
table.rows.fairness {
  table-layout: fixed;
}
table.rows.fairness col.c-group {
  width: 30%;
}
/* Seat map: fixed columns, so opening "Set deadline" grows only its row. */
table.rows.seat-map {
  table-layout: fixed;
  min-width: 62rem;
}
table.rows.seat-map col.c-seat {
  width: 6rem;
}
table.rows.seat-map col.c-student {
  width: 9.5rem;
}
table.rows.seat-map col.c-login {
  width: 10rem;
}
table.rows.seat-map col.c-deadline {
  width: 14rem;
}

/* Grouped (appeals): one <tbody> per item, its row plus an action row while open; the hairline
   falls between groups, not above an action row. */
table.rows.grouped tr.is-actions td {
  height: auto;
  padding-top: 0;
  border-top: 0;
}
table.rows.grouped tr.is-actions .cluster {
  gap: 0.5rem 1.5rem;
}

/* ---------- Chips, state words and Scores ---------- */

/* Chip: only the one state of the item a detail page is about (a Question's status, a Job's).
   Everywhere else a state is a coloured word, said once per place. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em; /* a flex item drops the space that starts a label's English half */
  height: 22px;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--fill-1);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.chip.is-ok {
  color: var(--ok-ink);
  background: var(--ok-tint);
}
.chip.is-warn {
  color: var(--warn-ink);
  background: var(--warn-tint);
}
.chip.is-danger {
  color: var(--danger-ink);
  background: var(--danger-tint);
}
.chip.is-info {
  color: var(--info-ink);
  background: var(--info-tint);
}

/* State word: coloured text only, like LeetCode's difficulty in lists */
.state {
  font-weight: 500;
  white-space: nowrap;
}
/* An ingest Anomaly's word comes first, then the file names it names: the list wraps between
   names, never inside one; a name longer than its line is cut, its title whole. */
.state.anomaly {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere; /* the English half, which Staff pages hide */
}
.state.anomaly > .file-cut {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
/* A phone can't show the title: there the names are whole on their own line. */
.file-full {
  display: none;
}
.state.is-ok {
  color: var(--ok-ink);
}
.state.is-warn {
  color: var(--warn-ink);
}
.state.is-danger {
  color: var(--danger-ink);
}
.state.is-info {
  color: var(--info-ink);
}
.state.is-muted {
  color: var(--text-3);
}
.state.is-brand {
  color: var(--brand-ink);
}
/* A state word that is a whole sentence wraps. */
p.state {
  white-space: normal;
}
/* A state word after a number (a Live count, an overridden Score) takes its own line, so the
   number stays one figure, flush with the column. */
.num .state {
  display: block;
}

/* Score: provisional (Judges only) vs verified by Staff, Codeforces style */
.score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.score.is-provisional {
  color: var(--info-ink);
}
.score.is-verified {
  color: var(--ok-ink);
}
.score.is-override {
  color: var(--brand-ink);
}

/* The English half inside a link, chip, state word or Score keeps that colour. */
a .en,
.chip .en,
.state .en,
.score .en {
  color: inherit;
  opacity: 0.8;
}

/* ---------- Buttons ---------- */

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  height: var(--control-h);
  padding: 0 0.875rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--fill-1);
  color: var(--text-1);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 150ms var(--ease),
    color 150ms var(--ease),
    box-shadow 150ms var(--ease);
}
.btn:hover,
button:hover {
  background: var(--fill-hover);
  text-decoration: none;
}
.btn:active,
button:active {
  background: var(--fill-active);
}
.btn-primary,
button.btn-primary {
  background: var(--primary);
  color: var(--text-on-fill);
}
.btn-primary:hover,
button.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-danger,
button.btn-danger {
  background: var(--danger-tint);
  color: var(--danger-ink);
}
.btn-danger:hover,
button.btn-danger:hover {
  background: var(--danger-tint-strong);
}
.btn-warn,
button.btn-warn {
  background: var(--warn-tint);
  color: var(--warn-ink);
}
.btn-warn:hover,
button.btn-warn:hover {
  background: var(--warn-tint-strong);
}
.btn-ghost,
button.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover,
button.btn-ghost:hover {
  background: var(--fill-2);
  color: var(--text-1);
}
.btn-sm,
button.btn-sm {
  height: var(--control-sm);
  padding: 0 0.625rem;
  font-size: var(--fs-sm);
}
/* The theme switch: a square moon, filled while dark. After button.btn-sm, whose specificity it
   shares; `button`'s display would otherwise show it before base.html's script does. */
button[data-theme-toggle] {
  width: var(--control-sm);
  padding: 0;
}
button[data-theme-toggle][hidden] {
  display: none;
}
button[data-theme-toggle][aria-pressed="true"] {
  background: var(--fill-1);
  color: var(--text-1);
}
.btn[disabled],
button[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
/* English half on a filled button keeps the button's ink. */
.btn-primary .en,
.btn-danger .en,
.btn-warn .en {
  color: inherit;
  opacity: 0.8;
}

/* ---------- Forms ---------- */

label {
  display: block;
  margin: 0 0 0.3rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
}
.field + .field {
  margin-top: 0.875rem;
}
/* A hint, footnote or field note: 13px text-3 wherever it sits. */
.hint {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-3);
}
.field .hint {
  margin-top: 0.25rem;
}
/* A footnote under a panel's form or another hint keeps to the panel's side padding only; a
   hint right under the panel head or a table keeps the panel's padding, so it does not read as
   part of the last row. */
:not(.panel-head, .table-wrap) + p.panel-body.hint {
  padding-top: 0;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 0.3rem 0.625rem;
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  background: var(--layer-1);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-base);
  line-height: 1.4;
  transition:
    border-color 150ms var(--ease),
    box-shadow 150ms var(--ease);
}
select {
  padding-right: 1.75rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8a8a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
}
textarea {
  min-height: 6rem;
  padding: 0.5rem 0.75rem;
  line-height: var(--lh-base);
  resize: vertical;
}
textarea.code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}
input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--border-hover);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 3px var(--info-tint-strong);
}
/* Same specificity as the base field rule above, so it wins over it. */
input:not([type="checkbox"]):not([type="radio"])[readonly],
input:not([type="checkbox"]):not([type="radio"]):disabled,
textarea[readonly],
select:disabled,
textarea:disabled {
  background: var(--layer-2);
  color: var(--text-2);
}
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  vertical-align: middle;
}
label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--text-1);
  font-weight: 400;
  font-size: var(--fs-base);
}

/* Labelled fields in two columns (one column on a phone). */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem 1rem;
  align-items: start;
}
.panel-body.form-grid > * + *,
.form-grid > .field + .field {
  margin-top: 0;
}
/* A row of controls in a panel body: its gap spaces them, not the stacked margin above, so a
   link-button sits level with a button in a form beside it. */
.panel-body.cluster > * + *,
.panel-body.toolbar > * + *,
.panel-body.form-actions > * + * {
  margin-top: 0;
}

/* A settings form: fieldsets without a frame, a two-number field, the buttons under it. */
fieldset.plain {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
fieldset.plain + .panel,
.panel + fieldset.plain,
.banner + form,
form.panel + .banner,
form.panel + form {
  margin-top: var(--gutter);
}
.form-grid .span-2 {
  grid-column: 1 / -1;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.form-rows td {
  vertical-align: top;
}
.form-rows th.wide {
  width: 55%; /* the column people write sentences in */
}
/* Two such columns (an outline step and the evidence it needs) share that room. */
.form-rows th.wide:has(+ th.wide),
.form-rows th.wide + th.wide {
  width: 30%;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* A filter toolbar or a compact one-line form */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.625rem 0.75rem;
}
.toolbar .field {
  margin: 0;
  min-width: 10rem;
}
.toolbar .field + .field {
  margin-top: 0;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
}
.inline-form input:not([type="checkbox"]):not([type="hidden"]),
.inline-form select {
  width: auto;
  min-width: 0;
  height: var(--control-sm);
  min-height: var(--control-sm);
  padding: 0 0.5rem;
  font-size: var(--fs-sm);
}
/* Same specificity as the .inline-form input rule above, so it follows it. */
.inline-form input.w-num:not([type="hidden"]) {
  width: 5.5rem;
}
.inline-form input.w-grow {
  flex: 1 1 10rem;
}
/* A number input whose placeholder is a bilingual word, e.g. "新分數 new Score".
   Same specificity as the .inline-form input rule above, so it must follow it. */
.inline-form input.w-score:not([type="hidden"]) {
  width: 9.5rem;
}
/* Per-row Staff decision (score review): reason and button stay on one line in every row. */
.inline-form.decide {
  flex-wrap: nowrap;
}
.inline-form.decide input:not([type="hidden"]) {
  min-width: 8rem;
}
/* After-Demo tables: a row form's text input takes its own line (follow-up outcome);
   the select arrow keeps its room. */
table.rows.wide td > .inline-form input.w-grow:not([type="hidden"]) {
  flex-basis: 100%;
}
table.rows.wide .inline-form select {
  padding-right: 1.75rem;
  background-position: right 0.5rem center;
}

/* An action form inside a detail page: reason + its button together, flat; a hairline
   separates one form from the next. */
.action + .action {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border-3);
}
.action h3 {
  margin-bottom: 0.5rem;
  font-size: var(--fs-base);
}
.action .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.action .row > input:not([type="checkbox"]) {
  flex: 1 1 14rem;
  width: auto;
}
/* A number input in an .action row keeps its narrow width. */
.action .row > input.w-num {
  flex: none;
  width: 5.5rem;
}

/* ---------- Banners (inline, never toasts) ---------- */

/* A tinted ground with body text in text-1; the leading icon carries the state's ink. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  background: var(--info-tint);
  color: var(--text-1);
}
.banner.is-ok {
  background: var(--ok-tint);
}
.banner.is-warn {
  background: var(--warn-tint);
}
.banner.is-danger {
  background: var(--danger-tint);
}
.banner > .icon {
  color: var(--info-ink);
}
.banner.is-ok > .icon {
  color: var(--ok-ink);
}
.banner.is-warn > .icon {
  color: var(--warn-ink);
}
.banner.is-danger > .icon {
  color: var(--danger-ink);
}
/* A banner is a running sentence: its English half takes its own line. */
.banner .en {
  display: block;
}
/* A banner button wraps on a phone instead of pushing the page sideways (DESIGN.md Layout). */
.banner .btn {
  flex-wrap: wrap;
  white-space: normal;
  height: auto;
  padding-block: 0.25rem;
  line-height: 1.3;
}
.banner .icon {
  flex: none;
  margin-top: 0.15em;
}
.banner[hidden] {
  display: none;
}
.secret {
  display: inline-block;
  margin: 0 0.25rem;
  padding: 0.1rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--layer-1);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.12em;
}

/* ---------- Login card ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 12vh 1rem 1.5rem;
}
.auth-card {
  width: min(100%, 400px);
  padding: 1.5rem;
  background: var(--layer-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
}
.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.auth-card h1 {
  font-size: var(--fs-lg);
  margin-bottom: 0.25rem;
}
.auth-card .sub {
  margin-bottom: 1.25rem;
  color: var(--text-2);
}
.auth-card .btn-primary {
  width: 100%;
  height: 40px;
  margin-top: 1.25rem;
  font-size: var(--fs-md);
}
/* Matches the base input rule's specificity so the larger login size applies. */
.auth-card
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  height: 40px;
  font-size: var(--fs-md);
}
.auth-switch {
  margin-top: 1rem;
  text-align: center;
  font-size: var(--fs-sm);
}
.auth-card input.code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.3em;
}

/* ---------- Student workspace (demo.html) ----------
   LeetCode's problem workspace: a 48px tool bar, then two white panel cards on the canvas
   with an 8px draggable gutter (Submission | Question + Response). demo.js adds
   .one-at-a-time; without JS every Question shows, stacked. */

.ws {
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  height: 100vh;
  height: 100dvh;
}
.ws .id {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}

/* Tool bar: identity | Question steps (centred) | timer, save status, Submit.
   Short of room, the outer tracks keep their content's width, so the Student ID, the Deadline,
   the save status and Submit always show whole; the steps give way and scroll. */
.ws-bar {
  flex: none;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: var(--tool-h);
  padding: 0 var(--gutter) 0 0.875rem;
  background: var(--topbar);
  border-bottom: 1px solid var(--border-2);
}
.ws-id {
  display: flex;
  align-items: center;
  min-width: 0;
}
.ws-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.ws-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Items set apart by space alone, like every meta line; a margin, since a flex gap would end the
   ellipsis. */
.ws-line > * + * {
  margin-left: 0.5rem;
}
.ws-meta,
.ws-meta .id {
  font-size: var(--fs-xs);
  color: var(--text-2);
}

/* Question steps; an empty list (no Questions) shows no pill. Positioned, so a step's hidden
   label scrolls with the steps and never widens the page. */
.ws-steps {
  position: relative;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-steps ol {
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  margin: 0;
  padding: 3px;
  list-style: none;
  background: var(--fill-2);
  border-radius: var(--radius);
}
.ws-steps ol:not(:has(li)) {
  display: none;
}
.ws-steps a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 30px;
  padding: 0 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color 150ms var(--ease),
    color 150ms var(--ease);
}
.ws-steps a:hover {
  background: var(--fill-2);
  color: var(--text-1);
  text-decoration: none;
}
.ws-steps a[aria-current="step"] {
  background: var(--raised);
  color: var(--text-1);
  box-shadow: inset 0 0 0 1px var(--border-2);
}
.ws-steps a:focus-visible {
  box-shadow: var(--ring);
}
/* The Assignment label before each group of steps (several Assignments). */
.ws .ws-set {
  padding: 0 0.375rem 0 0.5rem;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
/* Answered: a neutral dot, since a green check would read as "Accepted"; not yet: a hollow ring.
   The glyph stays for screen readers. */
.ws-steps .mark {
  position: relative;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--border-hover);
  overflow: hidden;
}
.ws-steps a.is-answered .mark {
  background: var(--text-2);
  box-shadow: none;
}

.ws-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
}
/* Nothing to save or submit: no Question, or the answers are in, so the bar no longer says they
   will be submitted. An open page has data-locked="". */
.ws-end > [hidden],
.ws:is([data-locked="submitted"], [data-locked="closed"])
  :is(.ws-then, #submit-early, [data-submit]) {
  display: none;
}

/* The countdown, calm until it matters: plain text at rest, an amber tint at 10 minutes left, a
   red tint at 3 (demo.js sets data-level), never a solid fill; grey when over or when the student
   has no Questions (idle). */
.timer {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 32px;
  padding: 0 0.625rem;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-1);
  font-size: var(--fs-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition:
    background-color 250ms var(--ease),
    color 250ms var(--ease);
}
.timer .icon {
  color: var(--text-3);
}
.timer[data-level="warn"] {
  background: var(--warn-tint);
  color: var(--warn-ink);
}
.timer[data-level="danger"] {
  background: var(--danger-tint-strong);
  color: var(--danger-ink);
}
.timer[data-level="warn"] .icon,
.timer[data-level="danger"] .icon {
  color: inherit;
}
.timer[data-level="over"],
.timer[data-level="idle"] {
  color: var(--text-3);
}

/* Save status: a state dot and one short line, never wrapped and never cut; demo.js puts the full
   sentence in its title. The minimum width holds "Saved at HH:MM:SS", so the centred steps do not
   shift on every autosave. */
.save-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 10rem;
  font-size: var(--fs-xs);
  line-height: 1.25;
  color: var(--text-3);
  white-space: nowrap;
}
.save-status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.save-status[data-state="ok"] {
  color: var(--text-2);
}
.save-status[data-state="ok"]::before {
  background: var(--ok);
}
.save-status[data-state="warn"] {
  color: var(--warn-ink);
  font-weight: 600;
}
.save-status[data-state="danger"] {
  color: var(--danger-ink);
  font-weight: 600;
}

/* Two panels and the gutter between them */
.ws-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, var(--left, 1fr)) 8px minmax(0, 1fr);
  padding: var(--gutter);
}
.ws-split > .panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ws-split > .panel + .panel {
  margin-top: 0;
}
.ws-split.is-dragging {
  cursor: ew-resize;
  user-select: none;
}
.ws-split.is-dragging iframe {
  pointer-events: none;
}
/* No Question Set: the Questions panel alone, no gutter to drag. */
.ws-split.is-single {
  grid-template-columns: minmax(0, 1fr);
}
.ws-split.is-single > .ws-gutter {
  display: none;
}
/* The gutter shows a grip: a short centred handle, darker on hover and while dragging,
   info blue on keyboard focus. */
.ws-gutter {
  position: relative;
  cursor: ew-resize;
  touch-action: none;
}
.ws-gutter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 4px;
  height: 40px;
  margin-top: -20px;
  border-radius: 2px;
  background: var(--grip);
  transition:
    background-color 150ms var(--ease),
    height 150ms var(--ease),
    margin-top 150ms var(--ease);
}
.ws-gutter:hover::after,
.ws-split.is-dragging .ws-gutter::after,
.ws-gutter:focus-visible::after {
  height: 56px;
  margin-top: -28px;
}
.ws-gutter:hover::after,
.ws-split.is-dragging .ws-gutter::after {
  background: var(--grip-active);
}
.ws-gutter:focus-visible::after {
  background: var(--info);
}

/* Left panel: tab bar over the report / notebook; no tabs (no files), no strip. */
.ws-tabs {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--tabbar-h);
  padding: 0 4px;
  background: var(--fill-3);
  border-bottom: 1px solid var(--border-3);
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-tabs:not(:has([role="tab"])) {
  display: none;
}
.ws-tabs [role="tab"] {
  height: 28px;
  padding: 0 0.625rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
}
.ws-tabs [role="tab"]:hover {
  background: var(--fill-2);
  color: var(--text-1);
}
.ws-tabs [role="tab"][aria-selected="true"] {
  background: var(--fill-1);
  color: var(--text-1);
}
.ws .pane {
  flex: 1;
  min-height: 0;
  display: flex;
}
.ws .pane[hidden] {
  display: none;
}
.ws .pane iframe {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  background: var(--layer-1);
}

/* Right panel: one Question, its Response filling the rest */
.ws-split > .questions {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.questions > .banner,
.questions > .hint {
  flex: none;
  margin: 0.875rem 1.25rem 0;
}
.question {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}
.question + .question {
  border-top: 1px solid var(--border-2);
}
.one-at-a-time .question:not(.is-current) {
  display: none;
}
.q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.875rem;
  padding: 1rem 1.25rem 0.5rem;
}
.q-head h1 {
  font-size: var(--fs-xl);
  line-height: 32px;
}
.q-prompt {
  padding: 0.25rem 1.25rem 0.875rem;
  font-size: 0.9375rem;
  line-height: 1.7;
}
.q-prompt p {
  max-width: 72ch;
  overflow-wrap: anywhere;
}
/* Where in the Submission a Question points: a label on its own line, the text links together on
   the next, at every width. No 72ch cap: in 13px it would push the second link under the label. */
.q-prompt .q-anchors {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.875rem;
  max-width: none;
  padding-top: 0.25rem;
  font-size: var(--fs-sm);
}
.q-anchors-label {
  flex-basis: 100%;
  color: var(--text-2);
}
/* An Anchor whose file is not in the Submission: a sentence, so it wraps on a phone. */
.q-anchors .state {
  white-space: normal;
}
.q-response {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0.875rem 1.25rem 0;
  border-top: 1px solid var(--border-3);
}
.q-response label {
  margin-bottom: 0.375rem;
}
.q-response textarea {
  flex: 1 0 10rem;
  min-height: 10rem;
  padding: 0.75rem 0.875rem;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.6;
  resize: none;
}
/* Read-only Response: no focus ring on a box that cannot be typed into. */
.ws textarea[readonly]:focus {
  border-color: var(--border-1);
  box-shadow: none;
}
/* Status line: the character count (plain text) left, the save state right. */
.q-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0.375rem 0 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.q-status .saved[data-state="warn"] {
  color: var(--warn-ink);
  font-weight: 600;
}
.q-status .saved[data-state="danger"] {
  color: var(--danger-ink);
  font-weight: 600;
}
.q-foot {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.875rem;
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--border-3);
  background: var(--layer-2);
}
.q-foot > :last-child {
  justify-self: end;
}
.q-foot > :first-child {
  justify-self: start;
}
/* The "n / N" counter never wraps; on phones it gives way so Previous and Next fit. */
.q-foot > .num {
  white-space: nowrap;
}

/* ---------- Responsive ---------- */

/* Workspace: the meta line drops its English halves, so the Deadline time stays whole. */
@media (max-width: 1400px) {
  .ws-meta .en {
    display: none;
  }
}

/* Workspace: stack, Question first, the Submission below at a fixed height. */
@media (max-width: 900px) {
  .ws {
    height: auto;
    min-height: 100vh;
  }
  .ws-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  .ws-id {
    flex: 1 1 12rem;
  }
  .ws-line {
    white-space: normal;
  }
  .ws-steps {
    order: 3;
    flex: 1 1 100%;
  }
  .ws-steps:not(:has(li)) {
    display: none;
  }
  .ws-end {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .ws-end .save-status {
    margin-right: auto;
  }
  .ws-end .btn-danger {
    height: 28px;
    padding: 0 0.625rem;
    font-size: var(--fs-sm);
  }
  .ws-split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gutter);
  }
  .ws-gutter {
    display: none;
  }
  .ws-split > .questions {
    order: -1;
    overflow: visible;
  }
  .ws-split > .submission {
    height: 75vh;
  }
  /* No file to show: the one line that says so, not an empty pane. */
  .ws-split > .submission:not(:has(.pane)) {
    height: auto;
  }
  .q-response textarea {
    min-height: 14rem;
  }
}

/* Staff shell below the width its one-line top bar needs (about 810px): the nav takes rows of
   its own under the brand and the buttons, so every section shows whole and none runs under
   the buttons or past the edge; the bar scrolls away with the page instead of keeping
   several rows on screen. */
@media (max-width: 820px) {
  .topbar {
    position: static;
    flex-wrap: wrap;
    height: auto;
    gap: 0 0.75rem;
    padding: 0 0.75rem;
  }
  .brand,
  .topbar-end {
    height: var(--topbar-h);
  }
  .topnav {
    order: 1;
    flex: 1 0 100%;
    flex-wrap: wrap;
    margin: 0 -0.5rem;
    overflow: visible;
  }
  .topnav a {
    min-height: 2.5rem;
  }
}

/* Phones. */
@media (max-width: 720px) {
  /* Chinese-only nav labels; Log out shrinks to its icon (text stays for screen readers). */
  .topnav a {
    padding: 0 0.5rem;
  }
  .topnav a .en,
  .topbar-end .en {
    display: none;
  }
  /* Same specificity as button.btn-sm, so it must come after the Buttons section. The theme
     switch has no label to hide and keeps its square. */
  .topbar-end button:not([data-theme-toggle]) {
    font-size: 0;
    padding: 0 0.5rem;
  }
  .page {
    padding: 1rem 0.75rem 2rem;
  }
  /* Panels and forms: one column. */
  dl.kv {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }
  dl.kv dd {
    margin-bottom: 0.5rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Row-stack tables become one card per row: every action stays on screen. */
  table.rows.stack thead {
    display: none;
  }
  table.rows.stack,
  table.rows.stack tbody,
  table.rows.stack tr,
  table.rows.stack td {
    display: block;
    width: 100%;
  }
  /* The desktop min-widths no longer apply. */
  table.rows.stack.wide,
  table.rows.stack.seat-map {
    min-width: 0;
  }
  /* A card's text lines up with the panel's (its cells inset 0.5rem more). */
  table.rows.stack tr {
    padding: 0.5rem calc(var(--panel-pad) - 0.5rem);
    border-bottom: 1px solid var(--border-3);
  }
  table.rows.stack tbody tr td,
  table.rows.stack tbody tr:hover td {
    height: auto;
    padding: 0.2rem 0.5rem;
    background: transparent;
    border-top: 0;
    text-align: left;
  }
  table.rows.stack tbody tr.is-attention,
  table.rows.stack tbody tr.stale {
    background: var(--warn-tint);
  }
  /* Room for "Demo 總分 Demo Score". The cell is a one-row table: the label is its first cell
     and the browser wraps everything else in one anonymous cell, so the value stays one flow,
     baseline-aligned with the label, and a two-line label grows the row. */
  table.rows.stack td[data-label] {
    display: table;
    table-layout: fixed;
  }
  /* Labels keep the body font even in .id / .num cells. */
  table.rows.stack td[data-label]::before {
    content: attr(data-label);
    display: table-cell;
    width: calc(8.5rem + 0.75rem);
    padding-right: 0.75rem;
    vertical-align: baseline;
    color: var(--text-2);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    white-space: normal;
  }
  /* A number and the chip after it may wrap in the card. */
  table.rows.stack td.num {
    text-align: left;
    white-space: normal;
  }
  /* A row's buttons (a .num cell with no label) wrap inside the card, like .cluster. */
  table.rows.stack td.num:not([data-label]) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  /* The names an anomaly may cut, whole under it; a line of their own in a .cluster. */
  .file-full {
    display: block;
    flex-basis: 100%;
    overflow-wrap: anywhere;
    color: var(--text-2);
    font-size: var(--fs-sm);
  }
  /* Row actions and the per-row Staff decision wrap inside the card instead of overflowing. */
  table.rows.stack .cluster.nowrap,
  table.rows.stack .inline-form.decide {
    flex-wrap: wrap;
  }
}

/* Workspace on small phones: the Question footer drops its counter. */
@media (max-width: 480px) {
  .q-foot {
    display: flex;
    justify-content: space-between;
  }
  .q-foot > .num {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
