:root {
  --bg-page: #f3f1eb;
  --bg-paper: #fffdf8;
  --bg-card: #ffffff;
  --bg-subtle: #f7f4ec;
  --ink-primary: #1f2328;
  --ink-secondary: #4c525a;
  --ink-muted: #767d87;
  --border-paper: #dfd9cc;
  --border-light: #eae5da;
  --accent: #1d4ed8;
  --accent-soft: #eef4ff;
  --accent-border: #bfd4ff;
  --seal-red: #b91c1c;
  --seal-bg: #fef2f2;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --shadow-paper: 0 4px 20px rgba(31, 35, 40, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.7;
  padding-bottom: 84px;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-paper);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seal-tag {
  display: inline-block;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 12px;
  color: var(--seal-red);
  border: 1.5px solid var(--seal-red);
  background: var(--seal-bg);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-switch,
.bank-switch {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-paper);
  border-radius: 8px;
  padding: 2px;
}

.mode-btn,
.bank-btn {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.mode-btn.active,
.bank-btn.active {
  background: #fff;
  color: var(--ink-primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.bank-btn.active {
  color: var(--accent);
}

/* Chat bubble card for Dialogue Quiz */
.chat-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: #faf8f2;
  border: 1px solid var(--border-light);
  border-radius: 12px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-row.is-user {
  align-items: flex-end;
}

.chat-row.is-gpt {
  align-items: flex-start;
}

.chat-role {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 0 4px;
}

.chat-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.68;
}

.chat-row.is-user .chat-bubble {
  background: #1d4ed8;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-row.is-gpt .chat-bubble {
  background: #fff;
  color: var(--ink-primary);
  border: 1px solid var(--border-paper);
  border-bottom-left-radius: 4px;
}

.glossary-strip {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 7px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  color: #1e3a8a;
}

.auto-next-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  background: #fff;
  border: 1px solid var(--border-paper);
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-paper);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.timer-pill.paused { opacity: 0.65; }

.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
}
.timer-pill.paused .timer-dot { background: #d97706; }

.progress-rail {
  height: 3px;
  background: var(--border-light);
  width: 100%;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  transition: width 0.25s ease;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #1e40af; }

.btn-ghost {
  background: #fff;
  color: var(--ink-primary);
  border-color: var(--border-paper);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); }

.btn-xs { padding: 4px 9px; font-size: 12px; }

.badge-num {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 999px;
}

/* Main shell */
.app-shell {
  max-width: 1320px;
  margin: 16px auto 0;
  padding: 0 20px;
}

.status-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.part-pill {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13.5px;
  background: #1e293b;
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
}

.seq-indicator {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-secondary);
}

.stat-chip {
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.stat-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.stat-err { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.stat-rem { background: #fff; color: var(--ink-secondary); border-color: var(--border-paper); }

/* Stage: split view (passage left, single question right) */
.quiz-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 20px;
  align-items: start;
}

.quiz-stage.single-column {
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
}

.passage-pane,
.question-pane {
  background: var(--bg-paper);
  border: 1px solid var(--border-paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-paper);
}

.passage-pane {
  padding: 22px 24px;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
}

.question-pane {
  padding: 24px 26px;
}

/* Passage elements */
.passage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border-paper);
}

.passage-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.passage-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.4;
}

.passage-instruction {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.user-bubble {
  background: #eef2ff;
  border: 1px solid #d5e0ff;
  border-radius: 8px;
  padding: 9px 12px;
  margin: 0 0 12px;
  font-size: 14px;
}
.user-bubble strong { color: #1e3a8a; }

.passage-lead { font-weight: 700; margin: 0 0 12px; }

.passage-para {
  margin: 0 0 10px;
  text-indent: 2em;
  font-size: 14.5px;
}
.passage-para:last-child { margin-bottom: 0; }

.dialogue-line { margin: 0 0 8px; font-size: 14.5px; }
.dialogue-line:last-child { margin-bottom: 0; }
.dialogue-speaker { font-weight: 700; color: #1e293b; margin-right: 4px; }

.exam-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 12px;
  font-size: 13.5px;
  background: #fff;
}
.exam-table th, .exam-table td {
  border: 1px solid var(--border-paper);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.exam-table th { background: #f3efe4; font-weight: 700; }

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border-paper);
  border-radius: 8px;
}
.timeline-item { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; }
.timeline-time { font-family: var(--font-mono); font-weight: 700; min-width: 56px; color: var(--accent); }

/* Inline gap pill in cloze / 7-choose-5 / grammar */
.gap-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  margin: 0 3px;
  min-width: 48px;
  justify-content: center;
  border: 0;
  border-bottom: 2px solid #94a3b8;
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  text-indent: 0;
  transition: 0.15s;
}

.gap-pill.filled {
  background: #dcfce7;
  border-bottom-color: var(--ok);
  color: #14532d;
}

.gap-pill.active-gap {
  background: #dbeafe;
  border-bottom: 2.5px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16);
}

