/* =================================================================
   Vitess/MySQL Sharded Topology — stylesheet
   Light, professional palette. Mobile-first, widescreen-aware.
   ================================================================= */

:root {
  /* Palette */
  --primary: #3a4cc8;
  --primary-600: #2f3da6;
  --primary-700: #283590;
  --primary-soft: #e7eafc;
  --accent: #14a99a;
  --accent-strong: #0f8a7e;
  --accent-soft: #d7f5f0;
  --amber: #ef9220;
  --amber-strong: #cf7912;
  --amber-soft: #fdeccf;

  --ink: #1b2236;
  --ink-soft: #2c3552;
  --muted: #5a647b;
  --faint: #8a93a8;

  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef1fb;
  --surface-3: #e7ebf7;
  --border: #e1e6f1;
  --border-strong: #cfd6e6;

  --code-bg: #f4f6fc;
  --code-border: #e3e8f3;

  /* Type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code",
    "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout */
  --wrap: 1320px;
  --article: 1180px;
  --header-h: 66px;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(27, 34, 54, 0.06), 0 1px 3px rgba(27, 34, 54, 0.05);
  --shadow: 0 6px 20px -6px rgba(27, 34, 54, 0.16);
  --shadow-lg: 0 22px 48px -18px rgba(27, 34, 54, 0.30);

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

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(16px, 0.97rem + 0.15vw, 18px);
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 88% -8%, rgba(58, 76, 200, 0.07), transparent 60%),
    radial-gradient(900px 460px at 4% 2%, rgba(20, 169, 154, 0.07), transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.22; color: var(--ink); }
p { margin: 0 0 1.05em; }

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color 0.18s var(--ease);
}
a:hover { color: var(--accent-strong); }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.75rem);
}

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

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

.site-main { flex: 1 0 auto; }
.icon { width: 1.15em; height: 1.15em; flex: none; }

/* =================================================================
   Header
   ================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 700;
  margin-right: auto;
}
.brand-logo { transition: transform 0.3s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-size: 1.06rem;
  letter-spacing: -0.01em;
  background: linear-gradient(95deg, var(--primary-600), var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { font-size: 0.7rem; color: var(--faint); font-weight: 600; letter-spacing: 0.03em; }

.primary-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  position: relative;
  transition: color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.nav-link .icon { color: var(--faint); transition: color 0.18s var(--ease); }
.nav-link:hover { color: var(--primary-700); background: var(--surface-2); }
.nav-link:hover .icon { color: var(--primary); }
.nav-link.is-active { color: var(--primary-700); background: var(--primary-soft); }
.nav-link.is-active .icon { color: var(--primary); }
.nav-link--teal.is-active { color: var(--accent-strong); background: var(--accent-soft); }
.nav-link--teal.is-active .icon { color: var(--accent-strong); }
.nav-link--amber.is-active { color: var(--amber-strong); background: var(--amber-soft); }
.nav-link--amber.is-active .icon { color: var(--amber-strong); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle .icon { width: 1.4em; height: 1.4em; }
.nav-toggle-close { display: none; }

/* =================================================================
   Footer
   ================================================================= */
