/* ============================================================
 * xlang website — style.css
 * Dark + Light theme, responsive, all features
 * ============================================================ */

/* ===== Dark theme (default) ===== */
:root {
  --bg: #0f0b1a;
  --bg-soft: #1a1528;
  --bg-card: #1a1528;
  --bg-code: #0a0714;
  --bg-input: #0f0b1a;
  --border: #2e2548;
  --text: #e2e8f0;
  --text-soft: #a0a0b8;
  --text-muted: #8d84a8;
  --brand: #c084fc;
  --brand-hover: #d8b4fe;
  --brand-dark: #9333ea;
  --on-brand: #1a0b2e;
  --brand-glow: rgba(192, 132, 252, 0.12);
  --accent: #f0abfc;
  --accent-glow: rgba(240, 171, 252, 0.10);
  --green: #4ade80;
  --green-glow: rgba(74, 222, 128, 0.10);
  --blue: #60a5fa;
  --blue-glow: rgba(96, 165, 250, 0.10);
  --orange: #fb923c;
  --orange-glow: rgba(251, 146, 60, 0.10);
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --nav-bg: rgba(15, 11, 26, 0.88);
  --code-kw: #c084fc;
  --code-fn: #67e8f9;
  --code-str: #86efac;
  --code-cm: #7d7294;
  --code-num: #fb923c;
  --code-type: #fbbf24;
  --code-time: #fbbf24;
  --font-sans: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  --max-w: 1120px;
  --nav-h: 64px;
}

/* ===== Light theme ===== */
[data-theme="light"] {
  --bg: #f8f9fc;
  --bg-soft: #eef0f6;
  --bg-card: #ffffff;
  --bg-code: #f4f4f9;
  --bg-input: #ffffff;
  --border: #dde0ea;
  --text: #1a1a2e;
  --text-soft: #555570;
  --text-muted: #6d6d85;
  --brand: #8b2dd6;
  --brand-hover: #7a1cc5;
  --brand-dark: #6b1bb0;
  --on-brand: #ffffff;
  --brand-glow: rgba(139, 45, 214, 0.08);
  --accent: #c026d3;
  --accent-glow: rgba(192, 38, 211, 0.06);
  --green: #16a34a;
  --green-glow: rgba(22, 163, 74, 0.08);
  --blue: #2563eb;
  --blue-glow: rgba(37, 99, 235, 0.08);
  --orange: #ea580c;
  --orange-glow: rgba(234, 88, 12, 0.08);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --nav-bg: rgba(248, 249, 252, 0.92);
  --code-kw: #8b2dd6;
  --code-fn: #0e7490;
  --code-str: #16a34a;
  --code-cm: #767089;
  --code-num: #ea580c;
  --code-type: #b8860b;
  --code-time: #b8860b;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--brand); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--brand-hover); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--font-mono); font-size: 0.9em; }

/* ===== Navigation ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--nav-bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); z-index: 100;
}
.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 24px; height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.nav-logo { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; white-space: nowrap; }
.nav-logo span { color: var(--brand); }
.nav-links { display: flex; gap: 24px; list-style: none; align-items: center; }
.nav-links a { color: var(--text-soft); font-size: 14px; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--brand); }

/* Nav action buttons */
.nav-toggle, .theme-toggle, .search-toggle {
  background: none; border: 1px solid var(--border); cursor: pointer;
  border-radius: var(--radius); width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  color: var(--text-soft); transition: all 0.2s; flex-shrink: 0;
}
.nav-toggle:hover, .theme-toggle:hover, .search-toggle:hover { border-color: var(--brand); color: var(--brand); }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
.nav-toggle { display: none; flex-direction: column; gap: 4px; }
.nav-toggle span { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; transition: all 0.2s; }
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ===== Hero ===== */
.hero {
  padding: calc(var(--nav-h) + 80px) 24px 80px; text-align: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, var(--brand-glow) 0%, transparent 100%),
    radial-gradient(ellipse 50% 40% at 80% 20%, var(--accent-glow) 0%, transparent 100%);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-soft);
  font-size: 13px; color: var(--text-soft); margin-bottom: 24px;
}
.hero-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.hero h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 800; line-height: 1.1; letter-spacing: -1.5px; margin-bottom: 20px; }
.hero h1 .gradient { background: linear-gradient(135deg, var(--brand), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-desc { max-width: 680px; margin: 0 auto 36px; font-size: 18px; color: var(--text-soft); line-height: 1.7; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.hero-pills { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 760px; margin: 0 auto 36px; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-soft); transition: all 0.2s;
}
.hero-pill:hover { border-color: var(--brand); color: var(--text); transform: translateY(-1px); }
.hero-pill .pill-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ===== Highlight cards ===== */
.hl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.hl-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; transition: all 0.25s; position: relative; overflow: hidden; }
.hl-card::before { content: ""; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--hl-color, var(--brand)); opacity: 0.7; }
.hl-card:hover { border-color: var(--hl-color, var(--brand)); transform: translateY(-2px); box-shadow: 0 4px 24px var(--hl-glow, var(--brand-glow)); }
.hl-icon { font-size: 20px; margin-bottom: 12px; line-height: 1; }
.hl-card h4 { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.hl-card p { font-size: 13px; color: var(--text-soft); line-height: 1.6; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; border-radius: 999px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); color: var(--on-brand); transform: translateY(-1px); box-shadow: 0 8px 24px var(--brand-glow); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

/* ===== Sections ===== */
.section { max-width: var(--max-w); margin: 0 auto; padding: 80px 24px; }
.section-title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 12px; }
.section-desc { color: var(--text-soft); font-size: 16px; max-width: 560px; margin-bottom: 48px; }

