/* =========================================================
   F1 StratLab Docs — Site styles
   ========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-0);
  color: var(--fg-1);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Atmosphere — a single faint halo at top + faint grid wash */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 40% at 70% -10%, rgba(108,92,231,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 35% at 10% 110%, rgba(51,133,255,0.08) 0%, transparent 60%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 30%, black 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 50% 30%, black 30%, transparent 85%);
}

/* =========================================================
   TOP NAV
   ========================================================= */
.topnav {
  position: sticky; top: 0;
  height: 60px;
  z-index: 40;
  background: rgba(8,8,12,0.72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--hairline);
}
.topnav-inner {
  height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 0 20px 0 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.005em;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background-image: url('../assets/favicon.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.brand-name { color: var(--fg-1); }
.brand-tag {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
}

.search-wrap {
  position: relative;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.search-input {
  width: 100%;
  height: 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 0 36px 0 36px;
  color: var(--fg-1);
  font-size: 13.5px;
  font-family: var(--font-body);
  outline: none;
  transition: all 0.15s cubic-bezier(0.2,0,0,1);
}
.search-input:focus {
  border-color: rgba(162,155,254,0.4);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.12);
}
.search-input::placeholder { color: var(--fg-4); }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--fg-4);
}
.search-kbd {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  padding: 2px 6px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-2);
  border: 1px solid var(--divider-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-elev);
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  z-index: 50;
}
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.search-result:hover, .search-result.active {
  background: rgba(108,92,231,0.14);
}
.search-result-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-1);
  margin-bottom: 2px;
}
.search-result-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-3);
}
.search-result-snippet {
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-result mark {
  background: rgba(108,92,231,0.32);
  color: var(--fg-1);
  border-radius: 2px;
  padding: 0 2px;
}
.search-empty {
  padding: 14px 14px;
  font-size: 12.5px;
  color: var(--fg-3);
  text-align: center;
}
.search-tag-section {
  padding: 10px 12px 10px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 4px;
}
.search-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-4);
  margin-bottom: 8px;
}
.search-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.search-tag-suggest {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px;
  background: rgba(108,92,231,0.10);
  border: 1px solid rgba(108,92,231,0.28);
  border-radius: 999px;
  color: var(--purple-200);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}
.search-tag-suggest:hover {
  background: rgba(108,92,231,0.20);
  border-color: rgba(162,155,254,0.55);
  color: #fff;
}
.search-tag-suggest .stt-hash {
  color: var(--purple-400);
  margin-right: -1px;
}
.search-tag-suggest .stt-count {
  margin-left: 4px;
  padding: 0 5px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--fg-3);
  font-size: 10px;
  font-weight: 600;
}

.nav-right {
  display: flex; align-items: center; gap: 6px;
}
.nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--fg-2);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2,0,0,1);
}
.nav-pill:hover {
  background: rgba(255,255,255,0.04);
  color: var(--fg-1);
}
.nav-pill.primary {
  background: var(--purple-600);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(162,155,254,0.25), 0 4px 16px rgba(108,92,231,0.3);
}
.nav-pill.primary:hover {
  background: var(--purple-500);
}
.nav-pill svg { width: 13px; height: 13px; }

/* =========================================================
   APP SHELL — three pane
   ========================================================= */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.shell-no-toc {
  grid-template-columns: 280px minmax(0, 1fr);
}
.shell-wide {
  grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1440px;
}

/* =========================================================
   LEFT SIDEBAR
   ========================================================= */
.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 28px 8px 40px 24px;
  border-right: 1px solid var(--hairline);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-section { margin-bottom: 22px; }
.sidebar-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--fg-4);
  padding: 0 12px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-section-title::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--purple-500);
  opacity: 0.7;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  margin: 1px 0;
  font-size: 13.5px;
  color: var(--fg-2);
  border-radius: 7px;
  position: relative;
  cursor: pointer;
  transition: all 0.12s ease;
}
.sidebar-link:hover {
  color: var(--fg-1);
  background: rgba(255,255,255,0.03);
}
.sidebar-link.active {
  color: var(--fg-1);
  background: linear-gradient(90deg, rgba(108,92,231,0.18) 0%, rgba(108,92,231,0.05) 100%);
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--purple-400);
  box-shadow: 0 0 8px var(--purple-500);
}
.sidebar-link-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  letter-spacing: 0;
}

