/* =========================================================================
   pgvector Index Management — site styles
   Light, professional palette. Wide on desktop, elegant on mobile.
   ========================================================================= */

:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-2: #f0f5fb;
  --text: #1f2d3d;
  --muted: #586a7d;
  --heading: #14253a;

  --primary: #2563a6;
  --primary-600: #1d4f86;
  --primary-700: #173f6c;
  --accent: #7c3aed;
  --teal: #0d9488;
  --amber: #f59e0b;

  --border: #e1e8f0;
  --border-strong: #cdd9e6;
  --ring: rgba(37, 99, 166, 0.35);

  --code-bg: #f4f7fb;
  --code-border: #e4ebf3;
  --inline-code-bg: #eaf1f9;
  --inline-code-text: #1d4f86;

  --shadow-sm: 0 1px 2px rgba(20, 37, 58, 0.06), 0 1px 3px rgba(20, 37, 58, 0.05);
  --shadow-md: 0 6px 18px rgba(20, 37, 58, 0.08);
  --shadow-lg: 0 16px 40px rgba(20, 37, 58, 0.12);

  --header-h: 66px;
  --container: 1320px;
  --prose: 1180px;
  --radius: 14px;
  --radius-sm: 10px;

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

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: 1.0625rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
.site-main { flex: 1 0 auto; width: 100%; }

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

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

/* =========================================================================
   Header / navigation
   ========================================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: var(--container); margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem clamp(1rem, 3vw, 2rem);
  min-height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 0.7rem; color: var(--heading); }
.brand-logo { transition: transform 0.3s ease; flex: none; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 800; font-size: 1.06rem; letter-spacing: -0.01em; }
.brand-accent { color: var(--primary); }
.brand-sub { font-size: 0.72rem; color: var(--muted); font-weight: 500; letter-spacing: 0.01em; }

.primary-nav { margin-left: auto; }
.primary-nav ul { display: flex; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.primary-nav a {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.85rem; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.primary-nav a .nav-icon { flex: none; }
.primary-nav a:hover { color: var(--primary-700); background: var(--surface-2); transform: translateY(-1px); }
.primary-nav a.is-active {
  color: var(--primary-700); background: linear-gradient(180deg, #eaf2fb, #dceafa);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 166, 0.18);
}

.nav-toggle {
  display: none; margin-left: auto; width: 44px; height: 40px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); cursor: pointer; padding: 0; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
}
.nav-toggle-bar { display: block; width: 20px; height: 2px; background: var(--primary-700); border-radius: 2px; transition: transform 0.25s ease, opacity 0.25s ease; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { flex-shrink: 0; background: #0f2236; color: #d7e2ee; margin-top: 4rem; }
.footer-inner {
  max-width: var(--container); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 2.5rem; justify-content: space-between;
  padding: 2.5rem clamp(1rem, 3vw, 2rem) 1.5rem;
}
.footer-brand { display: flex; align-items: center; gap: 0.9rem; max-width: 360px; }
.footer-title { margin: 0; font-weight: 800; color: #fff; }
.footer-tag { margin: 0.2rem 0 0; font-size: 0.9rem; color: #9fb3c8; }
.footer-heading { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: #7f97ad; margin: 0 0 0.7rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.footer-nav a { display: inline-flex; align-items: center; gap: 0.5rem; color: #d7e2ee; font-weight: 500; padding: 0.2rem 0; transition: color 0.2s ease, transform 0.2s ease; }
.footer-nav a:hover { color: #fff; transform: translateX(3px); }
.footer-nav .nav-icon { background: #fff; border-radius: 6px; padding: 2px; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.1); }
.footer-bottom p { max-width: var(--container); margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem); font-size: 0.85rem; color: #93a8bd; }

/* =========================================================================
   Hero / frontpage
   ========================================================================= */
