/* ============================================================
   MySQL Binary Log Archiving & PITR Automation — styles
   Light, professional teal/indigo scheme with amber/coral accents
   ============================================================ */

:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --surface-3: #e4eef4;
  --text: #1b2a33;
  --muted: #5a6b76;
  --primary: #1f6f8b;
  --primary-600: #185a72;
  --primary-700: #123f52;
  --accent: #ef6f4c;
  --accent-2: #f6a821;
  --link: #136d96;
  --link-hover: #0e526f;
  --border: #d8e3ea;
  --border-strong: #c4d3dc;
  --code-bg: #f1f6f9;
  --code-block-bg: #f7fafc;
  --check: #1f9d72;
  --shadow-sm: 0 1px 2px rgba(18, 63, 82, 0.06), 0 1px 3px rgba(18, 63, 82, 0.08);
  --shadow-md: 0 6px 18px rgba(18, 63, 82, 0.10);
  --shadow-lg: 0 18px 40px rgba(18, 63, 82, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --container: 1320px;
  --container-wide: 1480px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
a:hover {
  color: var(--link-hover);
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus {
  left: 0;
}

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

/* ---------- layout container ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 40px);
}
@media (min-width: 1700px) {
  .container {
    max-width: var(--container-wide);
  }
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--primary-700);
  font-size: 1.02rem;
}
.brand:hover {
  color: var(--primary);
}
.brand svg {
  width: 34px;
  height: 34px;
  flex: none;
  filter: drop-shadow(0 1px 2px rgba(18, 63, 82, 0.18));
  transition: transform 0.25s ease;
}
.brand:hover svg {
  transform: rotate(-6deg) scale(1.05);
}
.brand__text {
  white-space: nowrap;
}
@media (max-width: 560px) {
  .brand__text {
    display: none;
  }
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.96rem;
  border: 1px solid transparent;
}
.nav a svg {
  width: 18px;
  height: 18px;
}
.nav a:hover {
  background: var(--surface-2);
  color: var(--primary-700);
}
.nav a[aria-current="page"],
.nav a.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav a[aria-current="page"] svg,
.nav a.is-active svg {
  color: #fff;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--primary-700);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-toggle svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 760px) {
  .nav-toggle {
    display: inline-flex;
  }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px clamp(16px, 4vw, 40px) 18px;
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav a {
    justify-content: flex-start;
    padding: 12px 14px;
  }
}

/* ============================================================
   Main / footer scaffold
   ============================================================ */
.main {
  flex: 1 0 auto;
  width: 100%;
  padding-block: clamp(24px, 4vw, 48px);
}

.site-footer {
  flex: none;
  background: var(--primary-700);
  color: #d8eef6;
  margin-top: 56px;
}
.site-footer a {
  color: #cfeaf4;
}
.site-footer a:hover {
  color: #fff;
}
.site-footer__inner {
  display: grid;
  gap: 28px;
  grid-template-columns: 1.4fr 1fr 1fr;
  padding-block: 40px;
}
@media (max-width: 760px) {
  .site-footer__inner {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}
.site-footer h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8fc4d6;
  margin: 0 0 12px;
}
.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.site-footer__brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.site-footer__brand svg {
  width: 40px;
  height: 40px;
  flex: none;
}
.site-footer__legal {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-block: 18px;
  font-size: 0.85rem;
  color: #9dc6d5;
}

/* ============================================================
   Buttons / CTA
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff;
}
.btn--primary:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn--accent {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #3a1d0e;
}
.btn--accent:hover {
  color: #3a1d0e;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--primary-700);
}
.btn--ghost:hover {
  color: var(--primary-700);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Hero (frontpage)
   ============================================================ */
.hero {
  text-align: center;
  padding: 8px 0 8px;
}
.hero__logo {
  display: block;
  margin: 0 auto 18px;
  width: clamp(96px, 16vw, 148px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(18, 63, 82, 0.22));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.hero h1 {
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  line-height: 1.12;
  margin: 0 auto 0.4em;
  max-width: 18ch;
  background: linear-gradient(120deg, var(--primary-700), var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}
.hero__lede {
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  color: var(--muted);
  max-width: 70ch;
  margin: 0 auto 1.4em;
}
.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-bottom: 8px;
}

.prose-intro {
  max-width: 78ch;
  margin: 36px auto 0;
  color: var(--text);
}
.prose-intro p {
  margin: 0 0 1em;
}

.section-heading {
  text-align: center;
  margin: 56px 0 8px;
}
.section-heading h2 {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  margin: 0 0 0.25em;
  color: var(--primary-700);
}
.section-heading p {
  color: var(--muted);
  margin: 0 auto;
  max-width: 64ch;
}

/* ---------- card grids ---------- */
.card-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 28px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent-2));
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover::before {
  opacity: 1;
}
.card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  background: var(--surface-2);
  color: var(--primary);
}
.card__icon svg {
  width: 24px;
  height: 24px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
  color: var(--primary-700);
}
.card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.97rem;
}
.card__link {
  margin-top: auto;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.card__link::after {
  content: "→";
  transition: transform 0.15s ease;
}
.card:hover .card__link::after {
  transform: translateX(4px);
}
.card--stretch::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* ============================================================
   Article layout
   ============================================================ */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
@media (min-width: 1080px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr) 290px;
  }
}

