:root {
  --bg-canvas: #faf7f2;
  --bg-surface: #ffffff;
  --bg-subtle: #f2ece2;
  --bg-accent-tint: #faf0ec;
  --text-primary: #1e1d1a;
  --text-secondary: #4a4741;
  --text-muted: #6c675e;
  --accent: #9a3426;
  --accent-hover: #7f291d;
  --accent-text: #ffffff;
  --border: rgba(30, 29, 26, 0.12);
  --border-strong: rgba(30, 29, 26, 0.24);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-pinyin: "Noto Sans Pinyin", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-sheet: 0 1px 2px rgba(30, 29, 26, 0.05), 0 8px 24px rgba(30, 29, 26, 0.04);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
}

@font-face {
  font-family: "Noto Sans Pinyin";
  font-weight: 400;
  font-display: swap;
  src: url("./NotoSans-Regular.ttf") format("truetype");
}

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

html {
  color: var(--text-primary);
  background: var(--bg-canvas);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

h1, h2, h3, p, ul, ol, figure {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  left: 12px;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-canvas);
}

.header-inner {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 10px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--text-primary);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  font-size: 14px;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 0;
}

.site-nav a:hover {
  color: var(--text-primary);
}

.nav-meta {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Hero Workbench */
.hero {
  padding: var(--space-8) 0 var(--space-12);
  border-bottom: 1px solid var(--border);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.hero-title {
  font-size: 32px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-lead {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.draft-notice {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.draft-notice strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Format controls */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
}

.seg-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  border-color: var(--border-strong);
}

/* Action buttons */
.cta-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-text);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.cta-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  padding-top: 2px;
}

/* Live Sheet Inspector (Signature Element) */
.inspector {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.inspector-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.lesson-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.lesson-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.lesson-btn:hover {
  color: var(--text-primary);
}

.lesson-btn[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  border-color: var(--border-strong);
}

.sheet-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.status-dot.muted {
  background: var(--text-muted);
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-height: 36px;
  padding: 8px 10px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Authentic US Letter Paper Sheet Preview */
.paper-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sheet);
  padding: 24px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--text-primary);
  font-size: 12px;
  color: var(--text-secondary);
}

.sheet-head strong {
  color: var(--text-primary);
  font-weight: 600;
}

.sheet-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-kicker {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.sheet-h1 {
  font-family: var(--font-zh);
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-h2 {
  font-family: var(--font-zh);
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.zh-line {
  display: block;
  font-family: var(--font-zh);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-primary);
}

.py-line {
  display: block;
  font-family: var(--font-pinyin);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
  margin-top: 2px;
}

.sheet-h1 .py-line {
  font-size: 13px;
  font-weight: 400;
}

.sheet-h2 .py-line {
  font-size: 12px;
  font-weight: 400;
}

.clue-box {
  border: 1px solid var(--border-strong);
  padding: 12px 14px;
}

.clue-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clue-list li::marker {
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-task {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid rgba(30, 29, 26, 0.28);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.sheet-table th {
  font-weight: 600;
  background: #faf9f6;
}

.sheet-table td {
  height: 28px;
}

.sheet-table .zh-line {
  font-size: 13px;
}

.sheet-table .py-line {
  font-size: 11px;
}

.sheet-table tfoot td {
  font-weight: 600;
  height: auto;
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.frame-col {
  border: 1px solid var(--border-strong);
  padding: 12px 14px;
}

.frame-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: disc;
}

.helpers-strip {
  border: 1px solid var(--border-strong);
  padding: 10px 14px;
}

.helpers-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  padding: 0;
}

.helpers-row .zh-line {
  font-size: 14px;
}

.twist-box {
  border: 1.5px dashed rgba(30, 29, 26, 0.45);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.twist-receiver .zh-line {
  font-size: 14px;
  font-weight: 700;
}

.clocks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 4px 0;
}

.clock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sheet-foot-draft {
  color: #6b2e26;
  font-weight: 600;
}

.inspector-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.inspector-links {
  display: inline-flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* Main Content Sections */
.section {
  padding: var(--space-12) 0;
  border-bottom: 1px solid var(--border);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-6);
}

.section-title {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 68ch;
  margin-top: 4px;
}

/* 30-Minute Lesson Flow & Answer Keys */
.flow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--space-8);
  align-items: start;
}

.timeline-list {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--border);
}

.timeline-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: var(--space-4);
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.timeline-min {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.timeline-text .zh-line {
  font-size: 14px;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.answer-block {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.answer-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.answer-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.answer-list .zh-line {
  font-size: 14px;
  color: var(--text-secondary);
}

details.disclosure {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

details.disclosure summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 0;
  list-style-position: outside;
}

.dialogue-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.dialogue-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.dialogue-speaker {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.dialogue-row .zh-line {
  font-size: 14px;
}

/* Comparison Table */
.data-table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.data-table tr.is-selected {
  background: var(--bg-accent-tint);
}

.file-sub {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.table-actions {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
}

/* Validation & Feedback Band */
.feedback-band {
  padding: var(--space-8) 0;
  border-bottom: 1px solid var(--border);
}

.feedback-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
}

.feedback-copy {
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-copy p {
  font-size: 14px;
  color: var(--text-secondary);
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

/* Download Page */
.download-hero {
  padding: var(--space-8) 0 var(--space-6);
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--space-4);
}

.selected-box {
  margin-top: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.selected-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.selected-meta strong {
  font-size: 16px;
}

.selected-meta span {
  font-size: 13px;
  color: var(--text-secondary);
}

.selected-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.prep-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}

.prep-item {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.prep-step {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.prep-item h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.prep-item p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Footer */
.site-footer {
  padding: var(--space-6) 0 var(--space-8);
  font-size: 13px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3) var(--space-6);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-links a {
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 960px) {
  .workbench,
  .flow-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .prep-list {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 var(--space-4);
  }

  .header-inner {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .site-nav {
    gap: var(--space-4);
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 6px;
  }

  .site-nav a {
    white-space: nowrap;
    padding: 4px 0;
  }

  .nav-meta {
    display: none;
  }

  .hero {
    padding: var(--space-6) 0 var(--space-8);
  }

  .hero-title {
    font-size: 26px;
  }

  .paper-sheet {
    padding: 16px;
  }

  .frames-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: var(--space-3);
  }

  .selected-box {
    padding: var(--space-4);
  }

  .hide-mobile {
    display: none;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .table-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }
}

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