/* ==========================================================================
   transit-fare.org — design system
   Light, elegant, professional palette (transit blue · teal · amber)
   ========================================================================== */

:root {
  /* Palette */
  --bg: #f5f8fc;
  --bg-soft: #eef3fa;
  --surface: #ffffff;
  --ink: #1b2733;
  --ink-soft: #45566a;
  --muted: #6b7a8d;
  --border: #e1e8f1;
  --border-strong: #cdd8e6;

  --primary: #1d4ed8;
  --primary-deep: #1e3a8a;
  --primary-tint: #eaf0fe;
  --teal: #0d9488;
  --teal-tint: #e3f6f3;
  --amber: #d97706;
  --amber-tint: #fdf2e2;
  --rose: #e11d48;

  --code-bg: #f4f7fc;
  --inline-code-bg: #eef2fb;
  --inline-code-ink: #1e3a8a;

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

  /* Metrics */
  --header-h: 66px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 40, 80, 0.06), 0 1px 3px rgba(20, 40, 80, 0.08);
  --shadow-md: 0 6px 18px rgba(20, 40, 80, 0.08), 0 2px 6px rgba(20, 40, 80, 0.06);
  --shadow-lg: 0 18px 40px rgba(20, 40, 80, 0.12);
  --container: 1320px;
  --content-max: 1180px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2.5rem);
}

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

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

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

/* ===== Header ============================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  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: 0.7rem;
  color: var(--ink);
}
.brand-logo { transition: transform 0.35s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; letter-spacing: -0.01em; font-size: 1.08rem; color: var(--primary-deep); }
.brand-sub { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.02em; }

.primary-nav .nav-list {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.1;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.nav-icon { width: 18px; height: 18px; flex: none; }
.nav-link:hover { background: var(--primary-tint); color: var(--primary-deep); transform: translateY(-1px); }
.nav-link.is-current { background: var(--primary); color: #fff; }
.nav-link.is-current:hover { background: var(--primary-deep); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
}
.nav-toggle-bar { width: 22px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s var(--ease);
  }
  .primary-nav.open { max-height: 80vh; }
  .primary-nav .nav-list { flex-direction: column; align-items: stretch; gap: 0.2rem; padding: 0.8rem clamp(1rem, 3vw, 2.5rem) 1.2rem; }
  .nav-link { padding: 0.75rem 0.9rem; font-size: 1rem; }
}

/* ===== Hero ============================================================== */
.hero {
  background:
    radial-gradient(1100px 380px at 80% -10%, var(--teal-tint), transparent 60%),
    radial-gradient(900px 360px at 10% 0%, var(--primary-tint), transparent 55%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero-inner { padding-block: clamp(2.5rem, 6vw, 5rem); text-align: center; }
.hero-logo-line { margin: 0 0 1.4rem; }
.hero-logo { filter: drop-shadow(0 10px 22px rgba(29, 78, 216, 0.25)); transition: transform 0.4s var(--ease); }
.hero-logo:hover { transform: translateY(-4px) scale(1.04); }
.hero-title {
  margin: 0 auto 1.2rem;
  font-size: clamp(1.9rem, 1.2rem + 3.4vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--primary-deep);
  max-width: 18ch;
}
.hero-lede { max-width: 70ch; margin-inline: auto; color: var(--ink-soft); }
.hero-lede p { margin: 0 0 1rem; }

.hero-cta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  max-width: var(--content-max);
  margin: 2.4rem auto 0;
  text-align: left;
}
.cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.cta:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cta-icon { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.cta-icon svg { width: 26px; height: 26px; }
.cta-indigo:hover { border-color: var(--primary); }
.cta-indigo .cta-icon { background: var(--primary-tint); color: var(--primary); }
.cta-teal:hover { border-color: var(--teal); }
.cta-teal .cta-icon { background: var(--teal-tint); color: var(--teal); }
.cta-amber:hover { border-color: var(--amber); }
.cta-amber .cta-icon { background: var(--amber-tint); color: var(--amber); }
.cta-text { display: flex; flex-direction: column; }
.cta-title { font-weight: 700; color: var(--ink); line-height: 1.2; }
.cta-go { font-size: 0.85rem; color: var(--muted); transition: color 0.2s var(--ease); }
.cta:hover .cta-go { color: var(--primary); }

/* ===== Home sections ==================================================== */
.home-sections { padding-block: clamp(2.5rem, 5vw, 4rem); }
.section-heading { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); color: var(--primary-deep); margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.section-intro { color: var(--ink-soft); max-width: 65ch; margin: 0 0 2rem; }

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.3rem;
}
.pillar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.7rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.pillar-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.pillar-indigo { border-top-color: var(--primary); }
.pillar-teal { border-top-color: var(--teal); }
.pillar-amber { border-top-color: var(--amber); }
.pillar-card-title { margin: 0 0 0.6rem; font-size: 1.2rem; }
.pillar-card-title a { color: var(--ink); }
.pillar-card-title a:hover { color: var(--primary); }
.pillar-card-blurb { color: var(--ink-soft); margin: 0 0 1rem; font-size: 0.98rem; }
.pillar-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.pillar-links a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--ink-soft); font-weight: 500; font-size: 0.95rem;
  padding: 0.25rem 0; transition: color 0.2s var(--ease), padding-left 0.2s var(--ease);
}
.pillar-links a::before { content: "›"; color: var(--primary); font-weight: 700; }
.pillar-links a:hover { color: var(--primary-deep); padding-left: 0.25rem; }