.site-footer {
  flex-shrink: 0;
  margin-top: 4rem;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  justify-content: space-between;
  padding-top: 2.6rem;
  padding-bottom: 1.6rem;
}
.footer-brand { display: flex; gap: 0.85rem; align-items: flex-start; max-width: 360px; }
.footer-name { font-weight: 700; margin: 0; color: var(--ink); }
.footer-tagline { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; }
.footer-heading {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin: 0 0 0.7rem;
  font-weight: 700;
}
.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.5rem;
  color: var(--ink-soft);
  font-weight: 500;
}
.footer-nav a .icon { color: var(--faint); transition: color 0.18s var(--ease); }
.footer-nav a:hover { color: var(--primary-700); }
.footer-nav a:hover .icon { color: var(--accent); }
.footer-bottom {
  padding-block: 1rem 1.6rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-bottom p { margin: 0; }

/* =================================================================
   Hero / homepage
   ================================================================= */
.hero { padding-top: clamp(2.5rem, 6vw, 4.5rem); padding-bottom: 1rem; }
.hero-inner { text-align: center; }
.hero-logo img {
  width: clamp(140px, 22vw, 210px);
  filter: drop-shadow(0 18px 30px rgba(58, 76, 200, 0.22));
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
.hero-title {
  font-size: clamp(2rem, 1.3rem + 3.2vw, 3.5rem);
  letter-spacing: -0.02em;
  margin: 1.2rem 0 0.4rem;
  font-weight: 800;
}
.hero-title-accent {
  background: linear-gradient(95deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lede {
  max-width: 760px;
  margin: 0.5rem auto 0;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
  color: var(--muted);
}

.hero-cta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.1rem;
  margin: 2.6rem auto 0;
  max-width: 1100px;
  text-align: left;
}
.cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  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 {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 15px;
  color: #fff;
  flex: none;
  box-shadow: 0 8px 18px -6px rgba(0,0,0,0.35);
}
.cta-icon .icon { width: 1.5em; height: 1.5em; }
.cta-title { display: block; font-weight: 700; color: var(--ink); font-size: 1.08rem; }
.cta-sub { display: block; color: var(--muted); font-size: 0.86rem; margin-top: 0.15rem; }
.cta-go { margin-left: auto; color: var(--faint); transition: transform 0.25s var(--ease), color 0.25s var(--ease); }
.cta:hover .cta-go { transform: translateX(5px); }

/* Accent theming for CTA / nav / explore columns */
.cta--indigo .cta-icon, .explore-col--indigo .explore-col-icon { background: linear-gradient(135deg, #5667e8, var(--primary-700)); }
.cta--teal   .cta-icon, .explore-col--teal   .explore-col-icon { background: linear-gradient(135deg, #1fc6b4, var(--accent-strong)); }
.cta--amber  .cta-icon, .explore-col--amber  .explore-col-icon { background: linear-gradient(135deg, #f7ad4a, var(--amber-strong)); }
.cta--indigo:hover { border-color: var(--primary); }
.cta--teal:hover   { border-color: var(--accent); }
.cta--amber:hover  { border-color: var(--amber); }
.cta--indigo:hover .cta-go { color: var(--primary); }
.cta--teal:hover .cta-go   { color: var(--accent-strong); }
.cta--amber:hover .cta-go  { color: var(--amber-strong); }

/* Intro */
.intro { padding-top: 3.2rem; }
.intro-prose h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin: 0 0 0.8rem; }

/* Explore grid */
.explore { padding-top: 3rem; padding-bottom: 1rem; }
.explore-heading { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin: 0 0 0.3rem; }
.explore-sub { color: var(--muted); max-width: 720px; margin: 0 0 2rem; }
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.4rem;
  align-items: start;
}
.explore-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem 1.6rem;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--primary);
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}
.explore-col--teal  { border-top-color: var(--accent); }
.explore-col--amber { border-top-color: var(--amber); }
.explore-col:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.explore-col-head { display: flex; align-items: center; gap: 0.7rem; color: var(--ink); }
.explore-col-icon {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px; color: #fff; flex: none;
}
.explore-col-title { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.explore-col:hover .explore-col-title { color: var(--primary-700); }
.explore-col-blurb { color: var(--muted); font-size: 0.92rem; margin: 0.85rem 0 1rem; }

/* Link lists */
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.link-list > li > a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.link-list > li > a .icon { color: var(--accent); align-self: center; transition: transform 0.18s var(--ease); }
.link-list > li > a:hover { color: var(--primary-700); }
.link-list > li > a:hover .icon { transform: translateX(3px); }
.link-sublist { list-style: none; margin: 0.35rem 0 0.5rem 1.65rem; padding: 0; display: grid; gap: 0.3rem; }
.link-sublist a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.link-sublist a:hover { color: var(--accent-strong); }

/* =================================================================
   Article / content pages
   ================================================================= */
/* .article shares the same .wrap width as the header so content lines up with it */
.article {
  padding-top: 1.6rem;
  padding-bottom: 1rem;
}
.article-body { max-width: 100%; }

/* Breadcrumbs */
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.35rem;
  margin: 0 0 1.4rem;
  padding: 0;
  font-size: 0.86rem;
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.breadcrumbs a { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--primary-700); }
.breadcrumbs .icon-chevron { width: 0.95em; height: 0.95em; color: var(--border-strong); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }
.breadcrumbs li:first-child .icon { color: var(--accent); }

/* Headings within content */
.article-body h1 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.9rem);
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  font-weight: 800;
  background: linear-gradient(100deg, var(--primary-700) 10%, var(--primary) 45%, var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article-body h2 {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem);
  margin: 2.4rem 0 0.9rem;
  padding-top: 0.6rem;
  font-weight: 750;
  position: relative;
}
.article-body h2::before {
  content: "";
  display: block;
  width: 52px; height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  margin-bottom: 0.7rem;
}
.article-body h3 {
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.4rem);
  margin: 1.8rem 0 0.6rem;
  color: var(--primary-700);
  font-weight: 700;
}
.article-body h4 { font-size: 1.08rem; margin: 1.4rem 0 0.5rem; color: var(--ink-soft); }

/* Heading anchor offset for sticky header + hover link */
.article-body :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: calc(var(--header-h) + 1.2rem); }
.header-anchor {
  opacity: 0;
  margin-left: 0.4rem;
  color: var(--faint);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease);
}
.article-body :is(h2, h3, h4):hover .header-anchor { opacity: 1; }
.header-anchor:hover { color: var(--accent); }

.article-body p { color: var(--ink-soft); }
.article-body strong { color: var(--ink); font-weight: 700; }

/* In-content links */
.article-body a:not(.related-card):not(.btn) {
  color: var(--primary-600);
  font-weight: 600;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s var(--ease), color 0.18s var(--ease);
  padding-bottom: 1px;
}
.article-body a:not(.related-card):not(.btn):hover {
  color: var(--accent-strong);
  background-size: 100% 2px;
}

/* Lists */
.article-body ul, .article-body ol { padding-left: 1.4rem; margin: 0 0 1.1em; }
.article-body li { margin: 0.35em 0; color: var(--ink-soft); }
.article-body li::marker { color: var(--primary); }

/* Blockquote */
.article-body blockquote {
  margin: 1.4rem 0;
  padding: 0.4rem 1.2rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2.2rem 0; }

/* =================================================================
   Code
   ================================================================= */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  color: var(--primary-700);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  word-break: break-word;
}