.article {
  min-width: 0;
}

.breadcrumbs {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 6px;
  color: var(--border-strong);
}
.breadcrumbs a {
  color: var(--muted);
}
.breadcrumbs a:hover {
  color: var(--primary);
}
.breadcrumbs li[aria-current="page"] {
  color: var(--primary-700);
  font-weight: 600;
}

/* Article typography */
.article h1 {
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  background: linear-gradient(120deg, var(--primary-700), var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  margin: 2em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--surface-3);
  color: var(--primary-700);
  letter-spacing: -0.01em;
}
.article h3 {
  font-size: 1.22rem;
  margin: 1.6em 0 0.5em;
  color: var(--primary-600);
}
.article h4 {
  font-size: 1.05rem;
  margin: 1.4em 0 0.4em;
  color: var(--primary-700);
}
.article p,
.article li {
  color: var(--text);
}
.article p {
  margin: 0 0 1.1em;
}
/* lists */
.article ul:not(.contains-task-list),
.article ol {
  margin: 0 0 1.2em;
  padding-left: 0;
  list-style: none;
}
.article li {
  margin: 0.45em 0;
}
.article li > ul,
.article li > ol {
  margin: 0.55em 0 0.2em;
}

/* unordered — gradient diamond markers */
.article ul:not(.contains-task-list) > li {
  position: relative;
  padding-left: 1.65em;
}
.article ul:not(.contains-task-list) > li::before {
  content: "";
  position: absolute;
  left: 0.3em;
  top: 0.68em;
  width: 0.5em;
  height: 0.5em;
  border-radius: 2px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, var(--primary), var(--accent-2));
}
.article ul:not(.contains-task-list) ul > li::before {
  background: var(--border-strong);
}

/* ordered — numbered badges */
.article ol {
  counter-reset: ol-item;
}
.article ol > li {
  position: relative;
  padding-left: 2.5em;
  counter-increment: ol-item;
}
.article ol > li::before {
  content: counter(ol-item);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 1.65em;
  height: 1.65em;
  display: grid;
  place-content: center;
  background: var(--surface-2);
  color: var(--primary-700);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 0.72em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.article strong {
  color: var(--primary-700);
}

.article a {
  font-weight: 600;
  border-bottom: 1px solid color-mix(in srgb, var(--link) 35%, transparent);
}
.article a:hover {
  border-bottom-color: var(--link-hover);
  background: color-mix(in srgb, var(--accent-2) 16%, transparent);
}

.heading-anchor {
  margin-left: 0.4em;
  color: var(--border-strong);
  border-bottom: none;
  opacity: 0;
  font-weight: 700;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.article h2:hover .heading-anchor,
.article h3:hover .heading-anchor,
.article h4:hover .heading-anchor {
  opacity: 1;
}
.heading-anchor:hover {
  color: var(--accent);
  background: none;
}

/* Offset in-page targets below sticky header (single source of offset) */
:is(h1, h2, h3, h4, h5, h6)[id],
[id] {
  scroll-margin-top: calc(var(--header-h) + 14px);
}

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

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}

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

/* ---------- code blocks ---------- */
.code-block {
  position: relative;
  margin: 1.4em 0;
}
.code-block__lang {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--primary-700);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}
.copy-btn svg {
  width: 14px;
  height: 14px;
}
.copy-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.copy-btn.is-copied {
  background: var(--check);
  color: #fff;
  border-color: var(--check);
  opacity: 1;
}