.sidebar-footer {
  margin-top: 28px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.5;
}
.sidebar-footer strong { color: var(--fg-2); font-weight: 500; }
.sidebar-footer a { color: var(--purple-300); }
.sidebar-footer a:hover { color: var(--purple-200); }

/* =========================================================
   ARTICLE / CONTENT
   ========================================================= */
.content {
  padding: 40px 56px 80px;
  min-width: 0;
}
.content-wide {
  padding: 40px 80px 80px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-4);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--fg-3); }
.breadcrumb a:hover { color: var(--purple-300); }
.breadcrumb-sep { color: var(--fg-4); opacity: 0.5; }

.article h1 {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 16px;
  background: linear-gradient(180deg, #ffffff 0%, #d6d0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.article-lede {
  font-size: 18px;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 720px;
  margin: 0 0 36px;
}

.article h2 {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 600;
  line-height: 1.2;
  margin: 56px 0 14px;
  scroll-margin-top: 80px;
  position: relative;
}
.article h2 .heading-anchor,
.article h3 .heading-anchor {
  opacity: 0;
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.7em;
  color: var(--purple-300);
  font-weight: 400;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.article h2:hover .heading-anchor,
.article h3:hover .heading-anchor { opacity: 1; }
.article h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
  scroll-margin-top: 80px;
  color: var(--fg-1);
}
.article h4 {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple-300);
  margin: 28px 0 8px;
}
.article p {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--fg-2);
  margin: 0 0 16px;
  max-width: 760px;
  text-wrap: pretty;
}
.article ul, .article ol {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--fg-2);
  padding-left: 22px;
  margin: 0 0 18px;
  max-width: 760px;
}
.article li { margin: 4px 0; }
.article li > p { margin: 0; }
.article strong { color: var(--fg-1); font-weight: 600; }
.article em { color: var(--fg-1); font-style: italic; }

.article a:not(.heading-anchor) {
  color: var(--purple-300);
  border-bottom: 1px dashed rgba(162,155,254,0.35);
  padding-bottom: 1px;
  transition: all 0.12s ease;
}
.article a:not(.heading-anchor):hover {
  color: var(--purple-200);
  border-bottom-color: rgba(162,155,254,0.85);
}
.article a code { color: var(--purple-200); }

.article blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 2px solid var(--purple-500);
  background: rgba(108,92,231,0.06);
  border-radius: 0 8px 8px 0;
  color: var(--fg-2);
  font-size: 14.5px;
  line-height: 1.65;
}

.article hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--divider), transparent);
  margin: 42px 0;
}

/* Inline code */
.article :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(108,92,231,0.10);
  border: 1px solid rgba(108,92,231,0.18);
  color: #d4caff;
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 500;
}

