/* =========================================================================
   clusterautomation.org — MariaDB Galera Cluster Automation
   Light, elegant, professional theme. Teal/indigo primaries, warm accent.
   ========================================================================= */

:root {
  /* Brand palette */
  --teal-900: #134e4a;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-200: #99f6e4;
  --teal-100: #ccfbf1;
  --indigo-700: #4338ca;
  --indigo-600: #4f46e5;
  --indigo-200: #c7d2fe;
  --amber-400: #fbbf24;
  --amber-300: #fcd34d;

  /* Ink & surfaces */
  --ink: #15242b;
  --ink-soft: #3c4f57;
  --ink-muted: #64777f;
  --surface: #f7faf9;
  --surface-2: #eef4f3;
  --card: #ffffff;
  --line: #dde7e6;
  --line-strong: #c6d6d4;

  /* Semantic */
  --primary: var(--teal-700);
  --primary-strong: var(--teal-900);
  --accent: var(--indigo-600);
  --link: #0e7490;
  --link-hover: var(--indigo-600);

  /* Code */
  --code-bg: #f1f6f9;
  --code-inline-bg: #eaf2f1;
  --code-ink: #1f3b44;
  --code-border: #e2ecec;

  /* Geometry */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --header-h: 64px;
  --shadow-sm: 0 1px 2px rgba(15, 42, 38, 0.06), 0 1px 3px rgba(15, 42, 38, 0.05);
  --shadow: 0 6px 20px rgba(15, 42, 38, 0.08);
  --shadow-lg: 0 18px 50px rgba(15, 42, 38, 0.14);

  /* Layout widths — wide on desktop, never a narrow column */
  --wrap: 1180px;
  --wrap-wide: 1380px;

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

@media (min-width: 1600px) {
  :root { --wrap: var(--wrap-wide); --header-h: 70px; }
}

/* ----- 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(--ink);
  background: var(--surface);
  line-height: 1.65;
  font-size: clamp(16px, 0.95rem + 0.2vw, 18px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  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; }

.icon { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.18em; fill: none; }

/* ----- Header ----------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 250, 249, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--ink); }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; filter: drop-shadow(0 2px 5px rgba(15,42,38,.18)); transition: transform .25s ease; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; letter-spacing: -0.01em; font-size: 1.06rem; }
.brand-accent { color: var(--accent); }
.brand-sub { font-size: 0.7rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }

.primary-nav { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); transform: translateY(-1px); }
.nav-link .icon { color: var(--primary); }
.nav-link.is-active { background: var(--teal-100); color: var(--primary-strong); }
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -3px;
  transform: translateX(-50%);
  width: 18px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--teal-600), var(--indigo-600));
}

.nav-toggle {
  display: none;
  margin-left: auto;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  cursor: pointer;
}
.nav-toggle .icon { width: 22px; height: 22px; }
.nav-toggle .nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-block; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute;
    top: var(--header-h); left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem clamp(1rem, 3vw, 2rem) 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
  }
  .primary-nav.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .nav-link { padding: 0.7rem 0.9rem; border-radius: 10px; }
  .nav-link.is-active::after { display: none; }
}

/* ----- Main layout & footer pin ---------------------------------------- */
.site-main { flex: 1 0 auto; width: 100%; }
.site-footer { flex-shrink: 0; }

/* ----- Hero ------------------------------------------------------------- */
.hero {
  background:
    radial-gradient(1200px 500px at 18% -10%, var(--teal-100), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--indigo-200), transparent 55%),
    linear-gradient(180deg, #ffffff, var(--surface));
  border-bottom: 1px solid var(--line);
}
.hero-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 3vw, 2rem) clamp(2rem, 5vw, 4rem);
  text-align: center;
}
.hero-logo-row { display: block; margin-bottom: 1.5rem; }
.hero-logo {
  width: clamp(96px, 16vw, 156px);
  height: auto;
  border-radius: 32px;
  filter: drop-shadow(0 14px 30px rgba(15, 42, 38, 0.22));
  transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.hero-logo:hover { transform: translateY(-4px) scale(1.03); }
.hero-title {
  font-size: clamp(2rem, 1.4rem + 3vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin: 0 0 1rem;
  color: var(--ink);
}
.hero-title-accent {
  background: linear-gradient(100deg, var(--teal-600), var(--indigo-600));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede {
  max-width: 64ch;
  margin: 0 auto 2rem;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.28rem);
  color: var(--ink-soft);
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  color: var(--ink);
  min-width: 260px;
}
.cta-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.cta-icon {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent);
  flex-shrink: 0;
}
.cta-icon .icon { width: 24px; height: 24px; }
.cta-text { display: flex; flex-direction: column; }
.cta-label { font-weight: 700; }
.cta-sub { font-size: 0.82rem; color: var(--ink-muted); }
.cta-arrow { margin-left: auto; color: var(--accent); transition: transform .22s ease; }
.cta-btn:hover .cta-arrow { transform: translateX(4px); }

/* ----- Generic section shells ------------------------------------------ */
.intro-inner, .sections-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1rem, 3vw, 2rem);
}
.section-heading {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem);
  letter-spacing: -0.01em;
  margin: 0 0 1.2rem;
  position: relative;
  padding-left: 0.9rem;
}
.section-heading::before {
  content: ""; position: absolute; left: 0; top: 0.15em; bottom: 0.15em;
  width: 5px; border-radius: 5px;
  background: linear-gradient(180deg, var(--teal-500), var(--indigo-600));
}
.intro p { color: var(--ink-soft); }
.intro code { font-size: 0.92em; }

