/* =========================================================================
   Energy Settlement & Reconciliation Automation Hub
   Light, elegant, professional theme — energy/grid inspired palette.
   ========================================================================= */

:root {
  /* Palette */
  --bg: #f5f9f8;
  --surface: #ffffff;
  --surface-2: #eef5f3;
  --ink: #15303b;
  --ink-soft: #34505c;
  --muted: #5d7079;
  --line: #dde9e5;
  --line-strong: #c9ddd7;

  --teal: #0e8e8e;
  --teal-deep: #0b6e6e;
  --blue: #2f6fed;
  --violet: #6c5ce7;
  --amber: #f0a32a;
  --amber-soft: #fff3dd;

  --primary: var(--teal-deep);
  --primary-ink: #ffffff;

  /* Code */
  --code-bg: #f3f7f6;
  --code-inline-bg: #eaf3f0;
  --code-ink: #1f3a44;

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;

  /* Metrics */
  --header-h: 66px;
  --maxw: 1400px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 50, 60, .06), 0 2px 8px rgba(16, 50, 60, .05);
  --shadow-md: 0 6px 20px rgba(16, 50, 60, .10);
  --shadow-lg: 0 16px 44px rgba(16, 50, 60, .14);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(16px, 0.5vw + 15px, 18px);
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 110% -5%, rgba(47, 111, 237, .07), transparent 60%),
    radial-gradient(1000px 460px at -10% 0%, rgba(14, 142, 142, .08), transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.18em; }

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

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

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

