:root {
  --sidebar-w: 300px;
  --toc-w: 230px;
  --bg: #ffffff;
  --bg-sidebar: #fafafa;
  --border: #e5e7eb;
  --text: #1f2328;
  --text-dim: #57606a;
  --link: #0550ae;
  --link-hover: #0a3a7a;
  --accent: #444444;
  --code-bg: #f3f4f6;
  --callout-bg: #f6f8fa;
  --callout-border: #d0d7de;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* Sidebar */
#sidebar-mount {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 28px 0 40px;
}

.sb-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  padding: 0 24px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sb-brand small {
  display: block;
  font-weight: 400;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
}

.sb-nav { list-style: none; margin: 0; padding: 0 12px; }
.sb-nav li { margin: 1px 0; }
.sb-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
}
.sb-nav a:hover { background: #eef1f4; text-decoration: none; color: var(--text); }
.sb-nav a.active {
  background: #e8f0fe;
  color: var(--link);
  font-weight: 600;
}
.sb-nav .sb-chnum {
  display: inline-block;
  width: 1.6em;
  margin-right: 0.3em;
  color: #9aa4b2;
  font-variant-numeric: tabular-nums;
}

/* Main content */
main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 0 24px;
}

.content-col {
  width: 100%;
  max-width: 760px;
  padding: 40px 0 80px;
}

.crumb {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.crumb a { color: var(--text-dim); }
.crumb a:hover { color: var(--link); }

h1.page-title {
  font-size: 32px;
  margin: 0 0 6px;
  font-weight: 700;
}
.page-subtitle {
  color: var(--text-dim);
  font-size: 16px;
  margin: 0 0 32px;
}

article h2 {
  font-size: 22px;
  margin: 40px 0 14px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
article h2:first-of-type { border-top: none; padding-top: 0; margin-top: 20px; }
article h3 {
  font-size: 18px;
  margin: 28px 0 10px;
}
article h4 {
  font-size: 15px;
  margin: 22px 0 8px;
  text-transform: none;
}
article p { margin: 0 0 16px; }
article ul, article ol { margin: 0 0 16px; padding-left: 26px; }
article li { margin: 0 0 8px; }
article li > ul, article li > ol { margin-top: 8px; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-left: 4px solid #8250df;
  border-radius: 6px;
  padding: 14px 18px;
  margin: 0 0 20px;
}
.callout p:last-child { margin-bottom: 0; }

blockquote {
  margin: 0 0 20px;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 22px;
  font-size: 14.5px;
}
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
thead th {
  border-bottom: 2px solid var(--accent);
  font-weight: 600;
}
tbody tr:hover { background: #fafbfc; }

.section-label {
  display: inline-block;
  font-weight: 700;
  margin-right: 6px;
}

.eq-block {
  margin: 18px 0 22px;
  padding: 12px 4px;
  overflow-x: auto;
  text-align: center;
}

.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}
.page-nav a { display: block; max-width: 46%; }
.page-nav .dir { display: block; color: var(--text-dim); font-size: 12px; }
.page-nav .next { text-align: right; margin-left: auto; }

.cover {
  text-align: center;
  padding: 100px 0 40px;
}
.cover h1 { font-size: 40px; margin-bottom: 10px; }
.cover .tagline { color: var(--text-dim); font-size: 18px; margin-bottom: 30px; }
.cover .meta { color: var(--text-dim); font-size: 14px; }
.badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 18px 0 34px; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

.toc-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 30px 0; }
.toc-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}
.toc-card:hover { border-color: var(--link); text-decoration: none; background: #f8faff; }
.toc-card .toc-num { color: var(--text-dim); font-size: 13px; }
.toc-card .toc-name { font-weight: 600; font-size: 16px; color: var(--text); }
.toc-card:hover .toc-name { color: var(--link); }
.toc-card .toc-desc { color: var(--text-dim); font-size: 13.5px; margin-top: 2px; }

.term-def dt { font-weight: 700; margin-top: 16px; }
.term-def dd { margin: 4px 0 0; }

.ack-list { list-style: none; padding: 0; margin: 18px 0; }
.ack-list li { padding: 4px 0; }

footer.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 30px 0 10px;
}

.video-callout { padding: 14px 18px 4px; }
.video-callout > p:first-child { margin-top: 0; }

.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 6px;
  margin: 0 0 14px;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 900px) {
  #sidebar-mount { display: none; }
  main { padding: 0 18px; }
}
