:root {
  color-scheme: light;
  --bg: #eef0e8;
  --panel: #fbfaf4;
  --panel-strong: #ffffff;
  --ink: #1c1f1b;
  --muted: #667063;
  --line: #d7dacd;
  --accent: #0d766e;
  --accent-ink: #ffffff;
  --warn: #b45309;
  --bad: #b42318;
  --good: #16794c;
  --shadow: 0 18px 50px rgba(37, 44, 34, 0.12);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101410;
  --panel: #191e18;
  --panel-strong: #20271f;
  --ink: #edf1e8;
  --muted: #a7b2a2;
  --line: #354034;
  --accent: #5cc8b5;
  --accent-ink: #071210;
  --warn: #f5b85a;
  --bad: #ff8b7f;
  --good: #79d59e;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(13, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(13, 118, 110, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Noto Sans SC", "PingFang SC", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.focus-page .app-shell {
  width: min(1080px, 100%);
  padding-top: 10px;
}

.focus-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 8px;
}

.focus-topbar .eyebrow {
  display: none;
}

.focus-topbar h1 {
  font-size: clamp(20px, 4.8vw, 28px);
  line-height: 1;
}

.focus-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quiet-stat {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-weight: 900;
  font-size: 14px;
}

.focus-drawer {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: none;
}

.focus-drawer > summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 900;
  font-size: 14px;
}

.focus-drawer[open] > summary {
  border-bottom: 1px solid var(--line);
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.drawer-nav {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.inline-switches {
  align-content: end;
}

.compact-stats {
  grid-column: span 2;
}

.focus-workspace {
  max-width: 980px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 44px); line-height: 1.05; }
h2 { line-height: 1.55; font-size: clamp(20px, 2.2vw, 28px); }

.main-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 4px;
}

.main-nav a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 9px 14px;
  font-weight: 800;
}

.main-nav a.active {
  background: var(--ink);
  color: var(--panel);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

.full-span { grid-column: 1 / -1; }

.hero-panel, .page-panel, .control-panel, .question-card, .feedback-panel, .metric-card, .list-card {
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel, .page-panel {
  padding: clamp(18px, 4vw, 34px);
}

.hero-panel h2 {
  max-width: 760px;
  font-size: clamp(26px, 5vw, 58px);
  line-height: 1.08;
  margin-bottom: 16px;
}

.hero-panel p {
  color: var(--muted);
  line-height: 1.8;
}

.hero-actions, .settings-actions, .card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.type-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card {
  display: block;
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.metric-card strong {
  font-size: clamp(28px, 4vw, 42px);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.control-panel {
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 16px;
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.section-title strong { color: var(--ink); }

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select, input[type="search"], input[type="text"], input[type="number"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.7;
}

.switches {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.switches label, .setting-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-grid div {
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.stat-grid span {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.stat-grid small { color: var(--muted); }
.question-area { min-width: 0; }

.question-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
}

.q-pill {
  flex: 0 0 auto;
  min-width: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 10px;
}

.q-pill.active { background: var(--ink); color: var(--panel); }
.q-pill.done { border-color: var(--good); }
.q-pill.wrong { border-color: var(--bad); color: var(--bad); }

.question-card {
  padding: clamp(18px, 4vw, 34px);
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

#questionStem {
  white-space: pre-wrap;
  margin-bottom: 24px;
}

.answer-form {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.option-row, .blank-row, .self-score-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  line-height: 1.6;
}

.option-row input { margin-top: 6px; }

.option-row.is-correct-answer {
  border-color: color-mix(in srgb, var(--good) 70%, var(--line));
  background: color-mix(in srgb, var(--good) 13%, var(--panel-strong));
}

.option-row.is-correct-answer .option-key {
  background: var(--good);
  color: #fff;
}

.option-row.is-wrong-choice {
  border-color: color-mix(in srgb, var(--bad) 72%, var(--line));
  background: color-mix(in srgb, var(--bad) 12%, var(--panel-strong));
}

.option-row.is-wrong-choice .option-key {
  background: var(--bad);
  color: #fff;
}

.option-key {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 900;
}

.blank-row { align-items: center; }
.blank-row span { min-width: 54px; color: var(--muted); font-weight: 800; }

.primary-action, .secondary-action, .icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 42px;
  padding: 0 16px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-action {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 900;
}

.primary-action.danger { background: var(--bad); color: #fff; }
.secondary-action, .icon-button { background: var(--panel-strong); color: var(--ink); }
.icon-button { width: 42px; padding: 0; font-size: 20px; }

.feedback-panel {
  margin-top: 14px;
  padding: 18px;
}

.feedback-panel.hidden { display: none; }

.feedback-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.correct { color: var(--good); }
.incorrect { color: var(--bad); }
.manual { color: var(--warn); }

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 900;
}

.source-ref {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  background: var(--panel-strong);
  line-height: 1.7;
}

.source-ref small {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.key-points {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.8;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.list-card h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.list-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.list-card-actions {
  min-width: 180px;
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: end;
  color: var(--muted);
  font-weight: 800;
}

.list-card.compact {
  align-items: center;
}

.settings-panel {
  max-width: 760px;
}

.setting-row {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  font-weight: 800;
}

.settings-actions {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.focus-page .primary-action,
.focus-page .secondary-action,
.focus-page .icon-button {
  min-height: 34px;
  padding: 0 12px;
}

.focus-page .icon-button {
  width: 34px;
  font-size: 17px;
}

.focus-page .question-strip {
  gap: 6px;
  padding: 0 2px 6px;
}

.focus-page .q-pill {
  min-width: 46px;
  padding: 5px 8px;
  font-size: 14px;
}

.focus-page .question-card {
  padding: clamp(16px, 3vw, 24px);
}

.focus-page .question-meta {
  margin-bottom: 10px;
  font-size: 14px;
}

.focus-page #questionStem {
  margin-bottom: 18px;
  font-size: clamp(19px, 4.5vw, 25px);
  line-height: 1.5;
}

.focus-page .answer-form {
  gap: 10px;
  margin-bottom: 16px;
}

.focus-page .option-row,
.focus-page .blank-row,
.focus-page .self-score-row {
  padding: 11px 12px;
}

@media (max-width: 900px) {
  .app-shell { padding: 14px; }
  .dashboard-grid, .workspace { grid-template-columns: 1fr; }
  .drawer-grid { grid-template-columns: 1fr; }
  .compact-stats { grid-column: auto; }
  .control-panel { position: static; }
  .hero-panel h2 { font-size: clamp(30px, 9vw, 48px); }
  .card-actions { display: grid; grid-template-columns: 1fr 1fr; }
  #submitAnswer { grid-column: 1 / -1; order: -1; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .focus-topbar {
    display: flex;
    align-items: flex-end;
  }
  .focus-actions {
    justify-content: stretch;
  }
  .focus-actions .secondary-action {
    flex: 0 0 auto;
    width: auto;
  }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .question-meta, .feedback-head, .list-card { display: grid; }
  .list-card-actions { min-width: 0; justify-items: start; }
  .blank-row { display: grid; gap: 8px; }
  .primary-action, .secondary-action { width: 100%; }
}