/* ---- Layout containers -------------------------------------------------- */
.site-main { flex: 1 0 auto; width: 100%; }
.page-shell, .hero-inner, .home-sections, .header-inner, .footer-inner, .footer-bottom {
  width: min(100% - 2.4rem, var(--maxw));
  margin-inline: auto;
}
/* Content pages share the same container width as the homepage. */
.page-shell { padding-block: 1.6rem 3.5rem; }

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 1rem;
  padding-block: .5rem;
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); }
.brand-logo { width: 40px; height: 40px; filter: drop-shadow(0 3px 6px rgba(14, 142, 142, .28)); transition: transform .25s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-4deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; letter-spacing: -.01em; font-size: 1.06rem;
  background: linear-gradient(90deg, var(--teal-deep), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.primary-nav { margin-left: auto; }
.nav-list { display: flex; align-items: center; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .8rem; border-radius: 999px; color: var(--ink-soft); font-weight: 600; font-size: .95rem;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.nav-link .nav-icon { opacity: .95; }
.nav-link:hover { background: var(--surface-2); color: var(--teal-deep); }
.nav-link[aria-current="page"] { background: linear-gradient(90deg, rgba(14,142,142,.14), rgba(47,111,237,.14)); color: var(--teal-deep); box-shadow: inset 0 0 0 1px var(--line-strong); }

.nav-toggle { display: none; margin-left: auto; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: .45rem; cursor: pointer; }
.nav-toggle:hover { background: var(--surface-2); }

/* =========================================================================
   Hero (home)
   ========================================================================= */
.hero { padding-block: clamp(2rem, 4vw, 4rem) clamp(1rem, 2vw, 2rem); }
.hero-inner { text-align: center; }
.hero-logo-row { display: block; }
.hero-logo { width: clamp(96px, 12vw, 140px); height: auto; filter: drop-shadow(0 12px 26px rgba(14, 142, 142, .3)); animation: float 6s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-title {
  margin: 1.2rem auto .4rem; font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.02em; font-weight: 850;
  max-width: 18ch;
}
.hero-title .accent { background: linear-gradient(95deg, var(--teal), var(--blue) 55%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-tagline { font-size: clamp(1.05rem, 1.6vw, 1.3rem); color: var(--ink-soft); font-weight: 600; max-width: 46ch; margin: .2rem auto 1.4rem; }
.hero-lede { max-width: 72ch; margin: .8rem auto; color: var(--ink-soft); text-align: left; }
@media (min-width: 720px) { .hero-lede { text-align: center; } }

/* CTA buttons */
.hero-cta { display: grid; gap: 1rem; margin: 2rem auto 0; grid-template-columns: 1fr; }
@media (min-width: 720px) { .hero-cta { grid-template-columns: repeat(3, 1fr); } }
.cta {
  display: flex; align-items: center; gap: .9rem; text-align: left;
  padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
  position: relative; overflow: hidden;
}
.cta::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--teal)); }
.cta-architecture { --accent: var(--blue); }
.cta-calculator { --accent: var(--teal); }
.cta-pipeline { --accent: var(--violet); }
.cta:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-strong); color: var(--ink); }
.cta-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); flex: none; }
.cta-icon .icon { width: 28px; height: 28px; }
.cta-body { display: flex; flex-direction: column; min-width: 0; }
.cta-label { font-weight: 750; line-height: 1.2; }
.cta-sub { font-size: .82rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cta-arrow { margin-left: auto; color: var(--muted); transition: transform .22s var(--ease); }
.cta:hover .cta-arrow { transform: translateX(4px); color: var(--accent, var(--teal)); }

/* =========================================================================
   Home: feature grid
   ========================================================================= */
.home-sections { padding-block: 2.5rem 1rem; }
.section-subhead { font-size: clamp(1.4rem, 2.2vw, 1.9rem); letter-spacing: -.01em; margin: 0 0 .4rem; }
.section-intro { color: var(--ink-soft); }
.feature-grid { display: grid; gap: 1.2rem; margin-top: 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .feature-grid { grid-template-columns: repeat(3, 1fr); } }
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.feature-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); flex: none; }
.feature-icon .icon { width: 27px; height: 27px; }
.feature-title { margin: 0; font-size: 1.12rem; line-height: 1.25; }
.feature-title a { color: var(--ink); }
.feature-title a:hover { color: var(--teal-deep); }
.feature-text { color: var(--ink-soft); font-size: .95rem; margin: .2rem 0 .8rem; }
.feature-links { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .15rem; }
.feature-links a { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-soft); font-weight: 600; font-size: .92rem; padding: .25rem .35rem; border-radius: 8px; }
.feature-links a:hover { color: var(--teal-deep); background: var(--surface-2); }
.link-chevron { width: 1em; height: 1em; color: var(--teal); }
.feature-more { margin-top: auto; display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--teal-deep); }
.feature-more:hover .icon { transform: translateX(4px); }
.feature-more .icon { transition: transform .2s var(--ease); }

/* =========================================================================
   Breadcrumbs
   ========================================================================= */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .35rem; margin: 0 0 1.2rem; padding: 0; font-size: .9rem; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.breadcrumbs a { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-soft); font-weight: 600; }
.breadcrumbs a:hover { color: var(--teal-deep); }
.crumb-sep { width: 1em; height: 1em; color: var(--line-strong); }
.crumb-icon { width: 1.05em; height: 1.05em; }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 700; }

/* =========================================================================
   Prose (content pages)
   ========================================================================= */
.prose { color: var(--ink); }
.prose > * + * { margin-top: 1.05rem; }

.prose h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.1; letter-spacing: -.02em; font-weight: 850; margin: .2rem 0 1rem;
  background: linear-gradient(95deg, var(--teal-deep), var(--blue) 60%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2 { font-size: clamp(1.4rem, 2.4vw, 1.95rem); line-height: 1.2; letter-spacing: -.01em; margin-top: 2.4rem; padding-top: .4rem; color: var(--ink); position: relative; }
.prose h2::before { content: ""; display: block; width: 3rem; height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--teal), var(--blue)); margin-bottom: .7rem; }
.prose h3 { font-size: clamp(1.15rem, 1.8vw, 1.45rem); margin-top: 1.8rem; color: var(--teal-deep); }
.prose h4 { font-size: 1.1rem; margin-top: 1.4rem; color: var(--ink-soft); }
.prose :is(h1, h2, h3, h4) { scroll-margin-top: calc(var(--header-h) + 1.2rem); }

