/* =====================================================================
   Geospatial Data Observability — stylesheet
   Light, elegant, professional. Mobile-first, wide on desktop.
   ===================================================================== */

:root {
  /* Brand palette */
  --brand: #0d9488;          /* teal-600 */
  --brand-strong: #0f766e;   /* teal-700 */
  --brand-2: #2563eb;        /* blue-600 */
  --brand-3: #1d4ed8;        /* blue-700 */
  --accent: #f59e0b;         /* amber-500 */
  --brand-soft: #ccfbf1;     /* teal-100 */
  --brand-soft-2: #dbeafe;   /* blue-100 */

  /* Icon accent colours */
  --ico-teal: #0d9488;
  --ico-blue: #2563eb;
  --ico-green: #059669;
  --ico-violet: #7c3aed;
  --ico-amber: #d97706;
  --ico-rose: #e11d48;

  /* Neutrals */
  --ink: #1e293b;            /* slate-800 */
  --ink-soft: #475569;       /* slate-600 */
  --muted: #64748b;          /* slate-500 */
  --line: #e6ecf3;
  --line-strong: #cbd5e1;

  /* Surfaces */
  --bg: #f6f9fc;
  --bg-tint: radial-gradient(1200px 600px at 80% -10%, #e6fbf6 0%, rgba(230,251,246,0) 60%),
             radial-gradient(1000px 500px at 0% 0%, #e8f0fe 0%, rgba(232,240,254,0) 55%);
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --code-bg: #f6f8fd;
  --inline-code-bg: #eef2f9;

  /* Shape */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(13, 148, 136, 0.16);

  /* Layout */
  --container: 1180px;
  --container-wide: 1320px;
  --header-h: 64px;

  /* Type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (min-width: 768px) {
  :root { --header-h: 72px; }
}
@media (min-width: 1600px) {
  :root { --container: var(--container-wide); }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--bg);
  background-image: var(--bg-tint);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; vertical-align: middle; }
.site-main { flex: 1 0 auto; }

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}
@media (min-width: 768px) {
  .container { width: min(100% - 3rem, var(--container)); }
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--brand-3); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

:where(a, button, input, summary):focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Icon colour helpers ---------- */
.ico { display: inline-block; }
.ico-teal { color: var(--ico-teal); }
.ico-blue { color: var(--ico-blue); }
.ico-green { color: var(--ico-green); }
.ico-violet { color: var(--ico-violet); }
.ico-amber { color: var(--ico-amber); }
.ico-rose { color: var(--ico-rose); }

/* =====================================================================
   Header
   ===================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: inline-flex; align-items: center; gap: 0.65rem; color: var(--ink); }
.brand__mark { transition: transform 0.25s ease, filter 0.25s ease; }
.brand:hover .brand__mark { transform: rotate(-6deg) scale(1.06); filter: drop-shadow(0 4px 10px rgba(13,148,136,0.35)); }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--brand-strong), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand__sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }

.primary-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.nav-link__icon { display: inline-flex; color: var(--muted); transition: color 0.2s ease; }
.nav-link:hover {
  color: var(--brand-strong);
  background: var(--surface);
  border-color: var(--line);
  transform: translateY(-1px);
}
.nav-link:hover .nav-link__icon { color: var(--brand); }
.nav-link.is-active {
  color: var(--brand-strong);
  background: linear-gradient(180deg, var(--brand-soft), #e9fbf6);
  border-color: rgba(13, 148, 136, 0.25);
}
.nav-link.is-active .nav-link__icon { color: var(--brand); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle .ico--close { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .primary-nav ul { flex-direction: column; align-items: stretch; gap: 0.25rem; padding: 0.75rem; }
  .nav-link { justify-content: flex-start; border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; }
  .site-header.nav-open .primary-nav { max-height: 70vh; }
  .site-header.nav-open .nav-toggle .ico--menu { display: none; }
  .site-header.nav-open .nav-toggle .ico--close { display: inline-flex; }
}

/* =====================================================================
   Homepage
   ===================================================================== */
.hero { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3.5rem); }
.hero__inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
.hero__logo {
  width: clamp(120px, 22vw, 168px);
  filter: drop-shadow(0 18px 40px rgba(13, 148, 136, 0.28));
  transition: transform 0.4s ease;
}
.hero__logo:hover { transform: translateY(-6px) scale(1.03) rotate(2deg); }
.hero__title {
  margin: 1.25rem 0 0;
  font-size: clamp(2rem, 1.3rem + 3.4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--ink);
}
.hero__title span {
  background: linear-gradient(90deg, var(--brand), var(--brand-2) 60%, var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__lead {
  margin: 1.1rem auto 0;
  max-width: 60ch;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.28rem);
  color: var(--ink-soft);
  font-weight: 500;
}
.hero__text { margin: 0.9rem auto 0; max-width: 72ch; color: var(--ink-soft); }

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 2rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1.3rem;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn__icon {
  display: inline-flex;
  background: #fff;
  border-radius: 50%;
  padding: 0.35rem;
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn__go { display: inline-flex; transition: transform 0.2s ease; opacity: 0.8; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn:hover .btn__go { transform: translateX(4px); }
.btn--primary {
  background: linear-gradient(180deg, #0fb5a4, var(--brand));
  color: #fff;
}
.btn--secondary {
  background: linear-gradient(180deg, #3b82f6, var(--brand-2));
  color: #fff;
}

/* Sections */
.sections, .workflows { padding: clamp(2rem, 5vw, 4rem) 0; }
.workflows { background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.6) 100%); }
.section-heading {
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.1rem);
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0;
  color: var(--ink);
}
.section-intro { text-align: center; max-width: 60ch; margin: 0.6rem auto 2rem; color: var(--muted); }

.card-grid { display: grid; gap: 1.25rem; }
.card-grid--2 { grid-template-columns: 1fr; }
.card-grid--3 { grid-template-columns: 1fr; }
@media (min-width: 680px) { .card-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) {
  .card-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .card-grid--3 { grid-template-columns: repeat(3, 1fr); }
}

.pillar-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform 0.22s ease, box-shadow 0.3s ease, border-color 0.22s ease;
}
.pillar-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(13,148,136,0.3); }
.pillar-card__icon {
  display: inline-flex;
  width: 56px; height: 56px;
  align-items: center; justify-content: center;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--brand-soft), #eafbf6);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,0.18);
}
.pillar-card__title { margin: 0.3rem 0 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.pillar-card__desc { margin: 0; color: var(--ink-soft); }
.pillar-card__links { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.pillar-card__links li { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.92rem; }
.pillar-card__links .ico { color: var(--brand); flex: none; }
.pillar-card__cta {
  margin-top: auto;
  padding-top: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--brand-strong);
}
.pillar-card:hover .pillar-card__cta .ico { transform: translateX(4px); }
.pillar-card__cta .ico { transition: transform 0.2s ease; }

.workflow-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.28s ease, border-color 0.2s ease;
}
.workflow-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.workflow-card__icon {
  flex: none;
  display: inline-flex;
  width: 46px; height: 46px;
  align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.workflow-card__body { display: flex; flex-direction: column; }
.workflow-card__title { font-weight: 700; }
.workflow-card__desc { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
.workflow-card__go { margin-left: auto; color: var(--muted); transition: transform 0.2s ease, color 0.2s ease; }
.workflow-card:hover .workflow-card__go { transform: translateX(4px); color: var(--brand); }

/* =====================================================================
   Article / content page
   ===================================================================== */
.page { padding: 1.5rem 0 3rem; }

.breadcrumbs { margin: 0.25rem 0 1.25rem; font-size: 0.88rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0; padding: 0; }
.breadcrumbs__item { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--brand-strong); }
.breadcrumbs__sep { display: inline-flex; color: var(--line-strong); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 700; }

.article__header { margin-bottom: 1.5rem; }
.article__title {
  font-size: clamp(1.8rem, 1.3rem + 2.4vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 800;
  background: linear-gradient(120deg, var(--brand-strong), var(--brand-2) 55%, #4f46e5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article__header::after {
  content: "";
  display: block;
  width: 84px;
  height: 4px;
  margin-top: 1rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

/* Prose typography — wide, uses full container width on desktop */
.prose { color: var(--ink); }
.prose > * + * { margin-top: 1.15rem; }
.prose h2, .prose h3, .prose h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h2 {
  margin-top: 2.5rem;
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.85rem);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
.prose h2::before {
  content: "";
  display: inline-block;
  width: 0.55rem; height: 1.05rem;
  margin-right: 0.6rem;
  vertical-align: -0.1rem;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}
.prose h3 { margin-top: 2rem; font-size: clamp(1.2rem, 1.1rem + 0.6vw, 1.45rem); color: var(--brand-strong); }
.prose h4 { margin-top: 1.6rem; font-size: 1.12rem; color: var(--ink); }

.prose p { margin: 0; }
.prose :is(h2, h3, h4) + p { margin-top: 0.75rem; }

.prose a { font-weight: 600; text-decoration: underline; text-decoration-color: rgba(37, 99, 235, 0.35); text-underline-offset: 3px; text-decoration-thickness: 1.5px; transition: color 0.18s ease, text-decoration-color 0.18s ease; }
.prose a:hover { color: var(--brand-3); text-decoration-color: var(--brand-3); }

.prose ul, .prose ol { margin: 0; padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35rem; }
.prose li::marker { color: var(--brand); }

.prose blockquote {
  margin: 0;
  padding: 0.6rem 1.1rem;
  border-left: 4px solid var(--brand);
  background: linear-gradient(90deg, var(--brand-soft), rgba(204,251,241,0));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2rem 0; }

.prose strong { font-weight: 700; color: var(--ink); }

/* Anchored headers (markdown-it-anchor headerLink) */
.prose .header-anchor { color: inherit; text-decoration: none; }
.prose .header-anchor:hover { color: var(--brand); }

/* Inline code — subtle, borderless, blends with text */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.42em;
  border-radius: 6px;
  background: var(--inline-code-bg);
  color: var(--brand-strong);
  white-space: nowrap;
}

/* =====================================================================
   Code blocks
   ===================================================================== */
.code-block { position: relative; margin-top: 1.15rem; }
.prose pre {
  margin: 1.15rem 0 0;
  padding: 1.1rem 1.2rem;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 2;
}
.code-block pre { margin-top: 0; }
.prose pre code {
  font-family: var(--font-mono);
  background: none;
  padding: 0;
  color: #334155;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s ease, transform 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; transform: translateY(0); }
.copy-btn:hover { color: var(--brand-strong); border-color: var(--brand); }
.code-block.copied .copy-btn { color: #fff; background: var(--brand); border-color: var(--brand); opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* Prism light syntax theme — tuned to the palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #94a3b8; font-style: italic; }
.token.punctuation { color: #64748b; }
.token.namespace { opacity: 0.7; }
.token.tag, .token.property, .token.attr-name, .token.symbol, .token.deleted { color: var(--brand); }
.token.boolean, .token.number, .token.constant, .token.important { color: #b45309; }
.token.selector, .token.string, .token.char, .token.attr-value, .token.builtin, .token.inserted { color: #047857; }
.token.operator, .token.entity, .token.url { color: #475569; }
.token.atrule, .token.keyword { color: var(--brand-2); font-weight: 600; }
.token.function, .token.class-name { color: #7c3aed; }
.token.regex, .token.variable { color: #be123c; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* =====================================================================
   Tables — styled + responsive horizontal scroll
   ===================================================================== */
.table-wrap {
  margin-top: 1.15rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.prose table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.92rem; }
.prose th, .prose td { padding: 0.7rem 0.95rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose thead th {
  background: linear-gradient(180deg, var(--brand-soft), #e9fbf6);
  color: var(--brand-strong);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid rgba(13,148,136,0.25);
}
.prose tbody tr:nth-child(even) { background: #fafcff; }
.prose tbody tr:hover { background: var(--brand-soft); }
.prose td code { white-space: nowrap; }

/* =====================================================================
   Task-list checkboxes — no bullet, togglable, line-through when checked
   ===================================================================== */
.prose ul:has(> .task-list-item) { list-style: none; padding-left: 0.2rem; }
.prose .task-list-item { list-style: none; display: flex; align-items: flex-start; gap: 0.6rem; }
.prose .task-list-item::marker { content: ""; }
.prose .task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.2rem; height: 1.2rem;
  margin-top: 0.18rem;
  flex: none;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.prose .task-list-item input[type="checkbox"]:hover { border-color: var(--brand); }
.prose .task-list-item input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.prose .task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.prose .task-list-item.is-checked { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* =====================================================================
   FAQ accordions (built from FAQ headings by JS)
   ===================================================================== */
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 0.75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.2rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  width: 0.7rem; height: 0.7rem;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex: none;
}
.faq-item[open] summary::after { transform: rotate(-135deg); }
.faq-item summary:hover { color: var(--brand-strong); background: var(--surface-2); }
.faq-item__body { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }

/* =====================================================================
   Mermaid + KaTeX
   ===================================================================== */
pre.mermaid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
pre.mermaid:not([data-processed]) { color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem; }
pre.mermaid svg { max-width: 100%; height: auto; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }
.katex { font-size: 1.05em; }

/* =====================================================================
   "On this page" table of contents
   ===================================================================== */
.toc {
  margin: 0 0 2rem;
  padding: 0.2rem 1.1rem 0.85rem;
  background: linear-gradient(180deg, var(--brand-soft), #eafaf6);
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: var(--radius);
}
.toc > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--brand-strong);
}
.toc > summary::-webkit-details-marker { display: none; }
.toc > summary::after {
  content: "";
  margin-left: auto;
  width: 0.6rem; height: 0.6rem;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.toc[open] > summary::after { transform: rotate(-135deg); }
.toc ul {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  columns: 2;
  column-gap: 1.75rem;
}
@media (max-width: 640px) { .toc ul { columns: 1; } }
.toc li { margin: 0.1rem 0; break-inside: avoid; }
.toc a {
  display: block;
  padding: 0.28rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.toc a:hover { color: var(--brand-strong); background: rgba(255, 255, 255, 0.6); }
.toc a.is-active {
  color: var(--brand-strong);
  border-left-color: var(--brand);
  background: rgba(255, 255, 255, 0.8);
}

/* =====================================================================
   Related content
   ===================================================================== */
.related { margin-top: 3rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.related__group + .related__group { margin-top: 2rem; }
.related__heading { display: flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; margin: 0 0 1rem; color: var(--ink); }
.related__heading .ico { color: var(--brand); }
.related__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
@media (min-width: 760px) { .related__list { grid-template-columns: repeat(2, 1fr); } }
.related__list--compact { grid-template-columns: 1fr; }
@media (min-width: 760px) { .related__list--compact { grid-template-columns: repeat(3, 1fr); } }

.related__card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  height: 100%;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.28s ease, border-color 0.2s ease;
}
.related__card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(13,148,136,0.3); }
.related__title { font-weight: 700; color: var(--brand-strong); }
.related__summary { font-size: 0.88rem; color: var(--muted); line-height: 1.55; }
.related__go { position: absolute; top: 1rem; right: 1rem; color: var(--line-strong); transition: transform 0.2s ease, color 0.2s ease; }
.related__card:hover .related__go { color: var(--brand); transform: translateX(3px); }
.related__card--compact { flex-direction: row; align-items: center; }
.related__card--compact .related__go { position: static; margin-left: auto; }

/* =====================================================================
   Footer — pinned to bottom even on short pages
   ===================================================================== */
.site-footer { flex-shrink: 0; margin-top: 3rem; background: #0c2433; color: #cbd5e1; }
.site-footer__inner {
  display: grid;
  gap: 2rem;
  padding: 2.5rem 0;
}
@media (min-width: 760px) { .site-footer__inner { grid-template-columns: 1.6fr 1fr; } }
.site-footer__brand { display: flex; gap: 1rem; align-items: flex-start; }
.site-footer__mark { border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.site-footer__title { margin: 0 0 0.35rem; font-weight: 700; color: #f8fafc; }
.site-footer__desc { margin: 0; font-size: 0.9rem; color: #94a3b8; max-width: 52ch; line-height: 1.6; }
.site-footer__heading { margin: 0 0 0.75rem; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: #5eead4; }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.site-footer__nav a { display: inline-flex; align-items: center; gap: 0.5rem; color: #cbd5e1; font-weight: 500; }
.site-footer__nav a .ico { color: #5eead4; }
.site-footer__nav a:hover { color: #fff; }
.site-footer__bar { border-top: 1px solid rgba(255,255,255,0.08); padding: 1rem 0; }
.site-footer__bar p { margin: 0; font-size: 0.82rem; color: #7c8ea3; }