/* Tables */
.article table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 13.5px;
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: 10px;
  overflow: hidden;
}
.article thead { background: rgba(108,92,231,0.06); }
.article th {
  padding: 11px 14px;
  text-align: left;
  color: var(--fg-1);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--divider);
}
.article td {
  padding: 11px 14px;
  color: var(--fg-2);
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.article tr:last-child td { border-bottom: 0; }
.article tr:hover td { background: rgba(255,255,255,0.015); }
.article td code, .article th code {
  font-size: 12px;
}

/* Code blocks */
.code-block {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--divider);
  border-radius: 12px;
  margin: 18px 0 24px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.code-block-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(255,255,255,0.015);
}
.code-block-dots { display: flex; gap: 5px; }
.code-block-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}
.code-block-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: auto;
}
.code-copy {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  background: transparent;
  border: 1px solid var(--hairline);
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.code-copy:hover {
  color: var(--purple-300);
  border-color: var(--purple-500);
}
.code-block pre {
  margin: 0;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  color: var(--fg-1);
}
.code-block pre code { background: transparent !important; padding: 0 !important; border: 0 !important; font-size: inherit !important; }

/* Prism overrides */
.token.comment { color: rgba(255,255,255,0.38); font-style: italic; }
.token.keyword, .token.builtin { color: #c2b4ff; }
.token.string, .token.attr-value { color: #9ae6b4; }
.token.function { color: #a29bfe; }
.token.number, .token.boolean { color: #f6ad55; }
.token.operator, .token.punctuation { color: rgba(255,255,255,0.6); }
.token.class-name { color: #f6ad55; }
.token.property, .token.tag { color: #60a5fa; }
.token.parameter { color: #d4caff; }

/* Mermaid container */
.mermaid-block {
  background: var(--bg-1);
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 24px;
  margin: 18px 0 24px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  box-shadow: var(--shadow-card);
}
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--danger);
  padding: 12px;
  background: rgba(255,87,51,0.06);
  border: 1px solid rgba(255,87,51,0.18);
  border-radius: 8px;
}

/* =========================================================
   RIGHT TOC
   ========================================================= */
.toc {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 40px 24px 40px 8px;
  font-size: 12.5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.toc-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--fg-4);
  margin: 0 0 12px;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--hairline);
}
.toc-item {
  display: block;
  padding: 4px 0 4px 14px;
  color: var(--fg-3);
  font-size: 12.5px;
  line-height: 1.4;
  position: relative;
  cursor: pointer;
  transition: color 0.12s ease;
}
.toc-item.h3 { padding-left: 24px; font-size: 12px; }
.toc-item:hover { color: var(--fg-1); }
.toc-item.active {
  color: var(--purple-300);
}
.toc-item.active::before {
  content: "";
  position: absolute;
  left: -1px; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 14px;
  background: var(--purple-400);
  border-radius: 1px;
  box-shadow: 0 0 6px var(--purple-500);
}

/* =========================================================
   TAG CHIPS — Obsidian-style page tag pills
   ========================================================= */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 24px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: all 0.12s ease;
}
.tag-chip:hover {
  color: var(--purple-200);
  border-color: rgba(162,155,254,0.45);
  background: rgba(108,92,231,0.08);
}

/* Landing-site eyebrow strip on the home hero */
.home-landing-strip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: rgba(108,92,231,0.08);
  border: 1px solid rgba(108,92,231,0.24);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--fg-2);
  text-decoration: none;
  margin-bottom: 22px;
  transition: all 0.15s ease;
}
.home-landing-strip:hover {
  background: rgba(108,92,231,0.14);
  border-color: rgba(162,155,254,0.45);
}
.home-landing-strip-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--purple-600);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.home-landing-strip-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  color: var(--purple-300);
  transition: transform 0.18s cubic-bezier(0.2,0,0,1);
}
.home-landing-strip:hover .home-landing-strip-arrow { transform: translateX(3px); color: var(--purple-200); }

/* =========================================================
   HOMEPAGE
   ========================================================= */
.home-hero {
  padding: 64px 0 28px;
  position: relative;
}
.home-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--purple-300);
  margin-bottom: 22px;
}
.home-eyebrow-bar {
  width: 24px; height: 1px;
  background: linear-gradient(90deg, var(--purple-400), transparent);
}
.home-h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 64px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 22px;
  max-width: 900px;
  background: linear-gradient(180deg, #ffffff 0%, #d0c8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.home-h1 .accent {
  background: linear-gradient(120deg, #a29bfe 0%, #6c5ce7 55%, #3385ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.home-sub {
  font-size: 18px;
  line-height: 1.55;
  color: var(--fg-2);
  max-width: 700px;
  margin: 0 0 28px;
}
.home-cta-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2,0,0,1);
}
.btn-primary {
  background: var(--purple-600);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(162,155,254,0.25), 0 8px 24px rgba(108,92,231,0.32);
}
.btn-primary:hover {
  background: var(--purple-500);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(162,155,254,0.4), 0 12px 28px rgba(108,92,231,0.4);
}
.btn-ghost {
  background: transparent;
  color: var(--fg-1);
  border-color: var(--divider);
}
.btn-ghost:hover { background: var(--bg-3); border-color: var(--divider-strong); }
.btn svg { width: 14px; height: 14px; }

.home-meta {
  display: flex; gap: 22px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  margin-top: 6px;
}
.home-meta strong { color: var(--fg-1); font-weight: 500; }

.section-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--purple-300);
  margin-bottom: 14px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--fg-1);
}
.section-sub {
  font-size: 15px;
  color: var(--fg-3);
  margin: 0 0 24px;
  max-width: 640px;
}

.home-section { margin-top: 56px; }