.prose p { margin: 0; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose a { color: var(--blue); text-decoration: underline; text-decoration-color: rgba(47,111,237,.32); text-underline-offset: 2px; transition: color .18s var(--ease), text-decoration-color .18s var(--ease); }
.prose a:hover { color: var(--teal-deep); text-decoration-color: var(--teal); }

.prose ul, .prose ol { margin: 0; padding-left: 1.4rem; display: grid; gap: .4rem; }
.prose li { padding-left: .2rem; }
.prose li::marker { color: var(--teal); }

.prose blockquote {
  margin: 1.2rem 0; padding: .8rem 1.1rem; border-left: 4px solid var(--teal);
  background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft); box-shadow: var(--shadow-sm);
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

/* Heading anchor link */
.heading-anchor { margin-left: .4rem; color: var(--line-strong); opacity: 0; text-decoration: none; font-weight: 600; transition: opacity .18s var(--ease), color .18s var(--ease); }
.prose :is(h2,h3,h4):hover .heading-anchor, .heading-anchor:focus { opacity: 1; color: var(--teal); }

/* Inline code — subtle, borderless, blends with text (prose + any context) */
.hero-lede code, .prose :not(pre) > code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--code-inline-bg); color: var(--code-ink);
  padding: .12em .4em; border-radius: 6px; white-space: break-spaces;
}

/* =========================================================================
   Code blocks + copy button
   ========================================================================= */
.code-wrap { position: relative; margin: 1.4rem 0; }
.prose pre[class*="language-"] {
  margin: 0; overflow: auto; background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.15rem;
  font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; tab-size: 4;
  box-shadow: var(--shadow-sm);
}
.prose pre[class*="language-"] code { font-family: inherit; font-size: inherit; background: none; padding: 0; }
.code-wrap .copy-btn {
  position: absolute; top: .55rem; right: .55rem; display: inline-flex; align-items: center; gap: .35rem;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-soft);
  border-radius: 8px; padding: .32rem .6rem; font-size: .78rem; font-weight: 700; cursor: pointer;
  opacity: 0; transform: translateY(-2px); transition: opacity .18s var(--ease), transform .18s var(--ease), background .18s var(--ease), color .18s var(--ease);
}
.code-wrap:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; transform: none; }
.copy-btn:hover { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }
.copy-btn.copied { background: #1f9d6b; color: #fff; border-color: #1f9d6b; opacity: 1; }

/* Light Prism syntax theme tuned to palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7c8b93; font-style: italic; }
.token.punctuation { color: #5a6b73; }
.token.namespace { opacity: .7; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #b5532a; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #0a7a5e; }
.token.operator, .token.entity, .token.url { color: #2f6fed; }
.token.atrule, .token.attr-value, .token.keyword { color: #6c5ce7; }
.token.function, .token.class-name { color: #c0392b; }
.token.regex, .token.important, .token.variable { color: #b5532a; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* =========================================================================
   Task-list checkboxes
   ========================================================================= */
.prose ul.contains-task-list { list-style: none; padding-left: .2rem; }
.prose li.task-list-item { display: flex; align-items: flex-start; gap: .55rem; padding-left: 0; }
.prose li.task-list-item::marker { content: ""; }
.prose li.task-list-item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: .35em 0 0; width: 1.15em; height: 1.15em; flex: none;
  border: 2px solid var(--line-strong); border-radius: 5px; background: var(--surface); cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
  display: inline-grid; place-content: center;
}
.prose li.task-list-item input[type="checkbox"]::before {
  content: ""; width: .62em; height: .62em; transform: scale(0); transform-origin: center;
  background: #fff; clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 18%, 84% 0, 38% 70%);
  transition: transform .15s var(--ease);
}
.prose li.task-list-item input[type="checkbox"]:checked { background: var(--teal-deep); border-color: var(--teal-deep); }
.prose li.task-list-item input[type="checkbox"]:checked::before { transform: scale(1); }
.prose li.task-list-item:has(input:checked), .prose li.task-list-item.is-checked { color: var(--muted); }
.prose li.task-list-item:has(input:checked) label, .prose li.task-list-item.is-checked label { text-decoration: line-through; }