/* ----- Section cards (frontpage) --------------------------------------- */
.section-cards {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.section-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  display: flex;
  flex-direction: column;
}
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.section-card-head { display: flex; align-items: center; gap: 0.85rem; color: var(--ink); }
.section-card-head h3 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.section-card-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #000));
}
.section-card-icon .icon { width: 26px; height: 26px; }
.section-card-blurb { color: var(--ink-soft); margin: 1rem 0; }
.section-card-links { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.1rem; }
.section-card-links a {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.5rem; border-radius: 8px;
  color: var(--ink-soft); font-weight: 500;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.section-card-links a:hover { background: var(--surface-2); color: var(--primary-strong); transform: translateX(3px); }
.section-card-links .icon { width: 1rem; height: 1rem; color: var(--accent); }
.section-card-all {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 700; color: var(--accent);
}
.section-card-all .icon { transition: transform .2s ease; }
.section-card-all:hover .icon { transform: translateX(4px); }

/* ----- Document shell --------------------------------------------------- */
.doc-shell {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 3.5rem;  /* horizontal matches the header */
}

.breadcrumbs { margin: 0.5rem 0 1.5rem; font-size: 0.9rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem; margin: 0; padding: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.15rem; color: var(--ink-muted); }
.breadcrumbs a { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--ink-muted); padding: 0.2rem 0.35rem; border-radius: 7px; transition: background .18s, color .18s; }
.breadcrumbs a:hover { background: var(--surface-2); color: var(--primary); }
.breadcrumbs .icon { width: 0.95rem; height: 0.95rem; }
.crumb-sep { color: var(--line-strong); width: 0.85rem; height: 0.85rem; }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 600; padding: 0.2rem 0.35rem; }

/* ----- Prose / content -------------------------------------------------- */
/* Content fills the full width of its container (same --wrap as the header),
   never a narrow reading column. */
.prose, .prose > * { max-width: 100%; }

.prose h1 {
  font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin: 0.2rem 0 1.2rem;
  background: linear-gradient(100deg, var(--teal-700), var(--indigo-600) 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2, .prose h3, .prose h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  scroll-margin-top: calc(var(--header-h) + 1rem);  /* anchor offset under sticky header */
  position: relative;
}
.prose h2 {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
.prose h2::before {
  content: ""; position: absolute; left: -0.9rem; top: 0.15em; height: 1.1em; width: 5px;
  border-radius: 5px; background: linear-gradient(180deg, var(--teal-500), var(--indigo-600));
}
.prose h3 { font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem); margin: 1.8rem 0 0.7rem; color: var(--teal-900); }
.prose h4 { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; color: var(--ink-soft); }
.prose p { margin: 0 0 1.1rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); }

