/* 上海中考物理复习站 —— 纯静态样式（无外部依赖，离线可用） */
/* ---------- 界面风格（主题）令牌 ----------
   默认樱花粉（少女风）；html[data-theme] 切换经典蓝 / 薄荷绿 / 葡萄紫。
   规则一律写 var(--token, 经典蓝旧值)：主题块缺令牌时回落原值，classic 与旧版观感一致。 */
:root, html[data-theme="sakura"] {
  --bg: #fdf3f8;
  --card: #ffffff;
  --ink: #3f2d3d;
  --ink-2: #6f5568;
  --ink-3: #a98ba0;
  --line: #f2d9e4;
  --line-strong: #e9c4d4;
  --brand: #e0538a;
  --brand-weak: #fdeef5;
  --brand-line: #f6c3d8;
  --brand-mid: #f9dbe8;
  --brand-bright: #ec4899;
  --brand-ink: #701a3f;
  --green: #189a5f;
  --green-weak: #e9f9f0;
  --red: #e0335c;
  --red-weak: #fdeef2;
  --amber: #d97706;
  --amber-weak: #fff7e8;
  --violet: #9333ea;
  --ok-line: #b9e8cf;
  --warn-line: #f8df9d;
  --bad-line: #f8c5d2;
  --surface: #fdf6f9;
  --surface-2: #f9ecf2;
  --focus-ring: #f193bd;
  --focus-strong: #e0538a;
  --hero-bg: linear-gradient(135deg, #f9a8d4 0%, #ec4899 55%, #a855f7 100%);
  --hero-ink: #fff0f7;
  --hero-decor: radial-gradient(circle at 86% 18%, rgba(255, 255, 255, .28), transparent 42%), radial-gradient(circle at 12% 88%, rgba(255, 255, 255, .2), transparent 38%);
  --toast-bg: #5c3550;
  --fab-bg: linear-gradient(135deg, #f472b6, #db2777);
  --btn-bg: linear-gradient(135deg, #f472b6, #e6498f);
  --btn-radius: 999px;
  --btn-radius-sm: 999px;
  --btn-shadow: 0 4px 12px rgba(236, 72, 153, .22);
  --chip-radius: 999px;
  --radius: 18px;
  --shadow: 0 2px 6px rgba(214, 51, 108, .06), 0 10px 26px rgba(214, 51, 108, .08);
  --body-bg: radial-gradient(1000px 460px at 108% -10%, rgba(244, 114, 182, .16), transparent 60%), radial-gradient(760px 400px at -14% 14%, rgba(167, 139, 250, .12), transparent 55%), var(--bg);
  --brand-suffix: " 🌸";
  --lesson-accent: #d6336c;
  --lesson-accent-deep: #a61e4d;
  --lesson-accent-weak: #fdeef5;
  --lesson-accent-soft: #fbdce9;
  --lesson-accent-pressed: #f9d3e2;
  --lesson-accent-line: #f2c1d5;
  --lesson-accent-line-soft: #ecb6cb;
  --lesson-ink: #6f5568;
}
html[data-theme="classic"] {
  --bg: #f6f8fd;
  --card: #ffffff;
  --ink: #1e293b;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #2563eb;
  --brand-weak: #eff6ff;
  --brand-line: #bfdbfe;
  --brand-mid: #dbeafe;
  --brand-bright: #3b82f6;
  --brand-ink: #172554;
  --green: #16a34a;
  --green-weak: #f0fdf4;
  --red: #dc2626;
  --red-weak: #fef2f2;
  --amber: #d97706;
  --amber-weak: #fffbeb;
  --violet: #7c3aed;
  --ok-line: #bbf7d0;
  --warn-line: #fde68a;
  --bad-line: #fecaca;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --focus-ring: #60a5fa;
  --focus-strong: #2563eb;
  --hero-bg: linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #3b82f6 100%);
  --hero-ink: #dbeafe;
  --hero-decor: none;
  --toast-bg: #1e293b;
  --fab-bg: #1e293b;
  --btn-bg: #2563eb;
  --btn-radius: 9px;
  --btn-radius-sm: 7px;
  --btn-shadow: none;
  --chip-radius: 7px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 4px 14px rgba(15, 23, 42, .05);
  --body-bg: var(--bg);
  --brand-suffix: "";
  --lesson-accent: #0f766e;
  --lesson-accent-deep: #115e59;
  --lesson-accent-weak: #eff9f7;
  --lesson-accent-soft: #e3f4f0;
  --lesson-accent-pressed: #def5ef;
  --lesson-accent-line: #b7ddd7;
  --lesson-accent-line-soft: #9bcbbd;
  --lesson-ink: #526277;
}
html[data-theme="mint"] {
  --bg: #f2faf5;
  --card: #ffffff;
  --ink: #1f3a31;
  --ink-2: #48685c;
  --ink-3: #8faaa0;
  --line: #d9ece1;
  --line-strong: #bfe0d0;
  --brand: #0f9d6f;
  --brand-weak: #e8f8f0;
  --brand-line: #bfe8d5;
  --brand-mid: #d3f1e2;
  --brand-bright: #34d399;
  --brand-ink: #0b3d29;
  --green: #16a34a;
  --green-weak: #f0fdf4;
  --red: #dc2626;
  --red-weak: #fef2f2;
  --amber: #d97706;
  --amber-weak: #fffbeb;
  --violet: #7c3aed;
  --ok-line: #bbf7d0;
  --warn-line: #fde68a;
  --bad-line: #fecaca;
  --surface: #f4fbf7;
  --surface-2: #e9f5ee;
  --focus-ring: #2dd4bf;
  --focus-strong: #0f9d6f;
  --hero-bg: linear-gradient(135deg, #6ee7b7 0%, #10b981 55%, #0d9488 100%);
  --hero-ink: #ecfdf5;
  --hero-decor: radial-gradient(circle at 86% 18%, rgba(255, 255, 255, .3), transparent 42%), radial-gradient(circle at 12% 88%, rgba(255, 255, 255, .22), transparent 38%);
  --toast-bg: #134e3a;
  --fab-bg: linear-gradient(135deg, #34d399, #059669);
  --btn-bg: linear-gradient(135deg, #34d399, #0d9d6e);
  --btn-radius: 12px;
  --btn-radius-sm: 10px;
  --btn-shadow: 0 4px 10px rgba(13, 148, 88, .2);
  --chip-radius: 9px;
  --radius: 16px;
  --shadow: 0 2px 6px rgba(6, 95, 70, .06), 0 10px 24px rgba(6, 95, 70, .08);
  --body-bg: radial-gradient(1000px 460px at 108% -10%, rgba(52, 211, 153, .14), transparent 60%), radial-gradient(760px 400px at -14% 14%, rgba(45, 212, 191, .1), transparent 55%), var(--bg);
  --brand-suffix: "";
  --lesson-accent: #0e9f86;
  --lesson-accent-deep: #0b705f;
  --lesson-accent-weak: #e6f7f1;
  --lesson-accent-soft: #d3f0e6;
  --lesson-accent-pressed: #c5ecdc;
  --lesson-accent-line: #aee3cf;
  --lesson-accent-line-soft: #93d7bf;
  --lesson-ink: #48685c;
}
html[data-theme="grape"] {
  --bg: #f8f5fd;
  --card: #ffffff;
  --ink: #322547;
  --ink-2: #5d517a;
  --ink-3: #a49bbd;
  --line: #e7dff5;
  --line-strong: #d3c5ec;
  --brand: #7c3aed;
  --brand-weak: #f3effe;
  --brand-line: #d8c9f5;
  --brand-mid: #e6dcfb;
  --brand-bright: #8b5cf6;
  --brand-ink: #2e1065;
  --green: #16a34a;
  --green-weak: #f0fdf4;
  --red: #dc2626;
  --red-weak: #fef2f2;
  --amber: #d97706;
  --amber-weak: #fffbeb;
  --violet: #9333ea;
  --ok-line: #bbf7d0;
  --warn-line: #fde68a;
  --bad-line: #fecaca;
  --surface: #f9f6fd;
  --surface-2: #f1ecf9;
  --focus-ring: #a78bfa;
  --focus-strong: #7c3aed;
  --hero-bg: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 55%, #6366f1 100%);
  --hero-ink: #f3effe;
  --hero-decor: radial-gradient(circle at 86% 18%, rgba(255, 255, 255, .3), transparent 42%), radial-gradient(circle at 12% 88%, rgba(255, 255, 255, .22), transparent 38%);
  --toast-bg: #3b2b5c;
  --fab-bg: linear-gradient(135deg, #a78bfa, #7c3aed);
  --btn-bg: linear-gradient(135deg, #a78bfa, #7c3aed);
  --btn-radius: 12px;
  --btn-radius-sm: 10px;
  --btn-shadow: 0 4px 12px rgba(124, 58, 237, .22);
  --chip-radius: 9px;
  --radius: 16px;
  --shadow: 0 2px 6px rgba(76, 29, 149, .06), 0 10px 24px rgba(76, 29, 149, .09);
  --body-bg: radial-gradient(1000px 460px at 108% -10%, rgba(139, 92, 246, .15), transparent 60%), radial-gradient(760px 400px at -14% 14%, rgba(99, 102, 241, .1), transparent 55%), var(--bg);
  --brand-suffix: "";
  --lesson-accent: #7c3aed;
  --lesson-accent-deep: #5b21b6;
  --lesson-accent-weak: #f3effe;
  --lesson-accent-soft: #e6dcfb;
  --lesson-accent-pressed: #ddd0f8;
  --lesson-accent-line: #cabdf0;
  --lesson-accent-line-soft: #b7a5e8;
  --lesson-ink: #5d517a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--body-bg, var(--bg)); color: var(--ink); line-height: 1.65; font-size: 15.5px;
}
button { font-family: inherit; }

/* ---------- 全站一级入口与科目内二级导航 ---------- */
[hidden] { display: none !important; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1020px; margin: 0 auto; padding: 12px 16px 0; }
.brand-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 17px; }
.brand::after { content: var(--brand-suffix, ""); }
/* ---------- 风格切换按钮与菜单（菜单项由 js/theme.js 生成） ---------- */
.theme-switch-wrap { position: relative; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 80; min-width: 150px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.theme-menu[hidden] { display: none !important; }
.theme-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: none; background: none; border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 13.5px; color: var(--ink-2); cursor: pointer;
}
.theme-menu button:hover { background: var(--brand-weak); color: var(--brand); }
.theme-menu button[aria-checked="true"] { background: var(--brand-weak); color: var(--brand); font-weight: 700; }
.theme-menu .theme-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, .08); }
.global-utilities { display: flex; flex-shrink: 0; }
.utility-btn { border: 1px solid transparent; border-radius: var(--chip-radius, 7px); background: none; color: var(--ink-2); font: inherit; font-size: 12px; padding: 7px 9px; cursor: pointer; }
.utility-btn:hover, .utility-btn[aria-current="page"] { color: var(--brand); background: var(--brand-weak); }
.global-controls { display: grid; grid-template-columns: minmax(220px, .9fr) minmax(0, 1.5fr); align-items: start; gap: 20px; padding: 10px 0 12px; }
.subject-control label { display: block; font-size: 11px; font-weight: 700; color: var(--ink-2); margin-bottom: 3px; }
.subject-picker-row { display: flex; align-items: center; gap: 4px; }
.subject-picker-row select { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; border-color: var(--line-strong, #cbd5e1); background: var(--surface, #f8fafc); min-height: 42px; }
.subject-picker-row .utility-btn { flex-shrink: 0; }
.subject-navigation { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); padding: 9px 0; }
.subject-nav-label { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
#mainNav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn { border: 1px solid transparent; background: transparent; color: var(--ink-2); padding: 7px 10px; border-radius: var(--chip-radius, 7px); font-size: 14px; cursor: pointer; }
.nav-btn:hover { background: var(--brand-weak); color: var(--brand); }
.nav-btn.active { background: var(--brand); color: #fff; font-weight: 600; }
:where(button, a, summary, select, input):focus-visible { outline: 3px solid var(--focus-ring, #60a5fa); outline-offset: 3px; }
.skip-link { position: fixed; top: -80px; left: 12px; padding: 10px 16px; background: var(--ink); color: #fff; z-index: 100; border-radius: 8px; }
.skip-link:focus { top: 8px; }
#app:focus { outline: none; }
.subject-intro { padding: 16px 0 22px; }
.section-kicker { color: var(--brand); font-size: 12px; font-weight: 700; }
.subject-intro h1 { font-size: clamp(23px, 4vw, 30px); margin: 4px 0; }
.subject-intro p { color: var(--ink-2); font-size: 14px; }
.subject-card { border-top: 4px solid var(--subject-color); }
.subject-card .row:first-child { align-content: start; }
.subject-card .row:first-child > div { width: 100%; }
.subject-card h2 .muted { display: block; font-weight: 400; margin-top: 2px; }

main { max-width: 1020px; margin: 0 auto; padding: 18px 16px 60px; }
.site-footer { max-width: 1020px; margin: 0 auto; padding: 18px 16px 40px; color: var(--ink-3); font-size: 12.5px; }

/* ---------- 通用 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card h3 { font-size: 15.5px; margin: 12px 0 6px; }
.muted { color: var(--ink-3); font-size: 13px; }
.small { font-size: 13.5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; border: 1px solid var(--brand); background: var(--btn-bg, var(--brand)); color: #fff;
  padding: 8px 18px; border-radius: var(--btn-radius, 9px); font-size: 14.5px; cursor: pointer; line-height: 1.4;
  box-shadow: var(--btn-shadow, none);
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--card); color: var(--brand); }
.btn.green { border-color: var(--green); background: var(--green); }
.btn.green.ghost { background: var(--card); color: var(--green); }
.btn.red { border-color: var(--red); background: var(--red); }
.btn.red.ghost { background: var(--card); color: var(--red); }
.btn.sm { padding: 4px 12px; font-size: 13px; border-radius: var(--btn-radius-sm, 7px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tag { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface, #f8fafc); color: var(--ink-2); white-space: nowrap; }
.tag.d1 { background: var(--green-weak); color: var(--green); border-color: var(--ok-line, #bbf7d0); }
.tag.d2 { background: var(--amber-weak); color: var(--amber); border-color: var(--warn-line, #fde68a); }
.tag.d3 { background: var(--red-weak); color: var(--red); border-color: var(--bad-line, #fecaca); }
.tag.mod { font-weight: 600; }
input[type="text"], input[type="number"], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14.5px; font-family: inherit; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-line, #bfdbfe); border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
hr.sep { border: none; border-top: 1px dashed var(--line); margin: 14px 0; }

/* ---------- 首页 ---------- */
.hero { position: relative; overflow: hidden; background: var(--hero-bg, linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #3b82f6 100%)); color: #fff; border: none; }
.hero::after { content: ""; position: absolute; inset: 0; background: var(--hero-decor, none); pointer-events: none; }
.hero > * { position: relative; }
.hero h1 { font-size: 21px; margin-bottom: 6px; }
.hero p { color: var(--hero-ink, #dbeafe); font-size: 13.5px; }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-card { text-align: center; padding: 14px 8px; }
.stat-card .label { color: var(--ink-3); font-size: 13px; }

.scorebar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; font-size: 12px; color: #fff; margin: 8px 0 6px; }
.scorebar div { display: flex; align-items: center; justify-content: center; min-width: 30px; white-space: nowrap; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; color: var(--ink-2); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

table.exam-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.exam-table th, table.exam-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
table.exam-table th { background: var(--surface, #f8fafc); font-weight: 600; }

/* ---------- 知识点 ---------- */
.mod-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mod-tab {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 16px;
  cursor: pointer; font-size: 14.5px; color: var(--ink-2);
}
.mod-tab.active { color: #fff; font-weight: 600; }
.kp-card { margin-bottom: 12px; overflow: hidden; }
.kp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.kp-head h3 { font-size: 16px; margin: 0; }
.kp-score { text-align: right; white-space: nowrap; }
.kp-score b { font-size: 18px; }
.kp-body { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.kp-body ul { padding-left: 20px; }
.kp-body li { margin: 3px 0; }
.mis-item { background: var(--red-weak); border: 1px solid var(--bad-line, #fecaca); border-radius: 9px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.mis-item b.fix { color: var(--green); }
.ways-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 6px; }
.way { border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 14px; background: var(--surface, #fafbfd); }
.way .w-tag { font-weight: 700; margin-right: 8px; }
.way.b .w-tag { color: var(--green); } .way.m .w-tag { color: var(--amber); } .way.h .w-tag { color: var(--red); }
.formula-chip { display: inline-block; background: var(--surface-2, #f1f5f9); border: 1px solid var(--line); border-radius: 7px; padding: 2px 10px; margin: 2px 6px 2px 0; font-family: Cambria, "Times New Roman", serif; font-size: 15px; }
.linklike { color: var(--brand); cursor: pointer; text-decoration: underline; background: none; border: none; font-size: inherit; padding: 0; }

/* ---------- 练习 ---------- */
.quiz-head { position: sticky; top: var(--qh-top, 54px); z-index: 40; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-block { margin-bottom: 16px; padding: 18px; }
.q-block .q-no { font-weight: 700; margin-right: 6px; }
.q-stem { margin-bottom: 10px; }
.q-stem-text { white-space: pre-line; }
.q-figure { margin: 10px 0; text-align: center; }
.q-figure svg { max-width: 100%; height: auto; }
.opt { display: flex; gap: 9px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 12px; margin: 7px 0; cursor: pointer; }
.opt:hover { border-color: var(--brand); background: var(--brand-weak); }
.opt.sel { border-color: var(--brand); background: var(--brand-weak); }
.opt input { margin-top: 4px; }
.blank-input { display: inline-block; width: 130px; text-align: center; margin: 0 4px; padding: 4px 8px; border: none; border-bottom: 1.5px solid var(--ink-3); border-radius: 0; font-size: 16px; }
.blank-input:focus { outline: none; border-bottom-color: var(--brand); }
.part-q { margin: 8px 0; }
.sub-res { border-radius: 6px; padding: 0 4px; }
.sub-ok { background: var(--green-weak); box-shadow: 0 0 0 1px var(--ok-line, #bbf7d0) inset; }
.sub-bad { background: var(--red-weak); box-shadow: 0 0 0 1px var(--bad-line, #fecaca) inset; }
.explain { background: var(--brand-weak); border: 1px solid var(--brand-line, #bfdbfe); border-radius: 9px; padding: 10px 14px; margin-top: 10px; font-size: 14px; }
.explain b { color: var(--brand); }
.ans-ok { color: var(--green); font-weight: 600; }
.ans-bad { color: var(--red); font-weight: 600; }
.result-banner { text-align: center; padding: 18px; }
.result-banner .big { font-size: 34px; font-weight: 800; }
.fig-toggle { background: none; border: none; color: var(--brand); cursor: pointer; text-decoration: underline; font-size: 13.5px; }

/* ---------- 错题本 ---------- */
.wrong-item { border-left: 4px solid var(--red); }
.wrong-item.mastered { border-left-color: var(--green); opacity: .82; }
.wrong-meta { color: var(--ink-3); font-size: 12.5px; margin-top: 6px; }
.manual-card { border-left: 4px solid var(--violet); }
details.reveal { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
details.reveal summary { cursor: pointer; color: var(--brand); font-size: 13.5px; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--toast-bg, #1e293b); color: #fff; padding: 9px 20px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99; max-width: 86vw; }
#toast.show { opacity: .95; }

/* ---------- 答题进度条与题号跳转 ---------- */
.quiz-head { flex-wrap: wrap; top: var(--qh-top, 54px); }
.prog-wrap { flex-basis: 100%; height: 6px; border-radius: 4px; background: var(--line, #e2e8f0); overflow: hidden; margin-top: 4px; }
.prog-bar { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); border-radius: 4px; transition: width .3s; }
.q-chips { flex-basis: 100%; display: flex; gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding: 4px 0 2px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.q-chip { min-width: 26px; height: 26px; border-radius: var(--chip-radius, 7px); border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: 12.5px; cursor: pointer; flex: 0 0 auto; }
.q-chip.done { background: var(--green-weak); border-color: var(--ok-line, #bbf7d0); color: var(--green); font-weight: 700; }
.q-chip.bad { background: var(--red-weak); border-color: var(--bad-line, #fecaca); color: var(--red); }

/* ---------- 模块掌握度 ---------- */
.m-bar { display: inline-block; width: 64px; height: 8px; border-radius: 5px; background: var(--line, #e2e8f0); overflow: hidden; vertical-align: middle; }
.m-bar > span { display: block; height: 100%; border-radius: 5px; }

/* ---------- 专项背记（闪卡） ---------- */
.flash-card {
  margin: 14px 0; min-height: 170px; border-radius: var(--radius); cursor: pointer;
  border: 2px solid var(--line); background: var(--card); display: flex; align-items: center; justify-content: center;
  padding: 22px 18px; text-align: center; font-size: 17.5px; line-height: 1.7; transition: border-color .2s, box-shadow .2s;
}
.flash-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.flash-card.flipped { background: var(--brand-weak); border-color: var(--brand-line, #bfdbfe); cursor: default; }
.flash-card .flash-front, .flash-card .flash-back { max-width: 640px; white-space: pre-wrap; }
.flash-card .flash-back { color: var(--ink); font-weight: 500; }
.flash-card:not(.flipped) .flash-back { display: none; }
.flash-card.flipped .flash-front { display: none; }
.opt[role="button"]:focus-visible, .kp-head:focus-visible, .flash-card:focus-visible { outline: 3px solid var(--focus-strong, #2563eb); outline-offset: 3px; }
.opt[aria-disabled="true"] { cursor: default; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 首页倒计时：大号日数、分段时钟、铜色时间线。 */
/* A quiet, global timer. Editing expands only when explicitly opened. */
.countdown { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; border-left: 1px solid var(--line); padding: 4px 0 4px 20px; color: var(--ink-2); }
.cd-summary { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
#countdown-title { font-size: 12px; white-space: nowrap; }
.cd-display { display: inline-flex; gap: 4px; align-items: baseline; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.cd-display strong { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--brand); }
.cd-clock { font-size: 11px; margin-left: 4px; }
.cd-clock b { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.cd-note { color: var(--ink-2); font-size: 11px; line-height: 1.6; }
.cd-target { grid-column: 1/-1; }
.cd-phase { color: var(--green); font-size: 11px; }
.cd-phase:empty { display: none; }
.cd-settings { font-size: 12px; }
.cd-settings summary { color: var(--brand); cursor: pointer; padding: 4px; }
.cd-settings[open] { grid-column: 1/-1; grid-row: 3; margin-top: 5px; }
.cd-settings form { padding: 8px 0; }
.cd-settings label { color: var(--ink-2); font-size: 13px; }
.cd-settings input { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px; max-width: 170px; }
.cd-error { color: var(--red); font-size: 12px; }
.review-guide ol { padding-left: 22px; }
.review-guide li { margin: 7px 0; }
.coverage-note { background: var(--amber-weak, #fffbeb); border: 1px solid var(--warn-line, #fde68a); padding: 12px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; color: #713f12; }
.writing-ref { margin-top: 8px; padding: 10px 12px; background: var(--surface, #fafbfd); border-radius: 8px; font-size: 14px; line-height: 1.8; }

/* ---------- 回到顶部 ---------- */
.to-top { position: fixed; right: 18px; bottom: 22px; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--fab-bg, #1e293b); color: #fff; font-size: 18px; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 90; box-shadow: var(--shadow); }
.to-top.show { opacity: .88; pointer-events: auto; }
.to-top:hover { background: var(--brand); }

/* ---------- 面包屑导航 ---------- */
.crumb { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0 0; color: var(--ink-3); font-size: 13px; }
.crumb-link { color: var(--brand); border: none; background: none; font: inherit; cursor: pointer; padding: 2px 0; }
.crumb-path .crumb-sep { margin: 0 4px; color: var(--ink-3); }

/* ---------- 手机竖屏适配 ---------- */
@media (max-width: 760px) {
  .topbar { position: static; }
  .topbar-inner { padding: 8px 10px 0; }
  .global-controls { grid-template-columns: 1fr; gap: 8px; padding: 8px 0; }
  .subject-control { display: flex; align-items: center; gap: 8px; }
  .subject-control label { margin: 0; flex-shrink: 0; }
  .subject-picker-row { flex: 1; min-width: 0; }
  .subject-picker-row select { font-size: 15px; min-height: 40px; }
  .countdown { padding: 6px 0 0; border-left: none; border-top: 1px dashed var(--line); }
  .cd-display strong { font-size: 18px; }
  .subject-navigation { display: block; padding: 7px 0; }
  .subject-nav-label { margin-bottom: 4px; }
  .nav-btn { min-height: 38px; }
  .utility-btn { min-height: 36px; }
  .subject-intro { padding: 8px 0 16px; }
  .brand { font-size: 15px; }
  .nav-btn { padding: 5px 10px; font-size: 13.5px; }
  main { padding: 12px 10px 44px; }
  .card { padding: 14px; }
  .card h2 { font-size: 16px; }
  table.exam-table { font-size: 13px; }
  table.exam-table th, table.exam-table td { padding: 5px 7px; }
  .quiz-head { padding: 8px 10px; }
  .btn { padding: 7px 14px; font-size: 14px; }
  .flash-card { font-size: 16px; min-height: 150px; }
  .stat-num { font-size: 22px; }
}

/* ---------- 打印 ---------- */
@media print {
  .topbar, .site-footer, .btn, #toast, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ---------- 趣味闯关（游戏） ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.game-card h2 { margin-bottom: 2px; }
.game-stars { color: #f59e0b; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.g-hearts { font-size: 17px; letter-spacing: 2px; }

.game-lv-list { display: flex; flex-direction: column; gap: 10px; }
.game-lv {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 12px 14px;
  cursor: pointer; font-size: 15px; color: var(--ink); text-align: left; transition: border-color .15s;
}
.game-lv:not(:disabled):hover { border-color: var(--brand); background: var(--brand-weak); }
.game-lv:disabled { cursor: not-allowed; color: var(--ink-3); background: var(--bg); }
.game-lv-name { font-weight: 600; }

.match-wrap { display: flex; gap: 10px; align-items: flex-start; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.match-item {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; font-size: 14.5px; line-height: 1.5; color: var(--ink); text-align: left;
  transition: border-color .15s, background .15s; width: 100%;
}
.match-item:not(:disabled):hover { border-color: var(--brand); }
.match-item.sel { border-color: var(--brand); background: var(--brand-weak); font-weight: 600; }
.match-item.ok { border-color: var(--ok-line, #bbf7d0); background: var(--green-weak); color: var(--green); cursor: default; opacity: .7; }
.match-item.bad { border-color: var(--red); background: var(--red-weak); }
.gram-opt b { color: var(--ink-2); margin-right: 4px; }
.shake { animation: gshake .45s; }
@keyframes gshake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.gram-sent { font-size: 16.5px; line-height: 1.8; }
.gram-blank { display: inline-block; min-width: 84px; border-bottom: 2px solid var(--ink-2); color: var(--brand); font-weight: 700; text-align: center; }
.gram-opts { display: grid; gap: 10px; }

.spell-clue { font-size: 18px; font-weight: 600; margin-top: 14px; color: var(--ink); }
.spell-input {
  flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 17px; font-family: inherit;
}
.spell-input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.tile-area {
  min-height: 56px; border: 2px dashed var(--line); border-radius: 10px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.tile-area.filled { border-style: solid; border-color: var(--brand); background: var(--brand-weak); }
.tile-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tile {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 11px;
  cursor: pointer; font-size: 15px; color: var(--ink); transition: transform .1s, border-color .15s;
}
.tile:hover { border-color: var(--brand); }
.tile:active { transform: scale(.95); }

/* Persistent storage warning; independent of focused lesson/quiz input. */
.storage-status { position: sticky; top: var(--qh-top, 80px); z-index: 45; max-height: 55vh; overflow-y: auto; margin: 12px 0; padding: 14px; border: 2px solid #b45309; border-radius: 12px; color: #78350f; background: #fffbeb; }
.storage-status[hidden], .storage-status [hidden] { display: none !important; }
.storage-status p { margin: 8px 0; }
.lesson-draft-list { list-style: none; padding: 0; }
.lesson-draft-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line, #ddd); padding: 12px 0; overflow-wrap: anywhere; }
@media (max-width: 500px) { .lesson-draft-list li { align-items: flex-start; flex-direction: column; } }

/* Model and text production games: keyboard/touch equivalents, no drag-only input. */
.sg-model { border:1px solid var(--line); border-radius:14px; padding:16px; margin:14px 0; }
.sg-model-controls { display:flex; flex-wrap:wrap; align-items:end; gap:12px; }
.sg-field { display:flex; flex-direction:column; gap:6px; margin:12px 0; flex:1 1 200px; }
.sg-model input,.sg-model select,.sg-model textarea,.sg-text-workbench input,.sg-text-workbench textarea { box-sizing:border-box; max-width:100%; min-height:44px; padding:10px; font:inherit; color:var(--ink); background:var(--card); border:1px solid var(--line); border-radius:8px; }
.sg-model textarea,.sg-text-workbench textarea { width:100%; min-height:140px; line-height:1.7; }
.sg-expression { overflow-wrap:anywhere; padding:14px; background:var(--bg); border-radius:8px; font-size:1.15rem; }
.sg-expression-chain li { margin:10px 0; overflow-wrap:anywhere; }
.sg-checks { padding-left:22px; line-height:1.8; }
.sg-model table { border-collapse:collapse; width:100%; margin:12px 0; }
.sg-model th,.sg-model td { border:1px solid var(--line); padding:8px; text-align:left; }
.sg-model svg { display:block; max-width:100%; height:auto; }
.sg-model button:focus-visible,.sg-model input:focus-visible,.sg-model select:focus-visible,.sg-model textarea:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
@media(max-width:600px){.sg-model{padding:12px}.sg-model-controls{display:block}.sg-model-controls>.btn{margin:6px 6px 6px 0}.sg-field{min-width:0}.sg-model table{font-size:.85rem}}
