:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-radial-1: rgba(52, 103, 222, .14);
  --bg-radial-2: rgba(18, 169, 160, .10);
  --surface: rgba(255,255,255,.86);
  --surface-solid: #ffffff;
  --surface-soft: #f8fafc;
  --surface-tinted: #eef5ff;
  --sidebar: rgba(255,255,255,.78);
  --text: #334155;
  --text-strong: #101827;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #dbe4f0;
  --line-strong: #c5d1e0;
  --accent: #315fdd;
  --accent-2: #18a7a1;
  --accent-3: #7c3aed;
  --accent-soft: #eaf2ff;
  --accent-line: #bfd3ff;
  --success: #16875a;
  --warning: #b7791f;
  --danger: #c24150;
  --code-bg: #111827;
  --code-text: #e5edf8;
  --code-line: #243044;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 308px;
  --toc-width: 232px;
  --content-width: 920px;
  --shadow-sm: 0 8px 22px rgba(15, 23, 42, .06);
  --shadow: 0 18px 45px rgba(15, 23, 42, .09);
  --shadow-lg: 0 28px 80px rgba(15, 23, 42, .14);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d16;
  --bg-radial-1: rgba(74, 118, 255, .18);
  --bg-radial-2: rgba(23, 184, 176, .12);
  --surface: rgba(15, 23, 42, .76);
  --surface-solid: #111827;
  --surface-soft: #0f172a;
  --surface-tinted: #10203a;
  --sidebar: rgba(13, 20, 34, .78);
  --text: #cbd5e1;
  --text-strong: #f8fafc;
  --muted: #9aa8bb;
  --muted-2: #718096;
  --line: rgba(148, 163, 184, .22);
  --line-strong: rgba(148, 163, 184, .36);
  --accent: #8bb4ff;
  --accent-2: #4dd7d0;
  --accent-3: #b695ff;
  --accent-soft: rgba(77, 126, 255, .14);
  --accent-line: rgba(139, 180, 255, .30);
  --code-bg: #050812;
  --code-text: #e5edf8;
  --code-line: rgba(148, 163, 184, .18);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, .22);
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -8%, var(--bg-radial-1), transparent 34rem),
    radial-gradient(circle at 92% 2%, var(--bg-radial-2), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
  color: var(--text);
  font: 16.5px/1.78 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: -0.006em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), transparent 70%);
}

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
::selection { background: rgba(49, 95, 221, .20); }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--text-strong);
  color: var(--bg);
  font-weight: 850;
  box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); outline: 3px solid var(--accent); outline-offset: 3px; text-decoration: none; }
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(49, 95, 221, .35);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px;
  background: var(--sidebar);
  backdrop-filter: blur(22px) saturate(160%);
  border-right: 1px solid var(--line);
}
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  margin-bottom: 18px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-solid));
  color: var(--accent);
  border: 1px solid var(--accent-line);
  box-shadow: var(--shadow-sm);
}
.brand-icon { width: 24px; height: 24px; }
.brand-title { display: block; font-weight: 900; line-height: 1.05; letter-spacing: -0.04em; color: var(--text-strong); }
.brand-subtitle { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); letter-spacing: .01em; }

.search-wrap { position: relative; margin: 8px 0 16px; }
.search-wrap::before { content: "⌕"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 18px; line-height: 1; pointer-events: none; }
.search {
  width: 100%;
  height: 44px;
  padding: 0 13px 0 38px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-solid);
  color: var(--text-strong);
  outline: 0;
  font-size: 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset;
}
.search::placeholder { color: var(--muted-2); }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(49, 95, 221, .13); }

.nav { display: grid; gap: 4px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px 9px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
  border: 1px solid transparent;
}
.nav-link::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .15s ease, transform .15s ease;
}
.nav-link:hover { background: var(--surface-solid); text-decoration: none; color: var(--text-strong); border-color: var(--line); }
.nav-link:hover::before { background: var(--accent-2); transform: scale(1.1); }
.nav-link.active {
  background: linear-gradient(135deg, var(--accent-soft), rgba(24, 167, 161, .07));
  color: var(--accent);
  border-color: var(--accent-line);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm);
}
.nav-link.active::before { background: var(--accent); }

.sidebar-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 16px 0 0; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.sidebar-footer { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.sidebar-footer p { margin: 0 0 10px; color: var(--text-strong); font-weight: 850; }
.social-links { display: flex; flex-wrap: wrap; gap: 8px; }
.sidebar .social-links { display: grid; gap: 8px; }
.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}
.social-links a:hover { text-decoration: none; border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
}
.topbar .brand { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--text-strong);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 850;
  cursor: pointer;
}