.layer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.layer-card {
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: all 0.18s cubic-bezier(0.2,0,0,1);
}
.layer-card:hover {
  background: var(--bg-3);
  border-color: var(--divider-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-elev);
}
.layer-card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--purple-300);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.layer-card-num::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--purple-400);
  box-shadow: 0 0 8px var(--purple-500);
}
.layer-card h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--fg-1);
}
.layer-card p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--fg-3);
  margin: 0;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.agent-card {
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 18px;
  transition: all 0.18s ease;
  cursor: pointer;
  position: relative;
}
.agent-card:hover {
  background: var(--bg-3);
  border-color: rgba(162,155,254,0.32);
  transform: translateY(-1px);
}
.agent-card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.agent-card-code {
  color: var(--purple-300);
  background: rgba(108,92,231,0.12);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.agent-card h4 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 6px;
  color: var(--fg-1);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.agent-card p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg-3);
  margin: 0;
}
.agent-card-meta {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--fg-4);
}
.agent-card-meta strong { color: var(--purple-300); font-weight: 500; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.stat-cell {
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 18px;
}
.stat-cell-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fg-1);
  margin-bottom: 6px;
}
.stat-cell-num .unit { color: var(--purple-300); font-size: 0.6em; margin-left: 2px; }
.stat-cell-label {
  font-size: 11.5px;
  color: var(--fg-3);
  line-height: 1.4;
}

.cta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-top: 64px;
  padding: 28px 32px;
  background: linear-gradient(135deg, rgba(108,92,231,0.12) 0%, rgba(51,133,255,0.06) 100%);
  border: 1px solid rgba(108,92,231,0.24);
  border-radius: 16px;
  box-shadow: var(--shadow-glow);
}
.cta-strip-text h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--fg-1);
}
.cta-strip-text p {
  font-size: 13.5px;
  color: var(--fg-2);
  margin: 0;
  max-width: 500px;
}

/* Meet the author — home page card */
.stratlab-author {
  margin-top: 48px;
  padding: 36px 32px;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
}
.stratlab-author-row {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 760px;
  margin: 0 auto;
}
.stratlab-author-avatar {
  border-radius: 50%;
  border: 1px solid var(--divider, rgba(255,255,255,0.08));
  box-shadow: 0 0 0 4px rgba(108,92,231,0.10);
  flex-shrink: 0;
}
.stratlab-author-body { flex: 1; min-width: 0; }
.stratlab-author-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 6px 0 6px;
  color: var(--fg-1);
}
.stratlab-author-bio {
  font-size: 13.5px;
  color: var(--fg-3);
  line-height: 1.55;
  margin: 0 0 16px;
  max-width: 560px;
}
.stratlab-author-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stratlab-author-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--bg-2, rgba(255,255,255,0.02));
  border: 1px solid var(--divider, rgba(255,255,255,0.08));
  border-radius: 10px;
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s;
}
.stratlab-author-card:hover {
  border-color: var(--purple-400, #a29bfe);
  color: #fff;
  background: rgba(108, 92, 231, 0.10);
  transform: translateY(-1px);
}
.stratlab-author-card svg { color: var(--purple-300, #a29bfe); }
.stratlab-author-card-primary {
  background: rgba(108,92,231,0.14);
  border-color: rgba(108,92,231,0.40);
  color: var(--fg-1);
}
.stratlab-author-card-primary svg { color: #fff; }
@media (max-width: 640px) {
  .stratlab-author { padding: 28px 20px; }
  .stratlab-author-row { flex-direction: column; text-align: center; gap: 18px; }
  .stratlab-author-links { justify-content: center; }
  .stratlab-author-bio { margin-left: auto; margin-right: auto; }
}

/* Page footer (next/prev) */
.page-footer {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.page-footer-link {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.page-footer-link:hover {
  background: var(--bg-3);
  border-color: rgba(162,155,254,0.3);
}
.page-footer-link.next { text-align: right; }
.page-footer-label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-4);
  margin-bottom: 6px;
}
.page-footer-title {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--fg-1);
  font-weight: 500;
}
.page-footer-empty { visibility: hidden; }

/* =========================================================
   GRAPH OVERLAY (Obsidian-style)
   ========================================================= */
.graph-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,8,12,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.2s cubic-bezier(0.2,0,0,1);
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.graph-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(8,8,12,0.6);
}
.graph-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.graph-subtitle {
  font-size: 12.5px;
  color: var(--fg-3);
}
.graph-close {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--fg-2);
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.graph-close:hover {
  color: var(--fg-1);
  border-color: var(--divider-strong);
}
.graph-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.graph-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(17,24,39,0.85);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 11.5px;
  color: var(--fg-3);
  backdrop-filter: blur(8px);
  max-width: 280px;
  line-height: 1.5;
}
.graph-legend-row {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0;
}
.graph-legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17,24,39,0.95);
  border: 1px solid rgba(162,155,254,0.4);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--fg-1);
  white-space: nowrap;
  z-index: 5;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.graph-tooltip .gt-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  margin-top: 2px;
}

