/* ============================================================
   西安交大生存指南 · Design System
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", "WenQuanYi Micro Hei", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC",
    "Georgia", "Times New Roman", serif;
  --font-mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;

  --brand: #1b4d8f;
  --brand-600: #163f76;
  --brand-700: #0f2d52;
  --brand-100: #e6eefb;
  --accent: #c8102e;
  --gold: #c99700;

  --bg: #f7f8fb;
  --bg-elev: #ffffff;
  --bg-soft: #f0f3f9;
  --paper: #ffffff;
  --text: #111827;
  --text-1: #303a4a;
  --text-2: #5b6675;
  --text-3: #8a94a3;
  --border: #e4e8f0;
  --border-strong: #d3dae6;
  --shadow-sm: 0 1px 2px rgba(16, 32, 64, .05), 0 2px 6px rgba(16, 32, 64, .04);
  --shadow-md: 0 4px 14px rgba(16, 32, 64, .07), 0 14px 34px rgba(16, 32, 64, .06);
  --shadow-lg: 0 18px 50px rgba(16, 32, 64, .13);
  --ring: rgba(27, 77, 143, .35);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --maxw: 1280px;
  --header-h: 62px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
  --brand: #6fa8ff;
  --brand-600: #8dbaff;
  --brand-700: #b7d2ff;
  --brand-100: rgba(111, 168, 255, .14);
  --accent: #ff6b81;
  --gold: #e5b83c;

  --bg: #0d1117;
  --bg-elev: #151b24;
  --bg-soft: #1a212c;
  --paper: #131922;
  --text: #e8eef7;
  --text-1: #d3dbe6;
  --text-2: #9aa7b8;
  --text-3: #6f7d8f;
  --border: #232c39;
  --border-strong: #303b4b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, .55);
  --ring: rgba(111, 168, 255, .4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .25s var(--ease), color .25s var(--ease);
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, h5 { color: var(--text); line-height: 1.35; font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(27, 77, 143, .18); }
[data-theme="dark"] ::selection { background: rgba(111, 168, 255, .28); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Reading progress ---------- */
.reading-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 120;
  background: transparent; pointer-events: none;
}
.reading-progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  transition: width .12s linear;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--bg-elev); } }
.site-header.scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }
.header-inner {
  max-width: var(--maxw); margin: 0 auto; height: var(--header-h);
  padding: 0 22px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand-mark { display: flex; transition: transform .35s var(--ease); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; letter-spacing: .3px; }
.brand-text small { font-size: 10.5px; color: var(--text-3); letter-spacing: 1.1px; text-transform: uppercase; }

.site-nav { display: flex; gap: 4px; margin-left: 12px; }
.site-nav a {
  color: var(--text-2); font-size: 14px; padding: 7px 12px; border-radius: 999px;
  transition: color .18s, background-color .18s;
}
.site-nav a:hover { color: var(--brand); background: var(--brand-100); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; min-width: 36px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elev); color: var(--text-2);
  transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }
.search-trigger { padding-right: 10px; }
.kbd-hint { font-size: 12.5px; color: var(--text-3); }
.kbd-hint kbd {
  font-family: var(--font-mono); font-size: 10.5px; padding: 1px 5px; margin-left: 3px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-soft);
}
#theme-toggle .i-moon { display: none; }
[data-theme="dark"] #theme-toggle .i-sun { display: none; }
[data-theme="dark"] #theme-toggle .i-moon { display: block; }
.menu-btn { display: none; }