.mobile-scrim { display: none; }
.content {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, var(--content-width)) var(--toc-width);
  justify-content: center;
  gap: 42px;
  padding: 0 42px;
}
.page {
  min-width: 0;
  width: 100%;
  max-width: var(--content-width);
  padding: 56px 0 88px;
}
.page > h1:first-child { margin-top: 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page::after { content: ""; display: table; clear: both; }

.toc {
  position: sticky;
  top: 28px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow: auto;
  margin-top: 56px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: var(--shadow-sm);
}
.toc-title { display: block; margin-bottom: 10px; color: var(--text-strong); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.toc nav { display: grid; gap: 4px; }
.toc a { display: block; padding: 6px 8px; border-radius: 9px; color: var(--muted); font-size: 13px; line-height: 1.35; font-weight: 720; }
.toc a:hover, .toc a.active { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.toc a.toc-h3 { padding-left: 18px; font-size: 12.5px; font-weight: 650; }

main h1 { font-size: clamp(38px, 5vw, 60px); line-height: 1.02; letter-spacing: -0.06em; margin: 0 0 18px; color: var(--text-strong); }
main h2 { font-size: clamp(25px, 3vw, 32px); line-height: 1.18; letter-spacing: -0.04em; margin: 58px 0 16px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--text-strong); scroll-margin-top: 24px; }
main h3 { font-size: 22px; line-height: 1.28; letter-spacing: -0.03em; margin: 38px 0 10px; color: var(--text-strong); scroll-margin-top: 24px; }
main h4 { font-size: 18px; margin: 28px 0 8px; color: var(--text-strong); }
main p { margin: 0 0 17px; color: var(--text); }
main li { margin: 7px 0; color: var(--text); }
main ul, main ol { padding-left: 1.35rem; margin: 12px 0 24px; }
main strong { color: var(--text-strong); }
main > p:first-of-type, .hero + p, .page > h1:first-child + p { font-size: 19px; line-height: 1.72; color: color-mix(in srgb, var(--text) 88%, var(--text-strong)); }
main li::marker { color: var(--accent); font-weight: 900; }

.anchor { opacity: 0; margin-left: -30px; padding-right: 10px; color: var(--muted-2); font-size: .72em; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }

.hero {
  position: relative;
  margin-bottom: 36px;
  padding: clamp(30px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at 8% 0%, rgba(49, 95, 221, .18), transparent 25rem),
    radial-gradient(circle at 95% 0%, rgba(24, 167, 161, .12), transparent 22rem),
    linear-gradient(180deg, var(--surface-solid) 0%, color-mix(in srgb, var(--surface-solid) 84%, var(--accent-soft)) 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.hero:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(130deg, rgba(255,255,255,.15), transparent 44%, rgba(49, 95, 221, .07));
}
.hero > * { position: relative; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; padding: 7px 11px; border: 1px solid var(--accent-line); border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 900; letter-spacing: .01em; }
.eyebrow .brand-icon { width: 18px; height: 18px; }
.hero h1 { max-width: 820px; margin: 0 0 18px; font-size: clamp(45px, 7vw, 78px); line-height: .96; letter-spacing: -0.075em; }
.hero p { max-width: 780px; margin: 0; color: var(--text); font-size: 20px; line-height: 1.62; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 16px; border-radius: 13px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 860; box-shadow: 0 10px 22px rgba(49, 95, 221, .22); }
.button:hover { text-decoration: none; filter: brightness(.96); color: #fff; }
.button.secondary { background: var(--surface-solid); color: var(--text); border-color: var(--line-strong); box-shadow: none; }
.button.secondary:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); filter: none; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 24px 0 34px; }
.doc-card { position: relative; display: block; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease; overflow: hidden; }
.doc-card::after { content: "→"; position: absolute; right: 18px; top: 16px; color: var(--muted-2); font-weight: 900; opacity: 0; transform: translateX(-4px); transition: opacity .15s ease, transform .15s ease; }
.doc-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent-line); background: var(--surface-solid); box-shadow: var(--shadow); }
.doc-card:hover::after { opacity: 1; transform: translateX(0); }
.doc-card strong { display: block; margin-bottom: 7px; padding-right: 18px; color: var(--text-strong); font-size: 16px; }
.doc-card span { display: block; color: var(--muted); font-size: 14px; line-height: 1.55; }