.mini-graph {
  background: var(--bg-1);
  border: 1px solid var(--divider);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s ease;
  aspect-ratio: 16 / 9;
  min-height: 380px;
}
.mini-graph:hover {
  border-color: rgba(162,155,254,0.32);
  box-shadow: var(--shadow-elev);
}
.mini-graph canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.mini-graph-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 22px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8,8,12,0) 30%, rgba(8,8,12,0.7) 100%);
}
.mini-graph-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--purple-300);
}
.mini-graph-cta {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--fg-1);
  font-weight: 500;
}
.mini-graph-cta svg { width: 12px; height: 12px; }

/* =========================================================
   CALLOUTS
   ========================================================= */
.callout {
  background: rgba(108,92,231,0.06);
  border: 1px solid rgba(108,92,231,0.22);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 22px 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.callout-icon {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: rgba(108,92,231,0.18);
  color: var(--purple-300);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.callout-body { flex: 1; }
.callout-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-1);
  margin-bottom: 4px;
}
.callout-body p { font-size: 13.5px; line-height: 1.55; margin: 0; }

/* =========================================================
   FOOTER
   ========================================================= */
.docs-footer {
  border-top: 1px solid var(--hairline);
  background: var(--bg-1);
  padding: 48px 0 28px;
  margin-top: 80px;
}
.docs-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 56px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}
.docs-footer-brand-copy {
  font-size: 13px;
  color: var(--fg-3);
  line-height: 1.6;
  max-width: 360px;
  margin-top: 12px;
}
.docs-footer-col-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--fg-4);
  font-weight: 600;
  margin-bottom: 12px;
}
.docs-footer-col a {
  display: block;
  font-size: 13px;
  color: var(--fg-2);
  padding: 4px 0;
}
.docs-footer-col a:hover { color: var(--purple-300); }
.docs-footer-legal {
  max-width: 1440px;
  margin: 28px auto 0;
  padding: 18px 56px 0;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--fg-4);
  font-family: var(--font-mono);
}

/* =========================================================
   MOBILE — collapse sidebars
   ========================================================= */
.mobile-toggle { display: none; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 36px 40px 80px; }
}
@media (max-width: 820px) {
  .topnav-inner { grid-template-columns: auto 1fr auto; padding: 0 14px; gap: 12px; }
  .brand-tag { display: none; }
  .search-wrap { max-width: 100%; }
  .nav-pill span:not(.brand-name) { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--bg-1);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.2,0,0,1);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-elev); }
  .mobile-toggle {
    display: inline-flex;
    height: 32px; width: 32px;
    align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: 8px;
    color: var(--fg-2);
    cursor: pointer;
  }
  .content { padding: 28px 20px 60px; }
  .article h1 { font-size: 32px; }
  .article h2 { font-size: 22px; }
  .layer-grid, .agent-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .docs-footer-inner { grid-template-columns: 1fr 1fr; padding: 0 20px; gap: 24px; }
  .docs-footer-legal { padding: 18px 20px 0; }
}

