:root {
  --bg: #0a0a0b;
  --bg-soft: #0e0e10;
  --panel: #151517;
  --panel-2: #1b1b1f;
  --line: #2a2a2f;
  --text: #f5f5f5;
  --body: #c9c9cf;
  --muted: #9a9aa1;
  --accent: #e5484d;
  --accent-strong: #ff4d52;
  --accent-dark: #b91c1c;
  --radius: 12px;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
::selection { background: var(--accent); color: #fff; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Microsoft YaHei", "Noto Sans", sans-serif;
  line-height: 1.75;
  font-size: 16px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800; font-size: 17px; color: var(--text); text-decoration: none;
  white-space: nowrap; letter-spacing: 0.2px;
}
.brand .logo { color: var(--accent-strong); margin-right: 6px; }
.brand em { font-style: normal; color: var(--muted); }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 14px; border-radius: 8px; font-size: 15px;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: #fff; background: var(--accent); font-weight: 600; }

.lang-switch {
  margin-left: auto; font-size: 13px; white-space: nowrap; color: var(--muted);
  display: flex; align-items: center; gap: 2px;
}
.lang-switch a { color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.lang-switch a:hover { color: var(--text); background: var(--panel-2); }
.lang-switch a.cur-lang { color: var(--accent-strong); font-weight: 700; }
.lang-sep { color: #3f3f46; }

/* ---------- 搜索 ---------- */
.search { position: relative; width: min(280px, 30vw); }
.search input {
  width: 100%; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.18); }
.search input::placeholder { color: #6b6b72; }
.search-results {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(430px, 90vw); max-height: 65vh; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); padding: 6px;
}
.search-results .sr-item { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.search-results .sr-item:hover { background: var(--panel); }
.search-results .sr-head { color: var(--accent-strong); font-size: 12.5px; margin: 8px 12px 2px; text-transform: uppercase; letter-spacing: 1px; }
.search-results .sr-snippet { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results .sr-empty { padding: 14px; color: var(--muted); font-size: 14px; text-align: center; }
.search-results mark { background: rgba(229, 72, 77, 0.35); color: #fff; border-radius: 3px; padding: 0 2px; }

/* ---------- 布局 ---------- */
.layout { display: flex; gap: 0; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.content { flex: 1; min-width: 0; padding: 40px 0 80px; max-width: 860px; margin: 0 auto; }
.content.has-toc { margin: 0; }
.toc {
  width: 250px; flex-shrink: 0; position: sticky; top: 76px; align-self: flex-start;
  max-height: calc(100vh - 100px); overflow: auto; padding: 26px 20px 40px 0; font-size: 13.5px;
}
.toc-title { color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-size: 11.5px; margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; color: var(--muted); text-decoration: none; padding: 4px 12px; border-left: 2px solid transparent; margin-left: -1.5px; line-height: 1.45; }
.toc li.lv3 a { padding-left: 26px; font-size: 12.8px; }
.toc li a:hover, .toc li a.cur { color: var(--accent-strong); border-left-color: var(--accent); }

/* ---------- 正文排版 ---------- */
.content h1 {
  font-size: 30px; line-height: 1.35; margin: 10px 0 8px; letter-spacing: 0.2px; color: #fff;
}
.content h1 + blockquote { margin-top: 22px; }
.content h2 {
  font-size: 22.5px; margin: 46px 0 14px; padding-top: 14px; border-top: 1px solid var(--line); color: #fff;
}
.content h2:first-of-type { border-top: none; padding-top: 0; }
.content h3 { font-size: 18.5px; margin: 32px 0 10px; color: #ededf0; }
.content h4 { font-size: 16px; margin: 24px 0 8px; }
.content p { margin: 12px 0; color: var(--body); }
.content strong { color: #fff; }
.content a { color: var(--accent-strong); text-decoration: none; border-bottom: 1px dashed rgba(229, 72, 77, 0.45); }
.content a:hover { color: #ff7478; border-bottom-style: solid; }
.content ul, .content ol { padding-left: 24px; color: var(--body); }
.content li { margin: 6px 0; }
.content li::marker { color: var(--accent); }
.content hr { border: none; border-top: 1px solid var(--line); margin: 36px 0; }

blockquote {
  margin: 18px 0; padding: 12px 18px; border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(229, 72, 77, 0.09), rgba(229, 72, 77, 0.02));
  border-radius: 0 var(--radius) var(--radius) 0; color: #cfcfd6;
}
blockquote p { margin: 4px 0; color: inherit; }

code {
  font-family: var(--mono); font-size: 0.88em; background: var(--panel); color: #ff8589;
  padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line);
}
pre { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; overflow: auto; }
pre code { background: none; border: none; padding: 0; color: #d8d8de; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14.2px; min-width: 560px; }
thead th {
  background: var(--panel-2); color: #fff; text-align: left; font-weight: 600;
  padding: 10px 14px; border-bottom: 2px solid var(--accent-dark); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid rgba(42, 42, 47, 0.6); vertical-align: top; color: var(--body); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(229, 72, 77, 0.055); }

/* ---------- 首页 hero 区 ---------- */
.content > h1:first-child {
  font-size: 34px; padding: 34px 0 6px;
  background: linear-gradient(90deg, #ffffff 30%, var(--accent-strong));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line); padding: 26px 24px 34px; text-align: center;
  color: var(--muted); font-size: 13.5px;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent-strong); }
.foot-nav { margin-top: 8px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1020px) {
  .lang-switch { margin-left: auto; }
  .search { margin-left: 0; }
}
@media (max-width: 960px) {
  .layout { flex-direction: column; padding: 0 16px; }
  .toc { display: none; }
  .content { max-width: 100%; padding: 24px 0 60px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search { order: 4; width: 100%; margin-left: 0; }
  .nav { margin-left: 0; }
  .lang-switch { margin-left: auto; }
  .content h1:first-child { font-size: 27px; padding-top: 14px; }
}