/* =========================================================================
   Tables — styled + horizontally scrollable
   ========================================================================= */
.table-scroll { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; min-width: 32rem; background: var(--surface); font-size: .94rem; }
.prose thead th { background: var(--surface-2); color: var(--ink); text-align: left; font-weight: 700; }
.prose th, .prose td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.prose tbody tr:hover { background: rgba(14,142,142,.05); }
.prose tbody tr:last-child td { border-bottom: none; }

/* =========================================================================
   FAQ accordions
   ========================================================================= */
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); margin: .7rem 0; box-shadow: var(--shadow-sm); overflow: hidden; }
.faq-item > summary { cursor: pointer; list-style: none; padding: .95rem 1.1rem; 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: "+"; font-size: 1.4rem; line-height: 1; color: var(--teal); transition: transform .2s var(--ease); }
.faq-item[open] > summary::after { transform: rotate(45deg); }
.faq-item > summary:hover { color: var(--teal-deep); }
.faq-item > :not(summary) { padding: 0 1.1rem 1rem; margin: 0; color: var(--ink-soft); }

/* =========================================================================
   Child card grid + related
   ========================================================================= */
.child-grid-wrap { margin-top: 3rem; }
.card-grid { list-style: none; margin: 1.4rem 0 0; padding: 0; display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
@media (min-width: 680px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card > a { display: flex; flex-direction: column; height: 100%; padding: 1.2rem; color: var(--ink); }
.card-title { margin: 0 0 .4rem; font-size: 1.1rem; line-height: 1.25; color: var(--teal-deep); }
.card-text { margin: 0 0 1rem; font-size: .92rem; color: var(--ink-soft); }
.card-cta { margin-top: auto; display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--blue); }
.card:hover .card-cta .icon { transform: translateX(4px); }
.card-cta .icon { transition: transform .2s var(--ease); }

.related { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.related-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 680px) { .related-list { grid-template-columns: repeat(2, 1fr); } }
.related-list a { display: inline-flex; align-items: center; gap: .55rem; padding: .65rem .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink-soft); font-weight: 600; box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease); }
.related-list a:hover { transform: translateX(3px); color: var(--teal-deep); border-color: var(--line-strong); }
.related-icon { color: var(--teal); }
.related-up a { background: var(--surface-2); }

/* =========================================================================
   Mermaid + KaTeX
   ========================================================================= */
/* Raw mermaid source is hidden until rendered, then revealed as centered SVG. */
pre.mermaid { margin: 0; background: none; border: none; box-shadow: none; padding: 0; text-align: center; color: transparent; font-size: 0; line-height: 0; }
pre.mermaid:not([data-processed]) { min-height: 2rem; }
pre.mermaid[data-processed] { color: inherit; }
pre.mermaid svg { max-width: 100%; height: auto; }