.option-pool {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-paper);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pool-item {
  font-size: 13.5px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border-light);
}
.pool-item.used-pool {
  opacity: 0.58;
}
.pool-item strong { color: var(--accent); margin-right: 6px; }

/* GPT Decode Box */
.decode-box {
  margin-top: 14px;
  padding: 10px 13px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13.5px;
}
.decode-box summary {
  cursor: pointer;
  font-weight: 600;
  color: #1e40af;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.symptom-tag {
  font-size: 11.5px;
  font-weight: 500;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 2px 8px;
  border-radius: 999px;
}
.decode-text { margin: 8px 0 0; color: #1e293b; }

.decode-locked {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-paper);
  font-size: 12px;
  color: var(--ink-muted);
}

/* Single Question Card */
.q-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.q-meta-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.q-type-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

.q-pts-tag {
  font-size: 12px;
  color: var(--ink-muted);
}

.q-stem {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
}

.q-stem .q-num {
  font-family: var(--font-mono);
  color: var(--accent);
  margin-right: 6px;
}

.unscorable-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #78350f;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Big BaoDian-style option buttons */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 1.5px solid var(--border-light);
  border-radius: 11px;
  background: #fff;
  font-size: 15px;
  color: var(--ink-primary);
  cursor: pointer;
  transition: 0.14s;
  font-family: var(--font-sans);
  line-height: 1.5;
}

.option-btn:hover {
  border-color: var(--accent-border);
  background: #f8fbff;
  transform: translateY(-1px);
}

.option-circle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border-paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #1e3a8a;
  font-weight: 600;
}
.option-btn.selected .option-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.option-btn.opt-correct {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: #14532d;
  font-weight: 600;
}
.option-btn.opt-correct .option-circle {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.option-btn.opt-wrong {
  border-color: var(--err);
  background: var(--err-bg);
  color: #7f1d1d;
}
.option-btn.opt-wrong .option-circle {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}

/* Grammar single-question input */
.grammar-single-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grammar-hint {
  font-size: 13.5px;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  padding: 8px 12px;
  border-radius: 8px;
}

.grammar-input-wrap {
  display: flex;
  gap: 10px;
}

.grammar-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border-paper);
  border-radius: 10px;
  font-size: 16px;
  font-family: var(--font-sans);
  background: #fff;
}
.grammar-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* Essay single-question */
.essay-prompt {
  background: #faf8f2;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 14.5px;
}
.essay-prompt p { margin: 0 0 7px; }
.essay-prompt p:last-child { margin-bottom: 0; }

.essay-textarea {
  width: 100%;
  min-height: 175px;
  padding: 13px 15px;
  border: 1.5px solid var(--border-paper);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  resize: vertical;
}
.essay-textarea:focus { outline: none; border-color: var(--accent); }

.essay-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-muted);
  flex-wrap: wrap;
  gap: 8px;
}
.word-count-ok { color: var(--ok); font-weight: 700; }
.word-count-warn { color: var(--warn); font-weight: 700; }

/* Explanation box */
.explanation-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #dce5f2;
  font-size: 14px;
  color: var(--ink-secondary);
}

.explanation-box.is-ok {
  background: #f3fdf6;
  border-color: var(--ok-border);
}

.explanation-box.is-err {
  background: #fff7f7;
  border-color: var(--err-border);
}

.exp-verdict {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}
.exp-verdict.ok { color: var(--ok); }
.exp-verdict.err { color: var(--err); }

.writing-review-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #dbe4f0;
}
.writing-review-box h4 { margin: 0 0 8px; font-size: 14.5px; }