/* In-content links */
.prose a {
  color: var(--link);
  font-weight: 500;
  text-decoration: none;
  background-image: linear-gradient(var(--link-hover), var(--link-hover));
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size .25s ease, color .2s ease;
  padding-bottom: 1px;
}
.prose a:hover { color: var(--link-hover); background-size: 100% 2px; }

/* Heading permalink anchor */
.heading-anchor {
  opacity: 0;
  margin-left: 0.4rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  background: none;
  transition: opacity .15s ease;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor { opacity: 0.7; }

/* Lists */
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.2rem; color: var(--ink-soft); }
.prose li { margin: 0.35rem 0; }
.prose li::marker { color: var(--teal-600); }

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

/* Blockquotes */
.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.6rem 1.1rem;
  border-left: 4px solid var(--teal-500);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}

/* ----- Code blocks ------------------------------------------------------ */
.prose pre {
  position: relative;
  margin: 1.4rem 0;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.prose pre code { font-family: var(--font-mono); color: var(--code-ink); background: none; padding: 0; font-size: inherit; }

.code-copy {
  position: absolute;
  top: 0.55rem; right: 0.55rem;
  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.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity .18s ease, background .18s ease, color .18s ease, border-color .18s;
}
.prose pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: #fff; color: var(--primary); border-color: var(--teal-200); }
.code-copy .icon { width: 0.95rem; height: 0.95rem; }
.code-copy.is-copied { color: var(--teal-700); border-color: var(--teal-200); background: var(--teal-100); opacity: 1; }
@media (hover: none) { .code-copy { opacity: 1; } }

/* Prism light syntax theme — tuned to the palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7e8c93; font-style: italic; }
.token.punctuation { color: #5b6b72; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: #b45309; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #0f766e; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #6d28d9; }
.token.atrule, .token.attr-value, .token.keyword { color: #4f46e5; }
.token.function, .token.class-name { color: #be185d; }
.token.regex, .token.important, .token.variable { color: #c2410c; }

/* ----- Tables ----------------------------------------------------------- */
.table-scroll {
  width: 100%;
  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: 520px; font-size: 0.92rem; }
.prose thead th {
  background: linear-gradient(180deg, var(--teal-100), var(--surface-2));
  color: var(--primary-strong);
  text-align: left;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
  border-bottom: 2px solid var(--line-strong);
  white-space: nowrap;
}
.prose tbody td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-soft); }
.prose tbody tr:nth-child(even) { background: var(--surface-2); }
.prose tbody tr:hover { background: var(--teal-100); }
.prose tbody tr:last-child td { border-bottom: none; }

/* ----- Task lists (checkboxes) ----------------------------------------- */
.prose ul.contains-task-list, .prose .contains-task-list { list-style: none; padding-left: 0.2rem; }
.prose li.task-list-item { list-style: none; display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.2rem 0; }
.prose li.task-list-item::marker { content: ""; }       /* remove the dot in front */
.prose li.task-list-item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 1.2em; height: 1.2em; margin: 0.2em 0 0;
  flex-shrink: 0;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.prose li.task-list-item input[type="checkbox"]:hover { border-color: var(--teal-500); }
