:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e4e7ec;
  --line-strong: #d3d8df;
  --text: #1c2129;
  --text-dim: #5b6470;
  --text-faint: #8a93a3;
  --accent: #14968f;
  --accent-deep: #0f7f79;
  --accent-2: #0e7490;
  --accent-soft: rgba(20, 150, 143, 0.1);
  --accent-2-soft: rgba(14, 116, 144, 0.08);
  --code-bg: #f4f6f8;
  --code-line: #e2e6ea;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", "Noto Sans SC", monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-h: 60px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
code, pre { font-family: var(--mono); }

::selection { background: rgba(20, 150, 143, 0.2); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.16); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.28); }

/* 顶部导航 */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; }

.brand-text { font-family: var(--mono); font-weight: 600; font-size: 17px; }
.brand-text small {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.24em;
  margin-top: 1px;
}

.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--text-dim);
  transition: color 0.25s, background 0.25s;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.is-current { color: var(--accent); background: var(--accent-soft); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-link {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.icon-link:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.icon-link svg { width: 19px; height: 19px; }

/* 布局 */
.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 20px) 24px 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 220px;
  gap: 28px;
  align-items: start;
}

/* 左侧教程目录 */
.sidebar-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; padding-bottom: 20px; }

.sidebar-title {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--text-faint);
  margin-bottom: 12px;
  padding: 0 12px;
}

.nav-group { margin-bottom: 6px; }

.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  text-align: left;
  transition: background 0.25s;
}

.nav-group-title:hover { background: var(--surface-2); }

.nav-group-title .nav-arrow {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(45deg);
  transition: transform 0.3s;
  flex: none;
}

.nav-group.is-open .nav-arrow { transform: rotate(-135deg); }

.nav-group-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 8px;
  margin: 3px 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}

.nav-group.is-open .nav-group-list { max-height: 600px; opacity: 1; }

.nav-item {
  position: relative;
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}

.nav-item:hover { color: var(--text); background: var(--surface-2); }

.nav-item.is-current {
  color: var(--text);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.nav-item .nav-index { color: var(--text-faint); font-size: 11px; margin-right: 7px; font-family: var(--mono); }

.sidebar-foot {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.7;
}

.sidebar-foot a { color: var(--accent-2); }
.sidebar-foot a:hover { text-decoration: underline; }

/* 正文 */
.content { min-width: 0; }

.content-head { padding-bottom: 18px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.crumb a { color: var(--accent-2); }
.crumb a:hover { text-decoration: underline; }
.crumb-sep { opacity: 0.5; }

.page-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.page-intro { margin-top: 10px; font-size: 15px; color: var(--text-dim); }

/* 章节 */
.sec { margin: 34px 0; scroll-margin-top: calc(var(--topbar-h) + 14px); }

.sec h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sec h2 .sec-no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(20, 150, 143, 0.35);
  padding: 2px 9px;
  border-radius: 7px;
  flex: none;
}

.sec h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 26px 0 10px;
  color: var(--text);
}

.sec p { font-size: 14.5px; color: var(--text-dim); margin: 10px 0; }

.sec p code, .sec li code, .sec td code, .sec h3 code {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.sec ul, .sec ol { margin: 12px 0 12px 22px; color: var(--text-dim); font-size: 14.5px; }
.sec li { margin: 5px 0; }

/* 代码块（保持深色不变） */
.code-window {
  margin: 16px 0;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--code-line);
}