/* ===== Feature cards ===== */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: all 0.25s; }
.feature-card:hover { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); transform: translateY(-2px); }
.feature-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 16px; font-weight: 700; }
.feature-icon.purple { background: var(--brand-glow); color: var(--brand); }
.feature-icon.pink { background: var(--accent-glow); color: var(--accent); }
.feature-icon.green { background: var(--green-glow); color: var(--green); }
.feature-icon.blue { background: var(--blue-glow); color: var(--blue); }
.feature-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--text-soft); font-size: 14px; line-height: 1.7; }
.feature-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.feature-tag { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-family: var(--font-mono); background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== Code blocks ===== */
.code-block { background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-soft); gap: 12px; }
.code-header > span:first-child { font-size: 13px; color: var(--text-muted); font-family: var(--font-mono); }
.code-body { padding: 20px; overflow-x: auto; }
.code-body pre { margin: 0; font-family: var(--font-mono); font-size: 14px; line-height: 1.7; color: var(--text); }
.code-body .kw { color: var(--code-kw); }
.code-body .fn { color: var(--code-fn); }
.code-body .str { color: var(--code-str); }
.code-body .cm { color: var(--code-cm); }
.code-body .num { color: var(--code-num); }
.code-body .type { color: var(--code-type); }
.code-body .time { color: var(--code-time); }

.copy-btn {
  margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 12px; font-size: 12px; color: var(--text-muted); cursor: pointer;
  font-family: var(--font-sans); transition: all 0.15s; flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ===== Stdlib grid ===== */
.std-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.std-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: all 0.2s; }
.std-card:hover { border-color: var(--brand); }
.std-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--brand); font-family: var(--font-mono); }
.std-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ===== Stats ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.stat-card { text-align: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 16px; }
.stat-num { font-size: 36px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* ===== Footer ===== */
.footer { border-top: 1px solid var(--border); padding: 48px 24px 32px; }
.footer-inner { max-width: var(--max-w); margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.footer-brand h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.footer-brand h3 span { color: var(--brand); }
.footer-brand p { font-size: 13px; color: var(--text-muted); line-height: 1.6; max-width: 320px; }
.footer-col h4 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 6px; }
.footer-col a { font-size: 13px; color: var(--text-soft); }
.footer-col a:hover { color: var(--brand); }
.footer-bottom { max-width: var(--max-w); margin: 0 auto; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; color: var(--text-muted); font-size: 13px; }
.footer-bottom a { color: var(--text-soft); }

/* ===== Page header / content ===== */
.page-header { padding: calc(var(--nav-h) + 48px) 24px 48px; background: radial-gradient(ellipse 60% 40% at 50% 0%, var(--brand-glow) 0%, transparent 100%); text-align: center; }
.page-header h1 { font-size: 36px; font-weight: 700; margin-bottom: 12px; }
.page-header p { color: var(--text-soft); font-size: 16px; }
.page-content { max-width: 800px; margin: 0 auto; padding: 48px 24px 80px; }
.page-content h2 { font-size: 24px; font-weight: 600; margin: 48px 0 16px; padding-top: 24px; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--nav-h) + 16px); }
.page-content h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.page-content h3 { font-size: 18px; font-weight: 600; margin: 32px 0 12px; }
.page-content p { color: var(--text-soft); margin-bottom: 16px; }
.page-content ul, .page-content ol { color: var(--text-soft); padding-left: 24px; margin-bottom: 16px; }
.page-content li { margin-bottom: 6px; }
.page-content .code-block { margin: 20px 0; }
.breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--text-soft); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { color: var(--border); }
.api-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 24px 0; }
.api-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: all 0.2s; }
.api-card:hover { border-color: var(--brand); }
.api-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--brand); }
.api-card p { font-size: 13px; color: var(--text-soft); margin: 0; }