/* ---------- Mobile drawer ---------- */
.mobile-drawer[hidden] { display: none; }
.mobile-drawer { position: fixed; inset: 0; z-index: 140; background: rgba(9, 14, 22, .45); backdrop-filter: blur(2px); }
.mobile-drawer .drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(84vw, 330px);
  background: var(--bg-elev); border-left: 1px solid var(--border);
  padding: 18px 16px 40px; overflow-y: auto; animation: slideIn .28s var(--ease);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer-head strong { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; transition: all .2s var(--ease); white-space: nowrap;
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  color: #fff; box-shadow: 0 6px 18px rgba(27, 77, 143, .28);
}
[data-theme="dark"] .btn.primary { color: #07101d; box-shadow: 0 6px 18px rgba(111, 168, 255, .22); }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(27, 77, 143, .34); }
.btn.ghost { background: var(--bg-elev); color: var(--text-1); border-color: var(--border-strong); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-2px); }
.btn.ghost.light { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .38); }
.btn.ghost.light:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 84px 22px 72px; text-align: center; }
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px;
  background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none;
}
.hero-bg { position: absolute; inset: 0; pointer-events: none; }
.hero-bg .orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: float 18s ease-in-out infinite; }
.orb-1 { width: 460px; height: 460px; background: radial-gradient(circle, #6ea8ff, transparent 70%); top: -160px; left: -80px; }
.orb-2 { width: 400px; height: 400px; background: radial-gradient(circle, #ffd479, transparent 70%); top: -80px; right: -60px; animation-delay: -6s; }
.orb-3 { width: 420px; height: 420px; background: radial-gradient(circle, #ffb3bf, transparent 72%); bottom: -320px; left: 42%; opacity: .22; animation-delay: -11s; }
[data-theme="dark"] .hero-bg .orb { opacity: .22; }
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(24px, 26px, 0) scale(1.08); }
}
.grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 70% 62% at 50% 32%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 70% 62% at 50% 32%, #000 30%, transparent 78%);
  opacity: .55;
}
.hero-inner { position: relative; max-width: 900px; margin: 0 auto; }
.hero-badge {
  display: inline-block; padding: 6px 15px; border-radius: 999px; font-size: 13px;
  color: var(--brand); background: var(--brand-100); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-serif); font-size: clamp(38px, 7.2vw, 68px); line-height: 1.18;
  margin: 0 0 20px; letter-spacing: 2px; font-weight: 800;
}
.hero-title .grad {
  background: linear-gradient(120deg, var(--brand) 10%, #3f7fd6 45%, var(--gold) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: clamp(15px, 1.9vw, 17.5px); color: var(--text-2); margin: 0 auto 32px; max-width: 740px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 46px; }
.hero-stats {
  list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding: 0; margin: 0 auto; max-width: 660px;
}
.hero-stats li {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 16px 8px; border-radius: var(--radius);
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 75%, transparent);
  border: 1px solid var(--border); backdrop-filter: blur(6px);
}
.hero-stats strong { font-size: 24px; color: var(--text); font-family: var(--font-serif); letter-spacing: .5px; }
.hero-stats span { font-size: 12.5px; color: var(--text-3); }

/* ---------- Sections ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: 56px 22px 10px; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 26px; flex-wrap: wrap;
}
.section-head.sub { margin-top: 54px; }
.section-kicker {
  font-size: 12px; letter-spacing: 2.4px; text-transform: uppercase;
  color: var(--gold); margin: 0 0 6px; font-weight: 700;
}
.section-head h2 { font-family: var(--font-serif); font-size: clamp(24px, 3.4vw, 32px); margin: 0 0 8px; letter-spacing: 1px; }
.section-desc { color: var(--text-2); margin: 0; font-size: 14.8px; max-width: 620px; }
.filter-box {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev);
  color: var(--text-3); min-width: 240px; transition: border-color .2s, box-shadow .2s;
}
.filter-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.filter-box input { border: 0; background: transparent; outline: 0; color: var(--text); width: 100%; font-size: 14px; }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 18px; }
.card {
  position: relative; display: flex; flex-direction: column;
  padding: 24px 22px 18px; border-radius: var(--radius-lg);
  background: var(--bg-elev); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand) 32%, var(--border)); }
.card:hover::before { transform: scaleX(1); }
.card-index {
  position: absolute; right: 16px; top: 12px; font-family: var(--font-serif);
  font-size: 42px; font-weight: 700; color: var(--text); opacity: .06; letter-spacing: -1px;
}
.card-icon { font-size: 26px; line-height: 1; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 18.5px; letter-spacing: .4px; }
.card p { margin: 0 0 14px; color: var(--text-2); font-size: 14.2px; line-height: 1.7; flex: 1; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.card-tags span {
  font-size: 11.5px; color: var(--text-2); padding: 2.5px 9px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 12.8px; color: var(--text-3);
}
.card-go { color: var(--brand); font-weight: 600; transition: transform .2s var(--ease); }
.card:hover .card-go { transform: translateX(4px); }
.empty-tip { text-align: center; color: var(--text-3); padding: 30px 0; }

/* ---------- Resource cards ---------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.res-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 20px;
  border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border);
  transition: all .25s var(--ease);
}
.res-card:hover { border-color: var(--brand); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.res-icon {
  width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 20px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--border);
}
.res-card h3 { margin: 2px 0 5px; font-size: 16px; }
.res-card h3 .ext { color: var(--text-3); font-size: 12px; }
.res-card p { margin: 0; font-size: 13.6px; color: var(--text-2); }

/* ---------- CTA ---------- */
.cta-band { max-width: var(--maxw); margin: 70px auto 0; padding: 0 22px; }
.cta-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 26px; flex-wrap: wrap;
  padding: 40px 42px; border-radius: 26px; color: #fff;
  background: linear-gradient(120deg, var(--brand-700), #1d5aa8 55%, #2f7fbf);
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.cta-inner::after {
  content: ""; position: absolute; width: 320px; height: 320px; right: -70px; top: -140px;
  background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 65%); border-radius: 50%;
}
.cta-inner h2 { color: #fff; font-family: var(--font-serif); margin: 0 0 10px; font-size: 26px; letter-spacing: 1px; }
.cta-inner p { margin: 0; max-width: 620px; color: rgba(255, 255, 255, .86); font-size: 14.8px; }
.cta-actions { display: flex; gap: 12px; flex-wrap: wrap; position: relative; }
.cta-actions .btn.primary { background: #fff; color: var(--brand-700); box-shadow: none; }
.cta-actions .btn.primary:hover { background: #f2f6ff; }

/* ---------- Doc shell (article page) ---------- */
.doc-shell {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 22px 40px;
  display: grid; grid-template-columns: 244px minmax(0, 1fr) 232px; gap: 34px; align-items: stretch;
}
.doc-shell.no-toc { grid-template-columns: 244px minmax(0, 1fr); }
.doc-shell.no-toc .doc-toc { display: none; }
.doc-shell.no-toc .doc-main { max-width: 860px; }
.sidebar-sticky, .toc-sticky {
  position: sticky; top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 44px); overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-sticky::-webkit-scrollbar, .toc-sticky::-webkit-scrollbar, .search-results::-webkit-scrollbar { width: 6px; }
.sidebar-sticky::-webkit-scrollbar-thumb, .toc-sticky::-webkit-scrollbar-thumb, .search-results::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sidebar-kicker {
  font-size: 11.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 12px; padding-left: 10px; font-weight: 700;
}

/* nav list */
.doc-nav-group { margin-bottom: 20px; }
.doc-nav-title {
  font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 0 6px; padding-left: 10px;
}
.doc-nav ul { list-style: none; margin: 0; padding: 0; }
.doc-nav li { margin: 1px 0; }
.doc-nav a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 9px; font-size: 14px; color: var(--text-2);
  border-left: 2px solid transparent; transition: all .16s var(--ease);
}
.doc-nav a:hover { background: var(--bg-soft); color: var(--text); }
.doc-nav a.active {
  background: var(--brand-100); color: var(--brand); font-weight: 600;
  border-left-color: var(--brand);
}
.dn-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.dn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dn-ext { margin-left: auto; color: var(--text-3); font-size: 11px; }

/* article main */
.doc-main { min-width: 0; }
.breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-3); margin-bottom: 18px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .current { color: var(--text-1); }

.doc-header { padding-bottom: 22px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.chip {
  display: inline-block; font-size: 12.5px; padding: 4px 12px; border-radius: 999px;
  background: var(--brand-100); color: var(--brand); margin-bottom: 14px; font-weight: 600;
}
.doc-header h1 {
  font-family: var(--font-serif); font-size: clamp(28px, 4.6vw, 40px);
  margin: 0 0 12px; letter-spacing: 1.5px; line-height: 1.3;
}
.doc-summary { color: var(--text-2); font-size: 15.5px; margin: 0 0 16px; max-width: 62ch; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--text-3); }
.doc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.doc-progress-text { margin-left: auto; }

/* inline toc (mobile) */
.toc-inline {
  display: none;
  margin: 20px 0 4px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); padding: 14px 16px;
}
.toc-inline-title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--text-1); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 4px; }
.toc-inline-title::-webkit-details-marker { display: none; }
.toc-inline-title::after { content: "展开"; margin-left: auto; font-size: 12px; font-weight: 400; color: var(--brand); }
.toc-inline[open] .toc-inline-title { margin-bottom: 8px; }
.toc-inline[open] .toc-inline-title::after { content: "收起"; }
.toc-count { color: var(--text-3); font-weight: 400; }
.toc-inline a { display: block; padding: 5px 0; font-size: 14px; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.toc-inline a:last-child { border-bottom: 0; }
.toc-inline a.lv3 { padding-left: 14px; font-size: 13.4px; }
.toc-inline a.lv4 { padding-left: 28px; font-size: 13px; }

/* ---------- Prose ---------- */
.prose {
  font-size: 16.6px; line-height: 2.0; color: var(--text-1);
  padding: 22px 0 10px; max-width: 78ch; letter-spacing: .2px;
  word-wrap: break-word; overflow-wrap: break-word;
}
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-serif); letter-spacing: .8px; scroll-margin-top: calc(var(--header-h) + 22px);
  position: relative;
}
.prose h1 { font-size: 30px; margin: 2.2em 0 .8em; }
.prose h2 {
  font-size: 25px; margin: 2em 0 .8em; padding-bottom: .32em;
  border-bottom: 1px solid var(--border);
}
.prose h3 {
  font-size: 20.5px; margin: 1.9em 0 .7em; padding-left: 14px;
}
.prose h3::before {
  content: ""; position: absolute; left: 0; top: .28em; bottom: .28em; width: 4px;
  border-radius: 3px; background: linear-gradient(180deg, var(--brand), var(--gold));
}
.prose h4 { font-size: 17.6px; margin: 1.6em 0 .6em; color: var(--text-1); }
.prose h1:first-child, .prose h2:first-child, .prose h3:first-child { margin-top: .2em; }
.prose .anchor {
  position: absolute; left: -22px; width: 22px; text-align: center; color: var(--text-3);
  opacity: 0; font-weight: 400; transition: opacity .18s; text-decoration: none;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 1; }
