/* ==========================================================================
   Cryo Learn — stylesheet
   1. Tokens   2. Base   3. Header & nav   4. Buttons & chips   5. Home
   6. Cards    7. Listings   8. Article   9. Prose & code   10. Search
   11. Footer  12. 404   13. Responsive   14. Motion & print
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #0f1419;
  --text-2: #424b57;
  --text-3: #69727f;
  --prose: #28313c;
  --border: #e4e7ec;
  --border-2: #cdd3db;
  --accent: #0a7a5c;
  --accent-strong: #075e47;
  --accent-soft: #e3f3ec;
  --on-accent: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.82);
  --grid-line: rgba(15, 20, 25, 0.055);
  --glow: rgba(10, 122, 92, 0.13);
  --code-bg: #f6f8fa;
  --code-head: #eef1f4;
  --code-border: #e1e5ea;
  --code-text: #1f2328;
  --mark: #fff0a8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, 0.04), 0 12px 28px -8px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 30px 70px -20px rgba(16, 24, 40, 0.35);

  --syn-comment: #6e7781;
  --syn-keyword: #cf222e;
  --syn-string: #0a3069;
  --syn-number: #0550ae;
  --syn-function: #8250df;
  --syn-class: #953800;
  --syn-builtin: #953800;
  --syn-variable: #1f2328;
  --syn-tag: #116329;
  --syn-attr: #0550ae;
  --syn-operator: #cf222e;
  --syn-punct: #4b535d;

  --level-beg-bg: #e3f4ea;  --level-beg-fg: #17643a;
  --level-int-bg: #fcefd2;  --level-int-fg: #8a4b06;
  --level-adv-bg: #fde6ea;  --level-adv-fg: #a3122f;

  --note: #2563eb;   --note-bg: rgba(37, 99, 235, 0.055);
  --tip: #0a7a5c;    --tip-bg: rgba(10, 122, 92, 0.06);
  --warn: #c26a06;   --warn-bg: rgba(234, 150, 12, 0.08);
  --danger: #d0263f; --danger-bg: rgba(220, 38, 38, 0.055);

  --dg-1: #2563eb; --dg-2: #0a7a5c; --dg-3: #e8590c; --dg-4: #7c3aed; --dg-5: #db2777; --dg-6: #d97706; --dg-on: #ffffff;

  --radius: 12px;
  --radius-lg: 16px;
  --container: 1200px;
  --header-h: 64px;
  color-scheme: light;
}

/* Dark palette: applied when the reader chooses it, or by system preference without JS */
:root[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-soft: #0f1319;
  --surface: #121821;
  --surface-2: #19212c;
  --text: #e8ecf1;
  --text-2: #b2bbc7;
  --text-3: #8690a0;
  --prose: #cdd5de;
  --border: #212a36;
  --border-2: #2f3a48;
  --accent: #3ddc97;
  --accent-strong: #7cefbd;
  --accent-soft: rgba(61, 220, 151, 0.12);
  --on-accent: #04271a;
  --header-bg: rgba(11, 14, 19, 0.78);
  --grid-line: rgba(255, 255, 255, 0.045);
  --glow: rgba(61, 220, 151, 0.11);
  --code-bg: #0e131a;
  --code-head: #121922;
  --code-border: #212a36;
  --code-text: #e6edf3;
  --mark: rgba(61, 220, 151, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.3), 0 14px 30px -10px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
  --syn-comment: #8b949e;
  --syn-keyword: #ff7b72;
  --syn-string: #a5d6ff;
  --syn-number: #79c0ff;
  --syn-function: #d2a8ff;
  --syn-class: #ffa657;
  --syn-builtin: #ffa657;
  --syn-variable: #e6edf3;
  --syn-tag: #7ee787;
  --syn-attr: #79c0ff;
  --syn-operator: #ff7b72;
  --syn-punct: #c9d1d9;
  --level-beg-bg: rgba(52, 211, 153, 0.13);  --level-beg-fg: #6ee7b7;
  --level-int-bg: rgba(251, 191, 36, 0.13);  --level-int-fg: #fcd34d;
  --level-adv-bg: rgba(251, 113, 133, 0.14); --level-adv-fg: #fda4af;
  --note: #60a5fa;   --note-bg: rgba(96, 165, 250, 0.08);
  --tip: #3ddc97;    --tip-bg: rgba(61, 220, 151, 0.07);
  --warn: #fbbf24;   --warn-bg: rgba(251, 191, 36, 0.08);
  --danger: #fb7185; --danger-bg: rgba(251, 113, 133, 0.08);
  --dg-1: #60a5fa; --dg-2: #3ddc97; --dg-3: #fb923c; --dg-4: #a78bfa; --dg-5: #f472b6; --dg-6: #fbbf24; --dg-on: #0b0e13;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b0e13; --bg-soft: #0f1319; --surface: #121821; --surface-2: #19212c;
    --text: #e8ecf1; --text-2: #b2bbc7; --text-3: #8690a0; --prose: #cdd5de;
    --border: #212a36; --border-2: #2f3a48;
    --accent: #3ddc97; --accent-strong: #7cefbd; --accent-soft: rgba(61, 220, 151, 0.12); --on-accent: #04271a;
    --header-bg: rgba(11, 14, 19, 0.78); --grid-line: rgba(255, 255, 255, 0.045); --glow: rgba(61, 220, 151, 0.11);
    --code-bg: #0e131a; --code-head: #121922; --code-border: #212a36; --code-text: #e6edf3;
    --mark: rgba(61, 220, 151, 0.28);
    --syn-comment: #8b949e; --syn-keyword: #ff7b72; --syn-string: #a5d6ff; --syn-number: #79c0ff;
    --syn-function: #d2a8ff; --syn-class: #ffa657; --syn-builtin: #ffa657; --syn-variable: #e6edf3;
    --syn-tag: #7ee787; --syn-attr: #79c0ff; --syn-operator: #ff7b72; --syn-punct: #c9d1d9;
    --level-beg-bg: rgba(52, 211, 153, 0.13); --level-beg-fg: #6ee7b7;
    --level-int-bg: rgba(251, 191, 36, 0.13); --level-int-fg: #fcd34d;
    --level-adv-bg: rgba(251, 113, 133, 0.14); --level-adv-fg: #fda4af;
    --note: #60a5fa; --note-bg: rgba(96, 165, 250, 0.08); --tip: #3ddc97; --tip-bg: rgba(61, 220, 151, 0.07);
    --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, 0.08); --danger: #fb7185; --danger-bg: rgba(251, 113, 133, 0.08);
    --dg-1: #60a5fa; --dg-2: #3ddc97; --dg-3: #fb923c; --dg-4: #a78bfa; --dg-5: #f472b6; --dg-6: #fbbf24; --dg-on: #0b0e13;
    color-scheme: dark;
  }
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 20px);
}

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

