/*
 * [INPUT]: 依赖 index.html 的语义区块、app.js 渲染的训练卡片、本地状态元素与阅读 PDF 侧栏
 * [OUTPUT]: 对外提供 JLPT N2 2026 Day 1 桌面端训练驾驶舱与响应式阅读抽屉样式
 * [POS]: public/jlpt-n2-2026 的视觉层，定义高密度、克制、考试桌面感界面与原文阅读容器
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */

:root {
  color-scheme: light;
  --bg: #f4f1eb;
  --paper: #fffdf8;
  --panel: #ffffff;
  --ink: #1d252c;
  --muted: #66717d;
  --line: #d9dedf;
  --line-dark: #aeb8bd;
  --accent: #1e4f6f;
  --accent-ink: #11354d;
  --accent-soft: #e7f0f4;
  --done: #1f6b4f;
  --warn: #8a5a21;
  --shadow: 0 16px 40px rgba(29, 37, 44, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Hiragino Sans", sans-serif;
  line-height: 1.55;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  background: rgba(244, 241, 235, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand,
.nav,
.mission-grid,
.split-head,
.task-topline,
.task-meta,
.control-row,
.source-action,
.materials-panel summary {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: var(--accent-ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  background: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .08em;
}

.nav { gap: 3px; }
.nav a {
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.nav a:hover,
.nav a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

main {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 18px 0 64px;
}

.cockpit {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, .55fr);
  gap: 18px;
  min-height: calc(100vh - 94px);
  align-items: stretch;
}

.mission-panel,
.status-panel,
.task-card,
.metric-card,
.review-form,
.latest-record,
.latest-mini,
.materials-panel,
.rhythm-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mission-panel {
  display: grid;
  align-content: center;
  padding: clamp(24px, 3.2vw, 44px);
}

.kicker {
  display: block;
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 880px;
  margin-bottom: 22px;
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1;
  letter-spacing: -.06em;
}

.mission-grid {
  align-items: stretch;
  gap: 14px;
}

.mission-card {
  flex: 1;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  background: var(--paper);
}

.mission-label,
.task-index,
.rhythm-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mission-card strong {
  display: block;
  margin: 10px 0 12px;
  color: var(--accent-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.mission-card p,
.section-head p,
.task-goal,
.latest-mini p,
.latest-record dd,
.materials-body p,
.rhythm-card p,
.rhythm-card small,
.footer {
  color: var(--muted);
}

.primary-action,
.open-source,
.complete-button,
.drawer-close,
.drawer-nav-button,
.review-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent-ink);
  border-radius: 9px;
  padding: 0 15px;
  background: var(--accent-ink);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.status-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px;
}

.status-head h2,
.section-head h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 2.6vw, 40px);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.progress-list {
  display: grid;
  gap: 12px;
  margin: 0;
}
.progress-list div,
.latest-record dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
dt { color: var(--muted); font-weight: 750; }
dd { margin: 0; font-weight: 850; }
.progress-list dd { color: var(--accent-ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.latest-mini {
  padding: 18px;
  box-shadow: none;
}
.latest-mini h3,
.latest-record h3 { margin-bottom: 8px; }
.latest-mini p:last-child,
.latest-record p:last-child { margin-bottom: 0; }

.section {
  padding-top: 36px;
  scroll-margin-top: 82px;
}

.section-head { max-width: 880px; margin-bottom: 20px; }
.split-head {
  justify-content: space-between;
  align-items: stretch;
  gap: 22px;
  max-width: none;
}

.metric-card {
  min-width: 220px;
  padding: 18px 20px;
  box-shadow: none;
}
.metric-card span,
.metric-card small { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.metric-card strong {
  display: block;
  margin: 4px 0;
  color: var(--accent-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
}
.reading-grid { grid-template-columns: repeat(5, minmax(210px, 1fr)); }

.task-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: none;
}
.task-topline,
.task-meta {
  justify-content: space-between;
  gap: 12px;
}
.task-topline time {
  color: var(--accent-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 850;
}
.task-card h3 { margin-bottom: 0; font-size: 20px; line-height: 1.2; }
.task-goal { min-height: 74px; margin-bottom: 0; }
.task-card audio { width: 100%; }
.task-meta { align-items: flex-start; color: var(--muted); font-size: 12px; }
.task-meta a { color: var(--accent-ink); font-weight: 800; }

.control-row {
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.control-row label {
  display: grid;
  gap: 5px;
  min-width: 118px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
select,
input,
textarea {
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
}
select { min-height: 42px; padding: 0 10px; }
.complete-button[aria-pressed="true"] {
  border-color: var(--done);
  background: var(--done);
}

.source-action { align-items: center; justify-content: flex-start; gap: 10px; flex-wrap: wrap; }
.open-source { min-height: 44px; }
.open-reading-panel {
  border-color: var(--line-dark);
  background: var(--paper);
  color: var(--accent-ink);
}
.open-reading-panel[aria-expanded="true"] {
  border-color: var(--accent-ink);
  background: var(--accent-soft);
}
.reading-page-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.reading-card.is-active {
  border-color: var(--accent-ink);
  background: linear-gradient(180deg, #fff, var(--accent-soft));
  box-shadow: 0 0 0 2px rgba(30, 79, 111, .08);
}
.reading-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(29, 37, 44, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.reading-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(760px, calc(100vw - 48px));
  height: 100vh;
  padding: 14px;
  transform: translateX(100%);
  transition: transform .22s ease;
}
.reading-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.reading-drawer.is-open { transform: translateX(0); }
.reading-drawer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(29, 37, 44, .22);
}
.reading-drawer-head,
.reading-drawer-foot,
.drawer-controls {
  display: flex;
  align-items: center;
}
.reading-drawer-head {
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
}
.reading-drawer-head h2 { margin-bottom: 6px; }
.reading-drawer-cue { margin-bottom: 0; color: var(--muted); font-weight: 750; }
.drawer-close {
  width: 42px;
  padding: 0;
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
}
.reading-drawer-frame-wrap { min-height: 0; background: #f7f7f4; }
.reading-drawer-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.reading-drawer-foot {
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 14px 20px;
}
.drawer-controls { gap: 10px; }
.drawer-nav-button {
  min-height: 38px;
  border-color: var(--line-dark);
  background: var(--paper);
  color: var(--accent-ink);
}
.drawer-nav-button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
.drawer-pdf-link { color: var(--accent-ink); font-weight: 850; }
body.reading-drawer-open { overflow: hidden; }

.review-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .45fr);
  gap: 18px;
}
.review-section .section-head { grid-column: 1 / -1; }
.review-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
  box-shadow: none;
}
.review-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.review-form input,
.review-form textarea { width: 100%; padding: 11px 12px; }
.review-form textarea { resize: vertical; }
.review-form .wide,
.review-form button { grid-column: 1 / -1; }
.review-form button { justify-self: start; min-width: 140px; }
.latest-record { padding: 20px; box-shadow: none; }
.latest-record dl { display: grid; gap: 12px; margin: 0; }
.latest-record dl div { display: grid; justify-content: stretch; }
.latest-record dt { color: var(--accent); }

.materials-panel { overflow: hidden; box-shadow: none; }
.materials-panel summary {
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  list-style: none;
  cursor: pointer;
}
.materials-panel summary::-webkit-details-marker { display: none; }
.materials-panel summary strong { display: block; font-size: 24px; }
.summary-hint { color: var(--muted); font-size: 13px; font-weight: 800; }
.materials-body { border-top: 1px solid var(--line); padding: 18px 20px; }
.materials-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.materials-grid article {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--paper);
}
.materials-grid a { color: var(--accent-ink); font-weight: 800; }
.materials-grid p:last-child { margin-bottom: 0; }

.rhythm-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.rhythm-card {
  min-height: 210px;
  padding: 18px;
  box-shadow: none;
}
.rhythm-card h3 { margin: 10px 0; }
.rhythm-card small { display: block; border-top: 1px solid var(--line); padding-top: 12px; font-weight: 750; }

.footer {
  border-top: 1px solid var(--line);
  padding: 24px;
  text-align: center;
  font-size: 13px;
}
.footer p { margin: 0; }

@media (max-width: 1180px) {
  .cockpit,
  .review-section { grid-template-columns: 1fr; min-height: auto; }
  .mission-grid,
  .split-head { flex-direction: column; }
  .card-grid,
  .reading-grid,
  .materials-grid,
  .rhythm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; padding: 14px 18px; }
  .nav { flex-wrap: wrap; }
  main { width: min(100% - 28px, 640px); padding-top: 14px; }
  h1 { font-size: 38px; }
  .mission-panel,
  .status-panel { padding: 20px; }
  .card-grid,
  .reading-grid,
  .materials-grid,
  .rhythm-grid,
  .review-form { grid-template-columns: 1fr; }
}