.prose p { margin: 0 0 1.15em; }
.prose a {
  color: var(--brand); text-decoration: none;
  background-image: linear-gradient(var(--brand), var(--brand));
  background-size: 100% 1px; background-repeat: no-repeat; background-position: 0 100%;
  padding-bottom: 1px; transition: background-size .2s var(--ease), color .2s;
  word-break: break-word;
}
.prose a:hover { color: var(--brand-600); background-size: 100% 2px; }
.prose strong { color: var(--text); font-weight: 700; }
.prose em { color: var(--text); font-style: normal; background: transparent; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--gold) 38%, transparent) 0); padding: 0 2px; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin: .45em 0; }
.prose ul > li::marker { color: var(--brand); }
.prose ol > li::marker { color: var(--brand); font-weight: 600; }
.prose hr { border: 0; height: 1px; background: var(--border); margin: 2.4em 0; }
.prose blockquote {
  margin: 1.5em 0; padding: 14px 20px; border-left: 4px solid var(--brand);
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  font-family: var(--font-mono); font-size: .88em; padding: .15em .42em;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; color: var(--accent);
}
.prose pre {
  margin: 1.5em 0; padding: 16px 18px; overflow-x: auto; border-radius: var(--radius);
  background: #0f172a; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.prose pre code { background: transparent; border: 0; padding: 0; color: #e2e8f0; font-size: 13.6px; line-height: 1.7; }
.prose table {
  width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: 14.8px;
  display: block; overflow-x: auto; white-space: nowrap;
}
.prose th, .prose td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; }
.prose th { background: var(--bg-soft); color: var(--text); font-weight: 700; }
.prose tr:nth-child(even) td { background: var(--bg-soft); background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.prose img { border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 1.2em 0; }

/* doc actions & pager */
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 34px 0 26px; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13.6px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text-2); transition: all .2s var(--ease);
}
.ghost-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.pager-item {
  display: flex; flex-direction: column; gap: 5px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev);
  transition: all .22s var(--ease); min-height: 74px;
}
a.pager-item:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pager-item.placeholder { border: 1px dashed var(--border); background: transparent; }
.pager-label { font-size: 12px; color: var(--text-3); }
.pager-title { font-size: 15px; font-weight: 600; color: var(--text); }
.pager-item.next { text-align: right; }

