/* =================================================================
   coordinatetransformation.org — site styles
   Light, professional, geodetic palette. Mobile-first, wide on desktop.
   ================================================================= */

/* ---------------------------------------------------------- tokens */
:root {
  --teal-900: #134e5a;
  --teal-800: #155e75;
  --teal-700: #0e7490;
  --teal-600: #0891b2;
  --teal-100: #d7eef3;
  --teal-50:  #ecf7fa;

  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-100: #dbe5ff;

  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --orange-500: #f97316;
  --green-600: #15803d;
  --purple-600: #9333ea;
  --red-600: #cf222e;

  --ink:      #16252c;
  --ink-soft: #33474f;
  --muted:    #5b6b73;
  --faint:    #8595a0;

  --bg:       #f4f8fa;
  --bg-tint:  #eef4f7;
  --surface:  #ffffff;
  --surface-2:#f6fafc;
  --border:   #dbe6ea;
  --border-strong: #c4d6dc;

  --code-bg:  #f1f7f9;
  --code-border: #d7e6eb;
  --inline-bg: #e8f2f5;

  --shadow-sm: 0 1px 2px rgba(16, 47, 58, .06), 0 1px 3px rgba(16, 47, 58, .08);
  --shadow-md: 0 6px 18px rgba(16, 47, 58, .08), 0 2px 6px rgba(16, 47, 58, .06);
  --shadow-lg: 0 18px 40px rgba(16, 47, 58, .12), 0 6px 14px rgba(16, 47, 58, .08);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --header-h: 66px;

  --container: 1240px;
  --container-wide: 1440px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Source Code Pro", Menlo, Consolas, "Liberation Mono", monospace;

  --grad-brand: linear-gradient(135deg, var(--teal-800), var(--teal-700) 45%, var(--blue-600));
}

/* ---------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.25rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

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

img, svg { display: block; max-width: 100%; }
svg { height: auto; }

a { color: var(--teal-700); text-decoration: none; transition: color .18s ease; }
a:hover { color: var(--blue-700); }

:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--teal-100); color: var(--teal-900); }

/* ---------------------------------------------------------- layout */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 0.4rem + 3vw, 2.5rem);
}
@media (min-width: 1600px) {
  .container { max-width: var(--container-wide); }
}

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

