/* ============================================================
   Excel 基础、函数与实战 · 网页版教程
   样式表：设计变量 / 布局 / 文档排版 / 深色模式 / 打印
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --accent: #217346;          /* Excel 绿 */
  --accent-soft: #e7f2ec;
  --accent-strong: #1a5c38;
  --bg: #ffffff;
  --bg-alt: #f7f8f9;
  --bg-sunken: #f1f3f4;
  --text: #1f2429;
  --text-soft: #545c64;
  --text-faint: #66717b;
  --border: #e3e7ea;
  --border-strong: #cdd4d9;
  --code-bg: #f6f8f7;
  --code-text: #1c5233;
  --warn-bg: #fdf0ee;  --warn-bd: #e6a79c;  --warn-tx: #9c3a2b;
  --tip-bg: #fdf6e7;   --tip-bd: #dfc07f;   --tip-tx: #8a6416;
  --check-bg: #edf5ee; --check-bd: #a8cbaf; --check-tx: #256637;
  --exer-bg: #eaf1f8;  --exer-bd: #a3c1de;  --exer-tx: #1f5480;
  --ans-bg: #f2eef8;   --ans-bd: #bfaedb;   --ans-tx: #55408a;
  --sidebar-w: 288px;
  --toc-w: 216px;
  --topbar-h: 56px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,32,.06), 0 8px 24px rgba(16,24,32,.06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.dark {
  --accent: #4cae7d;
  --accent-soft: #16302a;
  --accent-strong: #6fc79a;
  --bg: #0e1113;
  --bg-alt: #15191c;
  --bg-sunken: #1b2024;
  --text: #e6eaed;
  --text-soft: #a8b2ba;
  --text-faint: #7b858d;
  --border: #262c31;
  --border-strong: #39424a;
  --code-bg: #14191b;
  --code-text: #8fd6ab;
  --warn-bg: #2b1a17;  --warn-bd: #7d4436;  --warn-tx: #f0a595;
  --tip-bg: #2a2415;   --tip-bd: #7d6a33;   --tip-tx: #e5c583;
  --check-bg: #16261b; --check-bd: #3f6b4c; --check-tx: #9ad3ac;
  --exer-bg: #17222c;  --exer-bd: #3c5a76;  --exer-tx: #a3c8e8;
  --ans-bg: #211c2c;   --ans-bd: #4f4270;   --ans-tx: #c4b3e6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
               "Source Han Sans SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.nav-open { overflow: hidden; }

img, svg, video { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed; top: .5rem; left: .5rem; z-index: 100;
  display: inline-flex; align-items: center; min-height: 44px;
  padding: .5rem .85rem; border-radius: 8px;
  background: var(--text); color: var(--bg); font-weight: 700;
  box-shadow: var(--shadow); transform: translateY(calc(-100% - 1rem));
  transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

/* ---------------- 阅读进度条 ---------------- */
.reading-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px;
  background: transparent; z-index: 60; pointer-events: none;
}
.reading-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .625rem;
  height: var(--topbar-h); padding: 0 .75rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; min-height: 44px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: 0 0 28px;
  background: var(--accent); color: #fff;
  border-radius: 7px; font-weight: 700; font-size: 15px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14px; white-space: nowrap; }
.brand-text small { color: var(--text-faint); font-size: 11px; white-space: nowrap; }

.search-wrap { position: relative; margin-left: auto; flex: 1 1 auto; min-width: 0; max-width: 420px; }
.search-wrap input {
  width: 100%; height: 44px; padding: 0 2.75rem 0 .75rem;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 13px; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); background: var(--bg); }
.search-clear {
  position: absolute; right: 0; top: 0;
  font-size: 12px; display: none;
}
.search-wrap.has-value .search-clear { display: grid; }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px;
  background: transparent; color: var(--text-soft);
  border: 1px solid transparent; border-radius: 8px;
  font-size: 16px; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.menu-btn { display: grid; }

