:root {
  --ink: #18171a;
  --muted: #68656d;
  --line: #e7e4e9;
  --soft: #f7f5f8;
  --accent: #603a78;
  --accent-soft: #eee6f3;
  --white: #ffffff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 48px;
  font-family: Abadi, "Abadi MT", Arial, Helvetica, sans-serif;
  background: var(--white);
  color: var(--ink);
}
a { color: inherit; }
button, input { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  width: min(100% - 2rem, 1180px);
  min-height: 52px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}
.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
.top-nav { display: flex; align-items: center; gap: 0.3rem; }
.top-nav a,
.nav-toggle {
  padding: 0.38rem 0.62rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.94rem;
  text-decoration: none;
}
.top-nav a:hover,
.top-nav a:focus-visible,
.nav-toggle:hover,
.nav-toggle:focus-visible { background: var(--soft); color: var(--ink); }
.top-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-toggle { display: none; cursor: pointer; }

.mobile-context { display: none; }
.workspace {
  width: min(100% - 2rem, 1180px);
  min-height: calc(100vh - 100px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: stretch;
}
.sidebar { padding: 2rem 1.5rem 3rem 0; border-right: 1px solid var(--line); }
.sidebar-title { margin: 0.6rem 0 1.2rem; font-size: 1.15rem; }
.sidebar-kicker,
.sidebar-back { display: block; margin: 0 0 0.8rem; color: var(--muted); font-size: 0.85rem; }
.sidebar-back { text-underline-offset: 0.2rem; }
.sidebar-links { display: grid; gap: 0.18rem; }
.sidebar-links a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.94rem;
  text-decoration: none;
}
.sidebar-links a:hover,
.sidebar-links a:focus-visible { background: var(--soft); color: var(--ink); }
.sidebar-links a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.section-group + .section-group { margin-top: 1rem; }
.section-group summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.section-group .sidebar-links { margin-top: 0.45rem; }