.skip-link {
  position: absolute;
  left: 0; top: -100px;
  background: var(--teal-700);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* ---------------------------------------------------------- icons */
.icon {
  width: 1.2em; height: 1.2em;
  flex: 0 0 auto;
  vertical-align: -0.18em;
}

/* ---------------------------------------------------------- header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  font-weight: 700;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}
.brand:hover .brand-mark { transform: translateY(-1px) rotate(-3deg); box-shadow: var(--shadow-md); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.06rem; letter-spacing: -0.01em; }
.brand-sub { font-size: .72rem; font-weight: 500; color: var(--muted); letter-spacing: .01em; }

.primary-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0;
}
.primary-nav a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .85rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.primary-nav a .icon { color: var(--teal-600); transition: color .18s ease; }
.primary-nav a:hover {
  background: var(--teal-50);
  color: var(--teal-800);
  border-color: var(--teal-100);
}
.primary-nav a.is-active {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.primary-nav a.is-active .icon { color: #fff; }

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

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute;
    left: 0; right: 0;
    top: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease;
  }
  .primary-nav.open { max-height: 70vh; }
  .primary-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
    padding: .75rem clamp(1rem, 0.4rem + 3vw, 2.5rem) 1.1rem;
  }
  .primary-nav a { justify-content: flex-start; padding: .75rem .9rem; border-radius: 12px; }
}

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1.15rem;
  border-radius: 999px;
  font-weight: 650;
  font-size: .98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { color: #fff; box-shadow: var(--shadow-lg); }

.btn-secondary {
  background: var(--surface);
  color: var(--teal-800);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--teal-600); color: var(--teal-800); box-shadow: var(--shadow-md); }

.btn-ghost {
  background: var(--teal-50);
  color: var(--teal-800);
  border-color: var(--teal-100);
}
.btn-ghost:hover { background: var(--teal-100); color: var(--teal-900); }

/* Colorful icon chip so glyphs stay vivid on any button */
.cta-icon {
  width: 1.55em; height: 1.55em;
  padding: .32em;
  background: #fff;
  border-radius: 9px;
  box-shadow: 0 1px 2px rgba(16,47,58,.12);
}
.cta-teal  { color: var(--teal-700); }
.cta-blue  { color: var(--blue-600); }
.cta-amber { color: var(--orange-500); }

/* ---------------------------------------------------------- hero */
.hero {
  background:
    radial-gradient(1100px 480px at 78% -8%, var(--teal-50), transparent 60%),
    radial-gradient(900px 420px at 10% 0%, var(--blue-100), transparent 55%),
    linear-gradient(180deg, #ffffff, var(--bg));
  border-bottom: 1px solid var(--border);
  padding-block: clamp(2.5rem, 1.5rem + 5vw, 5.5rem);
}
.hero-inner { text-align: center; }
.hero-logo {
  width: clamp(120px, 12vw, 176px);
  height: auto;
  margin: 0 auto 1.6rem;
  filter: drop-shadow(0 14px 28px rgba(16, 47, 58, .22));
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
}
.hero-logo:hover { transform: translateY(-4px) scale(1.02); }
.hero-title {
  font-size: clamp(1.9rem, 1.2rem + 3.4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 800;
  color: var(--ink);
  max-width: 20ch;
  margin-inline: auto;
}
.hero-title .accent {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead {
  margin: 1.4rem auto 0;
  max-width: 65ch;
  font-size: clamp(1.06rem, 1rem + 0.45vw, 1.28rem);
  color: var(--ink-soft);
}
.hero-text {
  margin: 1rem auto 0;
  max-width: 72ch;
  color: var(--muted);
}
.hero-cta {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .85rem;
}

/* ---------------------------------------------------------- sections / cards */
.section { padding-block: clamp(2.5rem, 1.6rem + 4vw, 4.5rem); }
.section-head { max-width: 60ch; margin-bottom: 2rem; }
.section-title {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.section-sub { margin-top: .6rem; color: var(--muted); font-size: 1.08rem; }

.cluster { margin-top: 2.5rem; }
.cluster:first-of-type { margin-top: 0; }
.cluster-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1.1rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}
.cluster-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 50px; height: 50px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.cluster-icon .icon { width: 1.6em; height: 1.6em; }
.cluster-title { font-size: 1.35rem; letter-spacing: -0.015em; }
.cluster-title a { color: var(--ink); }
.cluster-title a:hover { color: var(--teal-700); }
.cluster-desc { margin-top: .35rem; color: var(--muted); max-width: 80ch; }

.card-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  height: 100%;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--grad-brand);
  opacity: 0;
  transition: opacity .2s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal-100);
  color: var(--ink);
}
.card:hover::before { opacity: 1; }
.card-title { font-weight: 700; font-size: 1.06rem; letter-spacing: -0.01em; line-height: 1.3; }
.card-desc { color: var(--muted); font-size: .94rem; flex: 1 0 auto; }
.card-cta {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .25rem;
  color: var(--teal-700);
  font-weight: 650;
  font-size: .92rem;
}
.card-cta .icon { transition: transform .2s ease; }
.card:hover .card-cta .icon { transform: translateX(4px); }

/* ---------------------------------------------------------- page layout */
.page-layout { padding-block: 1.75rem clamp(3rem, 2rem + 4vw, 5rem); }

/* breadcrumbs */
.breadcrumbs ol {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem .15rem;
  font-size: .9rem;
  color: var(--muted);
}
.breadcrumb-item { display: inline-flex; align-items: center; }
.breadcrumbs a { color: var(--muted); font-weight: 600; padding: .15rem .25rem; border-radius: 6px; }
.breadcrumbs a:hover { color: var(--teal-700); background: var(--teal-50); }
.breadcrumbs [aria-current="page"] { color: var(--ink-soft); font-weight: 700; padding: .15rem .25rem; }
.crumb-sep { width: .85em; height: .85em; color: var(--faint); margin-inline: .1rem; }

/* ---------------------------------------------------------- prose */
.prose {
  margin-top: 1.5rem;
  font-size: 1.06rem;
  color: var(--ink-soft);
}
.prose > * + * { margin-top: 1.15rem; }

.prose h1 {
  font-size: clamp(1.85rem, 1.3rem + 2.4vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 800;
  color: var(--ink);
  margin-top: .25rem;
}
.prose h1 {
  background: linear-gradient(120deg, var(--teal-800), var(--teal-600) 55%, var(--blue-600));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.3vw, 1.95rem);
  letter-spacing: -0.018em;
  color: var(--ink);
  margin-top: 2.4rem;
  padding-top: .4rem;
  font-weight: 750;
}
.prose h2::after {
  content: "";
  display: block;
  width: 3.2rem; height: 3px;
  margin-top: .55rem;
  border-radius: 3px;
  background: var(--grad-brand);
}
.prose h3 {
  font-size: clamp(1.18rem, 1rem + 0.7vw, 1.45rem);
  color: var(--teal-800);
  margin-top: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.prose h4 { font-size: 1.12rem; color: var(--ink); margin-top: 1.4rem; font-weight: 700; }

/* Anchor offset is handled once via html { scroll-padding-top } — do not also
   set scroll-margin-top here, or the two values add and overshoot. */

/* Body text fills the (centered, capped) container width on desktop —
   wide, not a narrow column — per the site spec. */
.prose p, .prose ul, .prose ol, .prose blockquote { max-width: none; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .4rem; }
.prose li::marker { color: var(--teal-600); }

.prose a:not(.btn) {
  color: var(--blue-700);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--teal-100);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color .18s ease, text-decoration-color .18s ease, background .18s ease;
  border-radius: 3px;
}
.prose a:not(.btn):hover {
  color: var(--teal-800);
  text-decoration-color: var(--teal-600);
  background: var(--teal-50);
}
.prose a.btn-primary, .prose a.btn-primary:hover { color: #fff; }

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

.prose blockquote {
  border-left: 4px solid var(--teal-600);
  background: var(--surface-2);
  padding: .9rem 1.2rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin-block: 2.2rem; }

/* heading anchor links */
.heading-anchor {
  margin-left: .45rem;
  color: var(--faint);
  font-weight: 600;
  opacity: 0;
  text-decoration: none;
  transition: opacity .15s ease, color .15s ease;
}
.heading-anchor:hover { color: var(--teal-700); background: none; }
.prose :is(h2, h3, h4):hover .heading-anchor { opacity: 1; }

/* ---------------------------------------------------------- inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--inline-bg);
  color: var(--teal-900);
  padding: .14em .42em;
  border-radius: 6px;
  border: 0;
  white-space: break-spaces;
  word-break: break-word;
}
.prose a code { color: inherit; background: var(--teal-50); }

/* ---------------------------------------------------------- code blocks */
.code-block {
  position: relative;
  margin-block: 1.6rem;
  max-width: 100%;
}
.prose pre[class*="language-"],
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .9rem;
  line-height: 1.62;
  color: #233840;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
  tab-size: 4;
}
.prose pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
  color: inherit;
  white-space: pre;
}
.code-block pre { margin: 0; }