pre[class*="language-"] {
  margin: 0;
  padding: 34px 16px 16px;
  background: var(--code-block-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  -moz-tab-size: 4;
  tab-size: 4;
}
pre[class*="language-"] code {
  font-family: inherit;
  background: none;
  color: #233;
  padding: 0;
  white-space: pre;
}

/* Light Prism token theme (matches scheme) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #7a8c97;
  font-style: italic;
}
.token.punctuation {
  color: #5a6b76;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #b5482b;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #1f8a5b;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #1f6f8b;
}
.token.atrule,
.token.attr-value,
.token.keyword {
  color: #1565a6;
  font-weight: 600;
}
.token.function,
.token.class-name {
  color: #9b4dca;
}
.token.regex,
.token.important,
.token.variable {
  color: #ef6f4c;
}

/* ---------- tables (responsive scroll) ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.article table {
  border-collapse: collapse;
  width: 100%;
  min-width: 460px;
  font-size: 0.92rem;
}
.article th,
.article td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.article thead th {
  background: var(--surface-2);
  color: var(--primary-700);
  font-weight: 700;
  position: sticky;
  top: 0;
}
.article tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}
.article tbody tr:hover {
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

/* ---------- task list checkboxes ---------- */
.article ul:has(> li > input[type="checkbox"]),
.article ul.contains-task-list,
ul.contains-task-list {
  list-style: none;
  padding-left: 0.2em;
}
li.task-list-item {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0.6em;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
li.task-list-item::marker {
  content: "";
}
li.task-list-item:hover {
  background: var(--surface-2);
}
li.task-list-item > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0.35em 0 0;
  width: 1.15em;
  height: 1.15em;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
li.task-list-item > input[type="checkbox"]::before {
  content: "";
  width: 0.62em;
  height: 0.62em;
  transform: scale(0);
  transition: transform 0.12s ease;
  box-shadow: inset 1em 1em #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
li.task-list-item > input[type="checkbox"]:checked {
  background: var(--check);
  border-color: var(--check);
}
li.task-list-item > input[type="checkbox"]:checked::before {
  transform: scale(1);
}
li.task-list-item > input[type="checkbox"]:checked ~ label,
li.task-list-item.is-checked > label {
  text-decoration: line-through;
  color: var(--muted);
}
li.task-list-item > label {
  cursor: pointer;
}

/* ---------- accordions (FAQ) ---------- */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0.8em 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion > summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  font-weight: 700;
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.accordion > summary::-webkit-details-marker {
  display: none;
}
.accordion > summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex: none;
}
.accordion[open] > summary::after {
  transform: rotate(-135deg);
}
.accordion > summary:hover {
  background: var(--surface-2);
}
.accordion__body {
  padding: 0 18px 16px;
  color: var(--text);
}

/* ---------- diagrams (mermaid) + full-screen lightbox ---------- */
figure.diagram {
  position: relative;
  margin: 1.6em 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
figure.diagram .mermaid {
  text-align: center;
  margin: 0;
}
figure.diagram .mermaid svg {
  max-width: 100%;
  height: auto;
}
figure.diagram.is-zoomable {
  cursor: zoom-in;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
figure.diagram.is-zoomable:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
figure.diagram.is-zoomable:hover .diagram__expand {
  opacity: 1;
}
.diagram__expand {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-700);
  cursor: zoom-in;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.diagram__expand svg {
  width: 15px;
  height: 15px;
}
.diagram__expand:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.diagram__expand:focus-visible {
  opacity: 1;
}

/* lock scroll when modal open */
body.modal-open {
  overflow: hidden;
}

.diagram-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}
.diagram-modal.is-open {
  display: block;
}
.diagram-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 33, 43, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.18s ease;
}
.diagram-modal__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.diagram-modal__stage.is-grabbing {
  cursor: grabbing;
}
.diagram-modal__content {
  width: min(94vw, 1500px);
  height: min(88vh, 1000px);
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 36px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  transform-origin: center center;
  transition: transform 0.05s linear;
  will-change: transform;
  pointer-events: none;
}
.diagram-modal__content svg {
  width: 100%;
  height: 100%;
  max-width: none;
}
.diagram-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary-700);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.diagram-modal__close svg {
  width: 22px;
  height: 22px;
}
.diagram-modal__close:hover {
  background: var(--accent);
  color: #fff;
}
.diagram-modal__toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
}
.diagram-modal__btn {
  min-width: 40px;
  height: 36px;
  padding: 0 14px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-700);
  cursor: pointer;
}
.diagram-modal__btn:hover {
  background: var(--surface-2);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- "On this page" / related sidebar ---------- */
.toc {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  box-shadow: var(--shadow-sm);
}
.toc h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
  border: none;
  padding: 0;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.toc a {
  color: var(--text);
  border-bottom: none;
}
.toc a:hover {
  color: var(--primary);
}
.toc__related {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
@media (max-width: 1079px) {
  .toc {
    position: static;
  }
}

/* page navigation (prev/next + related cards) */
.related {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.related h2 {
  font-size: 1.2rem;
  color: var(--primary-700);
  margin: 0 0 16px;
  border: none;
  padding: 0;
}

/* misc */
.lede {
  font-size: 1.12rem;
  color: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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