:root {
  --bg: #efe6d6;
  --paper: #fbf6ee;
  --ink: #241c16;
  --muted: #6f6256;
  --line: #e4d5c2;
  --red: #8d2f2a;
  --red-soft: #f6e6df;
  --ok: #1d6a43;
  --ok-soft: #e4f3ea;
  --bad: #9d3030;
  --bad-soft: #f8e4e1;
  --gold: #8d5a22;
  --shadow: 0 18px 40px rgba(70, 42, 18, 0.08);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: #2a211b;
  color: #f6efe4;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0.04em; }
.brand p { margin: 4px 0 0; color: #cbbba6; font-size: 13px; }
.seal {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1.5px solid #e7c7a2;
  color: #f0d2ae;
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
}
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modes { display: flex; background: #3a2e26; border-radius: 999px; padding: 4px; }
.mode {
  border: 0; background: transparent; color: #e7d7c4;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.mode.is-on { background: #f4e2c8; color: #3a2416; font-weight: 650; }
.wrong-tab {
  min-height: 44px;
  border: 1px solid #e7c7a2;
  background: transparent;
  color: #f0d2ae;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.wrong-tab.is-on {
  background: #f4e2c8;
  color: #3a2416;
  border-color: #f4e2c8;
  font-weight: 650;
}
.wrong-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #8d2f2a;
  color: #fffaf6;
  font-size: 12px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.wrong-count:empty,
.wrong-count[hidden] {
  display: none;
}
.wrong-tab.is-on .wrong-count {
  background: #8d2f2a;
  color: #fffaf6;
}
.empty.is-cleared {
  color: #1d6a43;
  font-size: 22px;
  font-weight: 650;
}

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.side { padding: 22px 16px 32px; border-right: 1px solid var(--line); min-width: 0; }
.side-label { display: block; margin: 8px 4px; color: var(--muted); font-size: 12px; letter-spacing: 0.12em; }
.years, .filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.year-select {
  width: 100%;
  margin-bottom: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  color: var(--ink);
  font: inherit;
}
.passage {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf9;
  padding: 8px 14px 12px;
}
.passage summary {
  cursor: pointer;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 6px 0;
}
.passage-body {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 15px;
  color: #3a322b;
  max-height: 280px;
  overflow: auto;
}
.passage-translation {
  margin: 12px 0 0;
  padding: 10px 14px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  background: #faf6ef;
  border-radius: 0 12px 12px 0;
}
.passage-translation > summary.pt-label {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.08em;
  padding-bottom: 6px;
  cursor: pointer;
  list-style: none;
}
.passage-translation > summary.pt-label::-webkit-details-marker { display: none; }
.passage-translation > summary.pt-label::before { content: "▸ "; }
.passage-translation[open] > summary.pt-label::before { content: "▾ "; }
.pt-body {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 14px;
  color: #5a5044;
}
.passage-body mark {
  background: #f4e2c8;
  color: var(--ink);
  padding: 0 3px;
  border-radius: 4px;
}
.explain.missing { color: var(--muted); font-style: italic; }
.years button, .chip, .nums button, .nav button, .primary, .ghost {
  font: inherit; cursor: pointer;
}
.years button, .chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 6px 10px; font-size: 13px;
}
.years button.is-on, .chip.is-on { background: var(--ink); color: #fbf6ee; border-color: var(--ink); }
.paper-stat { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 8px 4px; }

.main { padding: 22px 28px 48px; }
.nums { display: flex; flex-wrap: wrap; gap: 6px; max-width: 860px; margin: 0 auto 16px; }
.nums button {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.nums button.is-on { border-color: var(--red); color: var(--red); font-weight: 700; }
.nums button.is-ok { background: var(--ok-soft); border-color: #b7d8c4; }
.nums button.is-bad { background: var(--bad-soft); border-color: #e4b6b2; }

.card {
  max-width: 860px; margin: 0 auto;
  background: var(--paper); border-radius: 18px;
  padding: 28px 32px 22px; box-shadow: var(--shadow);
}
.meta { display: flex; align-items: center; gap: 8px; justify-content: space-between; color: var(--muted); font-size: 13px; position: relative; }
.tag {
  color: var(--red); background: var(--red-soft);
  border-radius: 999px; padding: 3px 10px;
}
/* ---- 本题出处 ⓘ 气泡 ---- */
.src-btn {
  flex: none; width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: #fffdf9; color: var(--gold);
  font: 15px/1 "Helvetica Neue", Arial, sans-serif;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.src-btn:hover, .src-btn.is-on { background: var(--gold); color: #fff; border-color: var(--gold); }
.src-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  width: min(460px, 88vw); padding: 12px 14px 10px;
  background: #fffdf9; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 28px rgba(60,44,28,.18);
  text-align: left;
}
.src-pop::before {
  content: ""; position: absolute; top: -6px; right: 10px;
  width: 10px; height: 10px; transform: rotate(45deg);
  background: #fffdf9; border-left: 1px solid var(--line); border-top: 1px solid var(--line);
}
.src-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.src-pop-title { font-size: 12px; font-weight: 600; color: var(--gold); letter-spacing: .04em; }
.src-close {
  border: 0; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.src-path {
  font: 12px/1.7 "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--ink); background: #faf6ef;
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 9px 10px; word-break: break-all; user-select: all;
  max-height: 150px; overflow: auto;
}
.src-path.is-desc {
  font: 13px/1.75 inherit; white-space: pre-wrap; max-height: 200px;
}
.src-note {
  margin-top: 8px; font-size: 12px; line-height: 1.65; color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
}
.src-pop-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.src-copy {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.src-copy:hover { border-color: var(--gold); color: var(--gold); }
.src-copy-tip { font-size: 12px; color: #4a8; }
.stem {
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 20px; font-weight: 500; line-height: 1.75;
  white-space: pre-wrap; margin: 18px 0 8px;
}
.stem:empty { display: none; margin: 0; }
.media img, .answer img, .explain img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stem-note {
  margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted);
}
.stem-note.is-fixed { color: #8a7355; }
.answer-key {
  display: inline-block; margin: 2px 0 8px; padding: 6px 14px;
  border-radius: 8px; background: var(--red-soft); color: var(--red);
  font-size: 17px; font-weight: 700; white-space: normal;
}
.answer-src { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.raw-shot { margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.raw-shot summary { cursor: pointer; display: inline-block; padding: 4px 0; }
.raw-shot img { margin-top: 10px; }
.options { display: grid; gap: 10px; margin-top: 18px; }
.options.is-letters { grid-template-columns: repeat(4, minmax(72px, 1fr)); }
.options.is-letters .opt { justify-content: center; min-height: 44px; }
.opt {
  text-align: left; width: 100%;
  border: 1px solid var(--line); background: #fffdf9;
  border-radius: 12px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start;
  color: var(--ink); font-size: 16px; line-height: 1.55;
}
.opt .k {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid #d9c8b4; font-weight: 650;
}
.opt.is-picked { border-color: var(--gold); background: #fbf3e4; }
.opt.is-picked .k { background: var(--gold); color: #fffaf3; border-color: var(--gold); }
.opt.is-right { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-right .k { background: var(--ok); color: white; border-color: var(--ok); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.is-wrong .k { background: var(--bad); color: white; border-color: var(--bad); }
.opt:disabled { cursor: default; }

.draft {
  width: 100%; min-height: 120px; margin-top: 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fffdf9; padding: 12px 14px; font: inherit; line-height: 1.6;
  resize: vertical;
}
.actions, .nav { display: flex; gap: 10px; margin-top: 16px; }
.primary, .ghost, .nav button {
  border-radius: 999px; padding: 10px 18px; font-size: 14px;
}
.primary { background: var(--red); color: #fffaf6; border: 0; }
.ghost, .nav button { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.nav { justify-content: space-between; }

.result { margin-top: 18px; padding-top: 8px; border-top: 1px dashed var(--line); }
.result h3 { margin: 16px 0 8px; font-size: 14px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.answer, .explain { white-space: pre-wrap; line-height: 1.7; font-size: 16px; }
#verdict { font-weight: 700; margin: 8px 0; }
#verdict.ok { color: var(--ok); }
#verdict.bad { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 48px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .top { flex-wrap: wrap; padding: 14px 16px; }
  .main { padding: 16px; }
  .card { padding: 18px 16px; }
  .stem { font-size: 18px; }
}

/* 真题词表查阅面板 */
.words-panel {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(36, 28, 22, 0.55);
  display: grid; place-items: center; padding: 24px;
}
.words-panel[hidden] { display: none; }
.words-box {
  width: min(940px, 100%); max-height: min(86vh, 900px);
  background: var(--paper); border-radius: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.words-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; padding: 18px 22px 12px; border-bottom: 1px solid var(--line);
}
.words-head h2 { margin: 0; font-size: 19px; }
.words-head p { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.words-close {
  border: 0; background: transparent; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.words-tools {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.words-tools input {
  flex: 1; min-width: 220px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; font-size: 14px; color: var(--ink);
}
.words-list { overflow: auto; padding: 0 22px; flex: 1; }
.words-list table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.words-list th, .words-list td {
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top; line-height: 1.55;
}
.words-list th {
  position: sticky; top: 0; background: var(--paper);
  color: var(--muted); font-weight: 600;
}
.words-list td:nth-child(1) { width: 70px; color: var(--gold); }
.words-list td:nth-child(2) { width: 150px; font-weight: 600; }
.words-list td:nth-child(3) { width: 130px; color: var(--muted); }
.words-count { margin: 0; padding: 10px 22px 14px; font-size: 12px; color: var(--muted); }
@media (max-width: 800px) {
  .words-panel { padding: 10px; }
  .words-head, .words-tools, .words-list { padding-left: 14px; padding-right: 14px; }
}

/* 原始资料全文面板 */
.raws-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.5; cursor: pointer;
}
.raws-row:hover { background: rgba(180, 140, 80, 0.09); }
.raws-name { flex: 1; word-break: break-all; }
.raws-kind { flex: none; white-space: nowrap; font-size: 12px; color: var(--muted); }
.raws-row.is-scan .raws-kind { color: #b26b3a; }
.raws-view {
  margin: 0 22px 16px; padding: 14px; max-height: 38vh; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
@media (max-width: 800px) {
  .raws-view { margin-left: 14px; margin-right: 14px; }
}