.copy-btn {
  position: absolute;
  top: .6rem;
  right: .6rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .6rem;
  font-size: .78rem;
  font-weight: 650;
  font-family: var(--font-sans);
  color: var(--teal-800);
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .16s ease, transform .16s ease, background .16s ease, color .16s ease;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; transform: translateY(0); }
.copy-btn:hover { background: #fff; color: var(--teal-900); border-color: var(--teal-600); }
.copy-btn .icon { width: 1em; height: 1em; }
.copy-btn.is-copied { color: var(--green-600); border-color: var(--green-600); }
@media (hover: none) {
  .copy-btn { opacity: 1; transform: none; }
}

/* Prism token theme — light, harmonised with the palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6b8893; font-style: italic; }
.token.punctuation { color: #51707c; }
.token.namespace { opacity: .7; }
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted { color: var(--red-600); }
.token.boolean, .token.number { color: #b45309; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: var(--green-600); }
.token.operator, .token.entity, .token.url { color: #51707c; }
.token.atrule, .token.attr-value, .token.keyword { color: var(--teal-700); font-weight: 600; }
.token.function, .token.class-name { color: var(--blue-600); }
.token.regex, .token.important, .token.variable { color: var(--purple-600); }
.token.decorator, .token.annotation { color: var(--purple-600); }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* ---------------------------------------------------------- tables */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-block: 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: .94rem;
}
.table-scroll th, .table-scroll td {
  padding: .7rem .95rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-scroll thead th {
  background: var(--teal-50);
  color: var(--teal-900);
  font-weight: 700;
  position: sticky;
  top: 0;
}
.table-scroll tbody tr:nth-child(even) { background: var(--surface-2); }
.table-scroll tbody tr:hover { background: var(--teal-50); }
.table-scroll td code { white-space: nowrap; }

/* ---------------------------------------------------------- task lists */
.contains-task-list { list-style: none; padding-left: 0; }
.task-list-item { display: flex; align-items: flex-start; gap: .6rem; }
.task-list-item-checkbox,
.task-list-item input[type="checkbox"] {
  width: 1.15em; height: 1.15em;
  margin-top: .28em;
  accent-color: var(--teal-700);
  cursor: pointer;
  flex: 0 0 auto;
}
.task-list-item label { cursor: pointer; }
.task-list-item.is-checked,
.task-list-item input[type="checkbox"]:checked ~ label,
.task-list-item input[type="checkbox"]:checked + label {
  text-decoration: line-through;
  color: var(--faint);
}

/* ---------------------------------------------------------- FAQ accordions */
.faq { margin-block: 1.5rem; }
details.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-top: .75rem;
  overflow: hidden;
}
details.faq-item + details.faq-item { margin-top: .65rem; }
details.faq-item > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  font-weight: 650;
  color: var(--ink);
}
details.faq-item > summary::-webkit-details-marker { display: none; }
details.faq-item > summary::after {
  content: "";
  width: .7rem; height: .7rem;
  border-right: 2.5px solid var(--teal-600);
  border-bottom: 2.5px solid var(--teal-600);
  transform: rotate(45deg);
  transition: transform .2s ease;
  flex: 0 0 auto;
}
details.faq-item[open] > summary::after { transform: rotate(225deg); }
details.faq-item > summary:hover { color: var(--teal-800); background: var(--teal-50); }
.faq-body { padding: 0 1.15rem 1.15rem; color: var(--ink-soft); }