.text-btn {
  display: inline-flex; align-items: center; min-height: 44px;
  background: none; border: 0; padding: .35rem 0;
  color: var(--accent); font: inherit; font-size: 12px; cursor: pointer;
}
.text-btn:hover { text-decoration: underline; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg-alt); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .22s ease;
}
.sidebar.open { transform: none; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem .5rem; font-size: 12px;
  color: var(--text-faint); letter-spacing: .05em;
}
.sidebar nav { flex: 1 1 auto; overflow-y: auto; padding: 0 .5rem 1rem; }
.sidebar-foot {
  border-top: 1px solid var(--border); padding: .75rem 1rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.progress-line { font-size: 12px; color: var(--text-soft); }
.progress-track { height: 5px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.nav-root, .nav-chapters { list-style: none; margin: 0; padding: 0; }
.nav-part-btn {
  display: flex; align-items: center; gap: .4rem; width: 100%;
  min-height: 44px;
  padding: .5rem .55rem; margin-top: .15rem;
  background: none; border: 0; border-radius: 7px;
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  text-align: left; cursor: pointer;
}
.nav-part-btn:hover { background: var(--bg-sunken); }
.nav-part-link { text-decoration: none; }
.nav-part-link:hover { text-decoration: none; }
.nav-part.current > .nav-part-btn { color: var(--accent-strong); background: var(--accent-soft); }
.nav-caret { font-size: 9px; color: var(--text-faint); transition: transform .18s ease; flex: 0 0 auto; }
.nav-part.expanded .nav-caret { transform: rotate(90deg); }
.nav-part-text { flex: 1 1 auto; min-width: 0; }
.nav-count {
  flex: 0 0 auto; font-size: 10px; font-weight: 500;
  color: var(--text-faint); background: var(--bg-sunken);
  padding: 1px 6px; border-radius: 99px;
}
.nav-chapters { display: none; margin: .1rem 0 .35rem; padding-left: .35rem; }
.nav-part.expanded .nav-chapters { display: block; }
.nav-chapters a {
  display: flex; align-items: center; min-height: 44px; padding: .34rem .5rem .34rem .75rem;
  border-left: 2px solid var(--border);
  color: var(--text-soft); font-size: 12.5px; line-height: 1.5;
  border-radius: 0 6px 6px 0;
}
.nav-chapters a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.nav-chapters a.active {
  color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent); font-weight: 600;
}
.nav-chapters a.done::after { content: " ✓"; color: var(--accent); font-weight: 700; }

.scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35;
  background: rgba(12,16,20,.45); opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.content { flex: 1 1 auto; min-width: 0; padding: 0 1rem 4rem; }
.toc { display: none; }

.breadcrumb { padding-top: 1rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; color: var(--text-faint); font-size: 12.5px; }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: .35rem; color: var(--border-strong); }
.breadcrumb a { color: var(--text-soft); }

/* ---------------- 首屏 ---------------- */
.hero { padding: 2rem 0 1.75rem; border-bottom: 1px solid var(--border); }
.topic-hero { max-width: 820px; }
.topic-hero .hero-desc { max-width: 72ch; }
.hero-lead { display: grid; gap: 1.5rem; align-items: center; }
.hero-copy { min-width: 0; }
.hero-kicker {
  display: inline-block; margin: 0 0 .75rem;
  padding: .2rem .6rem; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 11.5px; font-weight: 600;
}
.hero h1 { margin: 0 0 .75rem; font-size: 1.95rem; line-height: 1.25; font-weight: 750; letter-spacing: -.02em; }
.hero h1 span { color: var(--accent); }
.hero-desc { margin: 0 0 1rem; color: var(--text-soft); max-width: 62ch; }
.hero-proof {
  display: flex; flex-wrap: wrap; gap: .4rem .65rem;
  margin: 0 0 1.25rem; padding: 0; list-style: none;
}
.hero-proof li {
  position: relative; padding-left: 1rem;
  color: var(--text-soft); font-size: 12.5px;
}
.hero-proof li::before {
  content: ""; position: absolute; left: 0; top: .58em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
a.hero-visual {
  display: none; position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--bg-alt); color: var(--text); box-shadow: var(--shadow);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.hero-visual:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.hero-visual img { display: block; width: 100%; aspect-ratio: 1.88 / 1; object-fit: cover; }
.hero-visual-label {
  position: absolute; top: .75rem; left: .75rem; z-index: 1;
  padding: .2rem .55rem; border-radius: 99px;
  background: rgba(255,255,255,.92); color: #1a5c38;
  font-size: 11px; font-weight: 700; box-shadow: 0 1px 5px rgba(16,24,32,.12);
}
.hero-visual-caption { display: flex; flex-direction: column; gap: .08rem; padding: .75rem .85rem .8rem; }
.hero-visual-caption strong { font-size: 13.5px; }
.hero-visual-caption small { color: var(--text-faint); font-size: 11.5px; }
.hero-note {
  margin: 1.25rem 0 0; padding: .7rem .85rem;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-soft); font-size: 13px;
}