/* =========================================================
   MISC
   ========================================================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  font-family: var(--font-mono);
  background: rgba(108,92,231,0.12);
  color: var(--purple-300);
  border: 1px solid rgba(108,92,231,0.28);
  letter-spacing: 0.04em;
}
.pill-live { background: rgba(67,255,100,0.08); color: #43ff64; border-color: rgba(67,255,100,0.22); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.pill-live .pill-dot { animation: pulse-dot 1.8s infinite; }

/* Skeleton loading state */
.skel {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* Article fade-in */
.article-enter {
  animation: article-fade 0.32s cubic-bezier(0.2,0,0,1);
}
@keyframes article-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Selection */
::selection { background: rgba(108,92,231,0.4); color: #fff; }

/* =========================================================
   RESPONSIVE OVERRIDES — surgical pass
   Breakpoints applied additively as max-width overrides
   so the desktop layout above stays the default.

   Scale:
     xl   1280px — TOC collapses, content widens
     lg   1024px — sidebar off-canvas, grids tighten
     md    768px — agent / stat grids tighten further, CTA stacks
     sm    480px — single-column, hero scales down, scrolling fallbacks

   Plus: @media (hover: hover) / (hover: none) and @media print.
   ========================================================= */

/* Sidebar off-canvas backdrop — base styles, only painted on mobile. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 29;
  animation: fade-in 0.18s cubic-bezier(0.2, 0, 0, 1);
}

/* Scroll wrapper applied by the markdown renderer around mermaid SVGs. */
.mermaid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------
   xl  ≤ 1280px — drop the right-hand TOC column.
   --------------------------------------------------------- */
@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .shell-no-toc {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
  .content {
    padding: 36px 48px 72px;
  }
  .content-wide {
    padding: 36px 56px 72px;
  }
  .docs-footer-inner {
    padding: 0 40px;
  }
  .docs-footer-legal {
    padding: 18px 40px 0;
  }
}

/* ---------------------------------------------------------
   lg  ≤ 1024px — sidebar becomes off-canvas, grids tighten.
   --------------------------------------------------------- */
@media (max-width: 1024px) {
  .topnav-inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 16px;
    gap: 12px;
  }
  .brand-tag {
    display: none;
  }
  /* Pills keep icons, drop labels except the GitHub call to action. */
  .nav-pill {
    padding: 0 10px;
  }
  .nav-pill span:not(.brand-name) {
    display: none;
  }
  .nav-pill.primary span:not(.brand-name) {
    display: inline;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .shell-no-toc {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 288px;
    max-width: 85vw;
    height: calc(100vh - 60px);
    padding: 22px 14px 32px 18px;
    background: var(--bg-1);
    border-right: 1px solid var(--divider);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-elev);
  }
  .sidebar-backdrop {
    display: block;
  }

  .mobile-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: 10px;
    color: var(--fg-2);
    cursor: pointer;
  }
  .mobile-toggle:hover {
    color: var(--fg-1);
    border-color: var(--divider-strong);
  }

  .content {
    padding: 32px 40px 64px;
  }
  .content-wide {
    padding: 32px 40px 64px;
  }

  /* Layer grid 3 → 2; agent grid 6 → auto-fit so it gracefully wraps. */
  .layer-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
  .agent-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .docs-footer-inner {
    grid-template-columns: 1fr 1fr;
    padding: 0 32px;
    gap: 32px;
  }
  .docs-footer-legal {
    padding: 18px 32px 0;
  }
}

/* ---------------------------------------------------------
   md  ≤ 768px — tablet portrait / phone landscape.
   --------------------------------------------------------- */
