:root {
  --bg: #0d0d10;
  --surface: #131318;
  --surface-raised: #19191f;
  --line: #2a2931;
  --line-soft: #202027;
  --text: #eeedf2;
  --muted: #96939f;
  --faint: #696671;
  --accent: #d33b63;
  --accent-soft: rgba(211, 59, 99, 0.13);
  --green: #48c78e;
  --yellow: #e8b85b;
  --blue: #6fa9ff;
  --sidebar-width: 286px;
  --toc-width: 220px;
  --topbar-height: 58px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20;
  width: var(--sidebar-width); padding: 28px 22px 20px;
  display: flex; flex-direction: column;
  background: #101014; border-right: 1px solid var(--line-soft);
}
.brand-block { padding: 0 8px 25px; border-bottom: 1px solid var(--line-soft); }
.eyebrow, .toc-label { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.brand { text-decoration: none; font-size: 28px; font-weight: 780; letter-spacing: -.04em; }
.brand-note { margin: 8px 0 0; max-width: 210px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.search-box { position: relative; margin: 20px 0 15px; }
.search-box > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.search-box input {
  width: 100%; height: 39px; padding: 0 42px 0 12px;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box kbd { position: absolute; right: 10px; top: 9px; color: var(--faint); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }

.document-nav { flex: 1; overflow: auto; padding-right: 3px; }
.nav-group { margin: 19px 8px 8px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.nav-link {
  display: block; margin: 2px 0; padding: 9px 10px;
  color: #aaa7b1; text-decoration: none; border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  font-size: 12.5px; line-height: 1.35; transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: #fff; background: var(--accent-soft); border-left-color: var(--accent); }
.sidebar-footer { display: flex; justify-content: space-between; padding: 16px 8px 0; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 10px; }

.workspace { margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 15; height: var(--topbar-height); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(13,13,16,.92); backdrop-filter: blur(15px); border-bottom: 1px solid var(--line-soft);
}
.crumb { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.language-switch { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.language-switch button { min-width: 34px; padding: 5px 8px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font: inherit; font-size: 10px; font-weight: 700; letter-spacing: .08em; cursor: pointer; }
.language-switch button:hover { color: var(--text); }
.language-switch button.active { color: #fff; background: var(--accent); }
.status-dot { width: 6px; height: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(72,199,142,.1); }
.menu-button { display: none; color: var(--text); background: none; border: 0; cursor: pointer; }

.reader-layout { display: grid; grid-template-columns: minmax(0, 820px) var(--toc-width); gap: 70px; max-width: 1170px; margin: 0 auto; padding: 64px 48px 120px; }
.document { min-width: 0; opacity: 1; transform: translateY(0); transition: opacity .16s ease, transform .16s ease; }
.document.switching { opacity: 0; transform: translateY(5px); }
.loading, .error { color: var(--muted); padding: 90px 0; }
.document h1 { margin: 0 0 32px; font-size: clamp(37px, 5vw, 62px); line-height: 1.02; letter-spacing: -.055em; max-width: 850px; }
.document h2 { margin: 64px 0 20px; padding-top: 12px; font-size: 25px; line-height: 1.2; letter-spacing: -.025em; border-top: 1px solid var(--line); }
.document h3 { margin: 38px 0 14px; font-size: 17px; letter-spacing: -.015em; }
.document h4 { margin: 30px 0 12px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.document p, .document li { color: #c6c3cc; font-size: 15px; line-height: 1.72; }
.document > p:first-of-type { color: var(--muted); font-size: 16px; }
.document ul, .document ol { padding-left: 21px; }
.document li { margin: 7px 0; padding-left: 4px; }
.document li::marker { color: var(--accent); }
.document strong { color: #fff; font-weight: 680; }
.document em { color: #d8d5de; }
.document a { color: #f27899; text-decoration: none; border-bottom: 1px solid rgba(242,120,153,.35); }
.document a:hover { border-bottom-color: currentColor; }
.document blockquote { margin: 25px 0; padding: 16px 19px; color: var(--muted); background: var(--surface); border-left: 3px solid var(--accent); }
.document blockquote p { margin: 0; }
.document hr { margin: 55px 0; border: 0; border-top: 1px solid var(--line); }
.document code { color: #f1b0c2; background: #1b171d; border: 1px solid #30242b; border-radius: 4px; padding: 2px 5px; font: .88em "Cascadia Code", Consolas, monospace; }
.document pre { overflow: auto; padding: 18px; background: #101014; border: 1px solid var(--line); border-radius: 7px; }
.document pre code { padding: 0; background: transparent; border: 0; color: #d7d4dc; }
.table-wrap { overflow-x: auto; margin: 24px 0 36px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.document table { width: 100%; border-collapse: collapse; min-width: 620px; }
.document th, .document td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; line-height: 1.5; }
.document th { color: #fff; background: var(--surface); font-weight: 650; }
.document td { color: #b7b4bd; }
.task-item { list-style: none; margin-left: -21px !important; }
.task-item input { margin-right: 9px; accent-color: var(--accent); }
.highlight { background: rgba(232,184,91,.25); color: #fff; border-radius: 2px; }

.toc-panel { position: sticky; top: calc(var(--topbar-height) + 32px); align-self: start; max-height: calc(100vh - var(--topbar-height) - 60px); overflow: auto; }
.toc-panel nav { border-left: 1px solid var(--line); }
.toc-link { display: block; padding: 5px 0 5px 14px; color: var(--faint); text-decoration: none; font-size: 11px; line-height: 1.35; transition: color .14s ease; }
.toc-link:hover, .toc-link.active { color: var(--text); }
.toc-link.level-3 { padding-left: 25px; }

.search-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(7,7,9,.72); backdrop-filter: blur(8px); }
.search-results { width: min(690px, calc(100vw - 40px)); max-height: 70vh; overflow: auto; margin: 90px auto; padding: 10px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.result { display: block; padding: 15px 16px; text-decoration: none; border-bottom: 1px solid var(--line-soft); border-radius: 6px; }
.result:hover { background: var(--accent-soft); }
.result-title { color: #fff; font-size: 13px; font-weight: 650; }
.result-snippet { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.empty-result { padding: 30px; color: var(--muted); text-align: center; }

@media (max-width: 1080px) {
  .reader-layout { grid-template-columns: minmax(0, 780px); max-width: 880px; }
  .toc-panel { display: none; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 30px 0 60px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 18px; }
  .crumb { display: none; }
  .reader-layout { padding: 38px 21px 80px; }
  .document h1 { font-size: 38px; }
  .document h2 { margin-top: 48px; }
}

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