.stat-grid {
  display: grid; gap: .6rem; margin: 1.25rem 0 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stat {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .6rem .7rem; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.stat-num { font-size: 1.2rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--text-faint); }

.hero-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong);
  font: inherit; font-size: 13px;
}
.btn:hover { background: var(--bg-sunken); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }

.route-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  margin-top: 1.55rem;
}
.route-head h2, .quick-start h2 { margin: 0; font-size: 1.1rem; line-height: 1.35; }
.route-head > a { display: inline-flex; align-items: center; min-height: 44px; flex: 0 0 auto; font-size: 12.5px; font-weight: 600; }
.section-kicker {
  margin: 0 0 .2rem; color: var(--accent); font-size: 11.5px;
  font-weight: 700; letter-spacing: .04em;
}

.route-grid {
  display: grid; gap: .6rem; margin-top: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 216px), 1fr));
}
.route {
  display: block; padding: .85rem .9rem; background: var(--bg-alt); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.route:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.route-tag { color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; }
.route h3 { margin: .18rem 0 .3rem; font-size: 14px; }
.route p { margin: 0 0 .55rem; min-height: 3.1em; font-size: 12.5px; color: var(--text-soft); line-height: 1.55; }
.route-link { font-size: 11.5px; color: var(--accent); font-weight: 700; }

.quick-start {
  display: grid; gap: 1rem; margin-top: 1.5rem; padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-alt) 72%);
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.quick-start-intro p:last-child { margin: .35rem 0 0; color: var(--text-soft); font-size: 12.5px; }
.quick-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.quick-list a {
  display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .65rem .7rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text);
}
.quick-list a:hover { border-color: var(--accent); text-decoration: none; }
.quick-num { flex: 0 0 auto; color: var(--accent); font-family: var(--mono); font-size: 11.5px; font-weight: 700; }
.quick-list a > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.quick-list strong { font-size: 12.5px; }
.quick-list small { color: var(--text-faint); font-size: 11.5px; }

