:root {
  --ink: #261c13;
  --muted: #75685e;
  --paper: #fffdf8;
  --cream: #f6efe3;
  --amber: #d97706;
  --dark: #713f12;
  --line: #dfd3c3;
  --ok: #166534;
  --shadow: 0 18px 50px rgba(74, 45, 15, 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;
}
a {
  color: inherit;
}
.hero {
  min-height: 480px;
  padding: 24px max(24px, calc((100vw - 1120px) / 2));
  color: #fff;
  background:
    radial-gradient(
      circle at 78% 20%,
      rgba(245, 158, 11, 0.32),
      transparent 32%
    ),
    linear-gradient(135deg, #2e1d0f, #713f12 58%, #92400e);
}
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: 86px 0 52px;
}
.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fbbf24;
}
.hero h1 {
  margin: 0;
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 1.15;
}
.hero-copy > p:last-child {
  max-width: 650px;
  font-size: 1.1rem;
  color: #f7ead6;
}
main {
  width: min(1120px, calc(100% - 32px));
  margin: -56px auto 64px;
}
.quickstart-card {
  margin-top: 24px;
  padding: 28px;
  border-radius: 20px;
  background: linear-gradient(120deg, #261c13, #7c2d22);
  color: #fff8e8;
  text-align: center;
  box-shadow: var(--shadow);
}
.quickstart-card p {
  margin: 10px 0 0;
  color: #eadccc;
}
.quickstart-button {
  border-color: #c2412d;
  background: #b93825;
  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: 24px;
  border-right: 1px solid var(--line);
}
.stats div:last-child {
  border: 0;
}
.stats strong {
  font-family: Georgia, serif;
  font-size: 2.2rem;
  color: var(--dark);
}
.stats span {
  color: var(--muted);
}
.panel {
  margin-top: 24px;
  padding: 30px;
  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;
}
.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-card > fieldset {
  margin: 0;
  padding: 22px;
  border: 0;
}
.question-card > fieldset > legend {
  float: left;
  width: 100%;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 1.08rem;
  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 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;
}
.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: 56px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.question-option input {
  position: absolute;
  opacity: 0;
}
.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;
  background: #f5ecd3;
}
.question-feedback > p:first-child {
  margin-top: 0;
}
.explanation {
  line-height: 1.9;
}
.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: 34px;
  padding: 5px 10px;
  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: 36px;
  height: 36px;
  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;
}
.checker .paper-actions {
  margin-top: 18px;
}
footer {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 760px) {
  .hero {
    min-height: 430px;
  }
  .hero-copy {
    padding-top: 64px;
  }
  .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 {
    gap: 14px;
    font-size: 0.9rem;
  }
  .hero nav a:last-child {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

.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;
}
.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;
}
.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;
}
#categoryOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}
#categoryOptions label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  font-weight: 700;
}
#categoryOptions input {
  width: 18px;
  height: 18px;
  accent-color: var(--dark);
}
.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 {
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
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-preview h3 {
  margin: 0;
  font-family: serif;
  font-size: 1.6rem;
}
.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,
  .secondary-filters > .check-control:first-child {
    grid-column: 1/-1;
  }
  .check-control {
    min-height: 44px;
  }
  .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: minmax(0, 1fr) minmax(0, 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;
  }
  .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,
  .practice-builder,
  .workspace,
  .archive,
  .prose,
  footer,
  .history-panel,
  .teacher-panel > .section-label,
  .teacher-panel > h2,
  .teacher-panel > p,
  .teacher-panel > .control-row {
    display: none !important;
  }
  main {
    width: 100%;
    margin: 0;
  }
  .teacher-panel {
    display: block !important;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .teacher-preview {
    margin: 0;
    padding: 0;
    border: 0;
  }
  .teacher-preview[data-paper="B4"] .print-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  @page {
    size: auto;
    margin: 12mm;
  }
}
