/* ============================================================
   PyDrive 智驾 Python 学习站 —— 样式
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --bg-soft: #eceff6;
  --card: #ffffff;
  --card-2: #f8f9fc;
  --text: #1c2333;
  --text-2: #465065;
  --muted: #7a8396;
  --line: #e2e6ee;
  --line-2: #d5dae4;
  --primary: #2f54eb;
  --primary-2: #4a6cf7;
  --primary-ink: #1d39c4;
  --primary-soft: #ebf0ff;
  --accent: #fa8c16;
  --accent-soft: #fff4e6;
  --ok: #16a34a;
  --ok-soft: #e7f6ed;
  --err: #dc2626;
  --err-soft: #fdeded;
  --warn: #c2410c;
  --warn-soft: #fff4e5;
  --purple: #7c3aed;
  --purple-soft: #f3edff;
  --code-bg: #f6f8fb;
  --code-gutter: #eef1f6;
  --code-text: #1f2937;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 40px rgba(16, 24, 40, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, "Roboto Mono", "Droid Sans Mono", "Noto Sans Mono", monospace;
  --topbar-h: 58px;
  --sidebar-w: 292px;
  --tabbar-h: 0px;
  --ce-font: 14px;
  --ce-lh: 22px;
  /* 代码高亮 */
  --hl-kw: #cf222e; --hl-str: #0a3069; --hl-com: #6e7781; --hl-num: #0550ae;
  --hl-bi: #8250df; --hl-fn: #6639ba; --hl-self: #953800; --hl-dec: #953800; --hl-op: #24292f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1320; --bg-soft: #151b2b; --card: #161d2d; --card-2: #1b2335; --text: #e6e9f0; --text-2: #b5bccb;
    --muted: #8a93a6; --line: #263048; --line-2: #313c57; --primary: #6b8cff; --primary-2: #8aa4ff; --primary-ink: #a9bcff;
    --primary-soft: #1d2747; --accent: #ffa940; --accent-soft: #33261a; --ok: #3fcf78; --ok-soft: #14301f; --err: #ff6b6b;
    --err-soft: #3a1c22; --warn: #ffa94d; --warn-soft: #362716; --purple: #b794f6; --purple-soft: #2a2140;
    --code-bg: #0f1525; --code-gutter: #131a2c; --code-text: #e1e6ef;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    --hl-kw: #ff7b72; --hl-str: #a5d6ff; --hl-com: #8b949e; --hl-num: #79c0ff; --hl-bi: #d2a8ff; --hl-fn: #d2a8ff;
    --hl-self: #ffa657; --hl-dec: #ffa657; --hl-op: #e6edf3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1320; --bg-soft: #151b2b; --card: #161d2d; --card-2: #1b2335; --text: #e6e9f0; --text-2: #b5bccb;
  --muted: #8a93a6; --line: #263048; --line-2: #313c57; --primary: #6b8cff; --primary-2: #8aa4ff; --primary-ink: #a9bcff;
  --primary-soft: #1d2747; --accent: #ffa940; --accent-soft: #33261a; --ok: #3fcf78; --ok-soft: #14301f; --err: #ff6b6b;
  --err-soft: #3a1c22; --warn: #ffa94d; --warn-soft: #362716; --purple: #b794f6; --purple-soft: #2a2140;
  --code-bg: #0f1525; --code-gutter: #131a2c; --code-text: #e1e6ef;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  --hl-kw: #ff7b72; --hl-str: #a5d6ff; --hl-com: #8b949e; --hl-num: #79c0ff; --hl-bi: #d2a8ff; --hl-fn: #d2a8ff;
  --hl-self: #ffa657; --hl-dec: #ffa657; --hl-op: #e6edf3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px;
  line-height: 1.7; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
code, pre, kbd, samp, textarea, .ce, .out-text, .q-input { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.only-mobile { display: none !important; }

/* ---------------- 顶栏 ---------------- */
#read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 60;
  background: linear-gradient(90deg, #52c41a, #faad14, #ff4d4f); transition: width .15s linear;
}
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 18px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; display: block; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .3px; line-height: 1.1; display: flex; flex-direction: column; }
.brand-name small { font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }
.topnav { display: flex; gap: 2px; margin-left: 14px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 7px 12px; border-radius: 9px; color: var(--text-2); font-size: 14.5px; white-space: nowrap; font-weight: 500;
}
.topnav a:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }
.topnav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.topnav .badge-dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 18px; flex: none;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