@media (max-width: 768px) {
  /* TopNav: keep brand + burger + only the primary CTA visible.
     Remaining pills collapse via existing label hide; icons stay. */
  .topnav {
    height: 56px;
  }
  .topnav-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .search-wrap {
    max-width: 100%;
  }
  .search-input {
    height: 38px;
    padding: 0 36px 0 36px;
  }
  .search-kbd {
    display: none;
  }
  /* Anchor dropdown to the input but clamp to viewport width. */
  .search-results {
    max-width: calc(100vw - 24px);
    max-height: 70vh;
  }
  .search-tag-row {
    gap: 6px;
  }

  .nav-right {
    gap: 4px;
  }
  /* Hide non-essential pills below 768px — Graph & Landing & DeepWiki. */
  .nav-right .nav-pill:not(.primary):not(:first-child) {
    display: none;
  }
  /* Keep Graph as the one non-primary affordance (icon-only). */
  .nav-pill {
    padding: 0 8px;
  }

  .content {
    padding: 24px 18px 56px;
  }
  .content-wide {
    padding: 20px 18px 56px;
  }

  /* Breadcrumb: never wrap onto two lines. Last segment truncates. */
  .breadcrumb {
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
  }
  .breadcrumb > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .article h1 {
    font-size: clamp(28px, 7.5vw, 36px);
    margin-bottom: 12px;
  }
  .article-lede {
    font-size: 16px;
  }
  .article h2 {
    font-size: 22px;
    margin: 40px 0 12px;
  }
  .article h3 {
    font-size: 18px;
    margin: 28px 0 8px;
  }
  .article p,
  .article ul,
  .article ol {
    font-size: 15px;
    max-width: 100%;
  }
  /* Article content uses the full content width on mobile, no left max. */
  .article ul,
  .article ol {
    padding-left: 20px;
  }
  /* Long URLs in inline code wrap so they never blow out the layout. */
  .article :not(pre) > code {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Tables become horizontally scrollable on mobile. */
  .article table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-radius: 10px;
  }
  .article thead,
  .article tbody,
  .article tr {
    width: max-content;
    min-width: 100%;
  }

  /* Code blocks already have overflow-x: auto, but force on the pre. */
  .code-block pre {
    padding: 14px 16px;
    font-size: 12.5px;
  }
  .code-block-chrome {
    padding: 6px 12px;
  }

  /* Mermaid diagrams scroll horizontally instead of squashing. */
  .mermaid-block {
    padding: 16px 14px;
    justify-content: flex-start;
  }
  .mermaid-block > svg,
  .mermaid-block .mermaid-scroll {
    min-width: 0;
    max-width: 100%;
  }

  /* Home hero. */
  .home-hero {
    padding: 36px 0 18px;
  }
  .home-h1 {
    font-size: clamp(36px, 9vw, 52px);
    margin-bottom: 18px;
  }
  .home-sub {
    font-size: 16px;
    margin-bottom: 22px;
  }
  .home-cta-row {
    gap: 8px;
  }
  .home-cta-row .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .home-meta {
    gap: 14px;
    row-gap: 8px;
  }

  /* Layer grid 3 → 2 then 1; agent grid 6 → 2. */
  .layer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .agent-card {
    padding: 16px;
  }
  .agent-card p,
  .agent-card-meta {
    overflow-wrap: anywhere;
  }

  /* Stat grid 6 → 3. */
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .stat-cell {
    padding: 14px;
  }
  .stat-cell-num {
    font-size: clamp(22px, 6vw, 28px);
  }

  /* CTA strip stacks vertically. */
  .cta-strip {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px 22px;
    gap: 18px;
    margin-top: 48px;
  }
  .cta-strip .btn {
    width: 100%;
    justify-content: center;
  }

  /* Page footer stacks. */
  .page-footer {
    grid-template-columns: 1fr;
  }
  .page-footer-link.next {
    text-align: left;
  }

  /* Footer columns 4 → 2 → and brand spans full width. */
  .docs-footer {
    padding: 36px 0 24px;
    margin-top: 56px;
  }
  .docs-footer-inner {
    grid-template-columns: 1fr 1fr;
    padding: 0 18px;
    gap: 24px;
  }
  .docs-footer-inner > div:first-child {
    grid-column: 1 / -1;
  }
  .docs-footer-legal {
    padding: 18px 18px 0;
    flex-direction: column;
    gap: 8px;
  }

  /* Mini-graph teaser. */
  .mini-graph {
    min-height: 0;
    aspect-ratio: auto;
    height: clamp(280px, 55vw, 420px);
  }
  .mini-graph-overlay {
    padding: 14px 16px;
  }

  /* Graph overlay (full viewport on small screens). */
  .graph-header {
    padding: 12px 14px;
    gap: 10px;
  }
  .graph-title {
    font-size: 14px;
  }
  .graph-subtitle {
    display: none;
  }
  .graph-legend {
    left: 12px;
    bottom: 12px;
    padding: 10px 12px;
    font-size: 11px;
    max-width: calc(100vw - 24px);
  }

  /* Permalink anchors: hide for h1 always; reveal for h2/h3 on touch. */
  .article h1 .heading-anchor {
    display: none;
  }
  .article h2 .heading-anchor,
  .article h3 .heading-anchor {
    opacity: 0.55;
    font-size: 0.6em;
    margin-left: 6px;
  }

  /* Tag chips: ensure adequate tap target. */
  .tag-chip {
    height: 28px;
    padding: 0 12px;
    font-size: 11.5px;
  }
}