.checklist-ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checklist-ul li { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.check-pass { color: var(--ok); font-weight: 700; }
.check-miss { color: var(--warn); font-weight: 700; }

.self-score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.self-score-bar input[type="range"] { flex: 1; min-width: 140px; }

.sample-essay {
  white-space: pre-wrap;
  background: #fffdf8;
  border: 1px solid var(--border-paper);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-top: 8px;
}

/* Result sheet */
.result-sheet {
  background: linear-gradient(180deg, #f8fbff 0%, #fffdf8 100%);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-paper);
  padding: 20px 24px;
  margin-bottom: 18px;
}

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

.score-hero { display: flex; align-items: baseline; gap: 8px; }
.score-big {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.score-denom { font-size: 15px; color: var(--ink-muted); }

.rank-badge {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.result-stat-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
}
.result-stat-label { font-size: 11.5px; color: var(--ink-muted); }
.result-stat-val { font-family: var(--font-mono); font-size: 16px; font-weight: 700; margin-top: 2px; }

.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Bottom dock (BaoDian style) */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  background: rgba(255, 253, 248, 0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-paper);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

.dock-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dock-nav-btn {
  min-width: 112px;
  padding: 9px 16px;
  font-size: 14px;
}

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

.kbd-hint {
  font-size: 12px;
  color: var(--ink-muted);
}

.flag-active {
  background: var(--warn-bg) !important;
  border-color: var(--warn-border) !important;
  color: var(--warn) !important;
}

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: min(410px, 94vw);
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.16);
}

.drawer-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.drawer-header h3 { margin: 0; font-size: 16px; }
.muted-sm { margin: 3px 0 0; font-size: 12px; color: var(--ink-muted); }

.drawer-legend {
  padding: 8px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-current { background: #fff; border: 2px solid var(--accent); }
.dot-ok { background: var(--ok); }
.dot-err { background: var(--err); }
.dot-answered { background: var(--accent); }
.dot-flagged { background: #f59e0b; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}

.card-group { margin-bottom: 14px; }
.card-group-title { font-size: 12.5px; font-weight: 700; color: var(--ink-secondary); margin-bottom: 7px; }
.card-num-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

.card-num {
  position: relative;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border-light);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
}
.card-num.current {
  box-shadow: 0 0 0 2.5px var(--accent);
  border-color: var(--accent);
}
.card-num.answered { background: var(--accent); border-color: var(--accent); color: #fff; }
.card-num.correct { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-num.wrong { background: var(--err); border-color: var(--err); color: #fff; }
.card-num.unscorable { background: #f1f5f9; color: #94a3b8; border-style: dashed; }
.card-num.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
}

.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* SHA drawer box */
.sha-drawer-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-paper);
  border-radius: 8px;
}
.sha-drawer-box summary { cursor: pointer; font-size: 12.5px; font-weight: 700; }

.sha-panel { margin-top: 10px; }
.sha-item { margin-bottom: 8px; }
.sha-item-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-muted); margin-bottom: 2px; }
.copy-mini { border: 0; background: transparent; color: var(--accent); font-size: 11.5px; cursor: pointer; }
.sha-code {
  display: block;
  padding: 5px 7px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  word-break: break-all;
}
.seq-code { letter-spacing: 0.7px; color: #1e3a8a; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.modal-lg { max-width: 680px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }

.alert-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 13px;
  color: #78350f;
  margin-bottom: 14px;
}
.alert-title { font-weight: 700; margin-bottom: 4px; }
.alert-banner p { margin: 0; }

.candidate-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-paper);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.candidate-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.candidate-box-head h4 { margin: 0; font-size: 14px; }
.candidate-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.candidate-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-secondary); }
.candidate-grid input { padding: 7px 9px; border: 1px solid var(--border-paper); border-radius: 6px; font-size: 13px; }
.hash-strip { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border-paper); display: flex; flex-direction: column; gap: 3px; }
.hash-label { font-size: 11.5px; color: var(--ink-muted); }
.hash-value { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); word-break: break-all; }

.notices-details { font-size: 13px; color: var(--ink-secondary); }
.notices-details summary { cursor: pointer; font-weight: 600; color: var(--ink-primary); }
.notices-details ol { margin: 8px 0; padding-left: 20px; }
.baseline-hashes { background: var(--bg-subtle); padding: 8px 10px; border-radius: 6px; font-size: 11.5px; }
.baseline-hashes code { font-family: var(--font-mono); word-break: break-all; }

.modal-hash-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border-paper);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  word-break: break-all;
  line-height: 1.55;
  margin: 12px 0 16px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.muted { margin: 0; font-size: 13.5px; color: var(--ink-secondary); }

.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.hidden { display: none !important; }

@media (max-width: 960px) {
  .quiz-stage { grid-template-columns: 1fr; }
  .passage-pane { position: static; max-height: none; }
  .result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kbd-hint { display: none; }
}

@media (max-width: 640px) {
  .app-shell { padding: 0 12px; }
  .passage-pane, .question-pane { padding: 16px; }
  .candidate-grid, .timeline-grid, .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auto-next-toggle { display: none; }
  .dock-nav-btn { min-width: 88px; padding: 8px 10px; font-size: 13px; }
}
