/* =========================================================================
   Film/TV Production Budget Tracking & Guild Compliance Automation
   Light, elegant, professional theme. Mobile → widescreen responsive.
   ========================================================================= */

:root {
  /* Color scheme */
  --c-bg: #fbfaf6;
  --c-surface: #ffffff;
  --c-surface-2: #f6f4ec;
  --c-primary: #1e2a52;
  --c-primary-600: #2b3a6b;
  --c-primary-300: #5566a0;
  --c-teal: #0e9aa7;
  --c-teal-700: #0a7b86;
  --c-accent: #f2b134;
  --c-accent-deep: #c8851a;
  --c-text: #23283a;
  --c-muted: #5b6275;
  --c-border: #e7e3d6;
  --c-border-strong: #d8d2c2;

  /* Code */
  --c-code-bg: #f5f7fc;
  --c-code-border: #e3e8f5;
  --c-inline-code-bg: rgba(14, 154, 167, 0.12);
  --c-inline-code-fg: #0a6b75;

  /* Layout */
  --header-h: 4.25rem;
  --container: 1400px;
  --measure: 72rem;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(30, 42, 82, 0.06), 0 2px 8px rgba(30, 42, 82, 0.05);
  --shadow-md: 0 6px 22px rgba(30, 42, 82, 0.10);
  --shadow-lg: 0 14px 40px rgba(30, 42, 82, 0.14);

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

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem); /* in-page links clear the sticky header */
  -webkit-text-size-adjust: 100%;
}

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

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

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

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

/* ---- Links ---- */
a { color: var(--c-teal-700); text-decoration: none; transition: color 0.18s var(--ease); }
a:hover { color: var(--c-accent-deep); }

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

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

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 250, 246, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--c-primary);
  font-weight: 700;
  margin-right: auto;
}
.brand:hover { color: var(--c-primary); }
.brand .logo-mark { transition: transform 0.3s var(--ease); }
.brand:hover .logo-mark { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-line1 { font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-line2 { font-size: 0.78rem; color: var(--c-teal-700); font-weight: 600; }

.site-nav { display: flex; align-items: center; gap: 0.35rem; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--c-primary);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.nav-link .ico { flex: none; }
.nav-link:hover { background: var(--c-surface-2); color: var(--c-primary); transform: translateY(-1px); }
.nav-link.is-active {
  background: linear-gradient(180deg, rgba(14,154,167,0.14), rgba(14,154,167,0.08));
  color: var(--c-teal-700);
  box-shadow: inset 0 0 0 1px rgba(14,154,167,0.25);
}

/* Mobile nav toggle (CSS only) */
.nav-toggle, .nav-burger { display: none; }
.nav-burger {
  width: 44px; height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 5px;
}
.nav-burger span {
  display: block; width: 22px; height: 2.5px; border-radius: 3px;
  background: var(--c-primary);
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}

@media (max-width: 920px) {
  .nav-burger { display: inline-flex; }
  .site-nav {
    position: absolute;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem clamp(1rem, 0.4rem + 3vw, 2.75rem) 1rem;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s;
  }
  .nav-toggle:checked ~ .site-nav { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
  .nav-link { font-size: 1.05rem; padding: 0.7rem 0.9rem; }
}

/* =========================================================================
   Hero / Home
   ========================================================================= */
.hero {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(14,154,167,0.10), transparent 60%),
    radial-gradient(1000px 460px at 95% 0%, rgba(242,177,52,0.12), transparent 55%),
    linear-gradient(180deg, #ffffff, var(--c-bg));
  border-bottom: 1px solid var(--c-border);
  padding: clamp(2.5rem, 1.5rem + 5vw, 5rem) 0 clamp(2.5rem, 1.5rem + 4vw, 4rem);
}
.hero-logo { text-align: center; margin-bottom: 1.25rem; }
.hero-logo .logo-mark {
  filter: drop-shadow(0 10px 24px rgba(30,42,82,0.18));
  transition: transform 0.4s var(--ease);
}
.hero-logo .logo-mark:hover { transform: translateY(-4px) scale(1.03); }

.hero-title {
  text-align: center;
  font-size: clamp(1.9rem, 1.2rem + 3.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 auto 0.75rem;
  max-width: 18ch;
  color: var(--c-primary);
}
.hero-title .amp { color: var(--c-accent-deep); font-style: italic; }
.hero-lede {
  text-align: center;
  font-size: clamp(1.1rem, 1rem + 0.6vw, 1.4rem);
  color: var(--c-muted);
  max-width: 52ch;
  margin: 0 auto 2rem;
}
.hero-body {
  max-width: var(--measure);
  margin: 0 auto 2.25rem;
  columns: 2;
  column-gap: 2.5rem;
}
.hero-body p { margin: 0 0 1rem; break-inside: avoid; }
@media (max-width: 760px) { .hero-body { columns: 1; } }

.hero-cta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: var(--measure);
  margin-inline: auto;
}
@media (max-width: 760px) { .hero-cta { grid-template-columns: 1fr; } }

.cta-btn {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.15rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.cta-btn:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--c-border-strong); }
.cta-ico {
  flex: none;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(14,154,167,0.16), rgba(242,177,52,0.16));
}
.cta-blueprint .cta-ico { background: linear-gradient(160deg, rgba(30,42,82,0.14), rgba(85,102,160,0.18)); }
.cta-pipeline .cta-ico { background: linear-gradient(160deg, rgba(14,154,167,0.20), rgba(14,154,167,0.08)); }
.cta-shield .cta-ico { background: linear-gradient(160deg, rgba(242,177,52,0.22), rgba(200,133,26,0.12)); }
.cta-text { display: flex; flex-direction: column; }
.cta-label { font-weight: 700; color: var(--c-primary); font-size: 1.05rem; }
.cta-sub { font-size: 0.85rem; color: var(--c-teal-700); display: inline-flex; align-items: center; gap: 0.3rem; }
.cta-btn:hover .cta-sub .ico { transform: translateX(3px); }
.cta-sub .ico { transition: transform 0.2s var(--ease); }

/* Home sections */
.home-sections { padding: clamp(2.5rem, 1.5rem + 4vw, 4.5rem) 0; }
.section-heading {
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2rem);
  color: var(--c-primary);
  text-align: center;
  margin: 0 0 2rem;
}

