/* =========================================================================
   DuckDB Spatial & Modern Analytical SQL for GIS — site styles
   Light, elegant, professional. Self-hosted. Responsive mobile → widescreen.
   ========================================================================= */

:root {
  /* Palette */
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f7f6;
  --border: #e6e2d8;
  --border-strong: #d6dbd9;

  --text: #1f2933;
  --text-muted: #5b6b78;
  --text-soft: #74808b;

  --teal: #0e7c7b;
  --teal-dark: #0a5f5e;
  --teal-soft: #e4f3f1;
  --indigo: #3f4eb5;
  --indigo-dark: #303c8f;
  --indigo-soft: #eaecf8;
  --amber: #d98012;
  --amber-bright: #f5a524;
  --amber-soft: #fdf1dd;

  --link: #0c6f6e;
  --link-hover: #0a5453;

  /* Code */
  --code-bg: #f3f7f6;
  --code-border: #e0e8e6;
  --inline-code-bg: #eaf3f1;
  --inline-code-text: #0b5f5e;

  /* Metrics */
  --header-h: 64px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 35, 40, 0.06), 0 1px 3px rgba(15, 35, 40, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 45, 50, 0.08), 0 2px 6px rgba(15, 45, 50, 0.06);
  --shadow-lg: 0 18px 48px rgba(15, 45, 50, 0.14);

  --maxw: 1320px;
  --content-maxw: 1180px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", "Cascadia Code",
    Consolas, "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 18px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.site-main { flex: 1 0 auto; width: 100%; }

img { max-width: 100%; height: auto; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--teal);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid rgba(14, 124, 123, 0.45);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { display: inline-block; vertical-align: middle; flex: none; }

/* ============================= Header ============================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 250, 247, 0.86);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 clamp(16px, 4vw, 36px);
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  margin-right: auto;
}
.brand-logo { width: 40px; height: 40px; transition: transform 0.25s ease; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 750; letter-spacing: -0.01em; font-size: 1.05rem; }
.brand-sub { font-size: 0.74rem; color: var(--text-soft); font-weight: 550; }

.primary-nav ul {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.nav-link .icon { color: var(--text-soft); transition: color 0.18s ease; }
.nav-link:hover {
  color: var(--teal-dark);
  background: var(--teal-soft);
}
.nav-link:hover .icon { color: var(--teal); }
.nav-link.is-active {
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-color: rgba(14, 124, 123, 0.25);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 11px;
  color: var(--text);
  cursor: pointer;
}
.nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-flex; }

/* ============================= Footer ============================= */