/* ===== Tour / 语法导览 ===== */
.tour-layout { max-width: var(--max-w); margin: 0 auto; display: grid; grid-template-columns: 190px 1fr; gap: 32px; padding: 32px 24px 80px; }
.tour-sidebar { position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto; }
.tour-sidebar::-webkit-scrollbar { width: 4px; }
.tour-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tour-sidebar h4 { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.8px; margin: 18px 0 6px; padding-left: 12px; font-weight: 700; }
.tour-sidebar h4:first-child { margin-top: 0; }
.tour-sidebar ul { list-style: none; }
.tour-sidebar li a { display: block; padding: 4px 12px; font-size: 13px; color: var(--text-soft); border-radius: 0 var(--radius) var(--radius) 0; border-left: 2px solid transparent; transition: all 0.15s; line-height: 1.5; }
.tour-sidebar li a:hover { color: var(--brand); background: var(--bg-soft); }
.tour-sidebar li a.active { color: var(--brand); border-left-color: var(--brand); }
.tour-content { min-width: 0; }
.tour-level-badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.tour-section { margin-bottom: 56px; scroll-margin-top: calc(var(--nav-h) + 16px); }
.tour-section h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.tour-section .lead { color: var(--text-soft); margin-bottom: 20px; font-size: 14px; }
.tour-section .code-block { margin: 16px 0; }
.tour-note { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; background: var(--brand-glow); border: 1px solid var(--border); color: var(--text-soft); margin: 16px 0; }
.tour-note code { color: var(--brand); }
.toc-mobile-btn { display: none; }

/* Tour prev/next */
.tour-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.tour-nav-link { flex: 1; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); transition: all 0.2s; }
.tour-nav-link:hover { border-color: var(--brand); transform: translateY(-1px); }
.tour-nav-link .nav-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.tour-nav-link .nav-title { font-size: 14px; font-weight: 600; color: var(--text); }
.tour-nav-link.next { text-align: right; }

/* ===== Back to top ===== */
.back-top { position: fixed; bottom: 32px; right: 32px; width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: var(--on-brand); border: none; font-size: 20px; cursor: pointer; opacity: 0; visibility: hidden; transition: all 0.3s; z-index: 90; box-shadow: var(--shadow); }
.back-top.visible { opacity: 1; visibility: visible; }
.back-top:hover { background: var(--brand-hover); transform: translateY(-2px); }