.card-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
.card-grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--c-border-strong); }

/* simple link-cards (related) */
.card > a {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 0.15rem 0.9rem;
  padding: 1.15rem 1.25rem;
  height: 100%;
  color: inherit;
}
.card-icon { grid-row: 1 / 3; align-self: start; }
.card > a .card-title { font-weight: 700; color: var(--c-primary); font-size: 1.08rem; }
.card > a .card-desc { grid-column: 2; color: var(--c-muted); font-size: 0.92rem; }
.card > a .card-cta { grid-column: 2; }

.card-cta {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.6rem; font-weight: 600; color: var(--c-teal-700);
}
.card:hover .card-cta .ico { transform: translateX(4px); }
.card-cta .ico { transition: transform 0.2s var(--ease); }

/* richer section cards on home */
.section-card { display: flex; flex-direction: column; padding: 1.4rem 1.5rem; border-top: 4px solid var(--card-accent, var(--c-teal)); }
.section-card .card-head { display: flex; align-items: center; gap: 0.75rem; color: inherit; }
.section-card .card-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 13px;
  background: var(--c-surface-2);
}
.section-card .card-title { font-weight: 700; color: var(--c-primary); font-size: 1.18rem; line-height: 1.2; }
.section-card .card-desc { color: var(--c-muted); margin: 0.9rem 0 0.6rem; }
.card-links { list-style: none; margin: 0.4rem 0 0.9rem; padding: 0; display: grid; gap: 0.3rem; }
.card-links a { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--c-primary); font-weight: 500; font-size: 0.95rem; }
.card-links a:hover { color: var(--c-accent-deep); }
.section-card .card-cta { margin-top: auto; }

