:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7078;
  --line: #e3e1da;
  --brand: #1d4e89;
  --brand-soft: #e8eff8;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --bad: #b3261e;
  --bad-soft: #fbeaea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --radius: 10px;
  --soft: #fbfaf7;     /* 材料、表头底色 */
  --chip: #f0eee8;     /* 徽标底色 */
  --field: #ffffff;    /* 输入框底色 */
  --disabled: #f3f2ee;
  font-size: 16px;
}
/* 字号：页脚 A− / A / A+ / A++ */
html[data-fs="-1"] { font-size: 14px; }
html[data-fs="1"] { font-size: 18px; }
html[data-fs="2"] { font-size: 21px; }
/* 深色模式：跟随系统 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --card: #1e2125; --ink: #e6e6e3; --muted: #a0a4ab; --line: #34383e;
    --brand: #7fb0ec; --brand-soft: #1f2d3e; --ok: #6fcf97; --ok-soft: #1b3326; --bad: #f28b82; --bad-soft: #3a2220;
    --warn: #f2c46b; --warn-soft: #3a2f17; --soft: #23262b; --chip: #2b2f35; --field: #181a1d; --disabled: #24272b;
  }
  .md img, .zoom img { background: #fff; }   /* 题图是白底扫描件，深色模式下保留白底才看得清 */
  .btn.primary { color: #10151c; }
  .years button.on, .entry button.on { color: #10151c; }
  .katex { color: var(--ink); }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.7;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--brand); margin-left: 4px; }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 15px; }
#nav .who { color: var(--muted); }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }
.foot { max-width: 980px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 13px; text-align: center; }