/* ===== Search overlay ===== */
.search-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 100px; opacity: 0; visibility: hidden; transition: all 0.2s; }
.search-overlay.active { opacity: 1; visibility: visible; }
.search-box { width: 90%; max-width: 560px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.search-input { width: 100%; padding: 16px 20px; border: none; background: transparent; color: var(--text); font-size: 16px; font-family: var(--font-sans); outline: none; border-bottom: 1px solid var(--border); }
.search-input::placeholder { color: var(--text-muted); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result { display: block; padding: 12px 20px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.search-result:hover { background: var(--bg-soft); }
.sr-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.sr-desc { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-empty { padding: 24px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
.search-hint { padding: 8px 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ===== Cross-platform section ===== */
.platform-section { max-width: var(--max-w); margin: 0 auto; padding: 80px 24px; }
.platform-matrix { display: flex; flex-direction: column; gap: 32px; margin-top: 40px; }
.platform-group h4 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.platform-badges { display: flex; flex-wrap: wrap; gap: 12px; }
.platform-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--text); transition: all 0.2s;
}
.platform-badge:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 4px 16px var(--brand-glow); }
.platform-badge .pf-icon { font-size: 18px; }
.platform-advantage { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 40px; }
.platform-advantage .hl-card { padding: 20px; }

/* ===== Stdlib browser page ===== */
.stdlib-layout { max-width: var(--max-w); margin: 0 auto; padding: 32px 24px 80px; }
.stdlib-search { margin-bottom: 24px; }
.stdlib-search input { width: 100%; padding: 12px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); color: var(--text); font-size: 15px; font-family: var(--font-sans); outline: none; }
.stdlib-search input:focus { border-color: var(--brand); }
.stdlib-ns { margin-bottom: 40px; }
.stdlib-ns h3 { font-size: 18px; font-weight: 700; color: var(--brand); font-family: var(--font-mono); margin-bottom: 12px; }
.stdlib-ns-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.stdlib-fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.stdlib-fn { padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); font-family: var(--font-mono); font-size: 13px; color: var(--text-soft); transition: all 0.15s; }
.stdlib-fn:hover { border-color: var(--brand); color: var(--brand); }

/* ===== Download page ===== */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 24px 0; }
.dl-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: all 0.2s; }
.dl-card:hover { border-color: var(--brand); }
.dl-card h4 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.dl-card .dl-size { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.dl-card .dl-desc { font-size: 14px; color: var(--text-soft); margin-bottom: 16px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .nav-links {
    display: none; position: fixed; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 16px 24px; gap: 0; z-index: 95;
  }
  .nav-links.nav-open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .nav-links li:last-child a { border-bottom: none; }
  .nav-toggle { display: flex; }
  .tour-layout { grid-template-columns: 1fr; }
  .tour-sidebar { display: none; position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0; max-height: none; background: var(--bg); z-index: 95; padding: 24px; overflow-y: auto; }
  .tour-sidebar.toc-mobile-open { display: block; }
  .toc-mobile-btn { display: block; padding: 8px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 24px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .hero h1 { font-size: 32px; }
  .hero-desc { font-size: 16px; }
  .feature-grid, .std-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 48px 20px; }
  .footer-inner { grid-template-columns: 1fr; }
  .tour-nav { flex-direction: column; }
}

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

/* ============================================================
 * Book channel — 教程封面页与章节页专用样式
 * （追加分区，不改动上方既有规则）
 * ============================================================ */

/* --- 封面页头部 --- */
.book-hero .book-kicker { font-size: 14px; font-weight: 700; letter-spacing: 0.2em; color: var(--brand); text-transform: uppercase; margin-bottom: 12px; }
.book-hero-meta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 24px; }
.book-pill { padding: 6px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-soft); font-size: 13px; font-weight: 600; }

/* --- 阅读路径 --- */
.book-path { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.book-path-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; }
.book-path-item p { font-size: 14px; color: var(--text-soft); margin: 0; }
.book-path-tag { display: inline-block; font-size: 13px; font-weight: 700; color: var(--brand); background: var(--brand-glow); border-radius: 999px; padding: 4px 12px; margin-bottom: 10px; }