/* ---------------- 文档正文 ---------------- */
.doc { max-width: 78ch; }
.part { padding-top: 1.5rem; }
.part-title {
  margin: 1.5rem 0 1rem; padding: .6rem 0 .6rem .85rem;
  border-left: 4px solid var(--accent);
  font-size: 1.4rem; font-weight: 700; line-height: 1.35;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.chapter { padding-top: .5rem; }
.chapter-title {
  display: flex; align-items: flex-start; gap: .6rem;
  margin: 1.75rem 0 .75rem; padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.14rem; font-weight: 700; line-height: 1.45;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.done-btn {
  flex: 0 0 auto; margin-left: auto;
  min-width: 44px; min-height: 44px;
  padding: .18rem .5rem; border-radius: 99px; cursor: pointer;
  background: var(--bg-alt); color: var(--text-faint);
  border: 1px solid var(--border); font: inherit; font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.done-btn:hover { border-color: var(--accent); color: var(--accent); }
.done-btn.is-done { background: var(--accent); border-color: var(--accent); color: #fff; }
.done-btn.is-done::before { content: "✓ "; }

.section-title {
  margin: 1.35rem 0 .5rem; font-size: 1rem; font-weight: 600; line-height: 1.5;
  color: var(--text);
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.section-title::before {
  content: ""; display: inline-block;
  width: 4px; height: 4px; margin: 0 .5rem .22rem 0;
  background: var(--accent); border-radius: 50%; vertical-align: middle;
}

/* 长公式与无空格英文串防溢出（代码块保留横向滚动，不参与换行） */
.doc p, .doc li, .doc td, .doc th, .doc figcaption,
.callout-body, .result-text, .result-crumb,
.hero-desc, .hero-note, .route p, .site-foot p,
.nav-chapters a, .toc a, .part-title, .chapter-title, .section-title {
  overflow-wrap: anywhere;
}

.doc p { margin: 0 0 .8rem; }
.doc ul, .doc ol { margin: 0 0 .9rem; padding-left: 1.35rem; }
.doc li { margin-bottom: .3rem; }
.doc li::marker { color: var(--accent); }
.caption { color: var(--text-faint); font-size: 12.5px; text-align: center; }

/* 提示框 */
.callout {
  display: flex; flex-direction: column; gap: .3rem;
  margin: 0 0 .9rem; padding: .7rem .85rem;
  border: 1px solid; border-left-width: 3px;
  border-radius: var(--radius); font-size: 14px; line-height: 1.7;
}
.callout-label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; }
.callout.warn  { background: var(--warn-bg);  border-color: var(--warn-bd);  color: var(--warn-tx); }
.callout.tip   { background: var(--tip-bg);   border-color: var(--tip-bd);   color: var(--tip-tx); }
.callout.check { background: var(--check-bg); border-color: var(--check-bd); color: var(--check-tx); }
.callout.exercise { background: var(--exer-bg); border-color: var(--exer-bd); color: var(--exer-tx); }
.callout.answer   { background: var(--ans-bg);  border-color: var(--ans-bd);  color: var(--ans-tx); }
.callout-body { color: inherit; }

/* 代码块 */
.code-block { position: relative; margin: 0 0 1rem; }
.code-block pre {
  margin: 0; padding: .8rem 1rem; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.code-block code {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  color: var(--code-text); white-space: pre;
}
.copy-btn {
  position: absolute; top: .4rem; right: .4rem; z-index: 2;
  min-width: 44px; min-height: 44px;
  padding: .18rem .5rem; border-radius: 6px; cursor: pointer;
  background: var(--bg); color: var(--text-soft);
  border: 1px solid var(--border); font: inherit; font-size: 11px;
  opacity: 0; transition: opacity .15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn.copied { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 表格 */
.table-wrapper {
  margin: 0 0 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.doc table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc thead th {
  position: sticky; top: 0;
  background: var(--accent); color: #fff;
  text-align: left; font-weight: 600; white-space: nowrap;
  padding: .5rem .65rem;
}
.doc tbody td {
  padding: .48rem .65rem; border-top: 1px solid var(--border);
  vertical-align: top; line-height: 1.6;
}
.doc tbody tr:nth-child(even) { background: var(--bg-alt); }

/* 插图 */
.figure { margin: 0 0 1.1rem; }
.figure img {
  display: block; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-alt);
}
.figure figcaption {
  margin-top: .4rem; color: var(--text-faint);
  font-size: 12.5px; text-align: center;
}

/* 搜索命中高亮 */
mark.hit { background: #ffe9a8; color: #6a4c00; padding: 0 1px; border-radius: 2px; }
.dark mark.hit { background: #6b5518; color: #ffe9a8; }
.flash { animation: flash 1.4s ease; }
@keyframes flash {
  0%, 100% { background: transparent; }
  18% { background: var(--accent-soft); }
}

/* 搜索结果面板 */
.search-panel { padding: 1.25rem 0 0; }
.search-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: .5rem; margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft);
}
.search-results { list-style: none; margin: 0; padding: 0; }
.search-results li { margin-bottom: .5rem; }
.search-results a {
  display: block; min-height: 44px; padding: .6rem .75rem;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
}
.search-results a:hover { border-color: var(--accent); text-decoration: none; }
.result-crumb { display: block; font-size: 11.5px; color: var(--accent); margin-bottom: .18rem; }
.result-text { display: block; font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.no-result { padding: 1rem; color: var(--text-faint); font-size: 13px; }
.search-section-label { padding: .65rem .2rem .25rem; color: var(--text-faint); font-size: 12px; font-weight: 650; letter-spacing: .03em; }

.course-pagination {
  display: grid; grid-template-columns: 1fr; gap: .65rem;
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.course-pagination a {
  min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .85rem; background: var(--bg-alt); color: var(--text); text-decoration: none;
}
.course-pagination a:hover { border-color: var(--accent); text-decoration: none; }
.course-page-link { display: flex; flex-direction: column; gap: .12rem; }
.course-page-link span { color: var(--text-faint); font-size: 11.5px; }
.course-page-link strong { font-size: 13px; line-height: 1.45; }
.course-page-link.next { text-align: right; }
.course-overview-link { display: flex; align-items: center; justify-content: center; color: var(--accent-strong) !important; font-weight: 650; }

/* 回到顶部 / 提示条 */
.to-top {
  position: fixed; right: .9rem; bottom: 1rem; z-index: 45;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 50%; cursor: pointer;
  background: var(--bg); color: var(--text-soft);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  z-index: 70; padding: .5rem .9rem; border-radius: 99px;
  background: var(--text); color: var(--bg);
  font-size: 12.5px; box-shadow: var(--shadow);
}

.site-foot {
  margin-top: 2.5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 12.5px;
}
.site-foot p { margin: 0 0 .3rem; }

/* ---------------- 响应式：≥720px ---------------- */
@media (min-width: 720px) {
  body { font-size: 15.5px; }
  .topbar { padding: 0 1.25rem; gap: .75rem; }
  .content { padding: 0 1.75rem 5rem; }
  .hero { padding: 2.75rem 0 1.75rem; }
  .hero h1 { font-size: 2.25rem; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick-start { grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr); align-items: start; }
  .part-title { font-size: 1.55rem; }
  .chapter-title { font-size: 1.24rem; }
  .course-pagination { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; }
}

@media (min-width: 900px) {
  .hero-lead { grid-template-columns: minmax(0, 1.12fr) minmax(320px, .88fr); gap: 2rem; }
  a.hero-visual { display: block; }
}

@media (max-width: 520px) {
  .topbar { gap: .35rem; padding-inline: .5rem; }
  .topbar .brand-text small { display: none; }
  .topbar .brand-text strong { font-size: 12px; }
  .search-wrap input { padding-left: .6rem; font-size: 12px; }
  .hero h1 { font-size: 1.85rem; }
  .route-head { align-items: flex-start; }
  .route-head > a { max-width: 7.5rem; text-align: right; line-height: 1.4; }
}

@media (hover: none) {
  .copy-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- 响应式：≥1060px（常驻侧栏） ---------------- */
@media (min-width: 1060px) {
  .menu-btn { display: none; }
  .sidebar { transform: none; }
  .scrim { display: none; }
  .content { margin-left: var(--sidebar-w); padding: 0 2.25rem 5rem; }
  .doc { max-width: 80ch; }
}

/* ---------------- 响应式：≥1400px（右侧小节目录） ---------------- */
@media (min-width: 1400px) {
  .content { margin-right: var(--toc-w); }
  .toc {
    display: block; position: fixed; right: 0; top: var(--topbar-h); bottom: 0;
    width: var(--toc-w); padding: 1rem .9rem 2rem;
    overflow-y: auto; border-left: 1px solid var(--border);
    background: var(--bg);
  }
  .toc-head {
    font-size: 11.5px; color: var(--text-faint);
    letter-spacing: .05em; margin-bottom: .5rem;
  }
  .toc ul { list-style: none; margin: 0; padding: 0; }
  .toc a {
    display: flex; align-items: center; min-height: 44px; padding: .25rem .4rem;
    border-left: 2px solid var(--border);
    color: var(--text-soft); font-size: 12px; line-height: 1.5;
  }
  .toc a:hover { color: var(--text); text-decoration: none; }
  .toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
}

/* ---------------- 打印 ---------------- */
@media print {
  .topbar, .sidebar, .toc, .scrim, .to-top, .reading-progress,
  .hero-actions, .search-panel, .done-btn, .copy-btn, .toast, .course-pagination, .breadcrumb { display: none !important; }
  body { font-size: 10.5pt; color: #000; background: #fff; }
  .content { margin: 0; padding: 0; }
  .doc { max-width: none; }
  .part { page-break-before: always; }
  .part-title, .chapter-title, .section-title { page-break-after: avoid; }
  .code-block, .table-wrapper, .figure, .callout { page-break-inside: avoid; }
  .doc thead th { background: #eee !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
}