/* ---------------- 布局 ---------------- */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); width: var(--sidebar-w); flex: none; height: calc(100vh - var(--topbar-h));
  overflow-y: auto; border-right: 1px solid var(--line); background: var(--card); padding: 14px 10px 40px;
  scrollbar-width: thin;
}
.main { flex: 1; min-width: 0; padding: 26px 32px 80px; outline: none; }
.page { max-width: 1080px; margin: 0 auto; }
.page-narrow { max-width: 880px; margin: 0 auto; }
.scrim { display: none; }

/* 课程目录 */
.outline-phase { margin-bottom: 8px; }
.outline-phase > button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: transparent;
  border-radius: 9px; cursor: pointer; text-align: left; color: var(--text); font-weight: 700; font-size: 14px;
}
.outline-phase > button:hover { background: var(--bg-soft); }
.outline-phase > button .chev { margin-left: auto; transition: transform .2s; color: var(--muted); font-size: 12px; }
.outline-phase.collapsed > button .chev { transform: rotate(-90deg); }
.outline-phase.collapsed .outline-list { display: none; }
.outline-phase .ph-progress { font-weight: 500; font-size: 12px; color: var(--muted); }
.outline-list { list-style: none; margin: 2px 0 6px; padding: 0; }
.outline-list a {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px 6px 12px; border-radius: 8px; color: var(--text-2);
  font-size: 14px; line-height: 1.45;
}
.outline-list a:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }
.outline-list a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.outline-list .num { width: 20px; flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.outline-list .ttl { flex: 1; min-width: 0; }
.outline-list a.pending .ttl { opacity: .55; }
.st-icon { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); position: relative; }
.st-icon.learning { border-color: var(--accent); background: conic-gradient(var(--accent) 0 50%, transparent 50% 100%); }
.st-icon.completed { border-color: var(--ok); background: var(--ok); }
.st-icon.completed::after {
  content: ""; position: absolute; left: 3.5px; top: 1px; width: 4px; height: 7px; border: solid #fff;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.outline-extra { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.outline-extra a { display: block; padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-size: 14px; }
.outline-extra a:hover { background: var(--bg-soft); text-decoration: none; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.stat-grid > .card, .phase-grid > .card, .two-col > .card, .mobile-grid > .card, .pg-layout .card { margin-top: 0; }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 19px; font-weight: 750; }
.section-title .extra { margin-left: auto; font-size: 13.5px; font-weight: 500; }
h1.page-title { font-size: 26px; margin: 4px 0 6px; line-height: 1.35; }
.page-sub { color: var(--muted); margin: 0 0 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text); cursor: pointer; font-size: 14.5px;
  font-weight: 550; line-height: 1.3; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none !important; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-ink); border-color: var(--primary-ink); }
:root[data-theme="dark"] .btn.primary:hover { color: #0e1320; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 16px; border-radius: 12px; }
.btn .kbd { font-size: 11px; opacity: .75; font-weight: 500; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; background: var(--bg-soft); color: var(--text-2); white-space: nowrap; line-height: 1.6;
}
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.tag.red { background: var(--err-soft); color: var(--err); }
.tag.orange { background: var(--accent-soft); color: var(--warn); }
.tag.purple { background: var(--purple-soft); color: var(--purple); }
.progress { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary-2), var(--primary)); }
.progress.green > i { background: linear-gradient(90deg, #4ade80, var(--ok)); }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.loading::before {
  content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--primary); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: transparent; padding: 9px 14px; cursor: pointer; color: var(--text-2); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 15px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.input, .textarea, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card);
  outline: none; transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
.input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.65; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; background: var(--card-2); }
table.tbl tr:hover td { background: var(--card-2); }
.score { font-weight: 750; font-variant-numeric: tabular-nums; }
.score.pass { color: var(--ok); }
.score.fail { color: var(--err); }