.code-block {
  position: relative;
  margin: 1.5rem 0;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: 0; left: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--surface-3);
  padding: 0.25rem 0.7rem;
  border-bottom-right-radius: var(--radius-sm);
  border-right: 1px solid var(--code-border);
  border-bottom: 1px solid var(--code-border);
}
.code-block pre {
  margin: 0;
  padding: 2.3rem 1.2rem 1.2rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  tab-size: 2;
}
.code-block code { font-family: var(--font-mono); color: var(--ink); }

.copy-btn {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--primary-700); border-color: var(--primary); }
.copy-done { display: none; color: var(--accent-strong); }
.code-block.is-copied .copy-btn { opacity: 1; border-color: var(--accent); }
.code-block.is-copied .copy-default { display: none; }
.code-block.is-copied .copy-done { display: inline; }

/* Prism token colours — tuned to the palette, light background */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8a93a8; font-style: italic; }
.token.punctuation { color: #6b7385; }
.token.keyword, .token.control, .token.atrule, .token.important { color: #5b1fb0; font-weight: 600; }
.token.boolean, .token.number, .token.constant { color: #b3541e; }
.token.string, .token.char, .token.attr-value, .token.regex { color: #117a52; }
.token.operator, .token.entity, .token.url { color: #b5179e; }
.token.function, .token.class-name { color: #1456b0; }
.token.builtin, .token.tag, .token.symbol { color: var(--accent-strong); }
.token.property, .token.attr-name { color: #2f3da6; }
.token.variable, .token.parameter { color: var(--ink); }
.token.deleted { color: #c0392b; }
.token.inserted { color: #117a52; }
.token.namespace { opacity: 0.7; }

/* =================================================================
   Tables (responsive)
   ================================================================= */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.article-body table {
  border-collapse: collapse;
  width: 100%;
  min-width: 440px;
  font-size: 0.92rem;
  background: var(--surface);
}
.article-body th, .article-body td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.article-body thead th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-strong);
}
.article-body tbody tr { transition: background-color 0.15s var(--ease); }
.article-body tbody tr:hover { background: var(--primary-soft); }
.article-body tbody tr:last-child td { border-bottom: none; }

/* =================================================================
   Task-list checkboxes
   ================================================================= */
.article-body ul.contains-task-list { list-style: none; padding-left: 0.2rem; }
.article-body ul.contains-task-list ul.contains-task-list { padding-left: 1.5rem; }
.task-list-item { display: flex; align-items: flex-start; gap: 0.6rem; }
.task-list-item::marker { content: ""; }
.task-list-item label { display: inline; }
.task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.2em; height: 1.2em;
  margin: 0.18em 0 0;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.task-list-item input[type="checkbox"]:hover { border-color: var(--primary); }
.task-list-item input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 0.32em; top: 0.12em;
  width: 0.32em; height: 0.6em;
  border: solid #fff;
  border-width: 0 0.16em 0.16em 0;
  transform: rotate(42deg);
}
.task-list-item:has(input[type="checkbox"]:checked) { color: var(--faint); }
.task-list-item:has(input[type="checkbox"]:checked) label,
.task-list-item input[type="checkbox"]:checked ~ * { text-decoration: line-through; color: var(--faint); }

/* =================================================================
   FAQ accordions
   ================================================================= */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0.7rem 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 3rem 1rem 1.1rem;
  font-weight: 700;
  color: var(--ink);
  position: relative;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  position: absolute;
  right: 1.2rem; top: 50%;
  width: 0.6rem; height: 0.6rem;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 0.22s var(--ease);
}
.faq-item[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq-item summary:hover { background: var(--surface-2); color: var(--primary-700); }
.faq-item[open] summary { background: var(--primary-soft); color: var(--primary-700); }
.faq-item > :not(summary) { margin-inline: 1.1rem; }
.faq-item > :last-child { margin-bottom: 1rem; }
.faq-heading { margin-bottom: 1rem; }

/* Mermaid + KaTeX */
.mermaid { text-align: center; margin: 1.6rem 0; position: relative; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }

/* Click-to-fullscreen diagrams */
.mermaid.diagram-zoomable {
  cursor: zoom-in;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.6rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.mermaid.diagram-zoomable:hover,
.mermaid.diagram-zoomable:focus-visible {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  outline: none;
}
.diagram-expand {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--primary-700);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}
.diagram-expand .icon,
.diagram-expand svg { width: 1.1rem; height: 1.1rem; }
.mermaid.diagram-zoomable:hover .diagram-expand,
.mermaid.diagram-zoomable:focus-visible .diagram-expand { opacity: 1; transform: scale(1); }

.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(16, 20, 34, 0.74);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.diagram-lightbox.is-open { display: flex; animation: lightboxIn 0.18s var(--ease); }
@keyframes lightboxIn { from { opacity: 0; } to { opacity: 1; } }
.diagram-lightbox-content {
  width: min(95vw, 1600px);
  height: min(90vh, 1100px);
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 2.2rem);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.diagram-lightbox-content svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
.diagram-lightbox-close {
  position: absolute;
  top: clamp(0.8rem, 2vw, 1.5rem);
  right: clamp(0.8rem, 2vw, 1.5rem);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: color 0.18s var(--ease), transform 0.18s var(--ease);
}
.diagram-lightbox-close:hover { color: var(--primary-700); transform: rotate(90deg); }
.diagram-lightbox-close svg { width: 1.4rem; height: 1.4rem; }
body.lightbox-open { overflow: hidden; }

/* =================================================================
   Related content blocks
   ================================================================= */
.related { margin-top: 2.8rem; padding-top: 1.8rem; border-top: 1px solid var(--border); }
.related-title { font-size: 1.25rem; margin: 0 0 1.1rem; }
.card-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}
.related-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 600;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
.related-card-title { flex: 1; }
.related-card-go { color: var(--accent); transition: transform 0.22s var(--ease); }
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); color: var(--primary-700); }
.related-card:hover .related-card-go { transform: translateX(4px); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
.btn:hover { color: #fff; background: var(--primary-700); transform: translateY(-2px); box-shadow: var(--shadow); }
.offline-page { text-align: center; padding-block: 3rem; }

/* =================================================================
   Responsive
   ================================================================= */
@media (max-width: 900px) {
  .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);
    transform: translateY(-130%);
    transition: transform 0.3s var(--ease);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .primary-nav ul { flex-direction: column; align-items: stretch; gap: 0.2rem; padding: 0.8rem clamp(1rem, 4vw, 2.75rem) 1.4rem; }
  .nav-link { padding: 0.8rem 1rem; border-radius: 12px; font-size: 1rem; }
  body.nav-open .primary-nav { transform: translateY(0); }
  body.nav-open .nav-toggle-open { display: none; }
  body.nav-open .nav-toggle-close { display: inline-flex; }
}

@media (min-width: 1500px) {
  :root { --wrap: 1480px; --article: 1240px; }
}

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