/* ============================================================
   馒头的知识库 · 静态站点样式
   A clean, modern, responsive documentation theme.
   ============================================================ */

:root {
  --brand: #2f6bff;
  --brand-2: #7b5cff;
  --brand-soft: #eef3ff;
  --bg: #ffffff;
  --bg-subtle: #f7f8fb;
  --text: #1a1d24;
  --text-soft: #545a67;
  --text-muted: #8a90a0;
  --border: #e8eaf0;
  --border-strong: #d8dbe5;
  --code-bg: #f5f6fa;
  --shadow-sm: 0 1px 2px rgba(20, 25, 40, .06), 0 1px 3px rgba(20, 25, 40, .04);
  --shadow-md: 0 6px 20px rgba(20, 25, 40, .08);
  --shadow-lg: 0 18px 48px rgba(20, 25, 40, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 268px;
  --header-h: 60px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6f96ff;
    --brand-2: #a08bff;
    --brand-soft: #1a2338;
    --bg: #0f1218;
    --bg-subtle: #151a23;
    --text: #e9ecf3;
    --text-soft: #a8b0c0;
    --text-muted: #737b8c;
    --border: #242b37;
    --border-strong: #313a49;
    --code-bg: #171d27;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}
.topbar .brand:hover { text-decoration: none; }
.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow-sm);
  flex: none;
}
.topbar .spacer { flex: 1; }
.topbar .tag {
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
}
.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 9px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

/* ---------- Home hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 74px 24px 60px;
  text-align: center;
  background:
    radial-gradient(1100px 420px at 50% -140px, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.2;
  letter-spacing: -.5px;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  margin: 0 auto;
  max-width: 620px;
  color: var(--text-soft);
  font-size: 17px;
}
.hero .meta {
  margin-top: 22px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.pill {
  font-size: 13px;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
}

/* ---------- Document grid ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 46px 0 20px;
}
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.section-head .count { font-size: 13.5px; color: var(--text-muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  padding-bottom: 70px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  color: inherit;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  text-decoration: none;
}
.card .icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.card h3 { margin: 0; font-size: 17px; }
.card p { margin: 0; font-size: 14px; color: var(--text-soft); }
.card .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.card .tags span {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

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

.sidebar {
  position: sticky;
  top: var(--header-h);
  width: var(--sidebar-w);
  flex: none;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 26px 18px 60px 24px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.sidebar .sb-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px 8px;
}
.sidebar nav a {
  display: block;
  padding: 7px 12px;
  margin: 2px 0;
  border-radius: 8px;
  font-size: 14.2px;
  color: var(--text-soft);
  border-left: 2px solid transparent;
}
.sidebar nav a:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.sidebar nav a.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidebar nav a.sub { padding-left: 22px; font-size: 13.4px; }
.sidebar hr { border: 0; border-top: 1px solid var(--border); margin: 18px 8px; }

.doc { flex: 1; min-width: 0; }
.doc-inner { max-width: 820px; margin: 0 auto; padding: 40px 40px 100px; }

.breadcrumb { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }

.doc h1.title {
  font-size: clamp(27px, 4vw, 36px);
  line-height: 1.25;
  letter-spacing: -.5px;
  margin: 0 0 16px;
}
.doc .lead { font-size: 17.5px; color: var(--text-soft); margin: 0 0 34px; }

.doc h2 {
  font-size: 23px;
  margin: 46px 0 14px;
  padding-top: 8px;
  letter-spacing: -.3px;
  scroll-margin-top: 80px;
}
.doc h2 .h2-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  vertical-align: 2px;
}
.doc h3 { font-size: 17.5px; margin: 28px 0 10px; color: var(--text); }
.doc p { margin: 0 0 16px; color: var(--text); }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 24px; color: var(--text); }
.doc li { margin: 6px 0; }

.doc code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}
.doc pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: 13.5px; }

.callout {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 0 0 20px;
  color: var(--text-soft);
  font-size: 14.5px;
}
.callout strong { color: var(--text); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc thead th {
  background: var(--bg-subtle);
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.doc tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tbody tr:hover { background: var(--bg-subtle); }
/* 首列（名称列）不换行，避免被其他内容多的列挤压 */
.doc tbody td:first-child { white-space: nowrap; }
.kbd-syntax { font-family: var(--mono); font-size: .86em; color: var(--brand); }

/* 窄屏：保持表格形态，按列数给足宽度并横向滚动，避免列被挤压 */
.table-hint {
  display: none;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 2px 8px;
}
.table-hint.show { display: block; }

@media (max-width: 760px) {
  .doc .table-wrap table { font-size: 13.5px; }
  .doc thead th, .doc tbody td { padding: 10px 13px; }
  .doc .table-wrap table[data-cols="4"] { min-width: 780px; }
  .doc .table-wrap table[data-cols="5"] { min-width: 880px; }
  .doc .table-wrap table[data-cols="6"] { min-width: 1020px; }
}

/* ---------- Steps ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 20px; }
.steps li {
  position: relative;
  padding: 4px 0 20px 52px;
  border-left: 2px solid var(--border);
  margin-left: 15px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.steps li strong { display: block; margin-bottom: 2px; }

/* ---------- Figures / screenshots ---------- */
figure.fig { margin: 0 0 22px; }
figure.fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--bg-subtle);
}
figure.fig figcaption {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}
figure.fig.cover { margin: 0 0 34px; }
figure.fig.cover img { border: 0; box-shadow: none; border-radius: 10px; }

/* 电脑端 + 移动端 并排 */
.shot-pair {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: center;
  margin: 0 0 22px;
}
.shot-pair figure { margin: 0; }
.shot-pair.two-narrow {
  grid-template-columns: 1fr 1fr;
  align-items: start;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
.steps li .shot-pair { margin: 12px 0 4px; }
.steps li figure.fig { margin: 12px 0 4px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 34px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}
.site-footer a { color: var(--text-soft); }

/* ---------- Prev / Next ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 54px; }
.pager a {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.pager a:hover { border-color: var(--brand); text-decoration: none; }
.pager .dir { font-size: 12.5px; color: var(--text-muted); display: block; }
.pager .next { text-align: right; }

/* ---------- 404 ---------- */
.center-page {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}
.center-page .code { font-size: 76px; font-weight: 800; line-height: 1;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 22px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.btn:hover { text-decoration: none; opacity: .93; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; place-items: center; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    z-index: 40;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop {
    position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(10, 14, 22, .42);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  .doc-inner { padding: 28px 20px 80px; }
  .topbar .tag { display: none; }
}

@media (max-width: 640px) {
  .shot-pair, .shot-pair.two-narrow { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