.content { min-width: 0; padding: 3.5rem 0 5rem 3.5rem; }
.content-inner { max-width: 780px; }
.content-inner.wide { max-width: 980px; }
.eyebrow { margin: 0 0 0.65rem; color: var(--accent); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; letter-spacing: -0.025em; }
h2 { margin: 2.4rem 0 0.8rem; font-size: 1.45rem; }
h3 { margin: 2rem 0 0.7rem; }
.lead { margin: 1rem 0 0; font-size: 1.18rem; line-height: 1.65; }
.updated { margin: 0.85rem 0 2rem; color: var(--muted); font-size: 0.9rem; }
.markdown-body { font-size: 1.04rem; line-height: 1.75; }
.markdown-body p { margin: 0 0 1rem; }
.markdown-body ul,
.markdown-body ol { padding-left: 1.35rem; }
.markdown-body li + li { margin-top: 0.55rem; }
.markdown-body blockquote { margin: 1.4rem 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.markdown-body code { padding: 0.1rem 0.28rem; background: var(--soft); border-radius: 4px; }
.markdown-body pre { overflow-x: auto; padding: 1rem; background: var(--soft); border-radius: 7px; }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body figure { margin: 2rem 0; }
.markdown-body figure img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.markdown-body figcaption { margin-top: 0.55rem; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.table-wrap { max-width: 100%; overflow-x: auto; margin: 1.5rem 0; }
.markdown-body table { width: 100%; border-collapse: collapse; }
.markdown-body th,
.markdown-body td { padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); text-align: left; }
.markdown-body th { background: var(--soft); font-weight: 700; }
.callout { margin: 1.5rem 0; padding: 1rem 1.1rem; border-left: 4px solid var(--accent); background: var(--soft); border-radius: 0 7px 7px 0; }
.callout strong { display: block; margin-bottom: 0.35rem; }
.callout p { margin: 0; }
.callout-evidence { border-left-color: #377353; }
.callout-warning { border-left-color: #a15d1d; }
.callout-question { border-left-color: #356d9b; }
.math-display { max-width: 100%; overflow-x: auto; margin: 1.5rem 0; padding: 1rem; background: var(--soft); border-radius: 7px; text-align: center; }
.footnote-ref a,
.footnote-back { text-underline-offset: 0.15rem; }
.footnotes { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.92rem; }
.footnotes h2 { margin-top: 0; }
.page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 3rem; align-items: start; }
.page-article { min-width: 0; }
.page-toc { position: sticky; top: 76px; display: grid; gap: 0.5rem; padding-left: 1rem; border-left: 1px solid var(--line); font-size: 0.86rem; }
.page-toc strong { margin-bottom: 0.2rem; }
.page-toc a { color: var(--muted); text-decoration: none; line-height: 1.35; }
.page-toc a:hover,
.page-toc a:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 0.18rem; }
.page-toc .toc-level-3,
.page-toc .toc-level-4 { padding-left: 0.75rem; }
.mobile-toc { display: none; margin-bottom: 1.5rem; padding: 0.8rem; background: var(--soft); border-radius: 7px; }
.mobile-toc summary { cursor: pointer; font-weight: 700; }
.mobile-toc nav { display: grid; gap: 0.45rem; margin-top: 0.75rem; }
.mobile-toc a { color: var(--muted); }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0 0 1rem; color: var(--muted); font-size: 0.86rem; }
.breadcrumbs a { text-underline-offset: 0.2rem; }
.updates-list { margin-top: 2.4rem; border-top: 1px solid var(--line); }
.update-row { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 1.4rem; padding: 1.25rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.update-row time { color: var(--muted); font-size: 0.88rem; }
.update-details { display: grid; gap: 0.28rem; }
.update-path { color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.update-summary { color: var(--muted); line-height: 1.5; }
.update-row:hover strong,
.update-row:focus-visible strong { text-decoration: underline; text-underline-offset: 0.2rem; }

.notebook-list { margin-top: 2.4rem; border-top: 1px solid var(--line); }
.notebook-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1.25rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.notebook-row > span:first-child { display: grid; gap: 0.35rem; }
.notebook-row > span:first-child span,
.notebook-row > span:last-child { color: var(--muted); }
.notebook-row:hover strong,
.notebook-row:focus-visible strong { text-decoration: underline; text-underline-offset: 0.2rem; }

.page-pagination { display: grid; grid-template-columns: 1fr 1px 1fr; gap: 1rem; margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.page-pagination a { text-underline-offset: 0.2rem; }
.page-pagination a:last-child { text-align: right; }

.search-form { margin-top: 2rem; }
.search-form label { display: block; margin-bottom: 0.5rem; font-weight: 700; }
.search-form > div { display: flex; gap: 0.5rem; }
.search-form input { min-width: 0; flex: 1; padding: 0.75rem; border: 1px solid var(--line); border-radius: 7px; }
.search-form button,
.sidebar-toggle { padding: 0.7rem 0.9rem; border: 0; border-radius: 7px; background: var(--accent); color: var(--white); cursor: pointer; }
.search-status { min-height: 1.5rem; color: var(--muted); }
.search-result { display: block; padding: 1.15rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-result-path { display: block; margin-bottom: 0.3rem; color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.search-result-summary { display: block; margin-top: 0.3rem; color: var(--muted); line-height: 1.5; }
.search-result:hover strong,
.search-result:focus-visible strong { text-decoration: underline; text-underline-offset: 0.2rem; }

.site-footer { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--line); }
.footer-inner { width: min(100% - 2rem, 1180px); min-height: 48px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.88rem; }
.footer-inner a { text-underline-offset: 0.22rem; }

@media (max-width: 760px) {
  .header-inner { min-height: 52px; flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .top-nav { display: none; width: 100%; padding-bottom: 0.6rem; }
  .top-nav.open { display: flex; flex-wrap: wrap; }
  .mobile-context { display: block; width: min(100% - 2rem, 1180px); margin: 0 auto; padding-top: 0.8rem; }
  .sidebar-toggle { padding: 0.5rem 0.7rem; font-size: 0.9rem; }
  .workspace { grid-template-columns: 1fr; min-height: auto; }
  .sidebar { display: none; padding: 1.1rem 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar.open { display: block; }
  .content { padding: 2.4rem 0 4rem; }
  .page-layout { grid-template-columns: 1fr; }
  .page-toc { display: none; }
  .mobile-toc { display: block; }
}

@media (max-width: 520px) {
  .update-row { grid-template-columns: 1fr; gap: 0.4rem; }
  .notebook-row { align-items: flex-start; flex-direction: column; gap: 0.55rem; }
  .search-form > div { align-items: stretch; flex-direction: column; }
  .page-pagination { grid-template-columns: 1fr; }
  .page-pagination a:last-child { text-align: left; }
}