/* Diagram figure: card-framed, clickable, with an enlarge affordance. */
figure.diagram {
  position: relative; margin: 1.6rem 0; padding: 1.2rem 1.2rem 1.4rem; cursor: zoom-in;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow-x: auto;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
figure.diagram:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.diagram-hint {
  position: absolute; top: .6rem; right: .6rem; display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; font-size: .76rem; font-weight: 700; color: var(--ink-soft);
  background: rgba(255,255,255,.86); border: 1px solid var(--line-strong); border-radius: 999px;
  opacity: 0; transform: translateY(-2px); transition: opacity .18s var(--ease), transform .18s var(--ease);
  pointer-events: none;
}
.diagram-hint .icon { width: 1em; height: 1em; color: var(--teal-deep); }
figure.diagram:hover .diagram-hint, figure.diagram:focus-visible .diagram-hint { opacity: 1; transform: none; }

/* Fullscreen modal with a large copy of the diagram. */
body.modal-open { overflow: hidden; }
.diagram-modal {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: clamp(1rem, 3vw, 3rem);
  background: rgba(12, 32, 38, .72); backdrop-filter: blur(4px);
  animation: modal-in .18s var(--ease);
}
.diagram-modal[hidden] { display: none; }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.diagram-modal-stage {
  width: min(96vw, 1500px); max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: clamp(1rem, 2.5vw, 2.2rem); display: grid; place-items: center;
}
.diagram-modal-stage svg { width: 100%; height: auto; max-width: none; max-height: none; }
.diagram-modal-close {
  position: absolute; top: max(1rem, env(safe-area-inset-top)); right: 1.1rem;
  display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 50%; box-shadow: var(--shadow-md); transition: background .18s var(--ease), color .18s var(--ease);
}
.diagram-modal-close svg { width: 22px; height: 22px; }
.diagram-modal-close:hover { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }

.katex-display { overflow-x: auto; overflow-y: hidden; padding: .4rem 0; }

/* =========================================================================
   404
   ========================================================================= */
.notfound { text-align: center; padding-block: clamp(2rem, 6vw, 5rem); }
.notfound-code { font-size: clamp(4rem, 14vw, 8rem); font-weight: 850; line-height: 1; margin: 0;
  background: linear-gradient(95deg, var(--teal), var(--blue) 60%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.notfound-title { font-size: clamp(1.5rem, 3vw, 2.2rem); margin: .4rem 0 .6rem; }
.notfound-text { color: var(--ink-soft); max-width: 52ch; margin: 0 auto 2rem; }
.notfound-cta { max-width: 760px; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { flex-shrink: 0; margin-top: 3rem; background: var(--ink); color: #cfe1dc; }
.footer-inner { display: grid; gap: 2rem; padding-block: 2.6rem 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .footer-inner { grid-template-columns: 1.4fr 1fr; } }
.footer-brand { display: flex; gap: .9rem; align-items: flex-start; }
.footer-logo { width: 40px; height: 40px; }
.footer-name { margin: 0; font-weight: 800; color: #fff; }
.footer-tagline { margin: .25rem 0 0; color: #9fbdb5; font-size: .92rem; max-width: 44ch; }
.footer-heading { text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; color: #8fb1a9; margin: 0 0 .7rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.footer-nav a { display: inline-flex; align-items: center; gap: .55rem; color: #d4e6e1; font-weight: 600; }
.footer-nav a:hover { color: #fff; }
.footer-icon { color: #69cbb8; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding-block: 1rem 1.4rem; }
.footer-bottom p { margin: 0; font-size: .82rem; color: #8fb1a9; }

/* =========================================================================
   Responsive — mobile nav
   ========================================================================= */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute; top: 100%; left: 0; right: 0; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    max-height: 0; overflow: hidden; transition: max-height .28s var(--ease);
  }
  .primary-nav.is-open { max-height: 70vh; }
  .nav-list { flex-direction: column; align-items: stretch; gap: .15rem; padding: .6rem; }
  .nav-link { width: 100%; }
  .brand-sub { display: none; }
}
@media (max-width: 420px) {
  .brand-name { font-size: .98rem; }
}

/* =========================================================================
   Widescreen — give content room to breathe
   ========================================================================= */
@media (min-width: 1600px) {
  :root { --maxw: 1520px; }
}
/* Homepage and content pages share one container width (--maxw): content fills
   the full width of that wide container — never a cramped narrow column —
   while staying comfortable on mobile. */