.hero {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(124, 58, 237, 0.10), transparent 60%),
    radial-gradient(900px 480px at 5% 0%, rgba(13, 148, 136, 0.10), transparent 55%),
    linear-gradient(180deg, #ffffff, var(--bg));
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: var(--container); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 3vw, 2rem) clamp(2rem, 5vw, 4rem); text-align: center; }
.hero-logo { display: block; }
.hero-logo img { filter: drop-shadow(0 12px 28px rgba(37, 99, 166, 0.28)); transition: transform 0.4s ease; }
.hero-logo img:hover { transform: translateY(-4px) rotate(-3deg); }
.hero-title { font-size: clamp(1.9rem, 5vw, 3.25rem); line-height: 1.1; letter-spacing: -0.02em; color: var(--heading); margin: 1.4rem auto 0.8rem; font-weight: 800; max-width: 18ch; }
.grad-text { background: linear-gradient(100deg, var(--primary), var(--accent) 55%, var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lede { font-size: clamp(1.1rem, 2.2vw, 1.35rem); color: var(--heading); max-width: 60ch; margin: 0 auto 1rem; font-weight: 500; }
.hero-body { color: var(--muted); max-width: 70ch; margin: 0 auto 1rem; }

.hero-cta { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 2rem; }
.cta-btn {
  display: inline-flex; align-items: center; gap: 0.85rem; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 0.85rem 1.1rem; box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  position: relative; overflow: hidden;
}
.cta-btn::before { content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.22s ease; }
.cta-architecture::before { background: linear-gradient(120deg, rgba(37,99,166,0.08), transparent); }
.cta-tuning::before { background: linear-gradient(120deg, rgba(124,58,237,0.09), transparent); }
.cta-pipeline::before { background: linear-gradient(120deg, rgba(13,148,136,0.09), transparent); }
.cta-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.cta-btn:hover::before { opacity: 1; }
.cta-icon { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); flex: none; position: relative; z-index: 1; }
.cta-text { display: flex; flex-direction: column; line-height: 1.2; position: relative; z-index: 1; }
.cta-label { font-weight: 800; color: var(--heading); }
.cta-sub { font-size: 0.82rem; color: var(--muted); }
.cta-arrow { color: var(--muted); margin-left: 0.4rem; position: relative; z-index: 1; transition: transform 0.22s ease, color 0.22s ease; }
.cta-btn:hover .cta-arrow { transform: translateX(4px); color: var(--primary); }

/* Section cards */
.sections { max-width: var(--container); margin: 0 auto; padding: clamp(2.5rem, 5vw, 4rem) clamp(1rem, 3vw, 2rem); }
.section-heading { text-align: center; font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--heading); margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.section-intro { text-align: center; color: var(--muted); max-width: 60ch; margin: 0 auto 2.5rem; }
.section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.5rem; }
.section-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.section-card-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.section-card-icon { display: inline-grid; place-items: center; width: 50px; height: 50px; border-radius: 13px; background: var(--surface-2); flex: none; }
.section-card-title { margin: 0; font-size: 1.2rem; line-height: 1.25; }
.section-card-title a { color: var(--heading); }
.section-card-title a:hover { color: var(--primary); }
.section-card-blurb { color: var(--muted); font-size: 0.95rem; margin: 0 0 1rem; }
.section-card-links { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: 0.35rem; }
.section-card-links a { display: flex; align-items: center; gap: 0.45rem; color: var(--primary-700); font-weight: 500; font-size: 0.92rem; padding: 0.25rem 0; transition: transform 0.18s ease, color 0.18s ease; }
.section-card-links a:hover { transform: translateX(4px); color: var(--accent); }
.section-card-links .li-icon { color: var(--teal); flex: none; }
.section-card-cta { margin-top: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; color: var(--primary); }
.section-card-cta:hover { color: var(--primary-700); }
.go-icon { transition: transform 0.2s ease; }
a:hover .go-icon { transform: translateX(4px); }

/* =========================================================================
   Page wrap (content pages)
   ========================================================================= */
.page-wrap { max-width: var(--container); margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 0; }

/* Breadcrumbs */
.breadcrumbs { margin: 0.5rem 0 1.25rem; font-size: 0.9rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0; padding: 0; }
.breadcrumbs a { color: var(--muted); font-weight: 500; transition: color 0.18s ease; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .crumb-sep { color: var(--border-strong); margin: 0 0.15rem; }
.breadcrumbs [aria-current="page"] { color: var(--heading); font-weight: 600; }

/* =========================================================================
   Prose / content typography
   ========================================================================= */
.content { max-width: var(--prose); }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.15rem; }

.prose h1 {
  font-size: clamp(1.8rem, 3.6vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em;
  margin: 0.3rem 0 1.2rem; font-weight: 800;
  background: linear-gradient(100deg, var(--primary), var(--accent) 60%, var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); color: var(--heading); margin-top: 2.4rem; font-weight: 750; letter-spacing: -0.01em; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: clamp(1.18rem, 2vw, 1.4rem); color: var(--primary-700); margin-top: 1.9rem; font-weight: 700; }
.prose h4 { font-size: 1.1rem; color: var(--heading); margin-top: 1.5rem; font-weight: 700; }
.prose h2, .prose h3, .prose h4 { scroll-margin-top: calc(var(--header-h) + 1.25rem); }

.prose p { color: var(--text); }
.prose strong { color: var(--heading); font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-top: 0.4rem; }
.prose li::marker { color: var(--primary); }

.prose blockquote {
  border-left: 4px solid var(--accent); background: var(--surface-2);
  margin: 1.4rem 0; padding: 0.8rem 1.2rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted);
}