pre { position: relative; overflow: auto; margin: 18px 0 26px; padding: 20px; border: 1px solid var(--code-line); border-radius: 18px; background: var(--code-bg); color: var(--code-text); box-shadow: var(--shadow); }
code { font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace; font-size: .9em; }
pre code { color: inherit; }
p code, li code, td code { padding: .16em .42em; border: 1px solid var(--accent-line); border-radius: 7px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; font-weight: 650; }
.copy-code { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 6px 9px; border: 1px solid rgba(148,163,184,.35); border-radius: 9px; background: rgba(255,255,255,.08); color: #dbeafe; font-size: 12px; font-weight: 850; cursor: pointer; backdrop-filter: blur(10px); }
.copy-code:hover { background: rgba(255,255,255,.14); }

.table-wrap { overflow: auto; margin: 20px 0 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-solid); box-shadow: var(--shadow-sm); }
table { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; margin: 0; background: transparent; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); color: var(--text-strong); font-size: 13px; font-weight: 900; letter-spacing: .02em; }
td { color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-soft) 78%, transparent); }

blockquote { margin: 24px 0; padding: 16px 18px; border: 1px solid var(--accent-line); border-left: 5px solid var(--accent); border-radius: 18px; background: var(--accent-soft); color: var(--text); }
blockquote p { margin: .15em 0; color: var(--text); }
.notice { padding: 16px 18px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 18px; color: var(--text); }

.media-placeholder { margin: 22px 0 28px; padding: 20px; border: 1px dashed var(--line-strong); border-radius: 18px; background: var(--surface-soft); color: var(--text); }
.media-placeholder .kind { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--warning); font-weight: 950; }
.media-placeholder .desc { margin-top: 5px; color: var(--text); font-weight: 750; }
.media-figure { margin: 26px 0 34px; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.media-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.media-kind { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.media-open { color: var(--muted); font-size: 13px; font-weight: 760; }
.media-open:hover { color: var(--accent); text-decoration: none; }
.media-link { display: block; background: #0b1020; }
.media-link:hover { text-decoration: none; }
.media-figure img, .media-figure video { display: block; width: 100%; height: auto; background: #0b1020; }
.media-figure video { aspect-ratio: 16 / 9; }
.media-figure figcaption { padding: 13px 16px 15px; color: var(--muted); font-size: 14px; line-height: 1.6; border-top: 1px solid var(--line); background: var(--surface-solid); }

.page-footer { margin-top: 66px; padding-top: 24px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 14px; }
.page-nav { margin-top: 54px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.page-nav a { display: block; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.page-nav a:hover { text-decoration: none; border-color: var(--accent-line); background: var(--accent-soft); }
.page-nav .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 900; margin-bottom: 4px; }
.page-nav .title { display: block; color: var(--text-strong); font-weight: 850; }
.page-nav .next { text-align: right; }

.nav-link:focus-visible, .button:focus-visible, .social-links a:focus-visible, .media-link:focus-visible, .media-open:focus-visible, .menu-btn:focus-visible, .theme-toggle:focus-visible, .search:focus-visible, .page-nav a:focus-visible, .toc a:focus-visible, .copy-code:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }

@media (max-width: 1180px) {
  .content { grid-template-columns: minmax(0, var(--content-width)); padding: 0 34px; }
  .toc { display: none; }
}
@media (max-width: 920px) {
  .layout { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(88vw, var(--sidebar-width)); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 24px 0 55px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .mobile-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.35); backdrop-filter: blur(2px); }
  body.mobile-open .mobile-scrim { display: block; }
  .content { display: block; padding: 0 18px; }
  .page { width: 100%; padding: 32px 0 58px; }
  .hero { padding: 28px; border-radius: 24px; }
  .hero h1 { font-size: 44px; }
  .hero p, main > p:first-of-type, .hero + p, .page > h1:first-child + p { font-size: 18px; }
  .anchor { display: none; }
  .page-footer { display: block; }
  .page-footer .social-links { margin-top: 14px; }
  .topbar .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
  .topbar .brand-title { font-size: 14px; }
  .topbar .brand-subtitle { display: none; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav .next { text-align: left; }
  .page-nav .empty { display: none; }
  p code, li code, td code { white-space: normal; }
  .media-head { padding: 10px 12px; }
  .media-open { font-size: 12px; }
  .media-figure { border-radius: 16px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .topbar { padding: 9px 10px; }
  .theme-toggle .label { display: none; }
  .hero h1 { font-size: 38px; }
  .hero-actions .button { width: 100%; }
  main h1 { font-size: 36px; }
  main h2 { font-size: 25px; }
}
@media print {
  .sidebar, .topbar, .page-footer, .page-nav, .toc, .reading-progress, .copy-code { display: none !important; }
  .layout, .content { display: block; padding: 0; }
  .page { width: auto; max-width: none; padding: 0; }
  body { background: white; color: #111827; }
  body::before { display: none; }
  main p, main li { color: #1f2937; }
  a { color: #111827; }
  pre, .table-wrap, .hero, .media-figure { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .doc-card:hover { transform: none; }
}