.prose li.task-list-item input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--teal-600), var(--indigo-600));
  border-color: transparent;
}
.prose li.task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute; left: 0.32em; top: 0.12em;
  width: 0.3em; height: 0.6em;
  border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(43deg);
}
.prose li.task-list-item input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.prose li.task-list-item.is-checked { color: var(--ink-muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ----- FAQ / accordions ------------------------------------------------- */
.prose details, details.faq {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin: 0.8rem 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.prose details > summary, details.faq > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  color: var(--ink);
  display: flex; align-items: center; gap: 0.6rem;
  transition: background .18s ease;
}
.prose details > summary::-webkit-details-marker { display: none; }
.prose details > summary::before {
  content: "";
  width: 0.55em; height: 0.55em;
  border-right: 2.5px solid var(--accent);
  border-bottom: 2.5px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.prose details[open] > summary::before { transform: rotate(45deg); }
.prose details > summary:hover { background: var(--surface-2); }
.prose details > *:not(summary) { padding: 0 1.1rem; }
.prose details[open] > *:not(summary):last-child { padding-bottom: 1rem; }

/* ----- Mermaid diagrams ------------------------------------------------- */
.prose pre.mermaid {
  background: var(--card);
  border: 1px solid var(--line);
  text-align: center;
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.prose pre.mermaid:not([data-processed]) { color: transparent; min-height: 3rem; }
.prose pre.mermaid svg { max-width: 100%; height: auto; }

/* Click-to-zoom affordance once a diagram has rendered */
.prose pre.mermaid.diagram-zoomable { cursor: zoom-in; transition: border-color .2s ease, box-shadow .2s ease; }
.prose pre.mermaid.diagram-zoomable:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow); }
.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(--line);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: zoom-in;
  opacity: 0;
  transition: opacity .18s ease, color .18s ease, border-color .18s ease;
}
.prose pre.mermaid:hover .diagram-expand,
.diagram-expand:focus-visible { opacity: 1; }
.diagram-expand:hover { color: var(--primary); border-color: var(--teal-200); }
.diagram-expand .icon { width: 0.95rem; height: 0.95rem; }
@media (hover: none) { .diagram-expand { opacity: 1; } }

/* Full-screen diagram modal */
.diagram-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  background: rgba(15, 42, 38, 0.62);
  backdrop-filter: blur(4px);
  animation: diagram-fade .18s ease;
}
.diagram-modal[hidden] { display: none; }
@keyframes diagram-fade { from { opacity: 0; } to { opacity: 1; } }
.diagram-modal-stage {
  width: 92vw;
  height: 86vh;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(1rem, 3vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.diagram-modal-stage svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
.diagram-modal-close {
  position: absolute;
  top: clamp(0.8rem, 2vw, 1.5rem);
  right: clamp(0.8rem, 2vw, 1.5rem);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.diagram-modal-close:hover { background: #fff; transform: scale(1.06); }
.diagram-modal-close .icon { width: 22px; height: 22px; }
body.modal-open { overflow: hidden; }

/* ----- Related navigation ---------------------------------------------- */
.related { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.related-title { font-size: 1.15rem; margin: 1.5rem 0 0.9rem; color: var(--ink); }
.related-grid { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.related-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  height: 100%;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  color: var(--ink);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.related-card-title { font-weight: 700; color: var(--primary-strong); padding-right: 1.6rem; }
.related-card-desc { font-size: 0.86rem; color: var(--ink-muted); }
.related-card-arrow { position: absolute; top: 1rem; right: 1rem; color: var(--accent); width: 1.1rem; height: 1.1rem; transition: transform .2s ease; }
.related-card:hover .related-card-arrow { transform: translate(3px, -3px); }
.related-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; }
.related-list a { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--link); font-weight: 500; padding: 0.35rem 0.5rem; border-radius: 8px; transition: background .18s, transform .18s; }
.related-list a:hover { background: var(--surface-2); color: var(--link-hover); transform: translateX(3px); }
.related-list .icon { width: 1rem; height: 1rem; color: var(--accent); }

/* ----- Footer ----------------------------------------------------------- */
.site-footer { background: linear-gradient(180deg, var(--surface), var(--surface-2)); border-top: 1px solid var(--line); }
.footer-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem);
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
}
.footer-brand { display: flex; gap: 1rem; align-items: flex-start; max-width: 52ch; }
.footer-logo { width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0; }
.footer-title { font-weight: 800; margin: 0 0 0.3rem; color: var(--ink); }
.footer-tagline { margin: 0; color: var(--ink-muted); font-size: 0.92rem; }
.footer-nav { display: flex; flex-direction: column; gap: 0.4rem; min-width: 200px; }
.footer-heading { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--ink-muted); margin: 0 0 0.3rem; }
.footer-nav a { color: var(--ink-soft); font-weight: 500; transition: color .18s, transform .18s; width: max-content; }
.footer-nav a:hover { color: var(--primary); transform: translateX(3px); }
.footer-base { border-top: 1px solid var(--line); }
.footer-base p { max-width: var(--wrap); margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem); font-size: 0.82rem; color: var(--ink-muted); }

/* ----- Misc ------------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
