:root {
  --bg: #f6f2ea;
  --card: #fffdf9;
  --ink: #2c2723;
  --muted: #8b8177;
  --line: #e7dfd2;
  --accent: #a63f31;
  --accent-soft: #f6e8e4;
  --ok: #3f7a56;
  --ok-soft: #e8f2ea;
  --bad: #b03a2e;
  --bad-soft: #fbe9e6;
  --gold: #b08b4f;
  --shadow: 0 10px 30px rgba(78, 58, 42, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(166, 63, 49, .045) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}

.app { display: flex; min-height: 100vh; }

/* ------------------------------------------------ sidebar */
.sidebar {
  width: 252px;
  flex: 0 0 252px;
  background: #fbf8f2;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 18px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 17px; letter-spacing: 1px;
  box-shadow: 0 6px 14px rgba(166, 63, 49, .25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px; color: var(--muted); letter-spacing: .12em;
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 10px; border-radius: 9px;
  border: none; background: transparent; color: var(--ink);
  font-size: 13.5px; font-family: inherit; cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f1ebe0; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .badge-count { background: rgba(255,255,255,.22); color: #fff; }
.nav-item.chapter { padding-left: 18px; font-size: 13px; }
.badge-count {
  font-size: 11px; padding: 1px 7px; border-radius: 99px;
  background: #efe7da; color: var(--muted); min-width: 26px; text-align: center;
}

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 10px; }
.stat-row {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--muted); padding: 3px 8px;
}
.stat-row b { color: var(--ink); font-weight: 600; }
.ghost-btn {
  width: 100%; margin-top: 10px; padding: 8px; border-radius: 8px;
  border: 1px dashed var(--line); background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12px; font-family: inherit;
}
.ghost-btn:hover { border-color: var(--bad); color: var(--bad); }

/* ------------------------------------------------ main */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 22px 40px 0;
  max-width: 1080px;
  margin: 0 auto;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.topbar h1 {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 22px; margin: 0; font-weight: 600; letter-spacing: .02em;
}
.counter { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.topbar-right { display: flex; gap: 8px; }
.icon-btn {
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.progress { height: 3px; background: #e9e1d3; border-radius: 99px; margin: 14px 0 0; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }

.stage { flex: 1; padding: 26px 0 90px; }

/* ------------------------------------------------ question card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px 38px 30px;
  animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-tags { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 99px;
  background: #f2ece1; color: #7d6f5d; letter-spacing: .02em;
}
.tag.type { background: var(--accent-soft); color: var(--accent); }
.tag.suspect { background: #fdf3d8; color: #96721f; }
.card-tags .spacer { flex: 1; }
.fav-btn {
  border: none; background: transparent; cursor: pointer; font-size: 18px;
  color: #cfc4b4; line-height: 1; padding: 2px 4px;
}
.fav-btn.on { color: var(--gold); }

.stem {
  font-family: "Songti SC", "SimSun", "Songti TC", serif;
  font-size: 19px; line-height: 1.85; letter-spacing: .01em;
  margin-bottom: 22px; white-space: pre-wrap; word-break: break-word;
}
.stem .blank {
  display: inline-block; min-width: 3.2em; border-bottom: 1.5px solid #c9b9a2;
  text-align: center; color: transparent; margin: 0 2px;
}
.blank-hint { color: #c9b9a2; font-size: 13px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff;
  font-family: "Songti SC", "SimSun", serif; font-size: 16px; line-height: 1.7;
  text-align: left; color: var(--ink); transition: all .14s;
  width: 100%;
}
.option:hover:not(.disabled) { border-color: #cdbba4; background: #fffdf8; transform: translateX(2px); }
.option .key {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid #d8cbb8; display: grid; place-items: center;
  font-size: 13px; font-family: "Helvetica Neue", Arial, sans-serif;
  color: #8d7f6b; margin-top: 2px; transition: all .14s;
}
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.selected .key { background: var(--accent); border-color: var(--accent); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.option.disabled { cursor: default; }
.option .mark { margin-left: auto; font-size: 12px; padding-top: 3px; letter-spacing: .05em; }
.option.correct .mark { color: var(--ok); }
.option.wrong .mark { color: var(--bad); }

/* fill */
.fill-row { display: flex; gap: 10px; margin-top: 6px; }
.fill-input {
  flex: 1; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  font-family: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
.fill-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  padding: 10px 20px; border-radius: 9px; border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; background: var(--accent); color: #fff;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* answer panel */
.panel { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; animation: rise .2s ease; }
.verdict { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict .icon { font-size: 16px; }
.answer-line { font-size: 14px; color: #5c5348; line-height: 1.8; }
.answer-line b { color: var(--ink); }
.answer-text {
  margin-top: 8px; padding: 14px 16px; border-radius: 10px;
  background: #f7f2e8; font-size: 15px; line-height: 1.9;
  font-family: "Songti SC", "SimSun", serif; white-space: pre-wrap;
}
.self-mark { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.self-mark button {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 12.5px; font-family: inherit; text-decoration: underline; padding: 0 2px;
}

/* short answer cards */
.short-answer { margin-top: 8px; }
.short-answer .answer-text { font-size: 15px; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* ------------------------------------------------ bottom bar */
.bottombar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 16px;
  padding: 14px 0 18px; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.nav-btn {
  padding: 10px 18px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-family: inherit; font-size: 13.5px;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-btn.primary:hover { filter: brightness(1.06); color: #fff; }
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.hint { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ modal */
.modal {
  position: fixed; inset: 0; background: rgba(44, 39, 35, .38);
  display: grid; place-items: center; z-index: 20; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card); border-radius: 16px; width: min(760px, 92vw);
  max-height: 82vh; display: flex; flex-direction: column; padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(40, 30, 20, .25);
}
.modal-head { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; }
.modal-head strong { font-size: 15px; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ded3c2; display: inline-block; margin-right: 4px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.modal-head .icon-btn { margin-left: auto; }
.map-grid {
  overflow-y: auto; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  padding: 6px 2px 4px;
}
.map-cell {
  aspect-ratio: 1; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; font-size: 11.5px; color: var(--muted);
  cursor: pointer; display: grid; place-items: center; font-family: inherit;
}
.map-cell:hover { border-color: var(--accent); color: var(--accent); }
.map-cell.ok { background: var(--ok-soft); border-color: #bcd8c6; color: var(--ok); }
.map-cell.bad { background: var(--bad-soft); border-color: #eec3bc; color: var(--bad); }
.map-cell.cur { outline: 2px solid var(--accent); outline-offset: 1px; }

.empty {
  text-align: center; padding: 90px 20px; color: var(--muted);
}
.empty strong { display: block; font-size: 16px; color: var(--ink); margin-bottom: 8px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex: none; padding: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .sidebar-foot { display: none; }
  .main { padding: 16px 16px 0; }
  .card { padding: 22px 18px; }
  .stem { font-size: 17px; }
  .hint { display: none; }
}
