/* =========================================================================
   UtilityBilling.org — light, elegant, professional theme
   ========================================================================= */
:root {
  /* Palette */
  --bg: #f5f8fb;
  --bg-tint: #eef4fa;
  --surface: #ffffff;
  --ink: #1c2a39;
  --ink-soft: #4d5e70;
  --ink-faint: #6b7c8e;

  --brand: #0b6ba8;
  --brand-dark: #075a8f;
  --accent-blue: #0b6ba8;
  --accent-teal: #0d9488;
  --accent-amber: #f59e0b;
  --accent-green: #22c55e;

  --link: #0b6ba8;
  --link-hover: #064d79;

  --border: #e2eaf2;
  --border-strong: #cdd9e6;

  --code-bg: #f4f7fb;
  --code-border: #e3eaf3;
  --inline-code-bg: rgba(13, 148, 136, 0.10);
  --inline-code-ink: #0f766e;

  /* Metrics */
  --header-h: 66px;
  --container: 1260px;
  --container-wide: 1460px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.05), 0 1px 3px rgba(16, 42, 67, 0.07);
  --shadow-md: 0 6px 20px rgba(16, 42, 67, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 42, 67, 0.14);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Sticky footer */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img, svg { max-width: 100%; }

/* ---- Layout container ---- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2.25rem);
}
@media (min-width: 1500px) {
  .container { max-width: var(--container-wide); }
}

/* ---- Links ---- */
a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--link-hover); }

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

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  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; height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); }
.brand-logo { width: 38px; height: 38px; flex: none; transition: transform .25s ease; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 1.06rem; letter-spacing: -0.01em; }
.brand-dot { color: var(--accent-teal); }
.brand-sub { font-size: .72rem; color: var(--ink-faint); font-weight: 500; }

.primary-nav ul { list-style: none; display: flex; align-items: center; gap: .35rem; margin: 0; padding: 0; }
.nav-link {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border-radius: 999px; color: var(--ink-soft);
  font-weight: 600; font-size: .92rem; transition: background .15s ease, color .15s ease;
}
.nav-icon { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: var(--bg-tint); color: var(--brand); }
.nav-link.is-active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav-link.is-active:hover { color: #fff; }

.nav-toggle {
  display: none; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); border-radius: 10px; padding: .4rem; cursor: pointer; line-height: 0;
}
.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; }

@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: .15rem; padding: .6rem clamp(1rem,3vw,2rem) 1rem; }
  .nav-link { width: 100%; }
}

/* =========================================================================
   Hero (home)
   ========================================================================= */
.hero {
  background:
    radial-gradient(1100px 380px at 12% -10%, rgba(11,107,168,0.10), transparent 60%),
    radial-gradient(900px 360px at 100% 0%, rgba(13,148,136,0.10), transparent 55%),
    var(--bg);
  padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 5vw, 3.5rem);
  text-align: center;
}
.error-code { font-size: clamp(3.5rem, 12vw, 7rem); font-weight: 800; line-height: 1; margin: 0 0 .3rem; background: linear-gradient(120deg, var(--accent-blue), var(--accent-teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-logo { display: block; }              /* logo on its own line */
.hero-logo-mark {
  width: clamp(96px, 16vw, 148px); height: auto; margin: 0 auto .5rem;
  filter: drop-shadow(0 10px 22px rgba(11,107,168,0.28));
  transition: transform .4s ease;
}
.hero-logo-mark:hover { transform: translateY(-4px) rotate(-3deg); }
.hero-logo-mark .logo-needle { transform-box: fill-box; transform-origin: 0% 100%; transition: transform .5s ease; }
.hero-logo-mark:hover .logo-needle { transform: rotate(-18deg); }

.hero-title {
  font-size: clamp(2rem, 4.6vw, 3.25rem); line-height: 1.12; letter-spacing: -0.02em;
  margin: .4rem auto .4rem; max-width: 18ch; font-weight: 800; color: var(--ink);
}
.hero-title .hl {
  background: linear-gradient(120deg, var(--accent-blue), var(--accent-teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede { font-size: clamp(1.05rem, 2vw, 1.3rem); color: var(--ink-soft); font-weight: 500; margin: 0 auto 1.5rem; max-width: 46ch; }
.hero-copy { max-width: 96ch; margin: 0 auto; text-align: left; }
.hero-copy p { margin: 0 0 1rem; color: var(--ink-soft); }

.hero-ctas {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .9rem; margin-top: 2rem;
}
.cta-btn {
  display: inline-flex; align-items: center; gap: .7rem;
  padding: .8rem 1.2rem; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--ink);
  font-weight: 700; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cta-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--cta-accent); color: var(--ink); }
.cta-icon { display: inline-flex; padding: .35rem; border-radius: 10px; background: color-mix(in srgb, var(--cta-accent) 14%, white); }
.cta-icon-svg { width: 24px; height: 24px; }
.cta-arrow { color: var(--cta-accent); display: inline-flex; transition: transform .18s ease; }
.cta-arrow svg { width: 18px; height: 18px; }
.cta-btn:hover .cta-arrow { transform: translateX(4px); }

/* =========================================================================
   Section cards (home)
   ========================================================================= */
.sections { padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(3rem, 6vw, 5rem); }
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0 0 .4rem; }
.section-head p { color: var(--ink-soft); margin: 0; }

.card-grid {
  display: grid; gap: 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}
.section-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.section-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--card-accent);
}
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card-top { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: .7rem; }
.card-icon { display: inline-flex; padding: .55rem; border-radius: 12px; background: color-mix(in srgb, var(--card-accent) 13%, white); flex: none; }
.card-icon-svg { width: 28px; height: 28px; }
.card-title { font-size: 1.18rem; margin: .1rem 0 0; line-height: 1.25; }
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--brand); }
.card-blurb { color: var(--ink-soft); font-size: .96rem; margin: 0 0 1rem; }
.card-links { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: .15rem; }
.card-links a { display: flex; align-items: center; gap: .35rem; padding: .35rem .4rem; border-radius: 8px; color: var(--ink-soft); font-weight: 600; font-size: .92rem; }
.card-links a:hover { background: var(--bg-tint); color: var(--brand); }
.li-chevron { width: 14px; height: 14px; color: var(--card-accent); flex: none; }
.card-more { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--card-accent); }
.card-more svg { width: 18px; height: 18px; transition: transform .18s ease; }
.card-more:hover { color: var(--card-accent); }
.card-more:hover svg { transform: translateX(4px); }