.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-r { background: #ff5f57; }
.dot-y { background: #febc2e; }
.dot-g { background: #28c840; }

.code-lang {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #5b6470;
  text-transform: uppercase;
}

.code-copy {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--code-line);
  border-radius: 7px;
  color: #5b6470;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.code-copy:hover { color: #1c2129; border-color: #d3d8df; background: rgba(0, 0, 0, 0.04); }
.code-copy.is-copied { color: #0f766e; border-color: rgba(15, 118, 110, 0.45); }
.code-copy svg { width: 14px; height: 14px; }

.code-body { padding: 16px 18px; overflow-x: auto; }

.code-body pre { font-size: 13.5px; line-height: 1.85; }
.code-body code { font-size: inherit; }

/* 高亮色（浅色代码块内） */
.tok-comment { color: #8a93a3; font-style: italic; }
.tok-kw { color: #0e7490; }
.tok-str { color: #b45309; }
.tok-num { color: #a16207; }
.tok-fn { color: #1d4ed8; }
.tok-bool { color: #7c3aed; }
.tok-prompt { color: #0f766e; }
.tok-out { color: #0f766e; }

/* 输出块 */
.code-body.is-output { padding: 12px 18px; }
.code-body.is-output pre { color: #0f766e; }

/* 提示框 */
.note {
  display: flex;
  gap: 12px;
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-2-soft);
  border: 1px solid rgba(20, 150, 143, 0.3);
}

.note-warn {
  background: rgba(255, 176, 80, 0.08);
  border-color: rgba(255, 176, 80, 0.4);
}

.note-danger {
  background: var(--accent-soft);
  border-color: rgba(20, 150, 143, 0.4);
}

.note-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--accent-2);
}
.note-warn .note-icon { color: #d97f16; }
.note-danger .note-icon { color: var(--accent); }
.note-icon svg { width: 100%; height: 100%; }

.note-body { font-size: 13.5px; color: var(--text-dim); }
.note-body strong { color: var(--text); font-weight: 600; }
.note-body code {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

/* 表格 */
.table-wrap {
  margin: 16px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
}

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl thead th {
  text-align: left;
  padding: 11px 14px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.tbl tbody td {
  padding: 10px 14px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--surface-2); }

.tbl td code {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  white-space: nowrap;
}

/* 实例卡片 */
.demo {
  margin: 18px 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px 20px;
}

.demo-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.demo-title svg { width: 15px; height: 15px; }

.demo-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
  color: #0d7a70;
  overflow-x: auto;
  white-space: pre;
}

.demo-result-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

/* 上一页下一页 */
.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 48px 0 10px;
}

.pn {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 0.25s, background 0.25s;
}

.pn:hover { border-color: var(--accent); background: var(--surface-2); }

.pn-next {
  text-align: right;
  align-items: flex-end;
}

.pn:hover.pn-next { border-color: var(--accent-2); }

.pn-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.pn-next .pn-label { flex-direction: row-reverse; }

.pn-arrow {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.pn-next .pn-arrow { color: var(--accent-2); }

.pn-arrow svg { width: 15px; height: 15px; }

.pn-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* 右侧章节导航 */
.aside-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); }

.aside-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.aside-label {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.onpage-nav { display: flex; flex-direction: column; gap: 2px; }

.onpage-link {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}

.onpage-link:hover { color: var(--text); background: var(--surface-2); }
.onpage-link.is-active { color: var(--accent-2); border-left-color: var(--accent-2); }

.aside-mini { font-size: 12.5px; color: var(--text-dim); line-height: 1.8; }
.aside-mini a { color: var(--accent-2); }
.aside-mini a:hover { text-decoration: underline; }
.aside-mini strong { color: var(--accent-2); font-family: var(--mono); font-weight: 600; }

.aside-version .version-big {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
}

/* 页脚 */
.footer {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.footer-note { font-size: 12.5px; color: var(--text-dim); }
.footer-copy { font-size: 12px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.06em; }

/* 首页卡片 */
.index-hero {
  padding: 30px 4px 8px;
}

.index-hero-title {
  font-family: var(--serif);
  font-size: clamp(34px, 4.5vw, 52px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.index-hero-title .grad {
  color: var(--accent);
}

.index-hero-desc { margin-top: 14px; max-width: 640px; font-size: 15.5px; color: var(--text-dim); }
.index-hero-desc code {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  padding: 1px 6px;
  border-radius: 5px;
}

.index-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 34px;
}

.index-card {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 0.3s, background 0.3s;
}

.index-card:hover {
  border-color: rgba(20, 150, 143, 0.45);
  background: var(--surface-2);
}

.index-card-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--accent-2);
  background: var(--accent-2-soft);
  border: 1px solid rgba(20, 150, 143, 0.3);
  margin-bottom: 13px;
}
.index-card-icon svg { width: 21px; height: 21px; }

.index-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.index-card p { font-size: 13px; color: var(--text-dim); line-height: 1.75; }
.index-card ul { list-style: none; margin: 8px 0 0; }
.index-card li {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 3px 0 3px 16px;
  position: relative;
}
.index-card li a { color: var(--text-dim); }
.index-card li a:hover { color: var(--accent); }
.index-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}

/* 滚动渐入 */
.reveal { opacity: 0; transition: opacity 0.5s ease; }
.reveal.is-in { opacity: 1; }

/* 响应式 */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .aside { display: none; }
}

@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topnav { display: none; }
}

@media (max-width: 620px) {
  .layout { padding: calc(var(--topbar-h) + 12px) 16px 0; }
  .page-title { font-size: 25px; }
  .prevnext { grid-template-columns: 1fr; }
  .pn-next { text-align: left; align-items: flex-start; }
  .pn-next .pn-label { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