/* =========================================================================
   Content page layout
   ========================================================================= */
.page-layout { padding-block: 1.75rem 3.5rem; }

.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.15rem; margin: 0 0 1.5rem; padding: 0;
  font-size: 0.9rem; color: var(--c-muted);
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.15rem; }
.breadcrumbs a { color: var(--c-muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--c-teal-700); }
.breadcrumbs .ico { color: var(--c-border-strong); }
.breadcrumbs [aria-current="page"] { color: var(--c-primary); font-weight: 600; }

.article { max-width: var(--measure); }

/* Headings */
.article h1 {
  font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  background: linear-gradient(120deg, var(--c-primary) 0%, var(--c-teal-700) 60%, var(--c-accent-deep) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article h2 {
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.95rem);
  color: var(--c-primary);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--c-border);
  letter-spacing: -0.01em;
}
.article h3 { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.45rem); color: var(--c-primary-600); margin: 1.8rem 0 0.6rem; }
.article h4 { font-size: 1.1rem; color: var(--c-primary-600); margin: 1.4rem 0 0.5rem; }
.article :is(h1,h2,h3,h4) { scroll-margin-top: calc(var(--header-h) + 1rem); }

.header-anchor {
  float: left;
  margin-left: -1.2em;
  padding-right: 0.35em;
  color: var(--c-border-strong);
  opacity: 0;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease);
  text-decoration: none;
}
.article :is(h2,h3,h4):hover .header-anchor { opacity: 1; }
.header-anchor:hover { color: var(--c-teal); }
@media (max-width: 720px) { .header-anchor { display: none; } }

.article p { margin: 0 0 1.15rem; }
.article > p:first-of-type { font-size: 1.08em; color: #2c3142; }

.article a {
  color: var(--c-teal-700);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(14,154,167,0.35);
  text-underline-offset: 3px;
  transition: color 0.18s var(--ease), text-decoration-color 0.18s var(--ease);
}
.article a:hover { color: var(--c-accent-deep); text-decoration-color: var(--c-accent); }

.article ul, .article ol { margin: 0 0 1.2rem; padding-left: 1.4rem; }
.article li { margin: 0.35rem 0; }
.article li::marker { color: var(--c-teal); }

.article blockquote {
  margin: 1.5rem 0;
  padding: 0.85rem 1.25rem;
  border-left: 4px solid var(--c-accent);
  background: var(--c-surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #3a4051;
}
.article hr { border: none; border-top: 1px solid var(--c-border); margin: 2.5rem 0; }

/* Inline code: soft tinted background, no border, blends in */
.article :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--c-inline-code-bg);
  color: var(--c-inline-code-fg);
  padding: 0.12em 0.42em;
  border-radius: 5px;
  white-space: break-spaces;
}