/* ---------------------------------------------------------
   sm  ≤ 480px — small phones.
   --------------------------------------------------------- */
@media (max-width: 480px) {
  .topnav {
    height: 54px;
  }
  .topnav-inner {
    padding: 0 10px;
    gap: 6px;
  }
  /* On very small screens the brand label drops; only the mark remains. */
  .brand-name {
    display: none;
  }

  .content {
    padding: 20px 14px 48px;
  }
  .content-wide {
    padding: 16px 14px 48px;
  }

  .home-hero {
    padding: 28px 0 12px;
  }
  .home-h1 {
    font-size: clamp(32px, 10vw, 40px);
    line-height: 1.05;
  }
  .home-sub {
    font-size: 15px;
  }
  .home-cta-row {
    flex-direction: column;
  }
  .home-cta-row .btn {
    width: 100%;
  }

  .layer-grid,
  .agent-grid {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .article h1 {
    font-size: clamp(26px, 8vw, 32px);
  }
  .article h2 {
    font-size: 20px;
    margin: 32px 0 10px;
  }

  /* Footer collapses to a single column on phones. */
  .docs-footer-inner {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .docs-footer-inner > div:first-child {
    grid-column: auto;
  }

  /* Search dropdown anchored to input, full viewport width minus gutter. */
  .search-results {
    left: -10px;
    right: -10px;
    max-width: calc(100vw - 20px);
    border-radius: 10px;
  }

  /* Mini-graph minimum sane height on tiny screens. */
  .mini-graph {
    height: clamp(240px, 70vw, 320px);
  }

  /* Tag chips wrap freely; keep tap-friendly height. */
  .tag-chips {
    gap: 6px;
  }

  /* Callouts breathe a bit less. */
  .callout {
    padding: 14px 14px;
    gap: 10px;
  }
}

/* ---------------------------------------------------------
   Pointer / hover capability — keep lift+shadow only where it makes sense.
   --------------------------------------------------------- */
@media (hover: hover) {
  /* No-op: hover styles defined above already apply on these devices. */
}

@media (hover: none) {
  /* On touch devices, suppress the lift transforms that "stick" after tap. */
  .layer-card:hover,
  .agent-card:hover,
  .btn-primary:hover,
  .page-footer-link:hover,
  .mini-graph:hover {
    transform: none;
  }
  /* Permalink anchors are always visible on touch (no hover to reveal them). */
  .article h2 .heading-anchor,
  .article h3 .heading-anchor {
    opacity: 0.5;
  }
  /* Ensure all interactive buttons meet the 44px tap target. */
  .btn {
    min-height: 44px;
  }
  .nav-pill {
    min-height: 36px;
  }
  .mobile-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ---------------------------------------------------------
   Print — useful for thesis annex export.
   --------------------------------------------------------- */
@media print {
  body {
    background: #ffffff;
    color: #000000;
  }
  body::before,
  body::after {
    display: none !important;
  }
  .topnav,
  .sidebar,
  .sidebar-backdrop,
  .toc,
  .docs-footer,
  .page-footer,
  .graph-overlay,
  .mobile-toggle,
  .nav-right,
  .home-cta-row,
  .cta-strip,
  .mini-graph {
    display: none !important;
  }
  .shell,
  .shell-no-toc,
  .shell-wide {
    display: block;
    max-width: none;
    margin: 0;
  }
  .content,
  .content-wide {
    padding: 0 !important;
    max-width: none;
  }
  .article h1,
  .article h2,
  .article h3,
  .article h4,
  .article p,
  .article li,
  .article strong,
  .article em {
    color: #000000 !important;
    background: none !important;
    -webkit-text-fill-color: #000000 !important;
  }
  .article a {
    color: #000000 !important;
    text-decoration: underline;
    border-bottom: 0 !important;
  }
  .article :not(pre) > code,
  .code-block,
  .mermaid-block,
  .callout,
  .article blockquote,
  .article table {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
  }
  .article table th,
  .article table td {
    color: #000000 !important;
  }
  /* Avoid awkward page breaks inside code/tables/figures. */
  .code-block,
  .mermaid-block,
  .article table,
  .callout,
  figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