h1 { font-size: 26px; margin: 0 0 6px; line-height: 1.35; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 17px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: #c9c6bc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #173f70; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 10px 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* 首页 */
.tabs { display: flex; gap: 0; margin: 16px 0 0; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 18px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-size: 15px; color: inherit; }
.tabs button.on { border-bottom-color: var(--ink); font-weight: 600; }
.years { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 20px; }
.years button { padding: 6px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.years button.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.paper .subj { font-size: 22px; font-weight: 700; }
.paper .meta { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.paper .note { font-size: 13px; color: var(--warn); margin-bottom: 10px; }
.paper .acts { display: flex; gap: 8px; }
.paper .acts .btn { flex: 1; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* 表单 */
.form { max-width: 380px; margin: 30px auto; }
.form label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 4px; }
.form input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.form .btn { width: 100%; margin-top: 18px; }
.form .alt { text-align: center; margin-top: 14px; font-size: 14px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* 题目 */
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 8px; }
.material { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; }
.material.fold { max-height: 320px; overflow: hidden; position: relative; }
.material.fold::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: linear-gradient(transparent, var(--soft)); }
.fold-btn { margin: -4px 0 12px; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; scroll-margin-top: 140px; }
.q.reading { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.q-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.q-no { font-weight: 700; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.part { background: var(--warn-soft); color: var(--warn); }
.stem p:first-child { margin-top: 0; }
.stem p:last-child { margin-bottom: 0; }
.md table { border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 10px; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.md .katex, .rubric .katex { position: relative; } /* 隐藏的 MathML 层是绝对定位的，不加这个会把手机页面撑宽 */
.md .katex.wide, .rubric .katex.wide { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.md pre { max-width: 100%; overflow-x: auto; }

.opts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--field); }
.opt .md { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; } /* 长方程式、代码在选项内横向滚动，不把手机页面撑宽 */
.opt input { margin-top: 6px; }
.opt .k { font-weight: 700; min-width: 1.2em; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt p { margin: 0; }
.fills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

textarea.ans { background: var(--field); width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; resize: vertical; line-height: 1.7; }
textarea.ans.essay { min-height: 360px; }
.count { font-size: 12px; color: var(--muted); text-align: right; }
input:disabled, textarea:disabled { background: var(--disabled); }

/* 考试 */
.exambar {
  position: sticky; top: 57px; z-index: 15; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 14px;
  box-shadow: 0 -8px 0 var(--bg); /* 盖住与顶栏之间的缝，滚动时不露出后面的题 */
}
.exambar .t { font-weight: 600; flex: 1; min-width: 160px; }
.clock { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.clock.low { color: var(--bad); }
.saved { font-size: 13px; color: var(--muted); min-width: 90px; }
.navq { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.navq a { min-width: 36px; height: 32px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--ink); background: var(--field); }
.navq a.done { background: var(--brand); color: #fff; border-color: var(--brand); }
.navq a:hover { text-decoration: none; border-color: var(--brand); }
.locked { position: fixed; inset: 0; background: rgba(20, 22, 26, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.locked .card { max-width: 380px; text-align: center; }
.rules { margin: 12px 0 20px; padding-left: 20px; }
.rules li { margin: 4px 0; }

/* 成绩 */
.score-big { font-size: 44px; font-weight: 800; line-height: 1.1; }
.score-big small { font-size: 20px; color: var(--muted); font-weight: 500; }
.result-row { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin-top: 10px; font-size: 15px; }
.result-row .lab { color: var(--muted); }
.yours { white-space: pre-wrap; word-break: break-word; }
.points { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.feedback { background: var(--soft); border-left: 3px solid var(--brand); padding: 8px 12px; margin-top: 8px; font-size: 14px; }

/* 解读 */
.studybar { position: sticky; top: 57px; z-index: 15; box-shadow: 0 -8px 0 var(--bg); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 14px; }
.studybar .grow { flex: 1; }
.block { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.block .lab { font-size: 13px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.check { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 6px 10px; border-radius: 6px; margin-top: 10px; }
.rubric { font-size: 14px; color: var(--muted); padding-left: 18px; margin: 4px 0 0; }

/* 表格（后台、记录） */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.list th { background: var(--soft); font-weight: 600; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin: 10px 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 14px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; flex: 1; min-width: 160px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 10px; font-size: 14px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

/* ---- 2026-10-31 体验改进 ---- */
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.entry { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; }
.entry button { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 15px; }
.entry button.on { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.years { margin: 16px 0 20px; }
.paper .note { color: var(--muted); }
.form input[type=checkbox] { width: auto; margin-right: 4px; }
.form .consent { color: var(--ink); font-size: 14px; line-height: 1.6; }
.fills { flex-direction: column; }
.fill { display: flex; align-items: center; gap: 8px; }
.fill span { font-size: 13px; color: var(--muted); min-width: 3.2em; }
.fill input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); min-width: 0; }
.onpaper { display: block; font-size: 14px; color: var(--muted); margin-top: 10px; }
.exam-title { font-size: 20px; margin: 4px 0 10px; }
.exambar { gap: 10px; padding: 8px 12px; }
.exambar .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navq { position: sticky; top: 110px; z-index: 14; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; max-height: 40vh; overflow-y: auto; }
.navq[hidden] { display: none; }
.navq a.half { border-color: var(--warn); color: var(--warn); }
.symbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; gap: 4px; overflow-x: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
.symbar[hidden] { display: none; }
.symbar button { flex: 0 0 auto; min-width: 40px; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); font-size: 17px; cursor: pointer; }
.zoom { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.85); overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 16px; }
.zoom img { max-width: none; width: min(1400px, 200%); height: auto; margin: auto; }
.zoom-tip { color: #ddd; font-size: 13px; padding: 8px; }
.md img { cursor: zoom-in; }
.score-parts { color: var(--muted); font-size: 14px; margin: 6px 0; }
.conv { display: inline-block; }
.tag-ai { font-size: 12px; padding: 0 6px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); }
.acts-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 0; }
.toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); cursor: pointer; }
.selfscore { margin-top: 10px; font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.selfscore input { width: 72px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); }
.yours-text { white-space: pre-wrap; }
.q-acts { margin-left: auto; display: inline-flex; gap: 6px; }
.show-btn { display: none; margin-top: 10px; }
.covered .q:not(.shown) .ans-area { display: none; }
.covered .q:not(.shown) .opt.right { border-color: var(--line); background: var(--field); }
.covered .q:not(.shown) .show-btn { display: inline-flex; }
.q.flash { box-shadow: 0 0 0 3px var(--warn-soft); }
.srcnote { font-size: 14px; }
.srcnote summary { cursor: pointer; color: var(--muted); }
.mist { margin-bottom: 10px; }
.mhead { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.redo:not(:empty) { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.weak { display: flex; flex-wrap: wrap; gap: 6px; }
.wtag { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bad-soft); color: var(--bad); }
.okc { color: var(--ok); }
.badc { color: var(--bad); }
.doc h3 { margin-top: 18px; }
.doc li { margin: 4px 0; }
.fbtext { white-space: normal !important; min-width: 220px; }
.foot .links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: center; }
.foot .fs button { border: 1px solid var(--line); background: var(--card); border-radius: 4px; margin-left: 2px; cursor: pointer; font-size: 12px; padding: 0 6px; }
.toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }

@media (max-width: 640px) {
  main { padding: 16px 16px 48px; }
  .topbar { padding: 10px 16px; }
  .brand { font-size: 16px; }
  .brand span { display: none; }
  #nav { gap: 10px; font-size: 14px; }
  #nav .who { display: none; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
  .exambar { top: 53px; }
  .studybar { position: static; box-shadow: none; }   /* 手机上工具栏会折成三行，吸顶会占掉近三成屏幕 */
  .clock { font-size: 20px; }
  .exambar .saved { display: none; }
  .navq { top: 100px; }
  .studybar label.muted { font-size: 13px; }
  .result-row { grid-template-columns: 1fr; }
  .result-row .lab { margin-top: 6px; }
  .q { padding: 14px; }
}
@media print {
  .topbar, .exambar, .studybar, .navq, .foot, .btn, .symbar { display: none !important; }
  .covered .q .ans-area { display: block !important; }
}

/* 深色模式下的浅色底按钮用深色字（放在文件最后，才能盖过前面的按钮样式） */
@media (prefers-color-scheme: dark) {
  .btn.primary, .btn.primary:hover, .entry button.on, .years button.on, .navq a.done { color: #10151c; }
  .btn.primary:hover { background: #a3c7f2; }
}
.recovery { font-size: 26px; font-weight: 800; letter-spacing: 2px; text-align: center; padding: 12px; border: 2px dashed var(--brand); border-radius: 10px; font-variant-numeric: tabular-nums; }
/* 首页：页签下的说明、卡片上的“我的进度”（与上海高考站一致） */
.tabnote { color: var(--muted); font-size: 14px; margin: -8px 0 0; }
.paper .mine { font-size: 13px; color: var(--muted); margin: -2px 0 10px; }
.paper .mine.doing { color: var(--bad); font-weight: 600; }