/* =========================================================================
   Breadcrumbs
   ========================================================================= */
.breadcrumbs { padding-top: 1.4rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem; margin: 0; padding: 0; font-size: .86rem; color: var(--ink-faint); }
.breadcrumbs li { display: inline-flex; align-items: center; }
.breadcrumbs li + li::before { content: "›"; margin: 0 .5rem; color: var(--border-strong); }
.breadcrumbs a { color: var(--ink-soft); font-weight: 600; }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 700; }

/* =========================================================================
   Content / prose
   ========================================================================= */
.content-shell { padding: 1rem 0 4rem; }
.prose { max-width: none; }            /* full width of container — not a narrow column */

/* Title styled & colorful */
.prose > h1:first-child, .prose h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem); line-height: 1.15; letter-spacing: -0.02em;
  margin: .8rem 0 1.2rem; font-weight: 800;
  background: linear-gradient(120deg, var(--accent-blue), var(--accent-teal) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.8rem); margin: 2.4rem 0 .9rem; font-weight: 750; letter-spacing: -0.01em;
  padding-bottom: .35rem; border-bottom: 2px solid var(--bg-tint); color: var(--ink);
}
.prose h3 { font-size: 1.28rem; margin: 1.9rem 0 .7rem; font-weight: 700; color: var(--brand-dark); }
.prose h4 { font-size: 1.08rem; margin: 1.5rem 0 .6rem; font-weight: 700; color: var(--ink); }

/* Header-height-aware in-page anchors */
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { scroll-margin-top: calc(var(--header-h) + 1.25rem); }

.heading-anchor { color: var(--border-strong); margin-right: .4rem; text-decoration: none; opacity: 0; transition: opacity .15s ease, color .15s ease; }
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .prose h4:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--brand); }

/* Text fills the full width of its container (not a narrow column). */
.prose p { margin: 0 0 1.15rem; color: var(--ink); }
.prose strong { color: var(--ink); font-weight: 700; }

/* ---- Lists ---- */
.prose ul, .prose ol { margin: 0 0 1.3rem; padding-left: 0; list-style: none; }
.prose li { margin: .5rem 0; line-height: 1.6; }
.prose li > p { margin: 0 0 .5rem; }

/* Unordered: gradient diamond markers */
.prose ul:not(.contains-task-list) > li {
  position: relative; padding-left: 1.7rem;
}
.prose ul:not(.contains-task-list) > li::before {
  content: ""; position: absolute; left: .25rem; top: .62em;
  width: .5rem; height: .5rem; border-radius: 2px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
  transform: rotate(45deg);
}

/* Ordered: numbered badges */
.prose ol { counter-reset: ub-counter; }
.prose ol > li {
  position: relative; padding-left: 2.5rem; counter-increment: ub-counter;
}
.prose ol > li::before {
  content: counter(ub-counter); position: absolute; left: 0; top: .05em;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--bg-tint); border: 1px solid var(--border-strong);
  color: var(--brand-dark); font-size: .8rem; font-weight: 700; line-height: 1;
}