/* Tables: styled + horizontally scrollable */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--c-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: 480px; font-size: 0.95rem; }
.table-wrap th, .table-wrap td { padding: 0.7rem 0.95rem; text-align: left; border-bottom: 1px solid var(--c-border); }
.table-wrap thead th { background: var(--c-primary); color: #fff; font-weight: 600; white-space: nowrap; }
.table-wrap tbody tr:nth-child(even) { background: var(--c-surface-2); }
.table-wrap tbody tr:hover { background: rgba(14,154,167,0.07); }

/* Task lists: interactive checkboxes, no bullet, line-through when checked */
.article ul.contains-task-list { list-style: none; padding-left: 0.2rem; }
.article .task-list-item { display: flex; align-items: flex-start; gap: 0.6rem; }
.article .task-list-item::marker { content: ""; }
.article .task-list-item-checkbox {
  appearance: none; -webkit-appearance: none;
  flex: none;
  width: 1.2em; height: 1.2em; margin-top: 0.28em;
  border: 2px solid var(--c-teal); border-radius: 5px;
  background: var(--c-surface);
  cursor: pointer;
  display: grid; place-content: center;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.article .task-list-item-checkbox::before {
  content: ""; width: 0.62em; height: 0.62em; transform: scale(0);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: #fff; transition: transform 0.15s var(--ease);
}
.article .task-list-item-checkbox:checked { background: var(--c-teal); border-color: var(--c-teal); }
.article .task-list-item-checkbox:checked::before { transform: scale(1); }
.article .task-list-item.is-done > label,
.article .task-list-item.is-done { text-decoration: line-through; color: var(--c-muted); }

/* FAQ accordions */
.faq-accordion {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  margin: 0.7rem 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.95rem 1.2rem;
  font-weight: 600;
  color: var(--c-primary);
  display: flex; align-items: center; gap: 0.6rem;
  transition: background 0.15s var(--ease);
}
.faq-accordion > summary::-webkit-details-marker { display: none; }
.faq-accordion > summary:hover { background: var(--c-surface-2); }
.faq-accordion > summary::before {
  content: ""; flex: none; width: 0.55em; height: 0.55em;
  border-right: 2.5px solid var(--c-teal); border-bottom: 2.5px solid var(--c-teal);
  transform: rotate(-45deg); transition: transform 0.2s var(--ease);
}
.faq-accordion[open] > summary::before { transform: rotate(45deg); }
.faq-accordion > .faq-body { padding: 0 1.2rem 1.1rem; color: #3a4051; }

/* =========================================================================
   Code blocks (Prism) — light theme matching the palette + copy button
   ========================================================================= */
.code-block {
  position: relative;
  margin: 1.5rem 0;
}
pre[class*="language-"] {
  background: var(--c-code-bg);
  border: 1px solid var(--c-code-border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
  tab-size: 4;
}
pre[class*="language-"] code { font-family: inherit; background: none; padding: 0; color: #2b3553; }

.code-copy-btn {
  position: absolute;
  top: 0.6rem; right: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.34rem 0.66rem;
  font: 600 0.78rem/1 var(--font-sans);
  color: var(--c-primary);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--c-code-border);
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
}
.code-block:hover .code-copy-btn,
.code-copy-btn:focus-visible { opacity: 1; }
.code-copy-btn:hover { background: var(--c-teal); color: #fff; border-color: var(--c-teal); }
.code-copy-btn:active { transform: scale(0.96); }
.code-copy-btn.is-copied { background: var(--c-accent); color: var(--c-primary); border-color: var(--c-accent); opacity: 1; }
@media (hover: none) { .code-copy-btn { opacity: 1; } }

/* Prism token colors (light) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8a93a6; font-style: italic; }
.token.punctuation { color: #5b6275; }
.token.property, .token.tag, .token.boolean, .token.number,
.token.constant, .token.symbol, .token.deleted { color: #b5651d; }
.token.selector, .token.attr-name, .token.string, .token.char,
.token.builtin, .token.inserted { color: #0a7b86; }
.token.operator, .token.entity, .token.url,
.language-css .token.string, .style .token.string { color: #2b3a6b; }
.token.atrule, .token.attr-value, .token.keyword { color: #8a3ffc; }
.token.keyword { color: #6f42c1; }
.token.function, .token.class-name { color: #1e2a52; font-weight: 600; }
.token.regex, .token.important, .token.variable { color: #c8851a; }
.token.decorator, .token.annotation { color: #0e9aa7; }

/* Mermaid diagrams */
.mermaid {
  margin: 0;
  text-align: center;
  overflow-x: auto;
  background: none;
  border: 0;
}
/* Bare (pre-enhancement / no-JS) diagrams still look intentional */
.mermaid:not([data-processed]) {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--c-muted);
}

.diagram-figure { margin: 1.75rem 0; }
.diagram-frame {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 1.3rem 1.3rem 1.1rem;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  overflow-x: auto;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.diagram-frame:hover { box-shadow: var(--shadow-md); border-color: var(--c-border-strong); }
.diagram-frame:focus-visible { outline: 3px solid var(--c-teal); outline-offset: 2px; }
.diagram-frame .mermaid svg { max-width: 100%; height: auto; }
.diagram-expand {
  position: absolute;
  top: 0.6rem; right: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  font: 600 0.75rem/1 var(--font-sans);
  color: var(--c-primary);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--c-code-border);
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}
.diagram-frame:hover .diagram-expand,
.diagram-frame:focus-visible .diagram-expand { opacity: 1; }
.diagram-frame:hover .diagram-expand { background: var(--c-teal); color: #fff; border-color: var(--c-teal); }
@media (hover: none) { .diagram-expand { opacity: 1; } }
.diagram-figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--c-muted);
  text-align: center;
  font-style: italic;
}

/* Full-screen lightbox */
.pb-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(20, 26, 48, 0.92);
  backdrop-filter: blur(6px);
  animation: pb-fade 0.18s var(--ease);
}
.pb-lightbox[hidden] { display: none; }
@keyframes pb-fade { from { opacity: 0; } to { opacity: 1; } }
.pb-lightbox__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem clamp(0.8rem, 3vw, 1.6rem);
  color: #fff;
  flex: none;
}
.pb-lightbox__caption {
  font-size: 0.95rem; color: #d7dcec; font-style: italic;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pb-lightbox__controls { display: inline-flex; align-items: center; gap: 0.4rem; flex: none; }
.pb-lightbox__controls button {
  min-width: 2.2rem; height: 2.2rem;
  padding: 0 0.7rem;
  font: 600 1rem/1 var(--font-sans);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease);
}
.pb-lightbox__controls button:hover { background: var(--c-teal); border-color: var(--c-teal); }
.pb-lightbox__controls button:active { transform: scale(0.95); }
.pb-lightbox__close { font-size: 1.4rem !important; }
.pb-lightbox__stage {
  flex: 1 1 auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
}
.pb-lightbox__stage.is-grabbing { cursor: grabbing; }
.pb-lightbox__zoom {
  transform-origin: center center;
  transition: transform 0.05s linear;
  will-change: transform;
  display: grid;
  place-items: center;
}
.pb-lightbox__zoom svg {
  width: min(94vw, 1600px) !important;
  max-width: min(94vw, 1600px) !important;
  height: auto !important;
  max-height: 86vh !important;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

/* KaTeX display blocks scroll on small screens */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.3rem 0; }

/* =========================================================================
   Related / siblings
   ========================================================================= */
.related, .siblings { max-width: var(--container); margin-top: 3rem; }
.related-title {
  font-size: 1.35rem; color: var(--c-primary); margin: 0 0 1.1rem;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.related-title::after { content: ""; }
.siblings ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.siblings a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 0.85rem; border-radius: var(--radius-sm);
  background: var(--c-surface); border: 1px solid var(--c-border);
  color: var(--c-primary); font-weight: 500;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.siblings a:hover { transform: translateX(3px); box-shadow: var(--shadow-sm); border-color: var(--c-teal); color: var(--c-teal-700); }
.siblings .ico { color: var(--c-teal); }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { flex-shrink: 0; margin-top: auto; background: var(--c-primary); color: #d7dcec; }
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 2rem 3rem;
  justify-content: space-between;
  padding-block: 2.5rem;
}
.footer-brand { display: flex; gap: 0.9rem; align-items: flex-start; max-width: 38ch; }
.footer-brand .logo-mark { background: #fff; border-radius: 10px; padding: 4px; flex: none; }
.footer-name { font-weight: 700; color: #fff; margin: 0 0 0.3rem; }
.footer-tag { margin: 0; font-size: 0.9rem; color: #aab3cf; }
.footer-heading { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: #8c97bd; margin: 0 0 0.7rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.footer-nav a { display: inline-flex; align-items: center; gap: 0.45rem; color: #d7dcec; font-weight: 500; }
.footer-nav a:hover { color: var(--c-accent); }
.footer-nav .ico { filter: brightness(0) invert(1); opacity: 0.85; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.12); }
.footer-bottom p { margin: 0; padding-block: 1.1rem; font-size: 0.85rem; color: #97a1c2; }

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