/* Links in content */
.prose a { color: var(--primary); font-weight: 500; text-decoration: none; background-image: linear-gradient(var(--primary), var(--primary)); background-size: 0% 2px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size 0.25s ease, color 0.2s ease; padding-bottom: 1px; }
.prose a:hover { color: var(--primary-700); background-size: 100% 2px; }
.prose a.ext-link { color: var(--teal); background-image: linear-gradient(var(--teal), var(--teal)); }
.prose a.ext-link:hover { color: #0b7d72; }

/* Header anchor link */
.header-anchor { margin-left: 0.4rem; color: var(--border-strong); opacity: 0; text-decoration: none; font-weight: 600; transition: opacity 0.2s ease, color 0.2s ease; background: none; }
.prose h2:hover .header-anchor, .prose h3:hover .header-anchor, .prose h4:hover .header-anchor { opacity: 1; }
.header-anchor:hover { color: var(--primary); }

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

/* =========================================================================
   Code blocks (light, with copy button)
   ========================================================================= */
.code-block { margin: 1.5rem 0; border: 1px solid var(--code-border); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.6rem 0.4rem 0.95rem; background: linear-gradient(180deg, #eef3f9, #e7eef7); border-bottom: 1px solid var(--code-border); }
.code-lang { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; color: var(--primary-700); text-transform: uppercase; }
.copy-btn { display: inline-flex; align-items: center; gap: 0.35rem; font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 0.25rem 0.6rem; cursor: pointer; transition: all 0.18s ease; }
.copy-btn:hover { color: var(--primary-700); border-color: var(--primary); background: #fff; }
.copy-btn.copied { color: #fff; background: var(--teal); border-color: var(--teal); }
.code-block pre { margin: 0; padding: 1rem 1.1rem; overflow-x: auto; background: var(--code-bg); font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.6; tab-size: 2; }
.code-block code { font-family: var(--font-mono); background: none; padding: 0; color: #243447; white-space: pre; }

/* Prism light token theme tuned to palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7d8ca0; font-style: italic; }
.token.punctuation { color: #5b6b7d; }
.token.keyword, .token.boolean, .token.atrule, .token.important { color: var(--primary); font-weight: 600; }
.token.string, .token.char, .token.attr-value, .token.inserted { color: #0b7d72; }
.token.number, .token.constant, .token.symbol { color: #b4690e; }
.token.function, .token.class-name { color: var(--accent); }
.token.operator, .token.entity, .token.url { color: #4b5b6c; background: none; }
.token.builtin, .token.tag, .token.selector { color: #c2410c; }
.token.property, .token.attr-name { color: #1d4f86; }
.token.variable { color: #b4690e; }
.token.deleted { color: #c0392b; }
.token.namespace { opacity: 0.7; }

/* =========================================================================
   Tables (responsive, styled)
   ========================================================================= */
.table-scroll { 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-scroll table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 0.95rem; background: var(--surface); }
.table-scroll th, .table-scroll td { padding: 0.7rem 0.95rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-scroll thead th { background: linear-gradient(180deg, #eef3f9, #e6eef7); color: var(--primary-700); font-weight: 700; position: sticky; top: 0; white-space: nowrap; }
.table-scroll tbody tr { transition: background 0.15s ease; }
.table-scroll tbody tr:nth-child(even) { background: #fafcfe; }
.table-scroll tbody tr:hover { background: #eef5fc; }
.table-scroll tbody tr:last-child td { border-bottom: 0; }

/* =========================================================================
   Task lists (interactive checkboxes)
   ========================================================================= */
.prose ul:has(> .task-list-item) { list-style: none; padding-left: 0.2rem; }
.task-list-item { display: flex; align-items: flex-start; gap: 0.55rem; }
.task-list-item::marker { content: ""; }
.task-list-paragraph { display: flex; align-items: flex-start; gap: 0.55rem; margin: 0; }
.task-checkbox { appearance: none; -webkit-appearance: none; flex: none; width: 1.18em; height: 1.18em; margin-top: 0.2em; border: 2px solid var(--border-strong); border-radius: 6px; background: var(--surface); cursor: pointer; display: inline-grid; place-content: center; transition: background 0.18s ease, border-color 0.18s ease; }
.task-checkbox::before { content: ""; width: 0.62em; height: 0.62em; transform: scale(0); transform-origin: center; transition: transform 0.15s ease; box-shadow: inset 1em 1em #fff; clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 22%, 80% 0%, 38% 70%); }
.task-checkbox:checked { background: var(--teal); border-color: var(--teal); }
.task-checkbox:checked::before { transform: scale(1); }
.task-checkbox:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.task-list-item:has(.task-checkbox:checked) { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(88, 106, 125, 0.6); }
.task-list-item:has(.task-checkbox:checked) code { text-decoration: line-through; }

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

/* =========================================================================
   Related content (bottom of page)
   ========================================================================= */
.related { max-width: var(--prose); margin: 3rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.related-group + .related-group { margin-top: 2rem; }
.related-title { display: flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; color: var(--heading); margin: 0 0 1rem; }
.related-icon { color: var(--accent); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.9rem; }
.related-card { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1.1rem; box-shadow: var(--shadow-sm); transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.related-card-title { font-weight: 600; color: var(--heading); }
.related-card-go { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--primary); font-size: 0.85rem; font-weight: 600; flex: none; }
.related-card--sm .related-card-title { font-size: 0.95rem; }

/* =========================================================================
   KaTeX / Mermaid theming
   ========================================================================= */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }
.katex { font-size: 1.05em; }
/* Diagram figures (Mermaid) + fullscreen lightbox */
.diagram { margin: 1.8rem 0; position: relative; }
.diagram-frame {
  position: relative; background: linear-gradient(180deg, #ffffff, var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sm); overflow-x: auto; transition: box-shadow 0.22s ease, border-color 0.22s ease;
}
.diagram--ready .diagram-frame:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
pre.mermaid { margin: 0; background: none; border: 0; padding: 0; text-align: center; line-height: initial; }
pre.mermaid:not([data-processed]) { color: transparent; min-height: 2rem; }
pre.mermaid svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.diagram-caption { margin-top: 0.6rem; text-align: center; font-size: 0.9rem; color: var(--muted); font-style: italic; }
.diagram-expand {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2;
  display: inline-flex; align-items: center; gap: 0.35rem;
  font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--primary-700);
  background: rgba(255, 255, 255, 0.92); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 0.3rem 0.55rem; cursor: zoom-in; opacity: 0; transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.diagram--ready:hover .diagram-expand, .diagram-expand:focus-visible { opacity: 1; transform: translateY(0); }
.diagram-expand:hover { background: #fff; border-color: var(--primary); }
@media (hover: none) { .diagram-expand { opacity: 1; transform: none; } }

.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  background: rgba(15, 34, 54, 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.2s ease;
}
.lightbox.is-open { opacity: 1; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem clamp(1rem, 3vw, 2rem); color: #fff; }
.lightbox-title { font-weight: 700; font-size: 1.02rem; }
.lightbox-close { font-size: 1.8rem; line-height: 1; color: #fff; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 10px; width: 44px; height: 44px; cursor: pointer; transition: background 0.18s ease, transform 0.18s ease; }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.24); transform: rotate(90deg); }
.lightbox-stage { flex: 1; display: grid; place-items: center; padding: 0 clamp(1rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2.5rem); min-height: 0; cursor: zoom-out; }
.lightbox-stage svg { background: #fff; border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-lg); }
body.lightbox-open { overflow: hidden; }

.offline-page { text-align: center; padding: 3rem 0; }

/* =========================================================================
   Responsive
   ========================================================================= */
@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-lg); transform: translateY(-12px); opacity: 0; pointer-events: none; transition: transform 0.22s ease, opacity 0.22s ease; max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
  body.nav-open .primary-nav { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .primary-nav ul { flex-direction: column; gap: 0.2rem; padding: 0.8rem clamp(1rem, 4vw, 2rem); }
  .primary-nav a { width: 100%; font-size: 1.02rem; padding: 0.75rem 0.9rem; }
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .brand-sub { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 1rem; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .cta-btn { width: 100%; }
  .footer-inner { flex-direction: column; gap: 1.8rem; }
}

/* Widescreen: use more real estate, but keep prose readable-wide (not narrow) */
@media (min-width: 1600px) {
  :root { --container: 1480px; --prose: 1280px; }
}

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