/* TOC right rail */
.doc-toc { min-width: 0; }
.toc-title { font-size: 11.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-3); margin: 0 0 12px; font-weight: 700; }
.toc { border-left: 1px solid var(--border); }
.toc a {
  display: block; padding: 6px 12px; font-size: 13.2px; color: var(--text-2);
  border-left: 2px solid transparent; margin-left: -1px; line-height: 1.5;
  transition: all .16s var(--ease); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc a:hover { color: var(--brand); background: var(--bg-soft); }
.toc a.lv3 { padding-left: 22px; font-size: 12.8px; }
.toc a.lv4 { padding-left: 32px; font-size: 12.4px; color: var(--text-3); }
.toc a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; background: var(--brand-100); }
.toc-empty { font-size: 13px; color: var(--text-3); padding-left: 12px; }

/* ---------- Search modal ---------- */
.search-modal { position: fixed; inset: 0; z-index: 200; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 18px 24px; }
.search-modal[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 26, .5); backdrop-filter: blur(3px); }
.search-panel {
  position: relative; width: min(680px, 100%); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: popIn .22s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.search-box { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.esc-btn { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--text-3); }
.search-results { overflow-y: auto; padding: 8px; }
.search-hint, .search-empty { color: var(--text-3); font-size: 14px; padding: 22px 14px; text-align: center; margin: 0; }
.sr-item { display: block; padding: 12px 14px; border-radius: 10px; transition: background-color .16s; }
.sr-item:hover, .sr-item.sel { background: var(--bg-soft); }
.sr-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sr-title { font-size: 15px; font-weight: 600; color: var(--text); }
.sr-cat { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--brand-100); color: var(--brand); }
.sr-snippet { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-snippet mark, .sr-title mark { background: color-mix(in srgb, var(--gold) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; right: 22px; bottom: 26px; z-index: 90;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-elev); color: var(--text-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: all .25s var(--ease);
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { color: var(--brand); border-color: var(--brand); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 80px; border-top: 1px solid var(--border); background: var(--bg-elev); }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 44px 22px 30px;
  display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap;
}
.footer-brand strong { display: block; font-family: var(--font-serif); font-size: 18px; color: var(--text); margin-bottom: 10px; letter-spacing: 1px; }
.footer-brand p { color: var(--text-3); font-size: 13.6px; max-width: 460px; margin: 0; line-height: 1.9; }
.footer-links { display: flex; gap: 56px; }
.fl-title { font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 10px; }
.footer-links a { display: block; font-size: 13.5px; color: var(--text-2); padding: 4px 0; }
.footer-links a:hover { color: var(--brand); }
.footer-bottom {
  max-width: var(--maxw); margin: 0 auto; padding: 16px 22px 26px;
  border-top: 1px solid var(--border); display: flex; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3);
}

/* ---------- 404 ---------- */
.nf-wrap { max-width: 640px; margin: 0 auto; padding: 90px 22px 60px; text-align: center; }
.nf-code { font-family: var(--font-serif); font-size: 96px; font-weight: 800; margin: 0; background: linear-gradient(120deg, var(--brand), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .doc-shell { grid-template-columns: 224px minmax(0, 1fr); }
  .doc-toc { display: none; }
  .toc-inline.ready { display: block; }
}
@media (max-width: 900px) {
  .site-nav, .kbd-hint { display: none; }
  .menu-btn { display: inline-flex; }
  .doc-shell { grid-template-columns: minmax(0, 1fr); padding-top: 18px; }
  .doc-sidebar { display: none; }
  .hero { padding: 56px 20px 48px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .cta-inner { padding: 30px 24px; }
  .pager { grid-template-columns: 1fr; }
  .pager-item.placeholder { display: none; }
  .footer-links { gap: 34px; }
  .prose { font-size: 16.2px; line-height: 1.92; }
}
@media (max-width: 560px) {
  .header-inner { padding: 0 14px; gap: 8px; }
  .brand-text small { display: none; }
  .section { padding: 40px 16px 6px; }
  .doc-shell { padding-left: 16px; padding-right: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .filter-box { width: 100%; }
  .doc-progress-text { display: none; }
  .search-modal { padding-top: 6vh; }
}

@media print {
  .site-header, .site-footer, .doc-sidebar, .doc-toc, .to-top, .pager, .doc-actions, .reading-progress, .toc-inline, .breadcrumb { display: none !important; }
  .doc-shell { display: block; }
  .prose { max-width: none; font-size: 12pt; }
}

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