main { flex: 1; }
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
pre code { font: inherit; } /* use the site's code font, not the browser's generic monospace */
h1, h2, h3, h4 { text-wrap: balance; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Show code exactly as typed: no "==" or "!=" ligatures, which confuse learners */
code, pre, kbd, .mono, .dg .mono, .editor-body, .terminal-body { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 808px; }

.skip-link {
  position: absolute; inset-inline-start: 16px; top: -60px; z-index: 300;
  padding: 10px 16px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.skip-link:focus { top: 12px; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  text-align: center;
}

.grid-bg { position: relative; isolation: isolate; overflow: hidden; }
.grid-bg::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 35%, transparent 100%);
  mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 35%, transparent 100%);
  pointer-events: none;
}
.grid-bg::after {
  content: "";
  position: absolute; z-index: -1;
  width: 760px; height: 760px; inset-inline-end: -200px; top: -340px;
  background: radial-gradient(circle, var(--glow), transparent 65%);
  pointer-events: none;
}

/* 3. Header & nav ---------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.header-inner { display: flex; align-items: center; gap: 28px; height: var(--header-h); }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.02em; color: var(--text);
}
.brand-sub { color: var(--text-3); font-weight: 500; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: -0.06em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.main-nav { display: flex; gap: 2px; }
.main-nav a {
  padding: 7px 12px; border-radius: 8px;
  color: var(--text-2); font-size: 0.9375rem; font-weight: 500;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

.search-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  height: 38px; min-width: 232px; padding: 0 8px 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-3);
  font-size: 0.875rem; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.search-trigger:hover { border-color: var(--border-2); color: var(--text-2); }
.search-trigger .icon { width: 16px; height: 16px; }
.search-trigger kbd { margin-inline-start: auto; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.menu-toggle { display: none; }

.mobile-nav { display: grid; padding-bottom: 12px; border-top: 1px solid var(--border); }
.mobile-nav a { padding: 13px 4px; border-bottom: 1px solid var(--border); color: var(--text-2); font-weight: 500; }
.mobile-nav a:last-child { border-bottom: 0; }
.mobile-nav a[aria-current="page"] { color: var(--accent); }

.read-progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: 3px; background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%;
}

/* 4. Buttons & chips ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 11px;
  font-size: 0.9375rem; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn .icon { width: 17px; height: 17px; transition: transform 0.15s ease; }
.btn:hover .icon-arrow-right { transform: translateX(3px); }
.btn-primary {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-2); }

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: 0.9375rem; font-weight: 600; white-space: nowrap;
}
.link-arrow .icon { width: 16px; height: 16px; transition: transform 0.15s ease; }
.link-arrow:hover .icon, .card:hover .link-arrow .icon { transform: translateX(3px); }

.badge {
  display: inline-grid; place-items: center; flex: none;
  min-width: 42px; height: 42px; padding: 0 8px;
  border-radius: 11px;
  background: var(--topic-bg); color: var(--topic-fg);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: -0.04em; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}
.badge-sm { min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; font-size: 10px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.badge-md { min-width: 48px; height: 48px; border-radius: 12px; font-size: 14px; }
.badge-lg { min-width: 72px; height: 72px; padding: 0 14px; border-radius: 18px; font-size: 22px; }

.topic-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.8125rem; font-weight: 600; }
a.topic-chip:hover { color: var(--text); }

.level {
  display: inline-flex; align-items: center; flex: none;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}
.level-beginner { background: var(--level-beg-bg); color: var(--level-beg-fg); }
.level-intermediate { background: var(--level-int-bg); color: var(--level-int-fg); }
.level-advanced { background: var(--level-adv-bg); color: var(--level-adv-fg); }

.sep { opacity: 0.6; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-count { font-size: 0.75rem; opacity: 0.6; font-variant-numeric: tabular-nums; }

.select {
  height: 34px; padding: 0 34px 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238690a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
  color: var(--text-2); font-size: 0.875rem; font-weight: 500; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.select:hover { border-color: var(--border-2); }

/* 5. Home ------------------------------------------------------------------ */
.hero { padding: 96px 0 96px; border-bottom: 1px solid var(--border); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 64px; align-items: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 0 0 22px; padding: 5px 13px 5px 11px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  color: var(--text-2); font-size: 0.8125rem; font-weight: 500;
}
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.hero-title {
  margin: 0;
  font-size: clamp(2.5rem, 5.4vw, 4.1rem); line-height: 1.03; letter-spacing: -0.045em; font-weight: 800;
}
.hero-title em {
  font-style: normal; color: var(--accent);
  background: linear-gradient(transparent 64%, var(--accent-soft) 64%);
  padding: 0 0.06em;
}
.hero-lead { margin: 24px 0 0; max-width: 540px; color: var(--text-2); font-size: 1.1875rem; line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

.hero-stats { display: flex; gap: 44px; max-width: 500px; margin: 48px 0 0; padding-top: 28px; border-top: 1px solid var(--border); }
.hero-stats div { display: flex; flex-direction: column-reverse; gap: 2px; }
.hero-stats dt { color: var(--text-3); font-size: 0.8125rem; font-weight: 500; }
.hero-stats dd { margin: 0; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.hero-visual { position: relative; }
.editor {
  --syn-comment: #8b949e; --syn-keyword: #ff7b72; --syn-string: #a5d6ff; --syn-number: #79c0ff;
  --syn-function: #d2a8ff; --syn-class: #ffa657; --syn-builtin: #ffa657; --syn-variable: #e6edf3;
  --syn-tag: #7ee787; --syn-attr: #79c0ff; --syn-operator: #ff7b72; --syn-punct: #c9d1d9;
  overflow: hidden;
  background: #0d1117; color: #e6edf3;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.editor-bar, .terminal .editor-bar {
  display: flex; align-items: center; gap: 16px;
  height: 44px; padding: 0 16px;
  background: #161b22; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.editor-dots { display: flex; gap: 7px; }
.editor-dots span { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.editor-dots span:nth-child(2) { background: #febc2e; }
.editor-dots span:nth-child(3) { background: #28c840; }
.editor-tab {
  padding: 4px 11px; border-radius: 6px;
  background: #0d1117; border: 1px solid rgba(255, 255, 255, 0.07);
  color: #c9d1d9; font-family: var(--font-mono); font-size: 12px;
}
.editor-body { display: flex; padding: 20px 0; overflow-x: auto; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.8; }
.editor-gutter { padding: 0 18px 0 20px; color: #484f58; text-align: right; user-select: none; }
.editor-code { margin: 0; padding: 0 24px 0 0; background: none; color: #e6edf3; font: inherit; white-space: pre; }
.editor-status {
  display: flex; gap: 18px; padding: 7px 16px;
  background: #161b22; border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #8b949e; font-family: var(--font-mono); font-size: 11.5px;
}
.editor-status .ok { color: #3fb950; }
.editor-status .status-end { margin-left: auto; }

.float-card {
  position: absolute; inset-inline-start: -28px; bottom: -26px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px 12px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.float-card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.float-card strong { display: block; font-size: 0.875rem; font-weight: 600; }
.float-card span { color: var(--text-3); font-size: 0.8125rem; }

.section { padding: 88px 0; }
.section-top-sm { padding-top: 48px; }
.section-alt { background: var(--bg-soft); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-alt + .section-alt { border-top: 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.section-head-spaced { margin-top: 80px; }
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.section-kicker::before { content: "// "; opacity: 0.55; }
.section-title { margin: 0; font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; }
.section-sub { margin: 10px 0 0; max-width: 580px; color: var(--text-2); }

.featured { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); overflow: hidden; border-radius: 20px; }
.featured-visual { position: relative; min-height: 320px; overflow: hidden; background: #0b1220; }
.featured-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: transform 0.5s ease; }
.featured-visual .featured-backdrop { object-fit: cover; filter: blur(32px) brightness(0.75) saturate(1.2); transform: scale(1.2); }
.featured:hover .featured-visual img:not(.featured-backdrop) { transform: scale(1.03); }
.featured-flag {
  position: absolute; top: 20px; inset-inline-start: 20px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.24); color: #fff;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.featured-body { display: flex; flex-direction: column; justify-content: center; padding: 44px 48px; }
.featured-title { margin: 0; font-size: clamp(1.5rem, 2.7vw, 2.125rem); line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; }
.featured-desc { margin: 14px 0 0; max-width: 560px; color: var(--text-2); font-size: 1.0625rem; }
.featured .card-meta { margin-top: 0; padding-top: 22px; }
.featured-cta { margin-top: 26px; }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 262px), 1fr)); gap: 16px; }
.topic-card { display: flex; align-items: flex-start; gap: 16px; padding: 22px; }
.topic-card-body h3 { margin: 0; font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.01em; }
.topic-card-body p { margin: 4px 0 0; color: var(--text-2); font-size: 0.875rem; line-height: 1.55; }
.topic-count { display: block; margin-top: 10px; color: var(--text-3); font-family: var(--font-mono); font-size: 0.75rem; }

.cta {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 40px;
  padding: 52px 56px; border-radius: 24px;
  background: linear-gradient(135deg, #0b2a21 0%, #0a1612 100%);
  border: 1px solid rgba(61, 220, 151, 0.16);
  color: #e9f6f0;
}
.cta::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background-image:
    radial-gradient(520px circle at 85% 0%, rgba(61, 220, 151, 0.22), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
}
.cta h2 { margin: 0; font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; color: #fff; }
.cta p { margin: 10px 0 0; max-width: 540px; color: rgba(233, 246, 240, 0.72); }
.cta-actions { display: flex; flex-wrap: wrap; gap: 12px; flex: none; }
.btn-cta { background: #3ddc97; color: #04271a; }
.btn-cta:hover { background: #7cefbd; }
.btn-cta-ghost { color: #e9f6f0; border-color: rgba(255, 255, 255, 0.2); }
.btn-cta-ghost:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.35); }

/* 6. Cards ----------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card:has(.stretched:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.stretched:focus-visible { outline: none; }
.stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 24px; }
.post-card { display: flex; flex-direction: column; overflow: hidden; }
.card-media { aspect-ratio: 1200 / 630; overflow: hidden; background: #0b1220; border-bottom: 1px solid var(--border); }
.card-media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.card:hover .card-media img { transform: scale(1.04); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 22px 24px 24px; }
.card-chips { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-chips-start { justify-content: flex-start; }
.card-title { margin: 0; font-size: 1.1875rem; line-height: 1.35; letter-spacing: -0.015em; font-weight: 650; }
.card-title a, .featured-title a, .topic-card-body h3 a, .row-title a { transition: color 0.15s ease; }
.card:hover .card-title a, .card:hover .featured-title a, .card:hover .topic-card-body h3 a { color: var(--accent); }
.card-desc { margin: 10px 0 0; color: var(--text-2); font-size: 0.9375rem; line-height: 1.6; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 20px; color: var(--text-3); font-size: 0.8125rem; }

/* 7. Listings -------------------------------------------------------------- */
.page-hero { padding: 72px 0 52px; border-bottom: 1px solid var(--border); }
.page-title { margin: 0; font-size: clamp(2rem, 4.2vw, 3rem); line-height: 1.1; letter-spacing: -0.035em; font-weight: 800; }
.page-lead { margin: 14px 0 0; max-width: 660px; color: var(--text-2); font-size: 1.125rem; }
.listing-head { display: flex; align-items: center; gap: 24px; }
.listing-count { margin: 12px 0 0; color: var(--text-3); font-family: var(--font-mono); font-size: 0.8125rem; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; color: var(--text-3); font-size: 0.875rem; }
.breadcrumb a { transition: color 0.15s ease; }
.breadcrumb a:hover { color: var(--accent); }

.archive { padding: 36px 0 104px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-side { display: flex; align-items: center; gap: 14px; }
.filter-count { color: var(--text-3); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.post-list { border-top: 1px solid var(--border); }
.post-row {
  position: relative;
  display: grid; grid-template-columns: 130px minmax(0, 1fr) 220px; grid-template-areas: "date body thumb";
  gap: 28px; align-items: start;
  padding: 28px 0; border-bottom: 1px solid var(--border);
}
.row-date { grid-area: date; }
.row-body { grid-area: body; }
.row-thumb { grid-area: thumb; overflow: hidden; aspect-ratio: 1200 / 630; border: 1px solid var(--border); border-radius: 12px; background: #0b1220; }
.row-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.post-row:hover .row-thumb img { transform: scale(1.04); }
.row-date { padding-top: 4px; color: var(--text-3); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.row-title { margin: 0; font-size: 1.25rem; line-height: 1.35; letter-spacing: -0.02em; font-weight: 650; }
.post-row:hover .row-title a { color: var(--accent); }
.row-desc { margin: 6px 0 0; max-width: 720px; color: var(--text-2); font-size: 0.9375rem; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; color: var(--text-3); font-size: 0.8125rem; }

.empty-state { display: grid; justify-items: center; gap: 16px; padding: 72px 16px; color: var(--text-3); text-align: center; }
.empty-state p { margin: 0; }

.topic-panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 24px; }
.topic-panel { display: flex; flex-direction: column; padding: 28px; }
.topic-panel:hover { transform: none; }
.topic-panel-head { display: flex; align-items: center; gap: 16px; }
.topic-panel-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.topic-panel-head h2 a:hover { color: var(--accent); }
.topic-panel-head .topic-count { margin-top: 2px; }
.topic-panel-desc { margin: 18px 0 0; color: var(--text-2); font-size: 0.9375rem; }
.topic-panel-list { display: grid; gap: 4px; margin: 20px 0 0; padding: 14px 0 0; border-top: 1px solid var(--border); list-style: none; }
.topic-panel-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -10px; padding: 8px 10px; border-radius: 8px;
  font-size: 0.9375rem; font-weight: 500; line-height: 1.4;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.topic-panel-list a:hover { background: var(--surface-2); color: var(--accent); }
.topic-panel-empty { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 0.9375rem; }
.topic-panel-foot { margin-top: auto; padding-top: 22px; }

/* 8. Article --------------------------------------------------------------- */
.post-layout {
  display: grid; grid-template-columns: minmax(0, 728px) 232px; justify-content: center; gap: 72px;
  padding-top: 48px; padding-bottom: 88px;
}
.post-header { margin-bottom: 32px; }
.post-cover { margin: 0 0 44px; overflow: hidden; aspect-ratio: 1200 / 630; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #0b1220; box-shadow: var(--shadow-md); }
.post-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.post-chips { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.post-title { margin: 0; font-size: clamp(2rem, 4.4vw, 2.875rem); line-height: 1.12; letter-spacing: -0.035em; font-weight: 800; }
.post-lead { margin: 18px 0 0; color: var(--text-2); font-size: 1.1875rem; line-height: 1.6; }
.post-byline { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #0a7a5c, #0e7490); color: #fff;
  font-size: 0.875rem; font-weight: 700; letter-spacing: 0.02em;
}
.byline-name { font-size: 0.9375rem; font-weight: 600; }
.byline-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--text-3); font-size: 0.8125rem; }

.toc-inner {
  position: sticky; top: calc(var(--header-h) + 36px);
  max-height: calc(100vh - var(--header-h) - 72px); overflow-y: auto;
  padding-bottom: 8px;
}
.toc-title {
  margin: 0 0 14px;
  color: var(--text-3); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.toc-list, .toc-list ul { margin: 0; padding: 0; list-style: none; }
.toc-list { border-inline-start: 1px solid var(--border); }
.toc-list a {
  display: block; margin-inline-start: -1px; padding-block: 5px; padding-inline: 16px 0;
  border-inline-start: 2px solid transparent;
  color: var(--text-3); font-size: 0.84375rem; line-height: 1.45;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-list ul a { padding-inline-start: 30px; font-size: 0.8125rem; }
.toc-list a:hover { color: var(--text); }
.toc-list a.is-active { color: var(--accent); border-inline-start-color: var(--accent); font-weight: 500; }
.toc-actions { display: grid; justify-items: start; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.toc-action {
  display: inline-flex; align-items: center; gap: 8px; padding: 0;
  border: 0; background: none; color: var(--text-3); font-size: 0.8125rem; cursor: pointer;
  transition: color 0.15s ease;
}
.toc-action .icon { width: 15px; height: 15px; }
.toc-action:hover, .toc-action.is-copied { color: var(--accent); }

.toc-mobile { display: none; margin: 0 0 36px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.toc-mobile summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-size: 0.9375rem; font-weight: 600; cursor: pointer; list-style: none;
}
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after { content: "+"; color: var(--text-3); font-family: var(--font-mono); font-size: 1.1rem; }
.toc-mobile[open] summary::after { content: "−"; }
.toc-mobile .toc-list { margin: 0 18px 16px; }

.post-end { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 36px; padding: 0; list-style: none; }
.tag {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); font-family: var(--font-mono); font-size: 0.78125rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tag:hover { background: var(--accent-soft); color: var(--accent); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.post-nav-link {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 22px; border: 1px solid var(--border); border-radius: 14px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.post-nav-link:hover { border-color: var(--accent); background: var(--bg-soft); }
.post-nav-link.next { grid-column: 2; align-items: flex-end; text-align: end; }
.post-nav-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 0.8125rem; font-weight: 500; }
.post-nav-label .icon { width: 15px; height: 15px; }
.post-nav-title { font-weight: 600; line-height: 1.4; }

/* 9. Prose & code ---------------------------------------------------------- */
.prose { color: var(--prose); font-size: 1.0625rem; line-height: 1.78; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35em; }
.prose h2 { margin: 2.3em 0 0.75em; color: var(--text); font-size: 1.625rem; line-height: 1.25; letter-spacing: -0.025em; font-weight: 700; }
.prose h3 { margin: 1.9em 0 0.6em; color: var(--text); font-size: 1.25rem; line-height: 1.35; letter-spacing: -0.015em; font-weight: 650; }
.prose h4 { margin: 1.6em 0 0.5em; color: var(--text); font-size: 1.0625rem; font-weight: 650; }
.prose .anchor { margin-inline-start: 0.35em; color: var(--text-3); font-weight: 500; text-decoration: none; opacity: 0; transition: opacity 0.15s ease, color 0.15s ease; }
.prose :is(h2, h3, h4):hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
.prose .anchor:hover { color: var(--accent); }
.prose a:not(.anchor) {
  color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  transition: text-decoration-color 0.15s ease;
}
.prose a:not(.anchor):hover { text-decoration-color: currentColor; }
.prose strong { color: var(--text); font-weight: 650; }
.prose ul, .prose ol { margin: 0 0 1.35em; padding-inline-start: 1.5em; }
.prose li { margin: 0.45em 0; padding-inline-start: 0.25em; }
.prose li::marker { color: var(--text-3); }
.prose ol > li::marker { font-weight: 600; font-variant-numeric: tabular-nums; }
.prose blockquote { margin: 1.8em 0; padding-block: 2px; padding-inline: 24px 0; border-inline-start: 3px solid var(--accent); color: var(--text); font-size: 1.125rem; }
.prose blockquote p { margin: 0.6em 0; }
.prose hr { margin: 3em 0; border: 0; border-top: 1px solid var(--border); }
.prose img { border: 1px solid var(--border); border-radius: var(--radius); }
.prose :not(pre) > code {
  padding: 0.14em 0.4em; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text);
  font-family: var(--font-mono); font-size: 0.86em;
}
.prose a code { color: inherit; }
.prose kbd { font-size: 0.8em; }

.prose .table-wrap { margin: 1.8em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; }
.prose th { background: var(--bg-soft); color: var(--text); font-size: 0.8125rem; font-weight: 600; text-align: start; }
.prose th, .prose td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; }

.code-block { margin: 1.8em 0; overflow: hidden; border: 1px solid var(--code-border); border-radius: var(--radius); background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 6px 0 16px;
  border-bottom: 1px solid var(--code-border); background: var(--code-head);
  color: var(--text-3); font-family: var(--font-mono); font-size: 0.75rem;
}
.code-title { color: var(--text-2); font-weight: 500; }
.code-lang { letter-spacing: 0.02em; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  height: 28px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--text-3); font-family: var(--font-sans); font-size: 0.75rem; font-weight: 500; cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.copy-btn .icon { width: 14px; height: 14px; }
.copy-btn:hover { background: var(--surface); border-color: var(--code-border); color: var(--text); }
.copy-btn.is-copied { color: var(--accent); }
.code-block pre {
  margin: 0; padding: 18px 20px; overflow-x: auto;
  background: transparent; color: var(--code-text);
  font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.7; tab-size: 4;
}
.code-block pre code { font: inherit; }

/* Syntax highlighting (Pygments token classes) */
.highlight .c, .highlight .ch, .highlight .cm, .highlight .c1, .highlight .cs, .highlight .cp, .highlight .cpf { color: var(--syn-comment); font-style: italic; }
.highlight .k, .highlight .kc, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt, .highlight .ow { color: var(--syn-keyword); }
.highlight .s, .highlight .sa, .highlight .sb, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .sh, .highlight .sx, .highlight .sr, .highlight .s1, .highlight .ss { color: var(--syn-string); }
.highlight .se, .highlight .si { color: var(--syn-class); }
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo { color: var(--syn-number); }
.highlight .nf, .highlight .fm { color: var(--syn-function); }
.highlight .nc, .highlight .nn, .highlight .ne { color: var(--syn-class); }
.highlight .nb, .highlight .bp, .highlight .no { color: var(--syn-builtin); }
.highlight .nd { color: var(--syn-function); }
.highlight .nt { color: var(--syn-tag); }
.highlight .na, .highlight .py { color: var(--syn-attr); }
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm { color: var(--syn-variable); }
.highlight .o { color: var(--syn-operator); }
.highlight .p { color: var(--syn-punct); }
.highlight .gp { color: var(--syn-comment); user-select: none; }
.highlight .gi { color: var(--syn-tag); }
.highlight .gd { color: var(--syn-keyword); }
.highlight .gh, .highlight .gu { color: var(--syn-number); font-weight: 600; }
.highlight .err { color: inherit; background: none; }

/* Diagrams: ![Caption](diagram:name) → inline SVG coloured by these classes */
.diagram { margin: 2em 0; }
.diagram-body { overflow-x: auto; padding: 26px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.diagram svg { display: block; width: 100%; min-width: 520px; height: auto; margin: 0 auto; }
.diagram figcaption { margin-top: 12px; color: var(--text-3); font-size: 0.875rem; line-height: 1.5; text-align: center; }
.dg { font-family: var(--font-sans); }
.dg text { fill: var(--text); }
.dg .mono { font-family: var(--font-mono); }
.dg .strong { font-weight: 650; }
.dg text.muted, .dg .muted text { fill: var(--text-3); }
.dg text.on { fill: var(--dg-on); }
.dg .panel { fill: var(--surface); stroke: var(--border-2); stroke-width: 1.5; }
.dg .stroke { fill: none; stroke: var(--border-2); stroke-width: 1.5; }
.dg .stroke-strong { fill: none; stroke: var(--text-3); }
.dg .arrow { fill: none; stroke: var(--text-3); stroke-width: 2; }
.dg .head { fill: var(--text-3); }
.dg .venn { fill: none; stroke: var(--text-2); stroke-width: 2; }
.dg .node circle { fill: var(--surface); stroke: var(--text-2); stroke-width: 3; }
.dg .node-feature circle { stroke: var(--dg-3); }
.dg .f1 { fill: var(--dg-1); } .dg .f2 { fill: var(--dg-2); } .dg .f3 { fill: var(--dg-3); }
.dg .f4 { fill: var(--dg-4); } .dg .f5 { fill: var(--dg-5); } .dg .f6 { fill: var(--dg-6); }
.dg .s1 { stroke: var(--dg-1); } .dg .s2 { stroke: var(--dg-2); } .dg .s3 { stroke: var(--dg-3); }
.dg .s4 { stroke: var(--dg-4); } .dg .s5 { stroke: var(--dg-5); } .dg .s6 { stroke: var(--dg-6); }
.dg path.s1, .dg path.s2, .dg path.s3, .dg path.s4, .dg path.s5, .dg path.s6 { fill: none; }

/* Callouts: !!! note | tip | warning | danger */
.admonition {
  --adm: var(--note); --adm-bg: var(--note-bg);
  --adm-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E");
  margin: 1.8em 0; padding: 16px 20px;
  border: 1px solid var(--border); border-inline-start: 3px solid var(--adm); border-radius: 10px;
  background: var(--adm-bg);
  font-size: 0.96875rem; line-height: 1.7;
}
.admonition.tip, .admonition.hint, .admonition.success {
  --adm: var(--tip); --adm-bg: var(--tip-bg);
  --adm-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4M12 3a6 6 0 0 0-3.6 10.8c.7.6 1.1 1.3 1.1 2.2h5c0-.9.4-1.6 1.1-2.2A6 6 0 0 0 12 3z'/%3E%3C/svg%3E");
}
.admonition.warning, .admonition.caution, .admonition.attention {
  --adm: var(--warn); --adm-bg: var(--warn-bg);
  --adm-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01'/%3E%3C/svg%3E");
}
.admonition.danger, .admonition.error {
  --adm: var(--danger); --adm-bg: var(--danger-bg);
  --adm-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86z'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
}
.prose .admonition-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; color: var(--text); font-size: 0.9375rem; font-weight: 650; }
.admonition-title::before {
  content: ""; flex: none; width: 18px; height: 18px; background: var(--adm);
  -webkit-mask: var(--adm-icon) center / contain no-repeat;
  mask: var(--adm-icon) center / contain no-repeat;
}
.prose .admonition > :last-child { margin-bottom: 0; }

/* 10. Search --------------------------------------------------------------- */
body.search-open { overflow: hidden; }
.search-modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.search-backdrop { position: absolute; inset: 0; background: rgba(6, 9, 13, 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade-in 0.15s ease; }
.search-dialog {
  position: relative; width: 100%; max-width: 640px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s ease;
}
.search-input-row { display: flex; align-items: center; gap: 12px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.search-input { flex: 1; min-width: 0; height: 58px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 1.0625rem; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-input::placeholder { color: var(--text-3); }
.kbd-btn { padding: 0; border: 0; background: none; cursor: pointer; }
.search-results { max-height: min(60vh, 520px); margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
.search-label { padding: 10px 12px 6px; color: var(--text-3); font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.search-result a { display: block; padding: 12px 14px; border-radius: 10px; }
.search-result a.is-active { background: var(--surface-2); }
.search-result-title { display: block; color: var(--text); font-weight: 600; line-height: 1.4; }
.search-result-meta { display: block; margin-top: 3px; color: var(--text-3); font-size: 0.75rem; }
.search-result-snippet {
  display: -webkit-box; margin-top: 5px; overflow: hidden;
  color: var(--text-2); font-size: 0.8125rem; line-height: 1.55;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.search-results mark { padding: 0 1px; border-radius: 3px; background: var(--mark); color: inherit; }
.search-empty { padding: 36px 16px; color: var(--text-3); font-size: 0.9375rem; text-align: center; }
.search-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--bg-soft); color: var(--text-3); font-size: 0.75rem; }
.search-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* 11. Footer --------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); }
.related + .site-footer, .section-alt + .site-footer { border-top: 0; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 48px; padding-top: 60px; padding-bottom: 44px; }
.footer-brand p { max-width: 360px; margin: 16px 0 20px; color: var(--text-2); font-size: 0.9375rem; }
.footer-rss { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 0.9375rem; font-weight: 600; }
.footer-rss .icon { width: 16px; height: 16px; }
.footer-col h2 { margin: 0 0 16px; color: var(--text-3); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.footer-col ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.footer-topics ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.footer-col a { color: var(--text-2); font-size: 0.9375rem; transition: color 0.15s ease; }
.footer-col a:hover { color: var(--text); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-top: 24px; padding-bottom: 32px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 0.8125rem; }

/* 12. 404 ------------------------------------------------------------------ */
.error-page { padding: 96px 0 120px; }
.error-wrap { max-width: 640px; margin: 0 auto; text-align: center; }
.error-wrap .page-lead { margin-left: auto; margin-right: auto; }
.terminal {
  margin: 36px 0 0; overflow: hidden; text-align: left;
  background: #0d1117; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.terminal-body { padding: 20px 22px; color: #e6edf3; font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.85; overflow-x: auto; white-space: nowrap; }
.t-prompt { color: #3fb950; }
.t-path { color: #79c0ff; }
.t-err { color: #ff7b72; }
.t-cursor { display: inline-block; width: 9px; height: 1.1em; background: #e6edf3; vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 36px; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }

/* Subscribe & sitemap pages -------------------------------------------------- */
.subscribe-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.subscribe-card { padding: 32px; }
.subscribe-card:hover { transform: none; }
.subscribe-card h2 { margin: 0 0 16px; font-size: 1.25rem; letter-spacing: -0.02em; }
.subscribe-card h3 { margin: 28px 0 8px; font-size: 1rem; }
.subscribe-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.subscribe-icon .icon { width: 22px; height: 22px; }
.feed-url { display: flex; align-items: center; gap: 10px; padding-block: 8px; padding-inline: 16px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); }
.feed-url code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-family: var(--font-mono); font-size: 0.875rem; direction: ltr; unicode-bidi: isolate; text-align: left; }
.btn-sm { height: 36px; padding: 0 14px; border-radius: 9px; font-size: 0.875rem; }
.btn-sm .icon { width: 15px; height: 15px; }
.reader-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; color: var(--text-3); font-size: 0.875rem; }
.feed-other { margin: 22px 0 0; font-size: 0.9375rem; }
.feed-other a { color: var(--accent); font-weight: 600; }
.steps { display: grid; gap: 12px; margin: 0; padding-inline-start: 1.4em; color: var(--text-2); line-height: 1.65; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.muted-text { margin: 0; color: var(--text-2); font-size: 0.9375rem; line-height: 1.7; }

.sitemap-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: 56px; }
.sitemap-col h2 { margin: 0 0 16px; font-size: 1.125rem; letter-spacing: -0.015em; }
.sitemap-col > h2 ~ h2 { margin-top: 40px; }
.sitemap-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.sitemap-list a { color: var(--text); font-weight: 500; transition: color 0.15s ease; }
.sitemap-list a:hover { color: var(--accent); }
.sitemap-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 32px 40px; align-content: start; }
.sitemap-topics > h2 { grid-column: 1 / -1; margin-bottom: 0; }
.sitemap-topic h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1rem; }
.sitemap-topic h3 a:hover { color: var(--accent); }
.sitemap-date { display: block; margin-top: 2px; color: var(--text-3); font-size: 0.8125rem; }
.sitemap-note { margin: 40px 0 0; color: var(--text-3); font-size: 0.875rem; line-height: 1.6; }
.sitemap-note code { direction: ltr; unicode-bidi: isolate; font-family: var(--font-mono); font-size: 0.8125rem; word-break: break-all; }
@media (max-width: 860px) {
  .subscribe-grid, .sitemap-grid { grid-template-columns: minmax(0, 1fr); }
  .sitemap-grid { gap: 40px; }
  .subscribe-card { padding: 24px; }
}

/* Right-to-left & Persian ---------------------------------------------------- */
/* Code, terminals and diagrams always read left-to-right, even on RTL pages */
.code-block, .editor, .terminal, .diagram-body { direction: ltr; text-align: left; }
.prose :not(pre) > code, kbd, .tag { direction: ltr; unicode-bidi: isolate; }

/* Arrows point the way the page reads */
[dir="rtl"] .icon-arrow-right, [dir="rtl"] .icon-arrow-left { transform: scaleX(-1); }
[dir="rtl"] .btn:hover .icon-arrow-right,
[dir="rtl"] .link-arrow:hover .icon,
[dir="rtl"] .card:hover .link-arrow .icon { transform: scaleX(-1) translateX(3px); }
[dir="rtl"] .read-progress { transform-origin: 100% 50%; }
[dir="rtl"] .select { background-position: left 12px center; padding: 0 14px 0 34px; }

:root[lang="fa"] {
  --font-sans: "Inter", "Vazirmatn", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-mono: "JetBrains Mono", "Vazirmatn", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* Small labels use the code font in English; in Persian its wide spaces look gappy, so use the text font */
:root[lang="fa"] :is(.section-kicker, .toc-title, .footer-col h2, .search-label, .topic-count, .listing-count) { font-family: var(--font-sans); }
/* Persian letters join up, so letter-spacing would break words apart */
:root[lang="fa"] * { letter-spacing: normal !important; }
/* Persian script needs more room between lines (taller letters, dots above and below) */
:root[lang="fa"] :is(.hero-title, .page-title, .post-title) { line-height: 1.4; }
:root[lang="fa"] :is(.featured-title, .section-title, .cta h2) { line-height: 1.5; }
:root[lang="fa"] :is(.card-title, .row-title, .prose h2, .prose h3, .post-nav-title) { line-height: 1.6; }
:root[lang="fa"] .prose { line-height: 2; }
:root[lang="fa"] :is(.hero-lead, .page-lead, .post-lead, .card-desc, .row-desc) { line-height: 1.85; }
:root[lang="fa"] .hero-title { font-size: clamp(2.2rem, 4.6vw, 3.5rem); }

/* Language switcher */
.lang-switch {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-2);
  font-size: 0.875rem; font-weight: 600; white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.lang-switch:hover { color: var(--text); border-color: var(--border-2); }
.lang-switch .icon { width: 16px; height: 16px; }
.lang-switch [lang="fa"] { font-family: "Vazirmatn", var(--font-sans); }
.lang-short { display: none; }

/* 13. Responsive ----------------------------------------------------------- */
@media (max-width: 960px) and (min-width: 761px) {
  .post-row { grid-template-columns: 110px minmax(0, 1fr) 170px; gap: 22px; }
}

@media (max-width: 1120px) {
  .post-layout { grid-template-columns: minmax(0, 760px); gap: 0; }
  .toc { display: none; }
  .toc-mobile { display: block; }
}

@media (max-width: 960px) {
  .hero { padding: 64px 0 80px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 56px; }
  .hero-lead { max-width: 640px; }
  .float-card { inset-inline-start: 16px; }
  .featured { grid-template-columns: minmax(0, 1fr); }
  .featured-visual { min-height: 0; aspect-ratio: 1200 / 630; }
  .featured-body { padding: 32px; }
  .cta { flex-direction: column; align-items: flex-start; }
  .footer-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  :root { --header-h: 60px; }
  .container { padding: 0 16px; }
  .header-inner { gap: 16px; }
  .main-nav { display: none; }
  .menu-toggle { display: inline-grid; }
  .search-trigger { width: 38px; min-width: 0; padding: 0; justify-content: center; }
  .search-trigger-label, .search-trigger kbd { display: none; }
  .lang-switch { padding: 0 10px; gap: 6px; }
  .lang-long { display: none; }
  .lang-short { display: inline; }

  .section { padding: 60px 0; }
  .section-top-sm { padding-top: 32px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .section-head-spaced { margin-top: 56px; }
  .hero-lead { font-size: 1.0625rem; }
  .hero-stats { gap: 28px; }
  .hero-stats dd { font-size: 1.5rem; }
  .featured-body { padding: 26px 22px; }
  .cta { padding: 36px 24px; border-radius: 20px; }
  .page-hero { padding: 48px 0 36px; }
  .listing-head { flex-direction: column; align-items: flex-start; gap: 18px; }
  .badge-lg { min-width: 60px; height: 60px; font-size: 18px; border-radius: 15px; }

  .filters { flex-direction: column; align-items: stretch; }
  .filter-side { justify-content: space-between; }
  .post-row { grid-template-columns: minmax(0, 1fr) 112px; grid-template-areas: "date thumb" "body thumb"; column-gap: 16px; row-gap: 6px; padding: 22px 0; }
  .row-thumb { border-radius: 10px; }
  .post-cover { margin-bottom: 32px; border-radius: 12px; }

  .post-layout { padding-top: 28px; padding-bottom: 64px; }
  .post-lead { font-size: 1.0625rem; }
  .prose { font-size: 1rem; }
  .prose h2 { font-size: 1.4375rem; }
  .code-block { margin-left: -16px; margin-right: -16px; border-left: 0; border-right: 0; border-radius: 0; }
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav-link.next { grid-column: auto; }

  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 44px; }
  .search-modal { padding-top: 12px; }
  .search-foot { display: none; }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
}

@media (max-width: 480px) {
  .float-card { display: none; }
  .hero-actions .btn { flex: 1 1 auto; }
  .editor-status span:nth-child(3) { display: none; }
}

/* 14. Motion & print ------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media print {
  .site-header, .site-footer, .toc, .toc-mobile, .read-progress, .post-nav, .copy-btn, .search-modal, .related, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .post-layout { display: block; padding: 0; }
  .code-block, .admonition { break-inside: avoid; }
}