/* Nested lists tighten up */
.prose li > ul, .prose li > ol { margin: .5rem 0 .35rem; }
.prose li > ul > li::before {
  background: none; border: 1.5px solid var(--accent-teal);
}
.prose blockquote {
  margin: 1.4rem 0; padding: .6rem 1.2rem; border-left: 4px solid var(--accent-teal);
  background: var(--bg-tint); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft);
}

/* Content links */
.prose a { color: var(--link); font-weight: 600; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 2px; transition: color .15s ease, text-decoration-color .15s ease; }
.prose a:hover { color: var(--link-hover); text-decoration-color: var(--link-hover); }

/* Inline code — subtle, borderless, blends in */
.prose :not(pre) > code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--inline-code-bg); color: var(--inline-code-ink);
  padding: .12em .42em; border-radius: 6px; border: 0; white-space: break-spaces;
}

/* =========================================================================
   Code blocks + copy button
   ========================================================================= */
.code-block {
  position: relative; margin: 1.5rem 0; border: 1px solid var(--code-border);
  border-radius: var(--radius-sm); background: var(--code-bg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block pre[class*="language-"], .prose pre[class*="language-"] {
  margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto; background: transparent;
  font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; tab-size: 4;
}
/* Bare pre (no highlight) fallback */
.prose pre:not([class*="language-"]) {
  margin: 1.5rem 0; padding: 1.1rem 1.2rem; overflow-x: auto; background: var(--code-bg);
  border: 1px solid var(--code-border); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: .9rem;
}
.prose pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

.copy-btn {
  position: absolute; top: .55rem; right: .55rem; z-index: 2;
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--font-sans); font-size: .76rem; font-weight: 700;
  color: var(--ink-soft); background: rgba(255,255,255,0.92); border: 1px solid var(--border-strong);
  padding: .32rem .55rem; border-radius: 8px; cursor: pointer; opacity: 0;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease, background .15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn svg { width: 15px; height: 15px; }
.copy-btn.copied { color: #fff; background: var(--accent-green); border-color: var(--accent-green); }

/* Prism light token theme tuned to the palette */
code[class*="language-"], pre[class*="language-"] { color: #243b53; }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7a8aa0; font-style: italic; }
.token.punctuation { color: #5b6b7d; }
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted { color: #b5306a; }
.token.boolean, .token.number { color: #b45309; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #0d8b6f; }
.token.operator, .token.entity, .token.url { color: #0b6ba8; }
.token.atrule, .token.attr-value, .token.keyword { color: #0b6ba8; font-weight: 600; }
.token.function, .token.class-name { color: #7c3aed; }
.token.regex, .token.important, .token.variable { color: #c2410c; }

/* =========================================================================
   Tables — styled + horizontally scrollable
   ========================================================================= */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 540px; font-size: .92rem; background: var(--surface); }
.table-wrap th, .table-wrap td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap thead th { background: var(--bg-tint); color: var(--brand-dark); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.table-wrap tbody tr:nth-child(even) { background: #fafcfe; }
.table-wrap tbody tr:hover { background: var(--bg-tint); }
.table-wrap code { white-space: nowrap; }

/* =========================================================================
   Task lists (GFM checkboxes) — togglable, no bullet, strike when checked
   ========================================================================= */
.prose ul.contains-task-list, .prose .contains-task-list { list-style: none; padding-left: .2rem; }
.prose li.task-list-item { display: flex; align-items: flex-start; gap: .6rem; margin: .45rem 0; }
.prose li.task-list-item::marker { content: ""; }       /* remove the dot */
.prose li.task-list-item input.task-list-item-checkbox {
  appearance: none; -webkit-appearance: none; margin: .28em 0 0; flex: none;
  width: 1.15em; height: 1.15em; border: 2px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); cursor: pointer; position: relative; transition: background .15s ease, border-color .15s ease;
}
.prose li.task-list-item input.task-list-item-checkbox:hover { border-color: var(--accent-teal); }
.prose li.task-list-item input.task-list-item-checkbox:checked { background: var(--accent-teal); border-color: var(--accent-teal); }
.prose li.task-list-item input.task-list-item-checkbox:checked::after {
  content: ""; position: absolute; left: 3px; top: 0px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.prose li.task-list-item.is-checked { text-decoration: line-through; color: var(--ink-faint); }
.prose li.task-list-item.is-checked > label { text-decoration: line-through; color: var(--ink-faint); }

/* =========================================================================
   FAQ accordions
   ========================================================================= */
.faq-accordion { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: .7rem 0; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.faq-accordion > .faq-q {
  margin: 0; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.2rem; font-weight: 700; color: var(--ink); background: none; border: 0; font-size: 1.02rem;
}
.faq-accordion > .faq-q:hover { color: var(--brand); background: var(--bg-tint); }
.faq-accordion > .faq-q::after { content: "+"; font-size: 1.4rem; color: var(--accent-teal); transition: transform .2s ease; line-height: 1; }
.faq-accordion.open > .faq-q::after { transform: rotate(45deg); }
.faq-accordion > .faq-a { padding: 0 1.2rem; max-height: 0; overflow: hidden; transition: max-height .28s ease, padding .28s ease; }
.faq-accordion.open > .faq-a { padding: 0 1.2rem 1.1rem; max-height: 1500px; }

/* =========================================================================
   Mermaid + KaTeX
   ========================================================================= */
.prose pre.mermaid { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.2rem; text-align: center; overflow-x: auto; box-shadow: var(--shadow-sm); }
.prose pre.mermaid svg { max-width: 100%; height: auto; }
.figure-caption { display: block; text-align: center; font-size: .85rem; color: var(--ink-faint); margin: -1rem 0 1.6rem; font-style: italic; }

/* Zoomable diagram affordance */
.prose pre.mermaid.diagram-zoomable { position: relative; cursor: zoom-in; transition: border-color .18s ease, box-shadow .18s ease; }
.prose pre.mermaid.diagram-zoomable:hover { border-color: var(--accent-teal); box-shadow: var(--shadow-md); }
.diagram-expand {
  position: absolute; top: .6rem; right: .6rem; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; cursor: zoom-in;
  color: var(--brand-dark); background: rgba(255,255,255,0.92);
  border: 1px solid var(--border-strong); border-radius: 8px;
  opacity: 0; transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}
.diagram-expand svg { width: 17px; height: 17px; }
.prose pre.mermaid.diagram-zoomable:hover .diagram-expand,
.diagram-expand:focus-visible { opacity: 1; }
.diagram-expand:hover { color: var(--accent-teal); border-color: var(--accent-teal); }

/* Fullscreen diagram modal */
.diagram-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 3vw, 3rem);
  background: rgba(14, 34, 51, 0.82); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .2s ease;
}
.diagram-modal.open { opacity: 1; }
.diagram-modal-inner {
  width: 95vw; height: 90vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: clamp(1rem, 3vw, 2.5rem);
  transform: scale(.97); transition: transform .2s ease; overflow: auto;
}
.diagram-modal.open .diagram-modal-inner { transform: scale(1); }
.diagram-modal-inner svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
.diagram-modal-close {
  position: absolute; top: clamp(.8rem, 2vw, 1.4rem); right: clamp(.8rem, 2vw, 1.4rem);
  z-index: 1001; display: inline-flex; align-items: center; justify-content: center;
  width: 2.6rem; height: 2.6rem; cursor: pointer; color: #fff;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.3); border-radius: 10px;
  transition: background .15s ease;
}
.diagram-modal-close:hover { background: rgba(255,255,255,0.26); }
.diagram-modal-close svg { width: 22px; height: 22px; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: .4rem 0; }
.prose .katex { color: var(--ink); }

/* =========================================================================
   Related links
   ========================================================================= */
.related { margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-title { font-size: 1.25rem; margin: 0 0 1rem; color: var(--ink); }
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.related-list a {
  display: flex; flex-direction: column; gap: .25rem; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .9rem 1rem; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.related-list a:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent-teal); }
.related-link-title { font-weight: 700; color: var(--brand-dark); }
.related-link-excerpt { font-size: .85rem; color: var(--ink-faint); font-weight: 500; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { flex-shrink: 0; background: #0e2233; color: #cddbe9; margin-top: 3rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 2.5rem; justify-content: space-between; padding-top: 2.6rem; padding-bottom: 1.6rem; }
.footer-name { font-weight: 800; font-size: 1.2rem; color: #fff; }
.footer-tagline { color: #9fb3c8; margin: .5rem 0 0; max-width: 32ch; }
.footer-brand .brand-dot { color: var(--accent-teal); }
.footer-heading { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #7f97ad; margin: 0 0 .8rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.footer-nav a { color: #cddbe9; font-weight: 500; }
.footer-nav a:hover { color: #fff; text-decoration: underline; }
.footer-meta { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 1.1rem; padding-bottom: 1.6rem; }
.footer-meta p { margin: 0; font-size: .82rem; color: #8ea6bd; }

/* =========================================================================
   Reduced motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
