:root {
  --ink: #12233f;
  --muted: #61708a;
  --paper: #fbfdff;
  --cream: #edf4fb;
  --amber: #0f8c8c;
  --dark: #143d73;
  --line: #cad8e8;
  --ok: #166534;
  --accent: #0f766e;
  --shadow: 0 18px 50px rgba(20, 61, 115, 0.1);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  line-height: 1.65;
}
.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: #fff;
  color: var(--dark);
  font-weight: 800;
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
a {
  color: inherit;
}
.hero {
  min-height: 390px;
  padding: 24px max(24px, calc((100vw - 1120px) / 2));
  color: #fff;
  background:
    radial-gradient(
      circle at 78% 20%,
      rgba(45, 212, 191, 0.26),
      transparent 32%
    ),
    linear-gradient(135deg, #0b1f3a, #143d73 58%, #0f766e);
}
nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
nav a {
  text-decoration: none;
  opacity: 0.86;
}
nav .brand {
  margin-right: auto;
  font-weight: 800;
  opacity: 1;
}
.hero-copy {
  max-width: 800px;
  padding: 50px 0 38px;
}
.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.eyebrow { color: #99f6e4; }
.section-label { color: #0f766e; }
.hero h1 {
  margin: 0;
  text-wrap: balance;
  font-family: "Noto Serif TC", "Songti TC", serif;
  max-width: 940px;
  font-size: clamp(2.35rem, 4.6vw, 4rem);
  line-height: 1.15;
}
.hero-copy > p:last-child {
  max-width: 650px;
  font-size: 1.1rem;
  color: #dbeafe;
}
main {
  width: min(1120px, calc(100% - 32px));
  margin: -40px auto 64px;
}
.quickstart-card {
  margin-top: 16px;
  padding: 22px;
  border-radius: 20px;
  background: linear-gradient(120deg, #0b1f3a, #0f766e);
  color: #f0fdfa;
  text-align: center;
  box-shadow: var(--shadow);
}
.introbox {
  margin-top: 24px;
  padding: 18px 20px;
  border-left: 3px solid #0f8c8c;
  background: #e3f2f6;
  color: var(--ink);
}
.introbox strong { color: #0f766e; }
.introbox span { display: block; margin-top: 4px; color: var(--muted); }
.quickstart-card p {
  margin: 10px 0 0;
  color: #d5f5f0;
}
.quickstart-button {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
  font-size: 1.22rem;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  border-right: 1px solid var(--line);
}
.stats div:last-child {
  border: 0;
}
.stats strong {
  font-family: Georgia, serif;
  font-size: 2rem;
  color: var(--dark);
}
.stats span {
  color: var(--muted);
}
.panel {
  margin-top: 24px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
h2 {
  margin: 0 0 10px;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.3;
}
.control-row,
.panel-head,
.paper-actions {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}
.controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
}
.controls > div:first-child {
  max-width: 560px;
}
.control-row label {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}
select,
input[type="number"] {
  min-height: 46px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
button,
.button-link {
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid var(--dark);
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}
button:hover:not(:disabled),
.button-link:hover { transform: translateY(-1px); }
:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}
.primary {
  background: var(--dark);
  color: #fff;
}
.quiet,
.secondary {
  background: transparent;
  color: var(--dark);
}
.muted,
.notice,
.source-card p,
.archive article p {
  margin: 6px 0 0;
  color: var(--muted);
}
.workspace {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 24px;
}
.workspace.structured-workspace {
  grid-template-columns: 1fr;
}
.workspace .panel {
  margin-top: 24px;
}
.panel-head {
  justify-content: space-between;
  align-items: center;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--dark);
}
.source-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 24px;
  padding: 28px;
  border-radius: 16px;
  background: #f4ead9;
}
.source-card > span {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  font-family: serif;
  font-size: 2rem;
}
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0;
}
.answer-grid.structured {
  grid-template-columns: 1fr;
  gap: 22px;
}
.question-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
}
.question-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 14px 16px 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.question-state {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f4ede1;
  color: #6d5136;
  font-weight: 700;
}
.question-tag {
  padding: 3px 8px;
  border-radius: 6px;
  background: #e8dfc5;
  color: #56412d;
}
.question-tag.cat-C1 { background: #eedaca; }
.question-tag.cat-C2 { background: #e8e5c5; }
.question-tag.cat-C3 { background: #dbead5; }
.question-tag.cat-C4 { background: #d4e9e6; }
.question-tag.cat-C5 { background: #dae3f2; }
.question-tag.cat-C6 { background: #e6dbef; }
.question-tag.cat-C7 { background: #efd9e2; }
.process-tag { color: #654b70; }
.question-card > fieldset {
  margin: 0;
  padding: 22px;
  border: 0;
}
.question-card > fieldset > legend {
  float: left;
  width: 100%;
  margin-bottom: 16px;
  color: var(--ink);
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: 1.14rem;
  font-weight: 800;
}
.question-card > fieldset > legend span {
  color: var(--dark);
}
.source-passage {
  margin: 12px;
  padding: 18px;
  overflow-x: auto;
  border-left: 4px solid var(--dark);
  border-radius: 10px;
  background: #f1e7c9;
}
.source-passage summary {
  min-height: 44px;
  color: var(--dark);
  font-weight: 800;
  cursor: pointer;
}
.passage-jump {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 10px 16px 0;
  color: var(--dark);
  font-weight: 700;
}
.source-passage p:first-child {
  margin-top: 0;
}
.source-passage p:last-child {
  margin-bottom: 0;
}
.source-passage table {
  width: 100%;
  border-collapse: collapse;
}
.source-passage td,
.source-passage th {
  padding: 6px;
  border: 1px solid #cdbf9c;
}
.source-figure {
  display: block;
  width: min(100%, 960px);
  height: auto;
  margin: 16px auto 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.passage-title {
  color: var(--dark);
  font-weight: 800;
}
.source-image-note {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  background: #fff4d6;
  color: #8a4b08;
  font-weight: 700;
}
.question-options {
  display: grid;
  gap: 10px;
  clear: both;
}
.question-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 58px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.question-option.is-locked { cursor: default; }
.question-option input {
  position: absolute;
  opacity: 0;
}
.question-option:focus-within {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
.option-letter {
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--dark);
  border-radius: 50%;
}
.question-option:has(input:checked) {
  border-color: var(--dark);
  background: #f3ead8;
}
.question-option:has(input:checked) .option-letter {
  background: var(--dark);
  color: #fff;
}
.question-option.is-correct {
  border: 2px solid #416b3b;
  background: #f0f6e9;
}
.question-option.is-wrong {
  border-color: #b93825;
  background: #fff0ed;
}
.question-feedback {
  padding: 20px;
  border-top: 1px solid #dfd1ae;
  border-left: 3px solid var(--ok);
  background: #f3ead2;
}
.feedback-status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 900;
}
.feedback-status span {
  font-size: 0.95rem;
  font-weight: 700;
}
.feedback-status.is-correct { color: #2f6331; }
.feedback-status.is-wrong { color: #a52c1d; }
.feedback-status.pending { color: var(--muted); }
.question-feedback > p:first-child {
  margin-top: 0;
}
.explanation {
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: 1rem;
  line-height: 1.9;
}
.explanation p { margin: 5px 0 0; }
.explain-label,
.official-source-label {
  display: table;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff8e7;
  color: #8a3f0c;
  font-family: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
}
.official-source-label {
  background: #e8f3e3;
  color: #315c2c;
}
.stats-unavailable {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.lure-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid #b93825;
  background: rgba(185, 56, 37, 0.08);
  line-height: 1.6;
}
.wrong-reason {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #cfbd94;
  color: var(--muted);
}
.wrong-reason button {
  min-height: 44px;
  padding: 7px 11px;
  border-color: #d5c49c;
  background: #fff7e5;
  color: var(--ink);
  font-weight: 500;
}
.wrong-reason-tip {
  flex: 1 0 100%;
  color: var(--muted);
}
.retry-question {
  min-height: 44px;
  margin-top: 10px;
  border-color: #9f2f20;
  background: #fff8ed;
  color: #8f2f22;
}
.wrong-reason button.active {
  background: var(--dark);
  color: #fff;
}
.answer-mode-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--dark);
  background: #f8f0de;
  color: var(--muted);
}
.session-progress {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-weight: 700;
}
.session-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--dark);
}
.storage-warning {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  margin: 0;
  padding: 12px 16px;
  border: 2px solid #a52c1d;
  border-radius: 10px;
  background: #fff0ed;
  color: #7f1d1d;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.metric-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.metric-badges span {
  padding: 4px 9px;
  border: 1px solid #d8c69e;
  border-radius: 999px;
  background: #fff9e9;
}
.official-stats {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #cfbd94;
}
.stats-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.stats-head button {
  min-height: 44px;
  padding: 7px 12px;
  border-color: #cdbf9c;
  background: transparent;
}
.stats-head button.active {
  background: var(--dark);
  color: #fff;
}
.option-stat-rows {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.option-stat-row {
  display: grid;
  grid-template-columns: 82px minmax(100px, 1fr) 54px;
  align-items: center;
  gap: 10px;
}
.option-stat-row > div {
  height: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6dabc;
}
.option-stat-row i {
  display: block;
  height: 100%;
  background: #b93825;
}
.option-stat-row i.correct {
  background: #416b3b;
}
.option-stat-row b {
  text-align: right;
  font-size: 0.82rem;
}
.answer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.answer-row legend {
  float: left;
  width: 32px;
  font-weight: 800;
  color: var(--dark);
}
.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.choice input:checked + span {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}
.submit {
  width: 100%;
}
.result {
  margin-top: 18px;
  padding: 20px;
  border-left: 5px solid var(--ok);
  border-radius: 10px;
  background: #ecfdf5;
}
.result strong {
  font-size: 1.35rem;
}
.archive-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.archive article {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.archive article > span {
  font:
    700 1.3rem Georgia,
    serif;
  color: var(--amber);
}
.archive article div {
  margin-right: auto;
}
.archive article a {
  font-size: 0.85rem;
  color: var(--dark);
}
.prose {
  max-width: 820px;
}
.compact-header {
  padding: 28px max(24px, calc((100vw - 800px) / 2)) 54px;
  background: var(--dark);
  color: #fff;
}
.compact-header h1 {
  margin: 46px 0 0;
  font-family: serif;
  font-size: 2.8rem;
}
.compact-header p {
  margin: 4px 0;
}
.narrow {
  width: min(800px, calc(100% - 32px));
  margin: -30px auto 60px;
}
.form-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-left: 3px solid #a52c1d;
  background: #fff0ed;
  color: #8d2317;
  font-weight: 700;
}
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.checker .paper-actions {
  margin-top: 18px;
}
footer {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 760px) {
  .hero {
    min-height: 360px;
    padding-inline: 20px;
  }
  .hero-copy {
    padding: 42px 0 34px;
  }
  .hero h1 { font-size: clamp(2.05rem, 9vw, 2.8rem); }
  .stats div {
    padding: 16px 8px;
  }
  .stats strong {
    font-size: 1.7rem;
  }
  .controls,
  .workspace {
    display: block;
  }
  .control-row > * {
    width: 100%;
  }
  .panel {
    padding: 22px;
  }
  .answer-grid,
  .archive-grid {
    grid-template-columns: 1fr;
  }
  .paper-actions {
    align-items: stretch;
  }
  .paper-actions > * {
    flex: 1;
    text-align: center;
  }
  nav {
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.9rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.text-button {
  min-height: 44px;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--dark);
}
.filter-grid {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.basic-filters {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf6ed;
}
.year-picker {
  position: relative;
  width: 190px;
}
.year-control {
  display: grid;
  gap: 6px;
}
.filter-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.year-picker > summary {
  min-height: 46px;
  padding: 10px 36px 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.year-picker > summary::-webkit-details-marker { display: none; }
.year-picker > summary::after {
  content: "⌄";
  position: absolute;
  top: 10px;
  right: 13px;
}
.year-picker[open] > summary::after { content: "⌃"; }
.year-picker-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 0;
  width: min(430px, calc(100vw - 56px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  box-shadow: 0 14px 32px rgba(54, 37, 21, 0.18);
}
.year-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.year-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  max-height: 310px;
  padding-top: 8px;
  overflow: auto;
}
.year-options label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.year-options label:hover { background: #f4ead7; }
.year-options input { width: 18px; height: 18px; accent-color: var(--dark); }
.filter-grid > label:not(.check-control) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.filter-grid input[type="number"] {
  width: 90px;
}
.check-control {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 8px 0;
  color: var(--ink);
  font-weight: 650;
}
.check-control input,
.metadata-filter input {
  width: 18px;
  height: 18px;
  accent-color: var(--dark);
}
.secondary-filters {
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.unavailable,
.metadata-filter:disabled {
  color: #8b8177;
}
.unavailable-note,
.annotation-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #9f2f20;
  background: #f8f0de;
  color: var(--muted);
}
.annotation-note { border-left-color: #8a6a3f; }
.metadata-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px dashed var(--line);
}
.metadata-filter legend {
  float: left;
  margin-right: 6px;
  color: var(--muted);
}
.metadata-filter label {
  display: flex;
  align-items: center;
  gap: 5px;
}
.match-count {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
}
.filter-summary {
  margin: 4px 0 0;
  color: var(--muted);
}
.category-filter {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.category-filter legend {
  padding: 0 8px;
  color: var(--dark);
  font-weight: 800;
}
.taxonomy-source {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--dark);
  background: #f8f1e4;
  color: var(--muted);
  line-height: 1.65;
}
.taxonomy-source a {
  margin-left: 6px;
  color: var(--dark);
  font-weight: 750;
}
#categoryOptions {
  display: grid;
  gap: 0;
}
.category-guide,
.category-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-guide {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}
.category-group {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.category-main strong {
  display: grid;
  gap: 2px;
  font-size: 1.02rem;
}
.category-main strong small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}
.category-dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #ecd7c7;
}
.cat-C2 .category-dot { background: #e5e2bd; }
.cat-C3 .category-dot { background: #d6e8cf; }
.cat-C4 .category-dot { background: #cce6e2; }
.cat-C5 .category-dot { background: #d6e0f2; }
.cat-C6 .category-dot { background: #e3d5ef; }
.cat-C7 .category-dot { background: #efd3df; }
.category-actions {
  display: flex;
  gap: 2px;
}
.category-select,
.category-detail-toggle {
  min-height: 44px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--dark);
  font-weight: 500;
}
.category-detail-toggle { margin-left: auto; }
.category-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 8px 0 2px 20px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f1e4;
}
.category-tag-list > b {
  align-self: center;
  color: var(--dark);
  font-size: 0.82rem;
}
.category-tag-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-weight: 600;
}
#categoryOptions input {
  width: 18px;
  height: 18px;
  accent-color: var(--dark);
}
.category-tag-list label > span {
  line-height: 1.1;
}
.metric-source {
  display: inline-block;
  margin-top: 8px;
  color: var(--dark);
  font-size: 0.9rem;
  font-weight: 700;
}
.action-row,
.more-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.accent {
  border-color: #a16207;
  background: #a16207;
  color: #fff;
}
.more-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.more-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf6ed;
}
.more-group > b { display: block; margin-bottom: 8px; color: var(--dark); }
.more-group > div { display: grid; gap: 7px; }
.more-group button,
.more-group .button-file { width: 100%; }
button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.button-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid var(--dark);
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.button-file input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.source-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.history-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.history-entry:last-child {
  border: 0;
}
.history-entry p {
  margin: 3px 0;
  color: var(--muted);
}
.history-entry b {
  min-width: 70px;
  text-align: right;
  font-size: 1.35rem;
  color: var(--dark);
}
.history-entry small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}
.empty-state {
  padding: 24px;
  border-radius: 14px;
  background: #f7f2e8;
}
.empty-state p {
  margin-bottom: 0;
}
.teacher-preview {
  margin-top: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  background: #fff;
  color: #111;
}
.teacher-panel > .control-row {
  display: grid;
  grid-template-columns: 180px repeat(3, minmax(140px, 1fr));
  align-items: end;
}
.teacher-panel #selectedTeacherCount {
  align-self: center;
  color: var(--dark);
}
.teacher-preview h3 {
  margin: 0;
  font-family: serif;
  font-size: 1.6rem;
}
.teacher-question-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.teacher-question-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #ddd0b9;
  border-radius: 8px;
  cursor: pointer;
}
.teacher-question-list input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: var(--dark);
}
.teacher-question-list span { min-width: 0; }
.teacher-question-list small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teacher-print {
  background: #fff;
  color: #111;
}
.print-question {
  break-inside: avoid;
  margin-bottom: 22px;
}
.print-question h3 { margin-bottom: 6px; }
.print-question li { margin: 5px 0; }
.print-passage {
  margin-bottom: 10px;
  padding: 12px;
  background: #f3ead5;
}
.print-figure-note {
  padding: 7px 10px;
  border-left: 3px solid #9f2f20;
  background: #fff3e7;
}
.teacher-answer-section {
  break-before: page;
}
.teacher-answer-section li { margin-bottom: 12px; }
.teacher-answer-section p { margin: 3px 0; }
.print-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 18px;
  margin-top: 18px;
}
.print-grid > div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-bottom: 1px solid #bbb;
}
.print-grid b {
  width: 28px;
}
.print-source {
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}
.teacher-preview[data-paper="B4"] .print-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.rank-table {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.rank-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.rank-row:last-child {
  border-bottom: 0;
}
.rank-head {
  background: #f1e7d7;
}

@media (max-width: 760px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats div:nth-child(2) {
    border-right: 0;
  }
  .stats div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  .filter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
  }
  .filter-grid > * {
    min-width: 0;
  }
  .filter-grid select,
  .filter-grid input[type="number"] {
    width: 100%;
    min-width: 0;
    padding-right: 30px;
  }
  .filter-grid > label:first-child,
  .basic-filters > .year-control,
  .secondary-filters > .check-control:first-child {
    grid-column: 1/-1;
  }
  .year-picker { width: 100%; }
  .check-control {
    min-height: 44px;
  }
  .category-main { flex-wrap: wrap; }
  .category-main strong {
    flex: 1 1 calc(100% - 24px);
    min-width: 0;
  }
  .category-actions { margin-left: 20px; }
  .category-detail-toggle { margin-left: 0; }
  .category-tag-list { margin-left: 0; }
  .metadata-filter {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .metadata-filter legend {
    grid-column: 1/-1;
  }
  .action-row,
  .more-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .action-row > * {
    width: 100%;
    min-width: 0;
  }
  .action-row .primary,
  .action-row .accent,
  .action-row .text-button {
    grid-column: 1/-1;
  }
  .more-actions > * {
    width: 100%;
    min-width: 0;
  }
  .session-progress { grid-template-columns: 1fr; }
  .teacher-panel > .control-row { grid-template-columns: 1fr; }
  .question-state { margin-left: 0; }
  .storage-warning { right: 10px; bottom: 10px; left: 10px; max-width: none; }
  .print-grid {
    grid-template-columns: 1fr;
  }
  .history-entry {
    align-items: flex-start;
  }
  .question-card > fieldset {
    padding: 16px;
  }
  .source-passage {
    margin: 8px;
    padding: 14px;
  }
  .rank-row {
    grid-template-columns: 48px 1fr 1fr 70px;
    padding: 9px;
  }
}

@media print {
  body {
    background: #fff;
  }
  .hero,
  .stats,
  .introbox,
  .quickstart-card,
  .practice-builder,
  .workspace,
  .archive,
  .prose,
  footer,
  .history-panel,
  .teacher-panel {
    display: none !important;
  }
  main {
    width: 100%;
    margin: 0;
  }
  .teacher-print {
    display: block !important;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .teacher-print[data-paper="B4"] .print-questions {
    column-count: 2;
    column-gap: 14mm;
  }
  @page {
    size: auto;
    margin: 12mm;
  }
}
