:root {
  --bg: #f3f7fd;
  --surface: #ffffff;
  --ink: #1a2b4a;
  --muted: #5d7194;
  --faint: #8aa0c0;
  --line: #e3ebf7;
  --accent: #2f6fed;
  --accent-deep: #1d4ed8;
  --accent-soft: #eaf2ff;
  --accent-ring: rgba(47, 111, 237, 0.16);
  --good: #0f9f6e;
  --good-soft: #e8f8f2;
  --bad: #e11d48;
  --bad-soft: #fff1f4;
  --shadow: 0 10px 30px rgba(47, 111, 237, 0.06);
  --shadow-strong: 0 16px 40px rgba(37, 99, 235, 0.12);
  --radius: 20px;
  --sidebar: 252px;
  --nav-h: calc(68px + env(safe-area-inset-bottom));
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --scale: 1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(47, 111, 237, 0.12), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(56, 189, 248, 0.1), transparent 50%),
    var(--bg);
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#app, .shell {
  height: 100dvh;
  overflow: hidden;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid rgba(211, 224, 245, 0.9);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 2px; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  background: linear-gradient(160deg, #69a2ff, #2f6fed);
  box-shadow: 0 10px 18px rgba(47, 111, 237, 0.28);
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-nav button, .bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.side-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 15px;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}
.side-nav button span { flex: 1; }
.side-nav button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
}
.side-nav button:hover:not(.active) { background: rgba(47, 111, 237, 0.06); color: var(--ink); }
.nav-ico { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.badge, .dot {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffe4ea;
  color: var(--bad);
  font-size: 12px;
  font-style: normal;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.side-foot {
  margin-top: auto;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f7faff, #eef4ff);
  color: #24509a;
  font-size: 12px;
  line-height: 1.6;
}

.main {
  min-width: 0;
  height: 100dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 32px 56px;
}
.view { max-width: 1080px; margin: 0 auto; }
.view.is-enter, .q-card.is-enter { animation: rise 0.32s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view.is-enter, .q-card.is-enter { animation: none; }
}

.hero { display: grid; grid-template-columns: 1.45fr 0.8fr; gap: 16px; margin-bottom: 8px; }
.card {
  background: var(--surface);
  border: 1px solid rgba(216, 228, 246, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-copy { position: relative; overflow: hidden; padding: 28px 28px 24px; }
.hero-copy::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -70px;
  top: -90px;
  background: radial-gradient(circle, rgba(47, 111, 237, 0.18), transparent 68%);
  pointer-events: none;
}
.eyebrow { margin: 0; color: var(--accent); font-size: 13px; font-weight: 700; }
.hero-copy h2 {
  position: relative;
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 42px);
  letter-spacing: -0.045em;
  line-height: 1.12;
}
.lead { margin: 0; color: var(--muted); line-height: 1.75; max-width: 46em; }
.quick { position: relative; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
  border: 1px solid #d5e3f8;
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14px;
  min-height: 42px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #b9d0f5; background: #f8fbff; }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #4b86f8, #2f6fed);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(47, 111, 237, 0.28);
}
.btn.primary:hover { background: linear-gradient(180deg, #5b92ff, #2563eb); }
.btn.good { background: var(--good); color: white; border-color: transparent; }
.btn.bad { background: white; color: var(--bad); border-color: #fecdd6; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }

.stats { padding: 22px 20px; display: grid; grid-template-columns: 96px 1fr; gap: 8px 16px; align-items: center; }
.ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), #e6eefb 0);
}
.ring span {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  color: var(--accent-deep);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.stat-list { display: grid; gap: 0; }
.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #eef3fb;
  font-size: 13px;
  color: var(--muted);
}
.stat-list div:last-child { border-bottom: 0; }
.stat-list strong { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }

.section-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 2px 12px;
}
.section-h h3 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.section-h span { color: var(--faint); font-size: 12px; }

.chapter-grid, .paper-grid { display: grid; gap: 12px; }
.chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.paper-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.chapter, .paper {
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.chapter { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; padding: 16px; }
.chapter:hover, .paper:hover {
  transform: translateY(-2px);
  border-color: #c5d9fb;
  box-shadow: var(--shadow-strong);
}
.ch-index, .paper-index {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 750;
  font-size: 18px;
}
.chapter .no, .paper .no { font-size: 12px; color: var(--accent); font-weight: 700; }
.chapter strong, .paper strong { display: block; margin: 4px 0 10px; font-size: 16px; letter-spacing: -0.02em; }
.paper { position: relative; padding: 16px 16px 14px; overflow: hidden; }
.paper-index {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 14px;
}
.bar { height: 6px; background: #e8f0fb; border-radius: 99px; overflow: hidden; }
.bar i, .track i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7eb0ff, #2f6fed); transition: width 0.45s ease; }
.meta-line { margin-top: 8px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }

.filters { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.filter-row { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid #d7e4f8;
  background: white;
  color: #3d5278;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: #b9d0f5; }
.chip.on { background: var(--accent-soft); color: var(--accent-deep); border-color: #c5dafb; font-weight: 700; }
.seg { display: flex; padding: 4px; background: #eef4fd; border-radius: 16px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 12px; padding: 11px 8px; font-size: 14px; color: var(--muted); }
.seg button.on { background: white; color: var(--accent-deep); font-weight: 700; box-shadow: 0 6px 16px rgba(47, 111, 237, 0.12); }
.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f5f9ff;
  color: #24406e;
  font-size: 14px;
}
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); }
.setup-actions { display: flex; gap: 10px; }
.count-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.quiz-wrap { max-width: 820px; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.quiz-top .left, .quiz-top .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.accent { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; font-weight: 700; }
.progress-num { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 14px; color: var(--accent-deep); }
.track { height: 6px; background: #e5eefb; border-radius: 99px; margin-bottom: 14px; overflow: hidden; }
.q-card { padding: 26px 26px 20px; }
.origins { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stem {
  font-size: calc(18px * var(--scale));
  line-height: 1.8;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
}
.blank {
  display: inline-block;
  min-width: 5.5em;
  max-width: 100%;
  margin: 2px 4px;
  padding: 4px 8px 5px;
  border: 0;
  border-bottom: 1.5px solid var(--accent);
  border-radius: 8px 8px 0 0;
  background: var(--accent-soft);
  font: inherit;
  font-size: 0.95em;
  color: var(--accent-deep);
  vertical-align: baseline;
}
.blank:focus { background: #f3f8ff; }
.blank.long { min-width: min(100%, 14em); }
.blank.ok { background: var(--good-soft); border-bottom-color: var(--good); color: #06734d; }
.blank.no { background: var(--bad-soft); border-bottom-color: var(--bad); color: var(--bad); }
.options { display: grid; gap: 10px; margin-top: 18px; }
.opt {
  width: 100%;
  text-align: left;
  border: 1px solid #dbe7f8;
  background: white;
  border-radius: 16px;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.opt:hover:not(:disabled) { transform: translateY(-1px); border-color: #b9d0f5; }
.opt .k {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #eef4fd; color: #3d5278; font-size: 13px; font-weight: 750;
}
.opt.on { border-color: #93c5fd; background: #f5f9ff; box-shadow: 0 0 0 4px var(--accent-ring); }
.opt.on .k { background: var(--accent); color: white; }
.opt.correct { border-color: #86efc6; background: var(--good-soft); box-shadow: none; }
.opt.correct .k { background: var(--good); color: white; }
.opt.wrong { border-color: #fecdd6; background: var(--bad-soft); box-shadow: none; }
.opt.wrong .k { background: var(--bad); color: white; }
.opt:disabled { cursor: default; }

.answer-box, .analysis {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
}
.answer-box { background: #f5f9ff; border: 1px solid #d7e6ff; }
.analysis { background: white; border: 1px solid var(--line); }
.answer-box h4, .analysis h4 { margin: 0 0 8px; font-size: 13px; color: var(--accent-deep); }
.answer-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.65;
}
.answer-box .prose, .analysis .prose { white-space: pre-wrap; line-height: 1.75; font-size: calc(15px * var(--scale)); }
.judge { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
textarea.mine {
  width: 100%;
  min-height: 110px;
  margin-top: 16px;
  border-radius: 16px;
  border: 1px solid #d5e3f8;
  padding: 14px;
  resize: vertical;
  background: #f8fbff;
  line-height: 1.65;
  font-size: 15px;
}
textarea.mine:focus { background: white; border-color: #93c5fd; }
.quiz-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  position: sticky;
  bottom: 16px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e3ebf7;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.1);
  backdrop-filter: blur(12px);
}
.quiz-actions .btn { border-radius: 14px; }
.spacer { flex: 1; }

.result { padding: 32px 24px; text-align: center; }
.result h2 { margin: 8px 0; letter-spacing: -0.04em; font-size: 32px; color: var(--accent-deep); }
.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; text-align: left; }
.score-row div, .score-row .card { padding: 16px; border-radius: 16px; background: #f5f9ff; border: 1px solid #e3ebf7; }
.score-row span { display: block; color: var(--muted); font-size: 12px; }
.score-row strong { font-size: 24px; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.wrong-hit { text-align: left; padding: 12px 0; border-top: 1px solid var(--line); }
.wrong-hit button { border: 0; background: transparent; padding: 0; text-align: left; color: var(--ink); }
.wrong-hit button:hover { color: var(--accent-deep); }
.wrong-hit small { color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: center;
}
.item p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.item .ops { display: flex; gap: 6px; }
.search {
  width: 100%;
  border: 1px solid #d5e3f8;
  background: white;
  border-radius: 16px;
  padding: 13px 14px;
  margin-bottom: 12px;
  font-size: 15px;
  box-shadow: var(--shadow);
}
.search:focus { border-color: #93c5fd; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-weight: 650; font-size: 12px; background: #f7faff; }
.panel { padding: 8px 16px 16px; overflow: auto; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 12px);
  transform: translateX(-50%) translateY(8px);
  background: white;
  color: var(--accent-deep);
  border: 1px solid #d6e4ff;
  box-shadow: 0 12px 30px rgba(47, 111, 237, 0.16);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.bottom-nav {
  display: none;
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  height: 62px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e3ebf7;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.12);
  backdrop-filter: blur(16px);
  z-index: 10;
  grid-template-columns: repeat(4, 1fr);
}
.bottom-nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  font-size: 11px;
}
.bottom-nav button.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }
.bottom-nav .dot { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: 10px; }
.empty { padding: 42px 18px; text-align: center; color: var(--muted); line-height: 1.7; }
.subject-select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 10px;
}
.font-ctl { display: flex; gap: 6px; }
.font-ctl button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid #d5e3f8;
  background: white;
  color: var(--accent-deep);
  font-weight: 700;
}

@media (max-width: 1024px) {
  .paper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .main { padding: 18px 14px calc(var(--nav-h) + 28px); }
  .chapter-grid, .score-row { grid-template-columns: 1fr; }
  .q-card, .hero-copy { padding: 18px 16px; }
  .quiz-actions {
    bottom: calc(var(--nav-h) + 6px);
    flex-wrap: wrap;
  }
  .quiz-actions .spacer { display: none; }
  .quiz-actions .btn { flex: 1; }
  .quiz-actions .btn.primary { flex: 1 1 100%; order: -1; }
  .item { grid-template-columns: 1fr; }
  .hide-quiz-nav .bottom-nav { display: none; }
  .hide-quiz-nav .main { padding-bottom: 28px; }
  .hide-quiz-nav .quiz-actions { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(var(--nav-h) + 16px); }
}
@media (min-width: 861px) and (max-width: 1180px) {
  :root { --sidebar: 220px; }
  .main { padding: 22px 18px 40px; }
}
