@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,500;6..72,600&display=swap');

:root {
  --paper: #f8f7f3;
  --paper-deep: #f1efe8;
  --ink: #20302b;
  --muted: #75817a;
  --line: #e5e3dc;
  --green: #365c4d;
  --green-dark: #254438;
  --mint: #dce9df;
  --orange: #ca704f;
  --white: #fffefa;
  --code: #172a26;
  --shadow: 0 12px 36px rgba(35, 54, 46, .07);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.72 'DM Sans', sans-serif; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--orange); }
button, input { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 8px 14px; transform: translateY(-150%); background: var(--white); border-radius: 8px; }
.skip-link:focus { transform: none; }

.topbar { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; height: 68px; padding: 0 36px; background: rgba(248,247,243,.93); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--green); color: white; font: 600 18px/1 'Newsreader', serif; letter-spacing: -2px; }
.brand-mark span { color: #e2a185; }
.brand-name { font-size: 14px; letter-spacing: -.3px; }
.brand-name b { font-weight: 700; }
.topbar-right { display: flex; gap: 26px; align-items: center; margin-left: auto; color: var(--muted); font-size: 13px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); color: var(--ink); font-size: 12px; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.theme-toggle:hover { transform: translateY(-1px); border-color: var(--green); }
.theme-icon { color: var(--orange); font-size: 16px; line-height: 1; }
.menu-toggle { display: none; border: 0; background: transparent; color: var(--ink); font-size: 21px; cursor: pointer; }

.page-shell { display: grid; grid-template-columns: 270px minmax(0, 820px); justify-content: center; gap: 54px; align-items: start; max-width: 1440px; min-height: calc(100vh - 68px); margin: 0 auto; padding: 0 40px; }
.sidebar { position: sticky; top: 68px; display: flex; flex-direction: column; height: calc(100vh - 68px); padding: 40px 16px 20px 0; overflow-y: auto; border-right: 1px solid var(--line); }
.sidebar-intro { padding: 0 18px 18px 0; }
.eyebrow, .nav-section { color: #87928b; font: 500 11px/1.4 'DM Mono', monospace; letter-spacing: .12em; }
.sidebar-intro p { max-width: 220px; margin: 11px 0 0; color: #59675f; font-size: 14px; line-height: 1.6; }
.search-box { display: flex; align-items: center; gap: 8px; height: 38px; margin: 5px 17px 25px 0; padding: 0 10px; border: 1px solid #e4e2db; border-radius: 7px; background: rgba(255,254,250,.7); color: #8c978e; }
.search-box > span { font-size: 20px; line-height: 1; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search-box input::placeholder { color: #9aa39c; }
.search-box kbd { padding: 0 5px; border: 1px solid #e4e2db; border-radius: 4px; font: 10px 'DM Mono', monospace; }
.chapter-nav { flex: 1; }
.nav-group { margin: 0 12px 23px 0; text-align: left; }
.nav-section { display: block; margin: 0 0 8px 13px; text-align: left; text-transform: uppercase; }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 7px 10px 7px 13px; border-radius: 6px; color: #5f6c64; font-size: 14px; line-height: 1.4; text-align: left; text-decoration: none; transition: background .16s, color .16s; }
.nav-link:hover { background: #f0efe9; color: var(--ink); }
.nav-link.is-active { background: var(--mint); color: var(--green-dark); font-weight: 600; }
.nav-indicator { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: #c6cdc5; }
.nav-link.is-active .nav-indicator { background: var(--orange); box-shadow: 0 0 0 3px rgba(202,112,79,.12); }
.nav-subsections { display: flex; flex-direction: column; align-items: stretch; gap: 3px; margin: 3px 12px 14px 24px; padding-left: 9px; border-left: 1px solid #d9ddd6; text-align: left; }
.nav-sub-link { position: relative; display: block; padding: 5px 7px; border-radius: 4px; color: #78857c; font-size: 12px; line-height: 1.5; text-align: left; text-decoration: none; transition: background .16s, color .16s; }
.nav-sub-link::before { position: absolute; top: 12px; left: -13px; width: 6px; height: 6px; border: 1px solid #9aa79e; border-radius: 50%; background: var(--paper); content: ""; }
.nav-sub-link:hover, .nav-sub-link.is-current { background: rgba(220,233,223,.55); color: var(--green-dark); }
.nav-sub-link.is-current { font-weight: 700; }
.nav-sub-link.is-current::before { border-color: var(--orange); background: var(--orange); box-shadow: 0 0 0 3px rgba(202,112,79,.12); }
.no-results { margin: 0 10px; color: var(--muted); font-size: 13px; }
.main-content { min-width: 0; padding: 45px 0 24px; }
.article-wrap { max-width: 740px; margin: 0 auto; }
.breadcrumbs { display: flex; gap: 10px; align-items: center; margin-bottom: 24px; color: #929a93; font: 10px 'DM Mono', monospace; letter-spacing: .08em; }
.breadcrumbs a { color: var(--green); text-decoration: none; }
.article { min-height: 300px; }
.article h1, .article h2, .article h3 { scroll-margin-top: 92px; }
.article h1 { max-width: 720px; margin: 0 0 20px; color: #243a31; font: 500 clamp(38px, 4.4vw, 57px)/1.06 'Newsreader', Georgia, serif; letter-spacing: -.035em; }
.article h2 { margin: 47px 0 13px; padding-top: 5px; color: #2d493c; font: 500 30px/1.2 'Newsreader', Georgia, serif; letter-spacing: -.02em; }
.article h3 { margin: 28px 0 10px; color: #344e41; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.article p { margin: 0 0 17px; color: #4e5d54; }
.article > h1 + p { max-width: 680px; margin: 0 0 30px; color: #526259; font-size: 18px; line-height: 1.66; }
.article li { margin: 8px 0; padding-left: 3px; color: #4e5d54; }
.article ul, .article ol { margin: 0 0 20px; padding-left: 22px; }
.article li::marker { color: var(--orange); }
.article blockquote { margin: 23px 0; padding: 15px 18px; border-left: 3px solid var(--orange); border-radius: 0 8px 8px 0; background: #f2f0e9; }
.article blockquote p { margin: 0; color: #58675e; }
.article strong { color: #304b3e; font-weight: 700; }
.article hr { height: 1px; margin: 35px 0; border: 0; background: var(--line); }
.article pre { position: relative; margin: 19px 0 25px; padding: 20px 22px; overflow: auto; border: 1px solid #243b35; border-radius: 9px; background: var(--code); box-shadow: var(--shadow); color: #e1ece4; font: 12px/1.75 'DM Mono', monospace; tab-size: 4; }
.article pre code { color: inherit; font: inherit; }
.article-figure { margin: 24px 0 30px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); box-shadow: 0 5px 20px rgba(35,54,46,.035); }
.article-figure img { display: block; width: 100%; height: auto; }
.article-figure figcaption { margin: 8px 4px 0; color: #78857c; font: 11px/1.5 'DM Sans', sans-serif; }
.article .copy-code { position: absolute; top: 9px; right: 9px; padding: 4px 8px; border: 1px solid #486059; border-radius: 5px; background: #213a33; color: #c5d3ca; font-size: 10px; cursor: pointer; }
.article .copy-code:hover { background: #315044; }
.article :not(pre) > code { padding: 2px 5px; border: 1px solid #e8e5dc; border-radius: 4px; background: #f1efe9; color: #a3523b; font: 12px 'DM Mono', monospace; }
.table-scroll { width: 100%; margin: 20px 0 24px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.article table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.article th, .article td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.article th { background: #f2f1eb; color: #43584b; font-size: 11px; font-weight: 700; }
.article tr:last-child td { border-bottom: 0; }
.loading { padding: 60px 0; color: var(--muted); }
.error-card { padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.error-card h1 { font-size: 32px; }

.page-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 55px; padding-top: 20px; border-top: 1px solid var(--line); }
.step-link { display: flex; min-height: 76px; flex-direction: column; justify-content: center; padding: 12px 15px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,254,250,.68); text-decoration: none; transition: border-color .16s, transform .16s; }
.step-link:hover { transform: translateY(-2px); border-color: #b8c7b9; }
.step-link span { color: #89948b; font: 9px 'DM Mono', monospace; letter-spacing: .08em; }
.step-link strong { margin-top: 3px; color: var(--green-dark); font-size: 12px; }
.step-link.next { align-items: flex-end; text-align: right; }
.scrim { display: none; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d1414;
  --paper-deep: #121d1b;
  --ink: #e3ece6;
  --muted: #90a197;
  --line: #293a36;
  --green: #a9ceb3;
  --green-dark: #d1e5d6;
  --mint: #203a30;
  --orange: #e9a27c;
  --white: #121e1b;
  --code: #08110f;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
}

:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] body { color: var(--ink); }
:root[data-theme="dark"] .topbar { background: rgba(13, 20, 20, .92); }
:root[data-theme="dark"] .brand-mark { background: #315947; }
:root[data-theme="dark"] .sidebar-intro p { color: #aebeb4; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .nav-section { color: #82978b; }
:root[data-theme="dark"] .search-box { border-color: #344a41; background: #121e1b; color: #a0b1a6; }
:root[data-theme="dark"] .search-box input { color: var(--ink); }
:root[data-theme="dark"] .search-box input::placeholder { color: #798d82; }
:root[data-theme="dark"] .search-box kbd { border-color: #344a41; color: #8ea196; }
:root[data-theme="dark"] .nav-link { color: #adbbb2; }
:root[data-theme="dark"] .nav-link:hover { background: #1a2a25; color: #e4ece6; }
:root[data-theme="dark"] .nav-link.is-active { background: #203a30; color: #d8eadc; }
:root[data-theme="dark"] .nav-indicator { background: #52665a; }
:root[data-theme="dark"] .nav-subsections { border-color: #33483f; }
:root[data-theme="dark"] .nav-sub-link { color: #9cada2; }
:root[data-theme="dark"] .nav-sub-link::before { border-color: #6b8173; background: #0d1414; }
:root[data-theme="dark"] .nav-sub-link:hover,
:root[data-theme="dark"] .nav-sub-link.is-current { background: #1a2e26; color: #d3e6d8; }
:root[data-theme="dark"] .nav-sub-link.is-current::before { border-color: #e9a27c; background: #e9a27c; }
:root[data-theme="dark"] .no-results { color: #9aaba1; }
:root[data-theme="dark"] .breadcrumbs { color: #85968c; }
:root[data-theme="dark"] .article h1 { color: #e7eee9; }
:root[data-theme="dark"] .article h2 { color: #b8d4bf; }
:root[data-theme="dark"] .article h3 { color: #c8d9ce; }
:root[data-theme="dark"] .article p,
:root[data-theme="dark"] .article li { color: #bfcdc5; }
:root[data-theme="dark"] .article > h1 + p { color: #adbbb2; }
:root[data-theme="dark"] .article blockquote { background: #182823; }
:root[data-theme="dark"] .article blockquote p { color: #bccbc2; }
:root[data-theme="dark"] .article strong { color: #d7e5db; }
:root[data-theme="dark"] .article-figure { border-color: #2b3c37; }
:root[data-theme="dark"] .article-figure figcaption { color: #91a197; }
:root[data-theme="dark"] .article :not(pre) > code { border-color: #35473f; background: #1a2924; color: #f0aa83; }
:root[data-theme="dark"] .table-scroll { border-color: #293a36; background: #121e1b; }
:root[data-theme="dark"] .article th { background: #1b2a25; color: #c4d5ca; }
:root[data-theme="dark"] .article td { color: #bfcdc5; }
:root[data-theme="dark"] .error-card { border-color: #293a36; background: #121e1b; }
:root[data-theme="dark"] .error-card h1 { color: #e7eee9; }
:root[data-theme="dark"] .step-link { background: rgba(18, 30, 27, .76); }
:root[data-theme="dark"] .step-link span { color: #8fa197; }
:root[data-theme="dark"] .step-link strong { color: #d1e5d6; }
:root[data-theme="dark"] .theme-toggle { border-color: #344a41; background: #14211e; color: #d5e2d9; }
:root[data-theme="dark"] .theme-toggle:hover { border-color: #82ad90; background: #1a2a25; }

@media (max-width: 1160px) {
  .page-shell { grid-template-columns: 226px minmax(0, 1fr); gap: 40px; padding: 0 30px; }
  .article-wrap { max-width: 740px; }
}
@media (max-width: 760px) {
  .topbar { height: 60px; gap: 12px; padding: 0 17px; }
  .menu-toggle { display: block; width: 25px; padding: 0; }
  .topbar-caption { display: none; }
  .topbar-right { gap: 10px; }
  .theme-toggle { width: 34px; min-width: 34px; padding: 0; }
  .theme-label { display: none; }
  .page-shell { display: block; min-height: calc(100vh - 60px); padding: 0 20px; }
  .sidebar { position: fixed; z-index: 12; top: 60px; bottom: 0; left: 0; width: min(300px, 86vw); height: auto; padding: 26px 20px 18px; transform: translateX(-105%); border-right: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main-content { padding: 30px 0 20px; }
  .breadcrumbs { margin-bottom: 20px; }
  .article h1 { font-size: clamp(38px, 11vw, 52px); }
  .article h2 { margin-top: 39px; font-size: 27px; }
  .article > h1 + p { font-size: 16px; }
  .article pre { padding: 18px 15px; font-size: 11px; }
  .page-nav { margin-top: 40px; }
  .scrim.is-visible { position: fixed; z-index: 11; inset: 60px 0 0; display: block; background: rgba(24,37,31,.28); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