/* ---------------------------------------------------------- KaTeX */
.katex { font-size: 1.04em; }
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: .35rem;
  max-width: 100%;
}
.katex-display > .katex { white-space: nowrap; }

/* ---------------------------------------------------------- mermaid */
.mermaid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-block: 1.6rem;
  text-align: center;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.mermaid:not([data-processed]) { color: transparent; min-height: 2rem; }
.mermaid svg { display: block; margin-inline: auto; max-width: 100%; height: auto; }

/* ---------------------------------------------------------- related nav */
.related {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.related-block + .related-block { margin-top: 2rem; }
.related-heading {
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}
.link-list { list-style: none; padding: 0; display: grid; gap: .5rem; }
.link-list a {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.link-list a .icon { color: var(--teal-600); transition: transform .18s ease; }
.link-list a:hover { background: var(--teal-50); color: var(--teal-800); }
.link-list a:hover .icon { transform: translateX(3px); }

/* ---------------------------------------------------------- footer */
.site-footer {
  flex-shrink: 0;
  margin-top: 4rem;
  background: linear-gradient(180deg, var(--bg-tint), #e7eff2);
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: grid;
  grid-template-columns: 1.4fr 2.6fr;
  gap: 2.5rem;
  padding-block: 3rem 2.5rem;
}
.footer-brand .brand { margin-bottom: .9rem; }
.footer-brand .brand-name { font-size: 1.1rem; }
.footer-tagline { color: var(--muted); max-width: 34ch; }
.footer-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.75rem;
}
.footer-col-title {
  display: block;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .7rem;
  font-size: .98rem;
}
a.footer-col-title:hover { color: var(--teal-700); }
.footer-col ul { list-style: none; padding: 0; display: grid; gap: .45rem; }
.footer-col a { color: var(--muted); font-size: .92rem; }
.footer-col a:hover { color: var(--teal-700); }
.footer-bar {
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.4);
}
.footer-bar p {
  padding-block: 1.1rem;
  color: var(--faint);
  font-size: .85rem;
}

@media (max-width: 720px) {
  .footer-inner { grid-template-columns: 1fr; gap: 1.75rem; }
}

/* ---------------------------------------------------------- on-page TOC */
.page-grid { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
/* Allow flex/grid children to shrink so wide diagrams/code scroll internally
   instead of forcing horizontal page overflow. */
.page-grid > * { min-width: 0; max-width: 100%; }
.toc-wrap { margin-block: .5rem; }
@media (max-width: 1023px) {
  .toc-wrap { order: -1; }  /* TOC above content on small screens */
}
.toc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: .4rem 1rem 1rem;
}
.toc-title {
  margin: 0 0 .5rem;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .15rem; }
.toc li { line-height: 1.35; }
.toc-l3 a { padding-left: 1.4rem; font-size: .88rem; }
.toc a {
  display: block;
  padding: .3rem .5rem;
  border-radius: 7px;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 600;
  border-left: 2px solid transparent;
}
.toc a:hover { background: var(--teal-50); color: var(--teal-800); }
.toc a.toc-active {
  color: var(--teal-800);
  background: var(--teal-50);
  border-left-color: var(--teal-600);
}

@media (min-width: 1024px) {
  .page-grid.has-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 248px;
    gap: 2.5rem;
    align-items: start;
  }
  .toc-wrap { margin-block: 0; }
  .toc {
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
    max-height: calc(100vh - var(--header-h) - 3rem);
    overflow-y: auto;
  }
}

/* ---------------------------------------------------------- figure captions */
.prose .mermaid + p,
.prose .table-scroll + p em:only-child {
  text-align: center;
}
.prose .mermaid + p {
  margin-top: .6rem;
  font-size: .88rem;
  color: var(--muted);
  text-align: center;
}
.prose .mermaid + p em { font-style: italic; }

/* ---------------------------------------------------------- back to top */
.to-top {
  position: fixed;
  right: clamp(1rem, 2vw, 2rem);
  bottom: clamp(1rem, 2vw, 2rem);
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--teal-700);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease, background .2s ease, color .2s ease;
  z-index: 90;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: var(--teal-700); color: #fff; border-color: var(--teal-700); }
.to-top .icon { width: 1.3em; height: 1.3em; transform: rotate(-90deg); }