/* ===== Content shell ==================================================== */
.content-shell { padding-block: 1.6rem clamp(2.5rem, 5vw, 4rem); }
.content { max-width: var(--content-max); }

/* Breadcrumbs */
.breadcrumbs ol {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  list-style: none; margin: 0 0 1.6rem; padding: 0;
  font-size: 0.85rem; color: var(--muted);
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.45rem; }
.breadcrumbs li + li::before { content: "›"; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--ink-soft); font-weight: 600; }

/* Typography */
.content h1 {
  font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  background: linear-gradient(95deg, var(--primary-deep), var(--primary) 45%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.content h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.85rem);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.4rem;
  color: var(--primary-deep);
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--border);
}
.content h3 { font-size: 1.3rem; margin: 1.8rem 0 0.7rem; color: var(--ink); }
.content h4 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; color: var(--ink); }
.content h2, .content h3, .content h4 { scroll-margin-top: calc(var(--header-h) + 1.1rem); }
.content p { margin: 0 0 1.15rem; color: var(--ink-soft); }
.content > p:first-of-type, .content .header-anchor + p { color: var(--ink); }

.content ul, .content ol { margin: 0 0 1.2rem; padding-left: 1.4rem; color: var(--ink-soft); }
.content li { margin-bottom: 0.45rem; }
.content li::marker { color: var(--primary); }

.content strong { color: var(--ink); font-weight: 700; }
.content blockquote {
  margin: 1.4rem 0;
  padding: 0.8rem 1.2rem;
  border-left: 4px solid var(--teal);
  background: var(--teal-tint);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}
.content hr { border: none; border-top: 1px solid var(--border); margin: 2.2rem 0; }

/* Content links */
.content a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  background-image: linear-gradient(var(--primary), var(--primary));
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s var(--ease), color 0.2s var(--ease);
  padding-bottom: 1px;
}
.content a:hover { color: var(--primary-deep); background-size: 100% 2px; }

/* Heading anchor links (markdown-it-anchor headerLink) */
.content .header-anchor { color: inherit; background: none; font-weight: inherit; }
.content .header-anchor:hover { color: inherit; }

/* Inline code */
.content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--inline-code-bg);
  color: var(--inline-code-ink);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  border: none;
  white-space: break-spaces;
}

/* ===== Code blocks ====================================================== */
.code-block {
  position: relative;
  margin: 1.5rem 0;
}
pre[class*="language-"] {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 4;
}
pre[class*="language-"] code { font-family: var(--font-mono); background: none; color: var(--ink); }