/* --- 状态徽章 --- */
.badge { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge-done { color: var(--green); background: var(--green-glow); }
.badge-wip { color: var(--blue); background: var(--blue-glow); }
.badge-plan { color: var(--orange); background: var(--orange-glow); }
.book-legend { font-size: 14px; color: var(--text-muted); }

/* --- 目录卷卡片 --- */
.book-toc { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.book-vol { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 24px; transition: border-color 0.2s; }
.book-vol:hover { border-color: var(--brand); }
.book-vol-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.book-vol-head h3 { margin: 0; font-size: 18px; }
.book-vol-range { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.book-ch-list { list-style: none; margin: 0; padding: 0; }
.book-ch, .book-ch a { display: flex; align-items: center; gap: 12px; }
.book-ch { padding: 7px 8px; border-radius: var(--radius); font-size: 14px; color: var(--text-soft); }
.book-ch a { color: inherit; text-decoration: none; flex: 1; }
.book-ch.done:hover { background: var(--brand-glow); }
.book-ch.done a:hover .ch-title { color: var(--brand); }
.ch-no { flex: 0 0 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--text-muted); font-family: var(--font-mono); }
.book-ch.done .ch-no { color: var(--green); border-color: var(--green); }
.ch-title { flex: 1; }

/* --- 章节页 --- */
.ch-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ch-progress { font-size: 13px; font-weight: 700; color: var(--brand); background: var(--brand-glow); border-radius: 999px; padding: 4px 14px; }
.ch-vol { font-size: 13px; color: var(--text-muted); }

.book-note, .book-deep, .book-pit, .book-ex, .book-quiz { border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 18px 22px; margin: 20px 0; font-size: 14.5px; }
.book-note { background: var(--brand-glow); border-color: var(--brand-dark); }
.book-deep { background: var(--blue-glow); border-color: var(--blue); }
.book-pit  { background: var(--orange-glow); border-color: var(--orange); }
.book-ex, .book-quiz { background: var(--bg-card); }
.book-note .box-tag, .book-deep .box-tag, .book-pit .box-tag, .book-ex .box-tag, .book-quiz .box-tag { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; letter-spacing: 0.05em; }
.book-note .box-tag { color: var(--brand); }
.book-deep .box-tag { color: var(--blue); }
.book-pit .box-tag { color: var(--orange); }
.book-ex .box-tag, .book-quiz .box-tag { color: var(--green); }
.book-note p:last-child, .book-deep p:last-child, .book-pit p:last-child, .book-ex p:last-child, .book-quiz p:last-child { margin-bottom: 0; }
.book-pit ol, .book-ex ol, .book-quiz ol { margin: 8px 0 0; padding-left: 22px; }
.book-pit li, .book-ex li, .book-quiz li { margin-bottom: 12px; }
.book-pit li:last-child, .book-ex li:last-child, .book-quiz li:last-child { margin-bottom: 0; }
.pit-cause { color: var(--text-soft); }

/* --- 终端输出块 --- */
.term-block { background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; overflow-x: auto; white-space: pre; color: var(--text-soft); margin: 12px 0; }
.term-block .t-cmd { color: var(--text); font-weight: 700; }
.term-block .t-err { color: var(--orange); }
.term-block .t-ok { color: var(--green); }
.term-block .t-cm { color: var(--code-cm); }

/* --- 小结速查表 --- */
.book-summary-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.book-summary-table th, .book-summary-table td { border: 1px solid var(--border); padding: 9px 14px; text-align: left; vertical-align: top; }
.book-summary-table th { background: var(--bg-card); color: var(--brand); font-weight: 700; white-space: nowrap; }
.book-summary-table td { color: var(--text-soft); }
.book-summary-table code { font-size: 12.5px; }

/* --- 章节底部翻页 --- */
.ch-prevnext { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; }
.ch-prevnext a, .ch-prevnext span.ch-disabled { flex: 1; display: block; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card); padding: 16px 20px; text-decoration: none; color: var(--text); transition: border-color 0.2s; }
.ch-prevnext a:hover { border-color: var(--brand); }
.ch-prevnext .pn-dir { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ch-prevnext .pn-title { font-weight: 700; }
.ch-prevnext .next { text-align: right; }
.ch-prevnext span.ch-disabled { color: var(--text-muted); cursor: default; }

@media (max-width: 900px) {
  .book-path { grid-template-columns: 1fr; }
  .book-toc { grid-template-columns: 1fr; }
  .ch-prevnext { flex-direction: column; }
  .ch-prevnext .next { text-align: left; }
}


/* ---------- 友情链接 ---------- */
.friend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.friend-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg-card); text-decoration: none;
  transition: border-color .2s, transform .2s;
}
.friend-item:hover { border-color: var(--brand); transform: translateY(-2px); }
.friend-logo {
  flex: none; width: 132px; height: 44px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  background: #ffffff; border-radius: 9px; padding: 6px;
}
.friend-logo img { max-width: 100%; max-height: 100%; }
.friend-logo--dark { background: #181818; border: 1px solid var(--border); }
.friend-text { display: flex; flex-direction: column; min-width: 0; }
.friend-name { color: var(--text); font-size: 14px; font-weight: 600; }
.friend-desc { color: var(--text-muted); font-size: 12px; line-height: 1.55; }
@media (max-width: 900px) { .friend-grid { grid-template-columns: 1fr; } }
