:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #5b6b7f;
  --border: #e3e8ef;
  --brand: #024764;
  --brand-2: #0e7490;
  --link: #0b5f86;
  --code-bg: #f1f5f9;
  --pre-bg: #0b1726;
  --pre-text: #e2e8f0;
  --mark: #fff3c4;
  --tip: #ecfdf5; --tip-b: #10b981;
  --note: #eff6ff; --note-b: #3b82f6;
  --warn: #fffbeb; --warn-b: #f59e0b;
  --top-h: 60px;
  color-scheme: light;
}
[data-theme='dark'] {
  --bg: #0b1018;
  --bg-soft: #0f1622;
  --panel: #111a28;
  --text: #e6edf6;
  --muted: #94a3b8;
  --border: #1f2b3d;
  --brand: #67c7ed;
  --brand-2: #38bdf8;
  --link: #7dd3fc;
  --code-bg: #172235;
  --pre-bg: #070c14;
  --mark: #3b3410;
  --tip: #052e23; --note: #0b1d3a; --warn: #33240a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 50; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; flex-shrink: 0; }
.brand img { height: 23px; width: auto; }
[data-theme='dark'] .brand img { filter: brightness(0) invert(1); }
.brand span { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted); }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); padding: 0 12px; font: inherit; font-size: 14px; }
.search input:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; background: var(--panel); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 50px -20px rgba(2, 30, 50, 0.45); padding: 6px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a.active { background: var(--bg-soft); }
.search-results .r-t { font-weight: 600; font-size: 14px; }
.search-results .r-s { font-size: 12px; color: var(--muted); }
.search-results .r-x { font-size: 13px; color: var(--muted); display: block; margin-top: 2px; }
.search-results mark, #search-page mark { background: var(--mark); color: inherit; border-radius: 3px; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.top-links a { color: var(--muted); text-decoration: none; }
.top-links a:hover { color: var(--text); }
.top-links .cta { background: var(--brand); color: #fff; padding: 7px 14px; border-radius: 10px; font-weight: 600; }
[data-theme='dark'] .top-links .cta { color: #04202d; }
.theme { display: inline-grid; place-items: center; }
.theme .i-sun { display: none; }
[data-theme='dark'] .theme .i-sun { display: block; }
[data-theme='dark'] .theme .i-moon { display: none; }
.theme, .menu-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; height: 34px; min-width: 34px; cursor: pointer; font-size: 16px; }
.menu-btn { display: none; }

/* Layout */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr) 220px; max-width: 1440px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 18px 12px 40px 20px; border-right: 1px solid var(--border); font-size: 14px; }
.nav-section { margin-bottom: 4px; }
.nav-title { width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; font-size: 13.5px; padding: 7px 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.nav-title:hover { background: var(--bg-soft); }
.nav-title::after { content: '›'; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.nav-section.open .nav-title::after { transform: rotate(90deg); }
.nav-section ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 10px; display: none; border-left: 1px solid var(--border); margin-left: 16px; }
.nav-section.open ul { display: block; }
.nav-section li a { display: block; padding: 4px 10px; color: var(--muted); text-decoration: none; border-radius: 6px; line-height: 1.45; }
.nav-section li a:hover { color: var(--text); background: var(--bg-soft); }
.nav-section li a[aria-current='page'] { color: var(--brand); font-weight: 600; background: color-mix(in srgb, var(--brand) 9%, transparent); }
.content { padding: 28px 48px 60px; min-width: 0; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.toc { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 28px 16px; font-size: 13px; }
.toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 3px 0 3px 10px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.4; }
.toc li.l3 a { padding-left: 22px; }
.toc li a.active { color: var(--brand); border-left-color: var(--brand); }

/* Prose */
.prose { max-width: 780px; }
.prose h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 10px; }
.prose .lead { font-size: 18px; color: var(--muted); margin: 0 0 28px; }
.prose h2 { font-size: 24px; letter-spacing: -0.01em; margin: 44px 0 10px; padding-top: 4px; }
.prose h3 { font-size: 18.5px; margin: 30px 0 6px; }
.prose h2, .prose h3 { position: relative; }
.anchor { position: absolute; left: -1.1em; opacity: 0; text-decoration: none; color: var(--muted); font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.prose code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.87em; background: var(--code-bg); padding: 2px 6px; border-radius: 6px; }
.prose pre { position: relative; background: var(--pre-bg); color: var(--pre-text); padding: 14px 16px; border-radius: 12px; overflow: auto; font-size: 14px; line-height: 1.55; }
.prose pre code { background: none; padding: 0; color: inherit; }
.copy { position: absolute; top: 8px; right: 8px; font: 600 12px Inter, sans-serif; background: rgba(255,255,255,0.1); color: #e2e8f0; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.prose pre:hover .copy, .copy:focus { opacity: 1; }
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { background: var(--bg-soft); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose kbd { font-family: 'JetBrains Mono', monospace; font-size: 0.82em; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--bg-soft); }
.prose blockquote { margin: 18px 0; padding: 10px 16px; border-left: 4px solid var(--border); background: var(--bg-soft); border-radius: 0 10px 10px 0; color: var(--text); }
.prose blockquote p { margin: 6px 0; }
.callout-tip { border-left-color: var(--tip-b) !important; background: var(--tip) !important; }
.callout-note { border-left-color: var(--note-b) !important; background: var(--note) !important; }
.callout-important, .callout-warning { border-left-color: var(--warn-b) !important; background: var(--warn) !important; }
.kazi-check-row { display: flex; gap: 8px; align-items: center; }

/* Home cards */
.hero { padding: 8px 0 8px; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 20px 0; }
.card { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text); background: var(--panel); transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.card:hover { border-color: var(--brand-2); transform: translateY(-2px); box-shadow: 0 14px 30px -20px rgba(2, 71, 100, 0.5); }
.card strong { display: flex; align-items: center; gap: 8px; font-size: 15.5px; }
.card span { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; line-height: 1.5; }

/* Pager + footer */
.pager { max-width: 780px; display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; }
.pager a { flex: 1; max-width: 50%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 600; }
.pager a:hover { border-color: var(--brand-2); }
.pager a span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.pager .next { text-align: right; margin-left: auto; }
.foot { max-width: 780px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.foot a { color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
#search-page .hit { padding: 14px 0; border-bottom: 1px solid var(--border); }
#search-page .hit a { font-weight: 600; font-size: 17px; }

@media (max-width: 1200px) {
  .shell { grid-template-columns: 260px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-block; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; top: var(--top-h); left: 0; width: min(320px, 86vw); background: var(--bg); transform: translateX(-100%); transition: transform 0.2s; visibility: hidden; }
  body.nav-open .sidebar { visibility: visible; box-shadow: 20px 0 40px -20px rgba(0,0,0,0.3); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 20px 16px 48px; }
  .top { gap: 10px; padding: 0 12px; }
  .top-links a:not(.cta) { display: none; }
  .brand span { display: none; }
  .anchor { display: none; }
}
@media print {
  .top, .sidebar, .toc, .pager { display: none !important; }
  .shell { display: block; }
}