/* Light Prism theme */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7c8aa0; font-style: italic; }
.token.punctuation { color: #5b6b7b; }
.token.keyword, .token.boolean, .token.atrule, .token.important { color: #9333ea; font-weight: 600; }
.token.string, .token.char, .token.attr-value, .token.regex { color: #0d8a6a; }
.token.number, .token.constant, .token.symbol { color: #c2410c; }
.token.function, .token.class-name { color: #1d4ed8; }
.token.operator, .token.entity, .token.url { color: #b4267a; }
.token.property, .token.tag, .token.attr-name { color: #1e3a8a; }
.token.builtin, .token.namespace { color: #0e7490; }
.token.deleted { color: var(--rose); }
.token.inserted { color: #0d8a6a; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0.32rem 0.55rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--primary-deep); border-color: var(--primary); background: var(--primary-tint); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.copied { color: #fff; background: var(--teal); border-color: var(--teal); }

/* ===== Tables =========================================================== */
.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;
}
.content table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 0.92rem; }
.content thead { background: var(--primary-tint); }
.content th { text-align: left; font-weight: 700; color: var(--primary-deep); padding: 0.75rem 1rem; white-space: nowrap; }
.content td { padding: 0.7rem 1rem; border-top: 1px solid var(--border); color: var(--ink-soft); vertical-align: top; }
.content tbody tr:hover { background: var(--bg-soft); }

/* ===== Task lists (togglable checkboxes) ================================ */
.content ul.contains-task-list { list-style: none; padding-left: 0.2rem; }
.content ul.contains-task-list ul { list-style: none; padding-left: 1.4rem; }
.content li.task-list-item {
  list-style: none;          /* removes the leading bullet dot */
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.55rem;
}
.content li.task-list-item::marker { content: ""; }
.content li.task-list-item input.task-list-item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.content li.task-list-item input.task-list-item-checkbox:hover { border-color: var(--primary); }
.content li.task-list-item input.task-list-item-checkbox:checked { background: var(--primary); border-color: var(--primary); }
.content li.task-list-item input.task-list-item-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 0.32em; top: 0.05em;
  width: 0.32em; height: 0.62em;
  border: solid #fff;
  border-width: 0 0.16em 0.16em 0;
  transform: rotate(45deg);
}
.content li.task-list-item label { cursor: pointer; }
/* Strike-through the whole item when checked (handles plain + inline-markup items) */
.content li.task-list-item:has(input.task-list-item-checkbox:checked) { color: var(--muted); text-decoration: line-through; }
.content li.task-list-item input.task-list-item-checkbox:checked ~ label { color: var(--muted); text-decoration: line-through; }

/* ===== FAQ / accordions ================================================= */
.content details.accordion, details.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0.7rem 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
details.faq-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.2rem;
  font-weight: 700;
  color: var(--primary-deep);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: background 0.2s var(--ease);
}
details.faq-item > summary::-webkit-details-marker { display: none; }
details.faq-item > summary:hover { background: var(--primary-tint); }
details.faq-item > summary::after { content: "+"; font-size: 1.4rem; font-weight: 400; color: var(--primary); transition: transform 0.25s var(--ease); }
details.faq-item[open] > summary::after { transform: rotate(45deg); }
details.faq-item .faq-body { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }

/* ===== Related / section nav ============================================ */
.related { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-title { font-size: 1.3rem; color: var(--primary-deep); margin: 0 0 1.2rem; }
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.9rem; }
.related-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 600;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); color: var(--primary-deep); }
.related-card-arrow { color: var(--primary); transition: transform 0.2s var(--ease); }
.related-card:hover .related-card-arrow { transform: translateX(4px); }

.page-updown { margin-top: 2rem; }
.updown-link { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; color: var(--ink-soft); }
.updown-link:hover { color: var(--primary); }

/* ===== 404 page ========================================================= */
.error-page { padding-block: clamp(3rem, 8vw, 6rem); text-align: center; max-width: 760px; }
.error-code {
  font-size: clamp(4rem, 8vw + 1rem, 8rem);
  font-weight: 800;
  line-height: 1;
  margin: 0;
  background: linear-gradient(95deg, var(--primary-deep), var(--primary) 45%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.error-title { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); color: var(--primary-deep); margin: 0.4rem 0 0.8rem; }
.error-lede { color: var(--ink-soft); margin: 0 auto 2rem; max-width: 48ch; }
.error-links { text-align: left; }

/* ===== Footer =========================================================== */
.site-footer { flex-shrink: 0; background: var(--primary-deep); color: #cfe0ff; margin-top: 3rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2rem; padding-block: 2.4rem; }
.footer-brand { display: flex; align-items: center; gap: 0.9rem; max-width: 360px; }
.footer-logo { background: #fff; border-radius: 10px; padding: 4px; }
.footer-name { font-weight: 800; color: #fff; margin: 0; }
.footer-tag { margin: 0.2rem 0 0; font-size: 0.9rem; color: #b6cdf5; }
.footer-heading { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: #8fb2ec; margin: 0 0 0.7rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.footer-nav a { color: #cfe0ff; font-weight: 500; transition: color 0.2s var(--ease), padding-left 0.2s var(--ease); }
.footer-nav a:hover { color: #fff; padding-left: 0.2rem; }
.footer-base { border-top: 1px solid rgba(255, 255, 255, 0.12); }
.footer-base p { margin: 0; padding-block: 1.1rem; font-size: 0.82rem; color: #9fbdef; }

/* ===== KaTeX ============================================================ */
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: 0.4rem; }

/* ===== Diagrams (Mermaid) + click-to-fullscreen ========================= */
.diagram {
  position: relative;
  margin: 1.8rem 0;
  padding: 1.2rem 1rem;
  background: linear-gradient(180deg, #fbfdff, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.diagram:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.diagram .mermaid {
  margin: 0;
  text-align: center;
  cursor: zoom-in;
  min-height: 1em;
}
.diagram .mermaid:not([data-processed]) { color: transparent; }
.diagram .mermaid svg { max-width: 100%; height: auto; }
.diagram .mermaid:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: var(--radius-sm); }

.diagram-expand {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: 600 0.74rem/1 var(--font-sans);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0.34rem 0.55rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.diagram:hover .diagram-expand,
.diagram-expand:focus-visible { opacity: 1; }
.diagram-expand:hover { color: var(--primary-deep); background: var(--primary-tint); border-color: var(--primary); }
.diagram-expand svg { width: 14px; height: 14px; }

/* Full-screen lightbox */
.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  background: rgba(15, 28, 50, 0.78);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}
.diagram-lightbox.open { display: flex; opacity: 1; }
.dlb-panel {
  position: relative;
  width: min(96vw, 1500px);
  height: min(92vh, 1000px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.2rem, 3vw, 2.4rem);
  display: flex;
  animation: dlbpop 0.24s var(--ease);
}
@keyframes dlbpop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dlb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.dlb-stage svg { width: 100%; height: 100%; }
.dlb-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.dlb-close:hover { background: var(--rose); color: #fff; transform: rotate(90deg); }

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