/* =================================================================
   CouchDB Replication Conflict Resolution & Sync Automation
   Light, elegant, professional theme. Mobile → widescreen.
   ================================================================= */

:root {
  /* Palette — light & professional */
  --color-bg: #f6f8fc;
  --color-bg-2: #eef2fb;
  --color-surface: #ffffff;
  --color-ink: #1d2733;
  --color-ink-soft: #36424f;
  --color-muted: #5d6b7a;
  --color-border: #e2e8f2;
  --color-border-strong: #cdd7e6;

  --color-primary: #3b5bdb;     /* indigo */
  --color-primary-dark: #2c45ab;
  --color-secondary: #1098ad;   /* teal */
  --color-secondary-dark: #0b7285;
  --color-accent: #fa5252;      /* coral */
  --color-accent-dark: #e03131;
  --color-amber: #f59f00;
  --color-green: #2f9e44;

  /* Section accents */
  --accent-indigo: #3b5bdb;
  --accent-teal: #1098ad;
  --accent-coral: #fa5252;

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

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(29, 39, 51, 0.06), 0 1px 3px rgba(29, 39, 51, 0.05);
  --shadow: 0 4px 14px rgba(29, 39, 51, 0.08);
  --shadow-lg: 0 16px 40px rgba(29, 39, 51, 0.14);

  --container: 1280px;
  --header-h: 68px;

  --code-bg: #f4f6fc;
  --inline-code-bg: #eef1f9;

  --ease: cubic-bezier(0.4, 0, 0.2, 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);
  color: var(--color-ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, #e9efff 0%, rgba(233, 239, 255, 0) 60%),
    radial-gradient(1000px 500px at 0% 0%, #e6fbf6 0%, rgba(230, 251, 246, 0) 55%),
    var(--color-bg);
  background-attachment: fixed;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }

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

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

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.18s var(--ease);
}
a:hover { color: var(--color-primary-dark); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid rgba(59, 91, 219, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Icons ---------- */
.icon { width: 1.35em; height: 1.35em; display: inline-block; vertical-align: -0.2em; flex: none; }
.icon-sm { width: 1.1em; height: 1.1em; }
.icon-xs { width: 0.9em; height: 0.9em; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--color-ink);
  font-weight: 700;
}
.brand:hover { text-decoration: none; }
.brand-mark { transition: transform 0.25s var(--ease); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-size: 1.05rem;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { font-size: 0.72rem; color: var(--color-muted); font-weight: 500; }

.primary-nav { margin-left: auto; }
.primary-nav ul {
  display: flex;
  align-items: center;
  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(--color-ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
}
.primary-nav a:hover {
  background: var(--color-bg-2);
  color: var(--color-primary);
  text-decoration: none;
}
.primary-nav a[aria-current="page"] {
  background: linear-gradient(90deg, rgba(59,91,219,0.12), rgba(16,152,173,0.12));
  color: var(--color-primary-dark);
}
.primary-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -2px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: var(--color-bg-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
  color: var(--color-ink);
  cursor: pointer;
}

/* ---------- Hero ---------- */
.hero {
  padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(1.5rem, 4vw, 3rem);
}
.hero-inner { text-align: center; max-width: 60rem; margin-inline: auto; }
.hero-logo { display: block; margin-bottom: 1.4rem; }
.hero-logo img {
  filter: drop-shadow(0 14px 26px rgba(59, 91, 219, 0.28));
  transition: transform 0.4s var(--ease);
}
.hero-logo img:hover { transform: translateY(-4px) scale(1.03); }
.hero-title {
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--color-primary) 0%, var(--color-secondary) 55%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { font-size: clamp(1.1rem, 2vw, 1.32rem); color: var(--color-ink-soft); margin: 0 auto 1.2rem; max-width: 52rem; }
.hero-text { color: var(--color-muted); max-width: 50rem; margin: 0 auto 1rem; }

/* CTA buttons */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  color: var(--color-ink);
  font-weight: 700;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.cta-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.cta-icon {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  color: #fff;
}
.cta-go { margin-left: 0.2rem; color: var(--color-muted); transition: transform 0.2s var(--ease); }
.cta-btn:hover .cta-go { transform: translateX(4px); }

/* Section accents */
.accent-indigo .cta-icon, .card.accent-indigo .card-icon { background: linear-gradient(135deg, #3b5bdb, #5c7cfa); }
.accent-teal .cta-icon, .card.accent-teal .card-icon { background: linear-gradient(135deg, #1098ad, #22b8cf); }
.accent-coral .cta-icon, .card.accent-coral .card-icon { background: linear-gradient(135deg, #fa5252, #ff8787); }
.cta-btn.accent-indigo:hover { border-color: var(--accent-indigo); }
.cta-btn.accent-teal:hover { border-color: var(--accent-teal); }
.cta-btn.accent-coral:hover { border-color: var(--accent-coral); }

/* ---------- Home sections / cards ---------- */
.home-sections { padding: clamp(1.5rem, 4vw, 3rem) 0 4rem; }
.section-heading {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  text-align: center;
  margin: 0 0 0.4rem;
  color: var(--color-ink);
}
.section-intro { text-align: center; color: var(--color-muted); max-width: 42rem; margin: 0 auto 2.5rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
}
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
}
.card.accent-indigo::before { background: linear-gradient(90deg, #3b5bdb, #5c7cfa); }
.card.accent-teal::before { background: linear-gradient(90deg, #1098ad, #22b8cf); }
.card.accent-coral::before { background: linear-gradient(90deg, #fa5252, #ff8787); }
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.card-icon {
  width: 3rem; height: 3rem;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #fff;
  margin-bottom: 1rem;
}
.card-title { font-size: 1.2rem; margin: 0 0 0.5rem; line-height: 1.3; }
.card-title a { color: var(--color-ink); }
.card-title a:hover { color: var(--color-primary); text-decoration: none; }
.card-blurb { color: var(--color-muted); margin: 0 0 1rem; font-size: 0.96rem; }
.card-links { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: 0.3rem; }
.card-links a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.92rem; color: var(--color-ink-soft); font-weight: 500;
}
.card-links a:hover { color: var(--color-primary); text-decoration: none; }
.card-links .icon { color: var(--color-secondary); }
.card-cta {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 700; color: var(--color-primary);
}
.card-cta:hover { gap: 0.7rem; text-decoration: none; }

/* ---------- Content layout ---------- */
.content-wrap { padding-top: 1.5rem; padding-bottom: 4rem; }

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

/* ---------- Prose ---------- */
.prose {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.4rem, 3.5vw, 3rem);
  box-shadow: var(--shadow);
}
.prose > :first-child { margin-top: 0; }
.prose h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  background: linear-gradient(100deg, var(--color-primary), var(--color-secondary) 70%, var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.4rem;
  color: var(--color-ink);
  border-bottom: 2px solid var(--color-bg-2);
  position: relative;
}
.prose h2::before {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 3rem; height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}
.prose h3 { font-size: clamp(1.15rem, 2vw, 1.35rem); margin: 1.8rem 0 0.6rem; color: var(--color-secondary-dark); }
.prose h4 { font-size: 1.08rem; margin: 1.4rem 0 0.5rem; color: var(--color-ink-soft); }
.prose h1, .prose h2, .prose h3, .prose h4 { scroll-margin-top: calc(var(--header-h) + 1.2rem); }
.prose p { margin: 0 0 1.1rem; color: var(--color-ink-soft); }
.prose ul, .prose ol { margin: 0 0 1.2rem; padding-left: 1.4rem; color: var(--color-ink-soft); }
.prose li { margin: 0.35rem 0; }
.prose li::marker { color: var(--color-secondary); }
.prose strong { color: var(--color-ink); }
.prose a { font-weight: 600; text-decoration: underline; text-decoration-color: rgba(59,91,219,0.35); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--color-primary); }
.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.6rem 1.2rem;
  border-left: 4px solid var(--color-secondary);
  background: var(--color-bg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-ink-soft);
}
.prose hr { border: none; border-top: 1px solid var(--color-border); margin: 2rem 0; }

/* Heading anchor link */
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--color-border-strong);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
  font-weight: 400;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor { opacity: 1; }

/* Inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--inline-code-bg);
  color: #364fc7;
  padding: 0.12em 0.42em;
  border-radius: 6px;
  border: none;
  white-space: nowrap;
}

/* ---------- Code blocks ---------- */
.code-block {
  position: relative;
  margin: 1.4rem 0;
}
.prose pre[class*="language-"] {
  background: var(--code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}
.prose pre[class*="language-"] code {
  font-family: var(--font-mono);
  background: none;
  color: var(--color-ink);
  padding: 0;
  font-size: inherit;
  white-space: pre;
}
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.34rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--color-ink-soft);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease);
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: #fff; color: var(--color-primary); border-color: var(--color-primary); }
.copy-btn.copied { color: var(--color-green); border-color: var(--color-green); }

/* Prism light token theme (palette-matched) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8a94a6; font-style: italic; }
.token.punctuation { color: #5d6b7a; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: #e8590c; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #0b7285; }
.token.operator, .token.entity, .token.url { color: #5f3dc4; }
.token.atrule, .token.attr-value, .token.keyword { color: #364fc7; font-weight: 600; }
.token.function, .token.class-name { color: #c2255c; }
.token.regex, .token.important, .token.variable { color: #e8590c; }
.token.deleted { color: #e03131; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  min-width: 32rem;
}
.prose thead { background: linear-gradient(90deg, rgba(59,91,219,0.1), rgba(16,152,173,0.1)); }
.prose th {
  text-align: left;
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: var(--color-ink);
  border-bottom: 2px solid var(--color-border-strong);
  white-space: nowrap;
}
.prose td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-ink-soft); }
.prose tbody tr { transition: background 0.15s var(--ease); }
.prose tbody tr:hover { background: var(--color-bg-2); }
.prose tbody tr:last-child td { border-bottom: none; }

/* ---------- Task lists (toggleable checkboxes) ---------- */
.prose ul.contains-task-list { list-style: none; padding-left: 0.2rem; }
.prose .task-list-item { list-style: none; display: flex; align-items: flex-start; gap: 0.6rem; }
.prose .task-list-item::marker { content: ""; }
.prose .task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15em; height: 1.15em;
  margin-top: 0.28em;
  border: 2px solid var(--color-border-strong);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  flex: none;
  display: grid;
  place-content: center;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.prose .task-list-item input[type="checkbox"]::before {
  content: "";
  width: 0.65em; height: 0.65em;
  transform: scale(0);
  transform-origin: center;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  transition: transform 0.15s var(--ease);
}
.prose .task-list-item input[type="checkbox"]:checked {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
}
.prose .task-list-item input[type="checkbox"]:checked::before { transform: scale(1); }
.prose .task-list-item input[type="checkbox"]:checked + label,
.prose .task-list-item input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  color: var(--color-muted);
}

/* ---------- FAQ accordions ---------- */
.faq { display: grid; gap: 0.7rem; margin: 1.4rem 0; }
.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.2rem;
  font-weight: 600;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  width: 0.7em; height: 0.7em;
  border-right: 2px solid var(--color-secondary);
  border-bottom: 2px solid var(--color-secondary);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
  flex: none;
}
.faq-item[open] summary::after { transform: rotate(-135deg); }
.faq-item[open] summary { background: var(--color-bg-2); }
.faq-item > :not(summary) { padding-inline: 1.2rem; }
.faq-item > :last-child { padding-bottom: 1rem; }

/* ---------- Mermaid ---------- */
.mermaid {
  position: relative;
  margin: 1.5rem 0;
  text-align: center;
  background: var(--color-bg-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.2rem;
  overflow-x: auto;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.mermaid[data-zoomable="true"] { cursor: zoom-in; }
.mermaid[data-zoomable="true"]:hover,
.mermaid[data-zoomable="true"]:focus-visible {
  border-color: var(--color-primary);
  box-shadow: var(--shadow);
}
/* "Click to enlarge" affordance */
.viz-hint {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  pointer-events: none;
}
.mermaid:hover .viz-hint,
.mermaid:focus-visible .viz-hint { opacity: 1; transform: translateY(0); }

/* Full-screen lightbox */
body.viz-open { overflow: hidden; }
.viz-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(17, 24, 36, 0.86);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.viz-lightbox.open { opacity: 1; }
.viz-card {
  width: min(96vw, 1500px);
  height: min(92vh, 1100px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(1rem, 3vw, 2.5rem);
  overflow: auto;
  transform: scale(0.96);
  transition: transform 0.2s var(--ease);
}
.viz-lightbox.open .viz-card { transform: scale(1); }
.viz-card svg {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: 100%;
}
.viz-close {
  position: absolute;
  top: clamp(0.8rem, 2vw, 1.4rem);
  right: clamp(0.8rem, 2vw, 1.4rem);
  display: inline-grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}
.viz-close:hover { background: rgba(255, 255, 255, 0.28); transform: rotate(90deg); }

/* ---------- KaTeX ---------- */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }

/* ---------- Related content ---------- */
.related { margin-top: 2.5rem; display: grid; gap: 1.6rem; }
.related-group h2 {
  font-size: 1.15rem;
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--color-ink);
  margin: 0 0 0.9rem;
}
.related-group h2 .icon { color: var(--color-secondary); }
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.related-list:not(.compact) { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.related-list.compact { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.related-list a {
  display: block;
  padding: 0.9rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.related-list a:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
  text-decoration: none;
}
.related-title { display: block; font-weight: 700; color: var(--color-ink); }
.related-list a:hover .related-title { color: var(--color-primary); }
.related-desc { display: block; font-size: 0.86rem; color: var(--color-muted); margin-top: 0.25rem; line-height: 1.45; }

/* ---------- Footer ---------- */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  background: #131c2b;
  color: #c4cfe0;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  padding-top: 2.5rem;
  padding-bottom: 1.5rem;
}
.footer-brand { display: flex; gap: 0.9rem; align-items: flex-start; max-width: 26rem; }
.footer-title { font-weight: 700; color: #fff; margin: 0 0 0.3rem; font-size: 1rem; }
.footer-tag { margin: 0; font-size: 0.9rem; color: #9aa8bf; }
.footer-nav h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7f8ea8; margin: 0 0 0.8rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.footer-nav a {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: #c4cfe0; font-weight: 500;
}
.footer-nav a:hover { color: #fff; text-decoration: none; }
.footer-nav .icon { color: var(--color-secondary); }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-block: 1rem;
  font-size: 0.85rem;
  color: #7f8ea8;
}
.footer-bottom p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s var(--ease);
  }
  .primary-nav.open { max-height: 70vh; }
  .primary-nav ul { flex-direction: column; align-items: stretch; padding: 0.6rem; gap: 0.2rem; }
  .primary-nav a { justify-content: flex-start; }
  .primary-nav a[aria-current="page"]::after { display: none; }
}

@media (min-width: 1500px) {
  :root { --container: 1400px; }
}

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