:root {
  color-scheme: light;
  --bg: #faf9f6;
  --panel: #f1f0ec;
  --line: #d5d2ca;
  --text: #171717;
  --muted: #68665f;
  --link: #8d1f1f;
  --active: #eee8e4;
  --max: 900px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); line-height: 1.72; }
button, input { font: inherit; }
button { color: inherit; }
a { color: var(--link); }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 20; background: #111; color: white; padding: 8px 12px; }
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  display: grid;
  grid-template-columns: 250px minmax(260px, 620px);
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 246, .97);
}

.brand { border: 0; background: transparent; padding: 0; text-align: left; font-size: 21px; font-weight: 700; cursor: pointer; }
.search-wrap input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; background: var(--panel); color: var(--text); }
.search-wrap input:focus { outline: 2px solid #8cb5e8; outline-offset: 1px; background: white; }
.nav-toggle { display: none; }

.layout { display: grid; grid-template-columns: 250px minmax(0, var(--max)) 210px; gap: 32px; padding: 28px; align-items: start; }
.sidebar, .toc { position: sticky; top: 92px; max-height: calc(100vh - 116px); overflow: auto; }
.nav-group { margin-bottom: 24px; }
.nav-group h2 { margin: 0 0 6px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.nav-item { display: block; width: 100%; border: 0; border-radius: 5px; background: transparent; padding: 7px 9px; text-align: left; cursor: pointer; line-height: 1.35; }
.nav-item:hover { background: var(--panel); }
.nav-item.active { background: var(--active); color: #761919; font-weight: 650; }

.article { min-width: 0; padding-bottom: 80px; }
.article-header { padding-bottom: 18px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.article-header h1 { margin: 0 0 6px; font-size: clamp(30px, 4vw, 44px); line-height: 1.2; letter-spacing: -.02em; }
.article-summary { margin: 0; color: var(--muted); font-size: 17px; }
.eyebrow { margin: 0 0 7px; color: #8d1f1f; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; letter-spacing: .12em; }
.status-note { margin: 18px 0; padding: 13px 15px; border-left: 4px solid #8795a6; background: var(--panel); }
.status-note strong { display: block; margin-bottom: 2px; }
.article h2 { margin-top: 42px; padding-bottom: 7px; border-bottom: 1px solid var(--line); font-size: 26px; line-height: 1.3; }
.article h3 { margin-top: 30px; font-size: 20px; line-height: 1.4; }
.article p, .article li { max-width: 78ch; }
.article code { padding: 2px 5px; border-radius: 4px; background: #eef0f3; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.article pre { overflow: auto; padding: 14px; background: #f2f4f6; border: 1px solid var(--line); border-radius: 6px; }
.article pre code { padding: 0; background: transparent; }
.article blockquote { margin: 20px 0; padding: 3px 0 3px 18px; border-left: 3px solid #aeb7c2; color: #475362; }
.table-wrap { width: 100%; overflow: auto; margin: 20px 0 28px; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 14px; line-height: 1.55; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { background: var(--panel); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.toc { font-size: 13px; }
.toc h2 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--link); }
.toc a.level-3 { padding-left: 12px; }

.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.home-card { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 16px; text-align: left; cursor: pointer; }
.home-card:hover { border-color: #8cabcf; background: #fbfdff; }
.home-card strong { display: block; margin-bottom: 4px; font-size: 17px; }
.home-card span { color: var(--muted); line-height: 1.5; }
.search-empty { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

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

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 60px; grid-template-columns: auto 1fr; gap: 12px; padding: 10px 14px; }
  .brand { font-size: 18px; }
  .nav-toggle { display: inline-block; grid-row: 1; border: 1px solid var(--line); border-radius: 5px; background: white; padding: 6px 9px; }
  .search-wrap { grid-column: 1 / -1; }
  .layout { display: block; padding: 20px 16px; }
  .sidebar { display: none; position: fixed; inset: 108px 0 0 0; z-index: 9; max-height: none; background: white; padding: 18px; border-top: 1px solid var(--line); }
  .sidebar.open { display: block; }
  .home-grid { grid-template-columns: 1fr; }
  .article-header h1 { font-size: 31px; }
}

@media print {
  .topbar, .sidebar, .toc { display: none !important; }
  .layout { display: block; padding: 0; }
  .article { max-width: none; }
}