.site-footer {
  flex-shrink: 0;
  margin-top: 64px;
  background: #0c2b2c;
  color: #cfe3e1;
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 42px clamp(16px, 4vw, 36px);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 36px;
}
.footer-brand { display: flex; gap: 14px; align-items: flex-start; }
.footer-brand img { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3)); }
.footer-name { margin: 0; font-weight: 700; color: #fff; }
.footer-tag { margin: 4px 0 0; color: #9fc1bf; font-size: 0.92rem; }
.footer-heading {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7fa8a5;
}
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-nav a { color: #d7eae8; }
.footer-nav a:hover { color: #fff; text-decoration: underline; }
.footer-base {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px clamp(16px, 4vw, 36px);
  text-align: center;
  font-size: 0.85rem;
  color: #8fb2b0;
}
.footer-base p { margin: 0; }

/* ============================= Hero (home) ============================= */

.hero {
  max-width: var(--content-maxw);
  margin: 0 auto;
  padding: clamp(40px, 7vw, 84px) clamp(16px, 4vw, 36px) clamp(24px, 4vw, 44px);
  text-align: center;
}
.hero-logo {
  display: block;
  margin: 0 auto 26px;
  width: clamp(96px, 16vw, 140px);
  height: auto;
  filter: drop-shadow(0 12px 30px rgba(14, 124, 123, 0.28));
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
.hero-title {
  font-size: clamp(1.85rem, 5.2vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  font-weight: 800;
  overflow-wrap: break-word;
  background: linear-gradient(105deg, var(--teal) 0%, var(--indigo) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead {
  font-size: clamp(1.12rem, 2.3vw, 1.38rem);
  color: var(--text);
  max-width: 56ch;
  margin: 0 auto 18px;
  font-weight: 500;
}
.hero-text {
  color: var(--text-muted);
  max-width: 70ch;
  margin: 0 auto 14px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 30px;
}
.cta {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 13px 20px;
  border-radius: 999px;
  font-weight: 650;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.cta .cta-icon { display: inline-flex; }
.cta .cta-arrow { color: var(--text-soft); transition: transform 0.18s ease; }
.cta:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.cta:hover .cta-arrow { transform: translateX(4px); }
.cta-teal:hover { border-color: var(--teal); color: var(--teal-dark); }
.cta-indigo:hover { border-color: var(--indigo); color: var(--indigo-dark); }
.cta-amber:hover { border-color: var(--amber-bright); color: var(--amber); }

/* ============================= Section cards ============================= */

.sections-overview {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 36px) 20px;
}
.section-head { text-align: center; margin-bottom: 30px; }
.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.section-head p { color: var(--text-muted); margin: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 24px;
}
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px 22px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--teal);
}
.card-teal::before { background: linear-gradient(90deg, #16b3a7, var(--teal)); }
.card-indigo::before { background: linear-gradient(90deg, #5563d6, var(--indigo)); }
.card-amber::before { background: linear-gradient(90deg, var(--amber-bright), var(--amber)); }
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}
.card-icon {
  display: inline-flex;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.card-title { margin: 0 0 8px; font-size: 1.22rem; letter-spacing: -0.01em; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--link-hover); }
.card-blurb { color: var(--text-muted); margin: 0 0 16px; font-size: 0.97rem; }
.card-links {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 7px;
  border-top: 1px dashed var(--border-strong);
  padding-top: 14px;
}
.card-links a {
  color: var(--text-muted);
  font-size: 0.93rem;
  font-weight: 500;
}
.card-links a:hover { color: var(--link); padding-left: 3px; }
.card-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  color: var(--teal-dark);
}
.card-more:hover .icon { transform: translateX(4px); }
.card-more .icon { transition: transform 0.18s ease; }

/* ============================= Doc layout ============================= */

.doc-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 36px) 10px;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 52px);
  align-items: start;
}

.doc-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  padding-right: 6px;
}
.secnav-title { margin: 4px 0 14px; font-weight: 750; font-size: 0.98rem; }
.secnav-title a { color: var(--text); }
.secnav-title a:hover { color: var(--link); }
.secnav-list { list-style: none; margin: 0; padding: 0; }
.secnav-list .secnav-list {
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--border-strong);
}
.secnav-link {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.secnav-link:hover { background: var(--teal-soft); color: var(--teal-dark); }
.secnav-link.is-current {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

.doc-article { min-width: 0; max-width: 920px; }

/* Breadcrumbs */
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  font-size: 0.86rem;
  color: var(--text-soft);
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumbs li:not(:last-child)::after {
  content: "›";
  color: var(--border-strong);
  margin-left: 6px;
}
.breadcrumbs a { color: var(--text-muted); font-weight: 550; }
.breadcrumbs a:hover { color: var(--link); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 650; }

/* Related links */
.related {
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 26px;
}
.related-heading {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-soft);
  margin: 0 0 12px;
}
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.related-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  font-size: 0.94rem;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.related-list a .icon { color: var(--teal); }
.related-list a:hover {
  border-color: var(--teal);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

/* ============================= Doc typography ============================= */

.doc-body { font-size: 1.02rem; }
.doc-body > *:first-child { margin-top: 0; }

.doc-body h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1.14;
  letter-spacing: -0.022em;
  margin: 0 0 22px;
  font-weight: 800;
  background: linear-gradient(100deg, var(--teal) 0%, var(--indigo) 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.doc-body h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.78rem);
  letter-spacing: -0.015em;
  margin: 2.1em 0 0.7em;
  padding-bottom: 0.28em;
  border-bottom: 2px solid var(--teal-soft);
  color: var(--text);
}
.doc-body h3 {
  font-size: 1.24rem;
  margin: 1.7em 0 0.5em;
  color: var(--indigo-dark);
  letter-spacing: -0.01em;
}
.doc-body h4 { font-size: 1.06rem; margin: 1.4em 0 0.4em; color: var(--text); }
.doc-body h2, .doc-body h3, .doc-body h4 { scroll-margin-top: calc(var(--header-h) + 18px); }

.doc-body p { margin: 0 0 1.15em; }
.doc-body strong { font-weight: 700; color: #15212b; }

.doc-body a {
  color: var(--link);
  font-weight: 550;
  text-decoration: underline;
  text-decoration-color: rgba(12, 111, 110, 0.35);
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.doc-body a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}

.doc-body ul, .doc-body ol { margin: 0 0 1.15em; padding-left: 1.45em; }
.doc-body li { margin: 0.35em 0; }
.doc-body li::marker { color: var(--teal); }

.doc-body blockquote {
  margin: 1.3em 0;
  padding: 4px 18px;
  border-left: 4px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
}

.doc-body hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* Heading anchor links */
.heading-anchor {
  color: var(--border-strong);
  text-decoration: none;
  margin-left: 0.4em;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.doc-body h2:hover .heading-anchor,
.doc-body h3:hover .heading-anchor,
.doc-body h4:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--teal); }

/* Inline code */
.doc-body :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 0.13em 0.42em;
  border-radius: 6px;
  word-break: break-word;
}

/* ============================= Code blocks ============================= */

.code-block {
  position: relative;
  margin: 1.4em 0;
}
.doc-body pre[class*="language-"],
.doc-body pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: 18px 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 2;
  color: #243b53;
}
.doc-body pre code {
  font-family: var(--mono);
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 650;
  font-family: var(--font);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; transform: translateY(0); }
.copy-btn:hover { color: var(--teal-dark); border-color: var(--teal); }
.copy-btn.is-copied { color: var(--teal-dark); border-color: var(--teal); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* PrismJS light theme — tuned to the palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7a8893; font-style: italic; }
.token.punctuation { color: #5b6b78; }
.token.property, .token.tag, .token.symbol, .token.deleted { color: #b3261e; }
.token.boolean, .token.number, .token.constant { color: #b9750f; }
.token.selector, .token.string, .token.char, .token.attr-value, .token.inserted,
.token.builtin { color: #0a7d57; }
.token.operator, .token.entity, .token.url { color: var(--teal-dark); }
.token.keyword, .token.atrule, .token.rule { color: #2f47c9; font-weight: 600; }
.token.function, .token.class-name { color: #8a3ffc; }
.token.attr-name, .token.regex, .token.important, .token.variable { color: #0b6b9b; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* ============================= Tables ============================= */

.table-scroll {
  overflow-x: auto;
  margin: 1.4em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
.doc-body table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 0.92rem;
}
.doc-body th, .doc-body td {
  text-align: left;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.doc-body thead th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
.doc-body tbody tr:nth-child(even) { background: rgba(244, 247, 246, 0.55); }
.doc-body tbody tr:hover { background: var(--teal-soft); }
.doc-body td code { white-space: nowrap; }

/* ============================= Task list checkboxes ============================= */

.doc-body ul.contains-task-list,
.doc-body .contains-task-list { list-style: none; padding-left: 0.2em; }
.doc-body li.task-list-item {
  position: relative;
  list-style: none;
  padding-left: 2em;
  margin: 0.5em 0;
}
.doc-body li.task-list-item::marker { content: ""; }
.doc-body li.task-list-item input.task-list-item-checkbox {
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  cursor: pointer;
  accent-color: var(--teal);
}
.doc-body li.task-list-item.is-checked > label,
.doc-body li.task-list-item.is-checked {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--teal);
}

/* ============================= FAQ accordions ============================= */

.doc-body details.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0.7em 0;
  overflow: hidden;
}
.doc-body details.faq-item[open] { box-shadow: var(--shadow-sm); }
.doc-body details.faq-item > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  font-weight: 650;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-body details.faq-item > summary::-webkit-details-marker { display: none; }
.doc-body details.faq-item > summary::before {
  content: "+";
  color: var(--teal);
  font-weight: 800;
  font-size: 1.2em;
  line-height: 1;
  transition: transform 0.2s ease;
}
.doc-body details.faq-item[open] > summary::before { transform: rotate(45deg); }
.doc-body details.faq-item > summary:hover { color: var(--teal-dark); }
.doc-body details.faq-item > *:not(summary) { padding: 0 18px; }
.doc-body details.faq-item > *:last-child { padding-bottom: 14px; }

/* ============================= Mermaid & KaTeX ============================= */

.mermaid-wrap {
  margin: 1.5em 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  text-align: center;
}
.mermaid-wrap pre.mermaid {
  margin: 0;
  background: none;
  border: 0;
  padding: 0;
  visibility: hidden; /* hidden until mermaid renders to avoid raw-source flash */
}
.mermaid-wrap pre.mermaid[data-processed="true"] { visibility: visible; }

.katex { font-size: 1.04em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ============================= Callouts ============================= */

.doc-body .callout {
  margin: 1.4em 0;
  padding: 12px 16px;
  border-left: 4px solid;
  border-radius: 0 10px 10px 0;
}
.doc-body .callout > strong:first-child { font-weight: 750; }
.doc-body .callout-tradeoff {
  background: var(--amber-soft);
  border-color: var(--amber-bright);
}
.doc-body .callout-tradeoff > strong:first-child { color: var(--amber); }
.doc-body .callout-diagnostic {
  background: var(--indigo-soft);
  border-color: var(--indigo);
}
.doc-body .callout-diagnostic > strong:first-child { color: var(--indigo-dark); }

/* ============================= On-this-page TOC ============================= */

.toc { display: none; }
.toc-title {
  margin: 0 0 10px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  font-weight: 700;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 5px 12px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.35;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-list .toc-h3 a { padding-left: 24px; font-size: 0.82rem; }
.toc-list a:hover { color: var(--link); }
.toc-list a.is-active {
  color: var(--teal-dark);
  border-left-color: var(--teal);
  font-weight: 650;
}

/* ============================= Back to top ============================= */

.to-top {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 40;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--teal-dark);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { background: var(--teal-soft); }

/* ============================= Responsive ============================= */

@media (max-width: 1040px) {
  .doc-shell { grid-template-columns: 1fr; }
  .doc-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 8px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .doc-article { max-width: none; }
}

@media (max-width: 820px) {
  body { font-size: 16px; }
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 12px clamp(16px, 4vw, 36px) 18px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .primary-nav.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .primary-nav ul { flex-direction: column; align-items: stretch; gap: 4px; }
  .nav-link { padding: 12px 14px; font-size: 1rem; }
  .footer-inner { grid-template-columns: 1fr; gap: 26px; }
}

/* Very wide screens: reveal the right-rail TOC as a third column. */
@media (min-width: 1500px) {
  :root { --maxw: 1580px; --content-maxw: 1280px; }
  .doc-shell { grid-template-columns: 264px minmax(0, 1fr) 236px; }
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 18px);
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow-y: auto;
    padding-left: 4px;
  }
  .doc-article { max-width: 1000px; }
}