/* toast & modal */
.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--tabbar-h)); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: #1f2433; color: #fff; padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14.5px;
  animation: toast-in .25s ease; pointer-events: auto; max-width: 92vw;
}
.toast.ok { background: #138a43; }
.toast.err { background: #c42727; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 25, .5); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 88vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .btn-row { justify-content: flex-end; margin-top: 18px; }
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .85); display: grid; place-items: center; padding: 12px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 6px; }

/* ---------------- Markdown 正文 ---------------- */
.md { font-size: 16.5px; line-height: 1.85; color: var(--text); overflow-wrap: anywhere; }
.md > *:first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.4; margin: 1.7em 0 .6em; font-weight: 750; }
.md h1 { font-size: 1.6em; }
.md h2 { font-size: 1.36em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.14em; }
.md h4 { font-size: 1em; color: var(--text-2); }
.md p { margin: .75em 0; }
.md ul, .md ol { padding-left: 1.6em; margin: .6em 0; }
.md li { margin: .25em 0; }
.md li > ul, .md li > ol { margin: .2em 0; }
.md strong { font-weight: 700; color: var(--text); }
.md mark { background: linear-gradient(transparent 55%, color-mix(in srgb, var(--accent) 35%, transparent) 55%); color: inherit; padding: 0 1px; }
.md hr { border: 0; border-top: 1px dashed var(--line-2); margin: 2em 0; }
.md blockquote { margin: 1em 0; padding: .4em 1em; border-left: 4px solid var(--line-2); color: var(--text-2); background: var(--card-2); border-radius: 0 8px 8px 0; }
.md code:not(pre code) {
  font-family: var(--mono); font-size: .88em; background: var(--bg-soft); border: 1px solid var(--line); padding: .08em .38em;
  border-radius: 6px; color: var(--hl-kw); white-space: break-spaces;
}
.md img { border-radius: 10px; display: block; margin: 1em auto; }
.md .table-wrap { margin: 1em 0; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: .94em; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: .55em .8em; text-align: left; vertical-align: top; }
.md th { background: var(--card-2); font-weight: 650; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.code-static { position: relative; margin: 1em 0; }
.md pre, .code-static pre {
  margin: 0; padding: 14px 16px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
  overflow-x: auto; font-family: var(--mono); font-size: 14px; line-height: 1.6; color: var(--code-text); tab-size: 4;
}
.md pre.plain { color: var(--text-2); }
.code-static .copy-btn {
  position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; padding: 3px 8px; font-size: 12px;
  border-radius: 7px; border: 1px solid var(--line-2); background: var(--card); color: var(--text-2); cursor: pointer;
}
.code-static:hover .copy-btn { opacity: 1; }
.code-label { font-size: 12px; color: var(--muted); margin: 0 0 4px 2px; font-weight: 600; letter-spacing: .5px; }

/* 提示框 */
.callout { margin: 1.2em 0; padding: 12px 16px 12px 16px; border-radius: 12px; border: 1px solid; }
.callout-title { font-weight: 700; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout.tip { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.callout.tip .callout-title { color: var(--ok); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn .callout-title { color: var(--warn); }
.callout.note, .callout.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.callout.note .callout-title, .callout.info .callout-title { color: var(--primary); }
.callout.car { background: var(--purple-soft); border-color: color-mix(in srgb, var(--purple) 28%, transparent); }
.callout.car .callout-title { color: var(--purple); }
.callout.key { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.callout.key .callout-title { color: var(--warn); }
.callout.goal { background: var(--card-2); border-color: var(--line-2); }
.callout.goal .callout-title { color: var(--text); }

/* 公式 */
.math { font-family: "Cambria Math", "Times New Roman", "STIX Two Math", "Noto Serif", serif; font-size: 1.08em; white-space: nowrap; }
.math i { font-style: italic; }
.math .mop { margin: 0 .22em; font-style: normal; }
.math .mfn { font-style: normal; margin-right: .1em; }
.math .mtext { font-family: var(--font); font-style: normal; font-size: .9em; }
.math .mbf { font-weight: 700; }
.math sub, .math sup { font-size: .72em; line-height: 0; }
.math .msubsup { display: inline-flex; flex-direction: column; vertical-align: middle; font-size: .72em; line-height: 1.05; margin-left: .05em; }
.math .msubsup sup, .math .msubsup sub { font-size: 1em; line-height: 1.05; vertical-align: baseline; }
.math .mfrac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .12em; }
.math .mfrac > span { padding: 0 .25em; line-height: 1.3; }
.math .mfrac > .mnum { border-bottom: 1px solid currentColor; }
.math .msqrt { white-space: nowrap; }
.math .msqrt-in { border-top: 1px solid currentColor; padding: 0 .1em; margin-left: .05em; }
.math .mmat { display: inline-block; vertical-align: middle; margin: 0 .2em; line-height: 1.45; }
.math .mmat-body { display: inline-table; position: relative; padding: .1em .5em; }
.math .mmat-row { display: table-row; }
.math .mmat-cell { display: table-cell; padding: .12em .5em; text-align: center; }
.math .bmatrix .mmat-body::before, .math .bmatrix .mmat-body::after,
.math .pmatrix .mmat-body::before, .math .pmatrix .mmat-body::after { content: ""; position: absolute; top: .05em; bottom: .05em; width: .4em; border: 1.3px solid currentColor; }
.math .bmatrix .mmat-body::before, .math .pmatrix .mmat-body::before { left: 0; border-right: 0; }
.math .bmatrix .mmat-body::after, .math .pmatrix .mmat-body::after { right: 0; border-left: 0; }
.math .pmatrix .mmat-body::before { border-radius: .7em 0 0 .7em / 50% 0 0 50%; border-top: 0; border-bottom: 0; }
.math .pmatrix .mmat-body::after { border-radius: 0 .7em .7em 0 / 0 50% 50% 0; border-top: 0; border-bottom: 0; }
.math .vmatrix .mmat-body { border-left: 1.3px solid currentColor; border-right: 1.3px solid currentColor; }
.math .cases .mmat-body { padding-left: .9em; }
.math .cases .mmat-body::before { content: ""; position: absolute; left: .1em; top: .05em; bottom: .05em; width: .45em; border-left: 1.5px solid currentColor; border-radius: .55em 0 0 .55em / 40% 0 0 40%; }
.math .cases .mmat-cell { text-align: left; padding: .15em .6em .15em .3em; }
.math-block { display: block; text-align: center; margin: 1.1em 0; padding: 10px 6px; overflow-x: auto; font-size: 1.12em; line-height: 2.2; }
.math-block .math { font-size: 1em; }

/* ---------------- 代码编辑器 ---------------- */
.runbox { margin: 1.1em 0; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); overflow: hidden; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.runbox-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--card-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.runbox-head .label { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .5px; margin-right: auto; display: flex; align-items: center; gap: 6px; }
.runbox-head .label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.ce { display: flex; background: var(--code-bg); font-family: var(--mono); font-size: var(--ce-font); line-height: var(--ce-lh); position: relative; }
.ce-gutter {
  flex: none; padding: 10px 8px 10px 6px; min-width: 2.9em; text-align: right; color: var(--muted); user-select: none;
  -webkit-user-select: none; background: var(--code-gutter); border-right: 1px solid var(--line); font-size: .86em;
}
.ce-gutter div { height: var(--ce-lh); line-height: var(--ce-lh); padding-right: 2px; }
.ce-gutter div.err { color: #fff; background: var(--err); border-radius: 4px; }
.ce-body { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ce-hl, .ce-input {
  margin: 0; padding: 10px 14px; font-family: inherit; font-size: inherit; line-height: inherit; tab-size: 4;
  white-space: pre; letter-spacing: normal; word-spacing: normal; border: 0; font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.ce-hl { position: absolute; top: 0; left: 0; pointer-events: none; min-width: 100%; color: var(--code-text); will-change: transform; }
.ce-input {
  position: relative; display: block; width: 100%; resize: none; overflow-x: auto; overflow-y: hidden; background: transparent;
  color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--text); outline: none; z-index: 1;
}
.ce-input::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }
.ce-input::placeholder { color: var(--muted); -webkit-text-fill-color: var(--muted); }
.ce-errband { position: absolute; left: 0; right: 0; height: var(--ce-lh); background: color-mix(in srgb, var(--err) 14%, transparent); pointer-events: none; }
.ce-readonly .ce-input { caret-color: transparent; }
.hl-kw { color: var(--hl-kw); }
.hl-str { color: var(--hl-str); }
.hl-com { color: var(--hl-com); font-style: italic; }
.hl-num { color: var(--hl-num); }
.hl-bi { color: var(--hl-bi); }
.hl-fn { color: var(--hl-fn); font-weight: 600; }
.hl-cls { color: var(--hl-self); font-weight: 600; }
.hl-self { color: var(--hl-self); }
.hl-dec { color: var(--hl-dec); }
.hl-op { color: var(--hl-op); }
.runbox-stdin { border-top: 1px solid var(--line); padding: 8px 10px; background: var(--card-2); }
.runbox-stdin label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.runbox-stdin textarea { width: 100%; min-height: 40px; font-family: var(--mono); font-size: 13.5px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--card); resize: vertical; outline: none; }
.runbox-out { border-top: 1px solid var(--line); background: var(--card); }
.out-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 13px; font-weight: 650; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.out-head.ok { color: var(--ok); }
.out-head.error, .out-head.crash { color: var(--err); }
.out-head.timeout, .out-head.busy { color: var(--warn); }
.out-head .time { margin-left: auto; color: var(--muted); font-weight: 500; }
.out-head .close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 4px; }
.out-text { margin: 0; padding: 10px 14px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; color: var(--text); }
.out-empty { padding: 10px 14px; color: var(--muted); font-size: 13.5px; }
.out-figs { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
.out-figs img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.out-err { margin: 8px 12px 12px; border-radius: 10px; background: var(--err-soft); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); padding: 10px 12px; }
.out-err .err-title { font-weight: 750; color: var(--err); font-size: 14.5px; }
.out-err .err-msg { font-family: var(--mono); font-size: 13px; margin: 4px 0 6px; overflow-wrap: anywhere; }
.out-err ul { margin: 6px 0 0; padding-left: 1.2em; font-size: 14px; }
.out-err details { margin-top: 6px; }
.out-err summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
.out-err pre { margin: 6px 0 0; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; background: var(--card); border-radius: 8px; overflow-x: auto; }
.out-tests { margin: 8px 12px 12px; padding: 10px 12px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
.out-tests .t-sum { font-weight: 750; margin-bottom: 4px; }
.out-tests .t-sum.ok { color: var(--ok); }
.out-tests .t-sum.fail { color: var(--err); }
.out-tests ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.out-tests li { padding: 2px 0; display: flex; gap: 8px; }
.out-tests li .i { flex: none; font-weight: 800; }
.out-tests li.ok .i { color: var(--ok); }
.out-tests li.fail .i { color: var(--err); }
.out-msg { padding: 10px 14px; font-size: 14px; }

/* 手机符号栏 */
.symbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex; gap: 4px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
.symbar::-webkit-scrollbar { display: none; }
.symbar button {
  flex: none; min-width: 38px; height: 36px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--card-2); font-family: var(--mono); font-size: 16px; color: var(--text); touch-action: manipulation;
}
.symbar button.wide { font-family: var(--font); font-size: 13px; font-weight: 650; }
.symbar button.run { background: var(--primary); border-color: var(--primary); color: #fff; }
.symbar button:active { background: var(--primary-soft); }

/* ---------------- 首页 ---------------- */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 26px 28px;
  background:
    radial-gradient(600px 220px at 100% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%),
    radial-gradient(500px 220px at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--card);
}
.hero .hello { color: var(--muted); font-weight: 600; }
.hero h1 { margin: 4px 0 6px; font-size: 26px; line-height: 1.35; }
.hero p { margin: 0 0 16px; color: var(--text-2); }
.hero .continue-meta { color: var(--muted); font-size: 13.5px; margin-top: 8px; }
.ring { width: 132px; height: 132px; position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-txt { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.25; }
.ring .ring-txt b { font-size: 26px; display: block; }
.ring .ring-txt span { font-size: 12px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.phase-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.phase-card { display: flex; flex-direction: column; gap: 10px; }
.phase-card .ph-no { font-size: 12px; font-weight: 800; letter-spacing: 1.5px; color: var(--primary); }
.phase-card h3 { margin: 0; font-size: 17px; line-height: 1.4; }
.phase-card .sub { color: var(--muted); font-size: 13.5px; margin-top: -4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); text-decoration: none !important;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.learning { background: var(--accent-soft); color: var(--warn); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.chip.completed { background: var(--ok); color: #fff; border-color: var(--ok); }
.chip.current { outline: 2px solid var(--primary); outline-offset: 1px; }
.phase-card .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 13px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; display: block; }
.hm0 { background: var(--bg-soft); }
.hm1 { background: color-mix(in srgb, var(--ok) 30%, var(--bg-soft)); }
.hm2 { background: color-mix(in srgb, var(--ok) 55%, var(--bg-soft)); }
.hm3 { background: color-mix(in srgb, var(--ok) 78%, var(--bg-soft)); }
.hm4 { background: var(--ok); }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 6px; justify-content: flex-end; }
.heat-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
body.pairing .sidebar, body.pairing #menu-btn, body.pairing .tabbar { display: none !important; }
.guide { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.guide .step { padding: 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); }
.guide .step b { display: block; margin-bottom: 2px; }
.guide .step .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.guide .step p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

/* ---------------- 课程目录页 ---------------- */
.course-phase { margin-bottom: 26px; }
.course-phase-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.course-phase-head h2 { margin: 0; font-size: 20px; }
.course-phase-head .sub { color: var(--muted); }
.course-phase-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.lesson-rows { display: grid; gap: 8px; }
.lesson-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 13px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none !important;
  transition: border-color .15s, transform .15s;
}
.lesson-row:hover { border-color: var(--primary); transform: translateY(-1px); }
.lesson-row .no { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--bg-soft); color: var(--muted); font-size: 14px; }
.lesson-row.completed .no { background: var(--ok); color: #fff; }
.lesson-row.learning .no { background: var(--accent-soft); color: var(--warn); }
.lesson-row .t { font-weight: 650; line-height: 1.45; }
.lesson-row .d { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.lesson-row .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.lesson-row.pending { opacity: .6; }

/* ---------------- 课时页 ---------------- */
.lesson { max-width: 900px; margin: 0 auto; }
.lesson-head { margin-bottom: 18px; }
.crumb { font-size: 13.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumb a { color: var(--muted); }
.lesson-head h1 { font-size: 28px; line-height: 1.35; margin: 6px 0 8px; }
.lesson-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lesson-summary { color: var(--text-2); margin: 10px 0 0; }
.lesson-content { margin-top: 10px; }
.ex-card { margin-top: 18px; padding: 18px 20px; }
.ex-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-head h3 { margin: 0; font-size: 17px; }
.ex-head .tag { margin-left: auto; }
.ex-desc { margin: 8px 0 4px; font-size: 15.5px; }
.ex-hints { margin: 10px 0 0; display: grid; gap: 8px; }
.ex-hint { padding: 9px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14.5px; }
.ex-hint b { color: var(--warn); }
.ex-solution { margin-top: 12px; }
.ex-actions { margin-top: 10px; }
.pass-burst { animation: burst .6s ease; }
@keyframes burst { 0% { transform: scale(1); } 40% { transform: scale(1.04); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 25%, transparent); } 100% { transform: scale(1); } }
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 34px; }
.lesson-nav a { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); text-decoration: none !important; }
.lesson-nav a:hover { border-color: var(--primary); }
.lesson-nav a small { display: block; color: var(--muted); font-size: 12.5px; }
.lesson-nav a.next { text-align: right; }
.notes-box textarea { min-height: 120px; }
.notes-box .status { font-size: 12.5px; color: var(--muted); margin-top: 4px; min-height: 18px; }
.lesson-section-title { display: flex; align-items: center; gap: 10px; margin: 40px 0 6px; font-size: 21px; font-weight: 800; }
.lesson-section-title .extra { margin-left: auto; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.lesson-section-desc { color: var(--muted); margin: 0 0 6px; font-size: 14.5px; }

/* ---------------- 测验 ---------------- */
.quiz { display: grid; gap: 14px; margin-top: 12px; }
.q-card { padding: 18px 20px; transition: border-color .2s; }
.q-card.right { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.q-card.wrong { border-color: color-mix(in srgb, var(--err) 55%, transparent); }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.q-no { width: 26px; height: 26px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.q-card.right .q-no { background: var(--ok); }
.q-card.wrong .q-no { background: var(--err); }
.q-from { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.q-stem { font-size: 16px; }
.q-stem.md pre { font-size: 13.5px; }
.q-opts { display: grid; gap: 8px; margin-top: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 11px;
  cursor: pointer; background: var(--card); transition: border-color .15s, background .15s; line-height: 1.6;
}
.opt:hover { border-color: var(--primary-2); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .key {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-weight: 750; font-size: 13px;
  border: 1.5px solid var(--line-2); color: var(--text-2); margin-top: 1px;
}
.opt.multi .key { border-radius: 6px; }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .key { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt .txt code { font-family: var(--mono); font-size: .9em; background: var(--bg-soft); padding: .05em .35em; border-radius: 5px; }
.opt.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--err); background: var(--err-soft); }
.opt.is-wrong .key { background: var(--err); border-color: var(--err); color: #fff; }
.q-locked .opt { cursor: default; }
.q-input { margin-top: 10px; font-family: var(--mono); }
textarea.q-input { min-height: 84px; }
.q-feedback { margin-top: 12px; padding: 10px 13px; border-radius: 10px; font-size: 14.5px; }
.q-feedback.right { background: var(--ok-soft); }
.q-feedback.wrong { background: var(--err-soft); }
.q-feedback .fb-title { font-weight: 750; }
.q-feedback.right .fb-title { color: var(--ok); }
.q-feedback.wrong .fb-title { color: var(--err); }
.q-feedback pre { margin: 4px 0; padding: 6px 10px; background: var(--card); border-radius: 8px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.q-feedback .md { font-size: 14.5px; line-height: 1.75; }
.quiz-submit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.quiz-result { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.quiz-result .big-score { font-size: 48px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.quiz-result .big-score small { font-size: 18px; font-weight: 700; margin-left: 2px; }
.quiz-result.pass { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: linear-gradient(135deg, var(--ok-soft), var(--card) 70%); }
.quiz-result.pass .big-score { color: var(--ok); }
.quiz-result.fail { border-color: color-mix(in srgb, var(--err) 40%, transparent); background: linear-gradient(135deg, var(--err-soft), var(--card) 70%); }
.quiz-result.fail .big-score { color: var(--err); }
.quiz-result h3 { margin: 0 0 4px; }
.quiz-result p { margin: 0 0 10px; color: var(--text-2); }

/* ---------------- 错题本 / 记录 ---------------- */
.wb-item { margin-top: 12px; }
.wb-item .wb-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.wb-item .wb-meta .right { margin-left: auto; display: flex; gap: 6px; }
.wb-ans { display: grid; gap: 6px; margin-top: 10px; font-size: 14.5px; }
.wb-ans .row { display: flex; gap: 8px; }
.wb-ans .row b { flex: none; width: 74px; color: var(--muted); font-weight: 600; }
.wb-ans .row pre { margin: 0; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; background: var(--card-2); padding: 4px 8px; border-radius: 6px; flex: 1; }
.wb-ans .bad { color: var(--err); }
.wb-ans .good { color: var(--ok); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--primary-2); }
.chart .bar.today { fill: var(--accent); }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 18px 1fr; gap: 8px; align-items: start; padding: 6px 0; font-size: 14.5px; }
.timeline .t { color: var(--muted); font-size: 12.5px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.timeline .d { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--line-2); justify-self: center; }
.timeline .d.complete { background: var(--ok); }
.timeline .d.quiz { background: var(--primary); }
.timeline .d.exercise { background: var(--accent); }
.timeline .d.start { background: var(--purple); }
.timeline .day { grid-column: 1 / -1; font-weight: 750; margin-top: 10px; font-size: 14px; color: var(--text-2); }

/* ---------------- 练习场 ---------------- */
.pg-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.pg-list { padding: 12px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.pg-list ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 60vh; overflow: auto; }
.pg-list li a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-list li a:hover { background: var(--bg-soft); text-decoration: none; }
.pg-list li a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.pg-list li a small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.pg-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.pg-toolbar .input { max-width: 300px; }

/* ---------------- 配对 / 手机 ---------------- */
.pair-wrap { min-height: 70vh; display: grid; place-items: center; }
.pair-card { width: min(420px, 100%); text-align: center; padding: 30px 26px; }
.pair-card img { width: 64px; height: 64px; border-radius: 14px; }
.pair-card h2 { margin: 12px 0 6px; }
.pin-input { font-size: 30px; letter-spacing: 12px; text-align: center; font-family: var(--mono); padding: 10px; margin: 16px 0 12px; }
.mobile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qr-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-img { background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); width: 200px; height: 200px; flex: none; }
.qr-img svg { width: 100%; height: 100%; display: block; }
.pin-show { font-family: var(--mono); font-size: 34px; font-weight: 800; letter-spacing: 8px; color: var(--primary); }
.url-show { font-family: var(--mono); font-size: 17px; font-weight: 700; word-break: break-all; }
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin: 6px 0; }
.env-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14.5px; }
.env-list .ok { color: var(--ok); font-weight: 650; }
.env-list .bad { color: var(--err); font-weight: 650; }

/* ---------------- 底部标签栏（手机） ---------------- */
.tabbar { display: none; }

/* ============================================================
   响应式：平板 / 手机
   ============================================================ */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .phase-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .guide { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  :root { --tabbar-h: 60px; --topbar-h: 54px; }
  .only-mobile { display: inline-grid !important; }
  .sidebar-head.only-mobile { display: flex !important; }
  .topnav { display: none; }
  .brand-name small { display: none; }
  .topbar { padding: 0 8px 0 6px; gap: 6px; }
  .sidebar {
    position: fixed; z-index: 80; top: 0; left: 0; bottom: 0; height: 100%; width: min(86vw, 330px);
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); padding-top: 6px;
  }
  .sidebar-head { align-items: center; justify-content: space-between; padding: 4px 6px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 75; }
  .main { padding: 16px 14px calc(var(--tabbar-h) + 30px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted);
    font-size: 11.5px; font-weight: 600; text-decoration: none !important; position: relative; -webkit-tap-highlight-color: transparent;
  }
  .tabbar a .ico { font-size: 20px; line-height: 1.1; filter: grayscale(.6); }
  .tabbar a.active { color: var(--primary); }
  .tabbar a.active .ico { filter: none; }
  .tabbar a .badge-dot { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--err); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
  body.kb-open .tabbar { display: none; }
  body.kb-open .main { padding-bottom: 70px; }
  .toast-root { bottom: calc(var(--tabbar-h) + 18px); }
  .mobile-grid { grid-template-columns: 1fr; }
  .pg-layout { grid-template-columns: 1fr; }
  .pg-list { position: static; }
  .pg-list ul { max-height: 180px; }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  :root { --ce-font: 13px; --ce-lh: 20px; }
  .card { padding: 16px 15px; border-radius: 12px; }
  .hero { grid-template-columns: 1fr; padding: 20px 16px; gap: 14px; }
  .hero h1 { font-size: 21px; }
  .hero .ring { width: 104px; height: 104px; justify-self: start; }
  .hero-row { display: flex; align-items: center; gap: 16px; }
  .stat-grid { gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .v { font-size: 22px; }
  .guide { grid-template-columns: 1fr; }
  h1.page-title { font-size: 22px; }
  .lesson-head h1 { font-size: 22px; }
  .md { font-size: 15.5px; line-height: 1.8; }
  .md pre, .code-static pre { font-size: 13px; padding: 12px; }
  .code-static .copy-btn { opacity: 1; }
  .lesson-section-title { font-size: 19px; margin-top: 32px; }
  .ex-card, .q-card { padding: 15px 14px; }
  .lesson-row { grid-template-columns: 30px 1fr; padding: 12px; gap: 10px; }
  .lesson-row .no { width: 30px; height: 30px; }
  .lesson-row .meta { grid-column: 2; justify-content: flex-start; }
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav a.next { text-align: left; }
  .quiz-result { grid-template-columns: 1fr; gap: 10px; }
  .quiz-result .big-score { font-size: 40px; }
  .runbox { margin-left: -4px; margin-right: -4px; }
  .runbox-head .btn .kbd { display: none; }
  .timeline li { grid-template-columns: 70px 14px 1fr; }
  .wb-ans .row { flex-direction: column; gap: 2px; }
  .wb-ans .row b { width: auto; }
  .qr-img { width: 170px; height: 170px; }
}
@media (hover: none) {
  .lesson-row:hover { transform: none; }
}
@media print {
  .topbar, .sidebar, .tabbar, .symbar, #read-progress { display: none !important; }
  .main { padding: 0; }
}
