/* ==========================================================================
   The Intelligence Stack — main stylesheet
   Mint-green + sky-blue palette on airy light surfaces, with a matching
   dark theme. Plain CSS, no build step required.

   1.  Tokens (light + dark)          9.  Post page
   2.  Base                          10.  Prose (article typography)
   3.  Layout helpers                11.  Diagrams & lightbox
   4.  Header & navigation           12.  Code blocks & syntax highlighting
   5.  Buttons, chips, tags          13.  Listing pages (blog, tags, search)
   6.  Soft bands & hero             14.  Footer
   7.  Sections & cards              15.  Utilities, motion, print
   8.  Topics
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Palette */
  --mint-50:  #F0FBF6;
  --mint-100: #DDF5EA;
  --mint-200: #BDEBD6;
  --mint-300: #8EDDB9;
  --mint-400: #5FCB9B;
  --mint-500: #34B27F;
  --mint-700: #11704B;
  --mint-800: #0D5A3C;

  --sky-50:  #F0F8FE;
  --sky-100: #DCEFFC;
  --sky-200: #B9DEF8;
  --sky-300: #8CC8F2;
  --sky-400: #5AAEE9;
  --sky-500: #2E8FD6;
  --sky-700: #155E96;
  --sky-800: #144C78;

  --ink-950: #0B1824;
  --ink-900: #132433;
  --ink-700: #33485A;

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

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --container: 1200px;
  --gutter: 16px;
  --header-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --grad-accent: linear-gradient(90deg, var(--mint-400), var(--sky-400));

  /* Semantic — light */
  color-scheme: light;
  --bg: #F7FBFA;
  --bg-alt: #EEF7F5;
  --surface: #FFFFFF;
  --surface-2: #EEF4F6;
  --text: var(--ink-900);
  --text-strong: var(--ink-950);
  --text-muted: #52677A;
  --border: #DCE7EA;
  --border-strong: #C3D3D9;
  --link: var(--sky-700);
  --link-hover: var(--sky-800);
  --accent: var(--mint-500);
  --accent-2: var(--sky-500);
  --accent-text: var(--mint-700);
  --grad-text: linear-gradient(90deg, var(--mint-700), var(--sky-700));
  --btn-bg: var(--mint-300);
  --btn-bg-hover: var(--mint-400);
  --btn-text: var(--ink-950);
  --btn2-bg: var(--sky-100);
  --btn2-bg-hover: var(--sky-200);
  --btn2-text: var(--sky-800);
  --active-bg: var(--mint-300);
  --active-text: var(--ink-950);
  --chip-bg: var(--mint-100);
  --chip-text: var(--mint-800);
  --header-bg: rgba(255, 255, 255, .84);
  --header-border: #DCE7EA;
  --header-text: var(--ink-700);
  --header-text-strong: var(--ink-950);
  --header-hover-bg: rgba(19, 36, 51, .05);
  --band-bg: linear-gradient(135deg, #E3F7EE 0%, #E6F2FC 100%);
  --band-grid: rgba(46, 143, 214, .09);
  --band-glow-1: rgba(95, 203, 155, .34);
  --band-glow-2: rgba(90, 174, 233, .30);
  --band-text: var(--ink-950);
  --band-muted: #44596B;
  --hd-frame-fill: rgba(255, 255, 255, .45);
  --code-bg: #132232;
  --inline-code-bg: #E6F1F6;
  --inline-code-text: #0E4F7E;
  --mark-bg: var(--mint-200);
  --note-bg: #EEF6FD;  --note-border: #CFE4F7;  --note-accent: var(--sky-700);
  --tip-bg: #EDF9F3;   --tip-border: #C5EBD8;   --tip-accent: var(--mint-700);
  --warn-bg: #FFF7E8;  --warn-border: #F6DEAE;  --warn-accent: #9A5A07;
  --footer-bg: #EAF3F6;
  --footer-border: #D5E3E8;
  --footer-text: var(--ink-700);
  --footer-heading: #5A6D7E;
  --footer-link: var(--ink-900);
  --tone-blue-bg: var(--sky-100);   --tone-blue-fg: var(--sky-800);   --tone-blue-solid: var(--sky-400);
  --tone-green-bg: var(--mint-100); --tone-green-fg: var(--mint-800); --tone-green-solid: var(--mint-400);
  --tone-teal-bg: #D9F3F4;          --tone-teal-fg: #0E5F6B;          --tone-teal-solid: #4FC0CC;
  --shadow-sm: 0 1px 2px rgba(19, 36, 51, .05), 0 1px 3px rgba(19, 36, 51, .06);
  --shadow-md: 0 16px 36px -16px rgba(19, 60, 90, .26);
  --focus-ring: 0 0 0 3px rgba(46, 143, 214, .32);
  --sun-display: none;
  --moon-display: block;
}

@media (min-width: 640px)  { :root { --gutter: 24px; } }
@media (min-width: 1024px) { :root { --gutter: 32px; } }

/* Dark tokens: applied when the OS prefers dark (unless the reader chose light)… */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1621;
    --bg-alt: #111C28;
    --surface: #152230;
    --surface-2: #1B2B3C;
    --text: #DFE8EE;
    --text-strong: #FFFFFF;
    --text-muted: #9DB0C0;
    --border: #233649;
    --border-strong: #30475D;
    --link: var(--sky-300);
    --link-hover: var(--sky-200);
    --accent: var(--mint-400);
    --accent-2: var(--sky-400);
    --accent-text: var(--mint-300);
    --grad-text: linear-gradient(90deg, var(--mint-300), var(--sky-300));
    --btn-bg: #6FD5A5;
    --btn-bg-hover: var(--mint-300);
    --btn-text: var(--ink-950);
    --btn2-bg: rgba(90, 174, 233, .16);
    --btn2-bg-hover: rgba(90, 174, 233, .26);
    --btn2-text: var(--sky-200);
    --active-bg: #6FD5A5;
    --active-text: var(--ink-950);
    --chip-bg: rgba(95, 203, 155, .16);
    --chip-text: #9FE5C2;
    --header-bg: rgba(14, 22, 33, .84);
    --header-border: #1E3042;
    --header-text: #B7C6D3;
    --header-text-strong: #FFFFFF;
    --header-hover-bg: rgba(255, 255, 255, .06);
    --band-bg: linear-gradient(135deg, #0F1D26 0%, #0F1A2C 100%);
    --band-grid: rgba(140, 200, 242, .07);
    --band-glow-1: rgba(95, 203, 155, .12);
    --band-glow-2: rgba(90, 174, 233, .22);
    --band-text: #FFFFFF;
    --band-muted: #B2C3D1;
    --hd-frame-fill: rgba(255, 255, 255, .03);
    --code-bg: #0B141E;
    --inline-code-bg: #1B2B3C;
    --inline-code-text: #A9D8F8;
    --mark-bg: rgba(95, 203, 155, .32);
    --note-bg: #13263A;  --note-border: #22405C;  --note-accent: var(--sky-300);
    --tip-bg: #11291F;   --tip-border: #1D4634;   --tip-accent: var(--mint-300);
    --warn-bg: #2B2212;  --warn-border: #4A3A1C;  --warn-accent: #F2C46F;
    --footer-bg: #0B121B;
    --footer-border: #1C2B3B;
    --footer-text: #A9BACA;
    --footer-heading: #7F93A6;
    --footer-link: #DFE8EE;
    --tone-blue-bg: rgba(90, 174, 233, .16);  --tone-blue-fg: #A9D8F8;
    --tone-green-bg: rgba(95, 203, 155, .16); --tone-green-fg: #9FE5C2;
    --tone-teal-bg: rgba(79, 192, 204, .16);  --tone-teal-fg: #9FE3EA;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 16px 36px -14px rgba(0, 0, 0, .6);
    --focus-ring: 0 0 0 3px rgba(90, 174, 233, .4);
    --sun-display: block;
    --moon-display: none;
  }
}
/* …or when the reader explicitly picked dark with the toggle. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1621;
  --bg-alt: #111C28;
  --surface: #152230;
  --surface-2: #1B2B3C;
  --text: #DFE8EE;
  --text-strong: #FFFFFF;
  --text-muted: #9DB0C0;
  --border: #233649;
  --border-strong: #30475D;
  --link: var(--sky-300);
  --link-hover: var(--sky-200);
  --accent: var(--mint-400);
  --accent-2: var(--sky-400);
  --accent-text: var(--mint-300);
  --grad-text: linear-gradient(90deg, var(--mint-300), var(--sky-300));
  --btn-bg: #6FD5A5;
  --btn-bg-hover: var(--mint-300);
  --btn-text: var(--ink-950);
  --btn2-bg: rgba(90, 174, 233, .16);
  --btn2-bg-hover: rgba(90, 174, 233, .26);
  --btn2-text: var(--sky-200);
  --active-bg: #6FD5A5;
  --active-text: var(--ink-950);
  --chip-bg: rgba(95, 203, 155, .16);
  --chip-text: #9FE5C2;
  --header-bg: rgba(14, 22, 33, .84);
  --header-border: #1E3042;
  --header-text: #B7C6D3;
  --header-text-strong: #FFFFFF;
  --header-hover-bg: rgba(255, 255, 255, .06);
  --band-bg: linear-gradient(135deg, #0F1D26 0%, #0F1A2C 100%);
  --band-grid: rgba(140, 200, 242, .07);
  --band-glow-1: rgba(95, 203, 155, .12);
  --band-glow-2: rgba(90, 174, 233, .22);
  --band-text: #FFFFFF;
  --band-muted: #B2C3D1;
  --hd-frame-fill: rgba(255, 255, 255, .03);
  --code-bg: #0B141E;
  --inline-code-bg: #1B2B3C;
  --inline-code-text: #A9D8F8;
  --mark-bg: rgba(95, 203, 155, .32);
  --note-bg: #13263A;  --note-border: #22405C;  --note-accent: var(--sky-300);
  --tip-bg: #11291F;   --tip-border: #1D4634;   --tip-accent: var(--mint-300);
  --warn-bg: #2B2212;  --warn-border: #4A3A1C;  --warn-accent: #F2C46F;
  --footer-bg: #0B121B;
  --footer-border: #1C2B3B;
  --footer-text: #A9BACA;
  --footer-heading: #7F93A6;
  --footer-link: #DFE8EE;
  --tone-blue-bg: rgba(90, 174, 233, .16);  --tone-blue-fg: #A9D8F8;
  --tone-green-bg: rgba(95, 203, 155, .16); --tone-green-fg: #9FE5C2;
  --tone-teal-bg: rgba(79, 192, 204, .16);  --tone-teal-fg: #9FE3EA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 16px 36px -14px rgba(0, 0, 0, .6);
  --focus-ring: 0 0 0 3px rgba(90, 174, 233, .4);
  --sun-display: block;
  --moon-display: none;
}

/* Topic tones — pick one per topic with `tone:` in _data/topics.yml */
.tone-blue  { --tone-bg: var(--tone-blue-bg);  --tone-fg: var(--tone-blue-fg);  --tone-solid: var(--tone-blue-solid); }
.tone-green { --tone-bg: var(--tone-green-bg); --tone-fg: var(--tone-green-fg); --tone-solid: var(--tone-green-solid); }
.tone-teal  { --tone-bg: var(--tone-teal-bg);  --tone-fg: var(--tone-teal-fg);  --tone-solid: var(--tone-teal-solid); }

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

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

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

main { flex: 1; outline: none; }

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

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--link-hover); }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.015em;
}

p { margin: 0; }

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

::selection { background: var(--mint-200); color: var(--ink-950); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--btn-text); }

.icon { width: 20px; height: 20px; flex: none; }

/* 3. Layout helpers -------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(780px + var(--gutter) * 2); }
.container--article { max-width: calc(760px + var(--gutter) * 2); }
.container--wide { max-width: calc(var(--container) + 50px); }   /* /write/ page */

.section { padding-block: 64px; }
.section--alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section--flush { padding-top: 0; }
.section--page { padding-block: 48px 80px; }
@media (min-width: 960px) {
  .section { padding-block: 88px; }
  .section--flush { padding-top: 0; }
  .section--page { padding-block: 56px 96px; }
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 32px;
}
.section-title { font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: -.02em; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 18px; height: 2px;
  border-radius: 2px;
  background: var(--grad-accent);
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.link-arrow .icon { width: 18px; height: 18px; transition: transform .2s var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* 4. Header & navigation --------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--header-border);
  color: var(--header-text-strong);
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: var(--header-text-strong);
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -.015em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--header-text-strong); }
.logo-mark { width: 30px; height: 30px; flex: none; }
@media (max-width: 479px) {
  .header-inner { gap: 8px; }
  .brand { min-width: 0; font-size: 1rem; }
  .brand-name { white-space: normal; line-height: 1.15; }
  .header-actions .icon-btn { width: 36px; }
}

.site-nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.site-nav a {
  position: relative;
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--header-text);
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.site-nav a:hover { color: var(--header-text-strong); background: var(--header-hover-bg); }
.site-nav a[aria-current="page"] { color: var(--header-text-strong); font-weight: 600; }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--grad-accent);
}

.header-actions { display: flex; align-items: center; gap: 2px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--header-text);
  cursor: pointer;
  transition: color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--header-text-strong); background: var(--header-hover-bg); }

.theme-toggle .icon-sun  { display: var(--sun-display); }
.theme-toggle .icon-moon { display: var(--moon-display); }

.nav-toggle { display: none; }
.nav-toggle-bars { display: grid; gap: 4px; width: 18px; }
.nav-toggle-bars span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .2s var(--ease), opacity .2s;
}
.nav-open .nav-toggle-bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-toggle-bars span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle-bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1099px) {
  .nav-toggle { display: inline-grid; }
  .site-nav {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    display: none;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 8px var(--gutter) 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .nav-open .site-nav { display: block; }
  .site-nav ul { flex-direction: column; gap: 2px; }
  .site-nav a { padding: 12px; font-size: 1rem; }
  .site-nav a[aria-current="page"] { background: var(--header-hover-bg); }
  .site-nav a[aria-current="page"]::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; border-radius: 3px; }
}

/* 5. Buttons, chips, tags -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn .icon { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); box-shadow: 0 6px 16px -8px rgba(52, 178, 127, .6); }
.btn-primary:hover { background: var(--btn-bg-hover); color: var(--btn-text); }
.btn-primary .icon-arrow-right { transition: transform .2s var(--ease); }
.btn-primary:hover .icon-arrow-right { transform: translateX(3px); }
.btn-secondary { background: var(--btn2-bg); color: var(--btn2-text); }
.btn-secondary:hover { background: var(--btn2-bg-hover); color: var(--btn2-text); }
.btn-outline { border-color: var(--border-strong); background: var(--surface); color: var(--text-strong); }
.btn-outline:hover { border-color: var(--accent-2); color: var(--link); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tone-bg, var(--chip-bg));
  color: var(--tone-fg, var(--chip-text));
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  transition: box-shadow .15s;
}
.chip:hover { color: var(--tone-fg, var(--chip-text)); box-shadow: inset 0 0 0 1px currentColor; }
.chip .icon { width: 14px; height: 14px; }
.chip--lg { padding: 6px 12px; font-size: .8125rem; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .78rem;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.tag:hover { border-color: var(--accent-2); color: var(--link); }
.tag-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .7rem;
}

/* 6. Soft bands & hero ----------------------------------------------------- */
.band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--band-bg);
  color: var(--band-text);
  border-bottom: 1px solid var(--border);
}
/* Faint blueprint grid */
.band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--band-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--band-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse 80% 90% at 75% 30%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 80% 90% at 75% 30%, #000 25%, transparent 78%);
}
/* Mint and sky glows */
.band::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 88% 0%, var(--band-glow-2), transparent 42%),
    radial-gradient(circle at 8% 100%, var(--band-glow-1), transparent 38%);
  pointer-events: none;
}
.band h1, .band h2 { color: var(--band-text); }

.hero-inner {
  display: grid;
  gap: 48px;
  align-items: center;
  padding-block: 64px 72px;
}
.hero h1 {
  max-width: 14em;
  font-size: clamp(2.25rem, 5.2vw, 3.6rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -.035em;
}
.hero h1 em {
  font-style: normal;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lede {
  max-width: 34em;
  margin: 20px 0 32px;
  color: var(--band-muted);
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  line-height: 1.6;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-latest {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin-top: 36px;
  padding: 6px 14px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: .875rem;
  text-decoration: none;
  transition: border-color .15s;
}
.hero-latest:hover { color: var(--text-strong); border-color: var(--accent-2); }
.hero-latest-badge {
  flex: none;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.hero-latest-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-latest .icon { width: 16px; height: 16px; }

.hero-art { display: none; }
.hero-diagram { display: block; width: 100%; max-width: 560px; height: auto; margin-inline: auto; }
.hero-diagram .hd-frame { fill: var(--hd-frame-fill); stroke: var(--sky-400); stroke-dasharray: 4 5; }
.hero-diagram .hd-node { fill: var(--surface); stroke: var(--border-strong); }
.hero-diagram .hd-node--mint { fill: var(--tone-green-bg); stroke: var(--mint-400); }
.hero-diagram .hd-node--sky { fill: var(--tone-blue-bg); stroke: var(--sky-400); }
.hero-diagram .hd-caption { fill: var(--accent-text); font: 600 11px var(--font-mono); letter-spacing: .14em; }
.hero-diagram .hd-label { fill: var(--text-strong); font: 700 15px var(--font-display); }
.hero-diagram .hd-label--sm { font-size: 13px; font-weight: 600; }
.hero-diagram .hd-sub { fill: var(--text-muted); font: 400 11px var(--font-mono); }
.hero-diagram .hd-edge { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.hero-diagram .hd-flow { stroke-dasharray: 4 6; animation: hd-flow 1.4s linear infinite; }
.hero-diagram .hd-flow--mint { stroke: var(--mint-500); }
.hero-diagram .hd-flow--sky { stroke: var(--sky-500); }
.hero-diagram .hd-head--mint { fill: var(--mint-500); }
.hero-diagram .hd-head--sky { fill: var(--sky-500); }
@keyframes hd-flow { to { stroke-dashoffset: -20; } }

@media (min-width: 640px) {
  .hero-art { display: block; }
}
@media (min-width: 960px) {
  .hero-inner { grid-template-columns: 1.1fr .9fr; gap: 56px; padding-block: 96px 104px; }
}

/* Page & post heroes */
.page-hero { padding-block: 56px 52px; }
.page-hero h1 { font-size: clamp(2rem, 4.2vw, 2.875rem); font-weight: 800; letter-spacing: -.025em; }
.page-lede {
  max-width: 40em;
  margin-top: 14px;
  color: var(--band-muted);
  font-size: 1.125rem;
}
.page-meta {
  margin-top: 20px;
  color: var(--band-muted);
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .04em;
}
.page-hero-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  margin-bottom: 20px;
  border-radius: 14px;
  background: var(--tone-bg, var(--chip-bg));
  color: var(--tone-fg, var(--chip-text));
}
.page-hero-icon .icon { width: 28px; height: 28px; }

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 24px;
  color: var(--band-muted);
  font-size: .8125rem;
}
.breadcrumbs a { color: var(--band-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--band-text); text-decoration: underline; }

/* 7. Sections & cards ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.post-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.post-card:focus-within { border-color: var(--accent-2); }

.post-card-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
/* `contain` keeps whole architecture diagrams visible in thumbnails */
.post-card-media img {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #fff;
  transition: transform .5s var(--ease);
}
.post-card:hover .post-card-media img { transform: scale(1.03); }
.post-card-media--placeholder {
  background:
    linear-gradient(var(--band-grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--band-grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(135deg, var(--tone-bg, var(--chip-bg)), var(--surface-2));
}
.post-card-media--placeholder .icon { width: 48px; height: 48px; color: var(--tone-fg, var(--chip-text)); stroke-width: 1.4; }

.post-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px 22px;
}
.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--text-muted);
  font-size: .8125rem;
}
.post-card-title { font-size: 1.1875rem; line-height: 1.3; letter-spacing: -.01em; }
.post-card-title a { color: var(--text-strong); text-decoration: none; }
.post-card-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }   /* whole card clickable */
.post-card-title a:hover { color: var(--text-strong); }
.post-card-title a:focus-visible { outline: none; }
.post-card .chip { position: relative; z-index: 2; }
.post-card-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: .9375rem;
  line-height: 1.55;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
  color: var(--text-muted);
  font-size: .8125rem;
}
.read-more { display: inline-flex; align-items: center; gap: 4px; color: var(--link); font-weight: 600; }
.read-more .icon { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.post-card:hover .read-more .icon { transform: translateX(3px); }

/* Horizontal card (home page "Recent articles"): image left, then title,
   description and details, left aligned. Stacks on phones. */
.post-list { display: grid; gap: 20px; }
.post-card--row .post-card-body { gap: 10px; text-align: left; }
.post-card--row .post-card-title { order: 1; font-size: 1.375rem; line-height: 1.25; letter-spacing: -.015em; }
.post-card--row .post-card-excerpt { order: 2; font-size: 1rem; }
.post-card--row .post-card-meta { order: 3; margin-top: 4px; }
.post-card--row .post-card-footer { order: 4; }
@media (min-width: 640px) {
  .post-card--row { display: grid; grid-template-columns: minmax(200px, 32%) 1fr; }
  .post-card--row .post-card-media { aspect-ratio: auto; min-height: 190px; border-bottom: 0; border-right: 1px solid var(--border); }
  .post-card--row .post-card-body { justify-content: center; padding: 24px 28px; }
}
}

/* Call-to-action band */
.cta-band {
  display: grid;
  gap: 24px;
  align-items: center;
  padding: 40px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.cta-band h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.02em; }
.cta-band p { max-width: 34em; margin-top: 10px; color: var(--band-muted); }
.cta-actions { display: flex; flex-wrap: wrap; gap: 12px; }
@media (min-width: 860px) {
  .cta-band { grid-template-columns: 1fr auto; padding: 56px; }
}

.empty-state {
  padding: 48px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}
.empty-state p + .btn { margin-top: 20px; }
.empty-state--large { padding: 56px 24px 64px; }
.empty-state--large .hero-actions { justify-content: center; margin-top: 28px; }
.empty-state-code {
  margin-bottom: 8px;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: var(--font-display);
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
}

/* 8. Topics ---------------------------------------------------------------- */
.topic-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.topic-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--tone-solid, var(--accent));
  transform: scaleX(.18);
  transform-origin: left;
  transition: transform .35s var(--ease);
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.topic-card:hover::before { transform: scaleX(1); }
.topic-card-icon {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--tone-bg, var(--chip-bg));
  color: var(--tone-fg, var(--chip-text));
}
.topic-card-icon .icon { width: 26px; height: 26px; }
.topic-card-title { margin-top: 4px; font-size: 1.25rem; }
.topic-card-title a { color: var(--text-strong); text-decoration: none; }
.topic-card-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.topic-card-desc { color: var(--text-muted); font-size: .9375rem; }
.topic-card-posts {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 8px;
  margin: 4px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  font-size: .9375rem;
}
.topic-card-posts a { color: var(--text); text-decoration: none; }
.topic-card-posts a:hover { color: var(--link); text-decoration: underline; }
.topic-card-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--link);
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-weight: 600;
}
.topic-card-count .icon { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.topic-card:hover .topic-card-count .icon { transform: translateX(3px); }

/* 9. Post page ------------------------------------------------------------- */
.reading-progress {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  z-index: 49;
  height: 3px;
  pointer-events: none;
}
.reading-progress span {
  display: block;
  height: 100%;
  background: var(--grad-accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.post-hero { padding-block: 44px 56px; }
.post-title {
  margin-top: 18px;
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.03em;
}
.post-lede {
  max-width: 40em;
  margin-top: 18px;
  color: var(--band-muted);
  font-size: clamp(1.0625rem, 1.8vw, 1.25rem);
  line-height: 1.55;
}
.post-byline { display: flex; align-items: center; gap: 14px; margin-top: 32px; }
.byline-name { display: block; color: var(--band-text); font-weight: 600; }
.byline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--band-muted);
  font-size: .875rem;
}
.byline-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.byline-meta .icon { width: 15px; height: 15px; opacity: .8; }
.byline-link { display: inline-flex; align-items: center; gap: 6px; color: var(--band-muted); text-decoration: none; }
.byline-link:hover { color: var(--band-text); text-decoration: underline; }

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px; height: 44px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--grad-accent);
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: .9375rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 72px; height: 72px; font-size: 1.375rem; }

.post-layout { padding-block: 48px 24px; }
@media (min-width: 1100px) { .post-layout { padding-top: 56px; } }

.post-footer {
  display: grid;
  gap: 28px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-label { margin-right: 6px; color: var(--text-strong); font-size: .875rem; font-weight: 600; }
.share-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.share-btn .icon { width: 18px; height: 18px; }
.share-btn:hover, .share-btn.is-done { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-text); }

.author-card {
  display: flex;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.author-card-eyebrow { color: var(--text-muted); font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; }
.author-card .author-card-name { margin-top: 2px; font-size: 1.125rem; }   /* beats .prose h2 on the About page */
.author-card .author-card-role { margin-top: 0; color: var(--accent-text); font-size: .875rem; font-weight: 600; }
.author-card-bio { margin: 10px 0 14px; font-size: .9375rem; }
@media (max-width: 480px) { .author-card { flex-direction: column; } }

.comments {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.comments-title { font-size: 1.5rem; letter-spacing: -.02em; }
.comments-note { margin: 6px 0 24px; color: var(--text-muted); font-size: .9375rem; }
.comments-status { margin: 0 0 24px; color: var(--text-muted); font-size: .9375rem; }
.comments-status:empty { display: none; }

.comment-list { display: grid; gap: 16px; margin: 0 0 32px; padding: 0; list-style: none; }
.comment-list:empty { display: none; }
.comment { display: flex; gap: 14px; scroll-margin-top: calc(var(--header-h) + 16px); }
.comment:target .comment-main { border-color: var(--accent-2); }
.comment-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-family: var(--font-display);
  font-weight: 700;
}
.comment-main {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.comment-author { color: var(--text-strong); font-weight: 600; }
.comment-date { color: var(--text-muted); font-size: .8125rem; }
.comment-body { margin-top: 6px; overflow-wrap: anywhere; }
.comment-body p { margin: 0; white-space: pre-line; }
.comment-body p + p { margin-top: 10px; }

.comment-form {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.comment-form-title { font-size: 1.125rem; }
.comment-form-row { display: grid; gap: 16px; }
@media (min-width: 640px) { .comment-form-row { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 6px; }
.field label { color: var(--text-strong); font-size: .875rem; font-weight: 600; }
.field-hint { margin-left: 4px; color: var(--text-muted); font-weight: 400; }
.field-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-strong);
  font: inherit;
  font-size: 1rem;
}
textarea.field-input { min-height: 120px; resize: vertical; line-height: 1.6; }
.field-input:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--focus-ring); }
.field-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.comment-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.comment-form-actions .btn:disabled { opacity: .6; cursor: progress; }
.comment-form-status { margin: 0; color: var(--text-muted); font-size: .9375rem; }
.comment-form-privacy { margin: 0; color: var(--text-muted); font-size: .8125rem; }

/* Moderation page (/moderate/) */
.moderate { max-width: 860px; }
.moderate-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.moderate-toolbar .filter-bar { margin: 0; }
.moderate-status { margin: 20px 0; color: var(--text-muted); font-size: .9375rem; }
.moderate-status:empty { display: none; }
.moderate-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.moderate-item {
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.moderate-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-size: .9375rem; }
.moderate-post { margin: 4px 0 0; color: var(--text-muted); font-size: .875rem; }
.moderate-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.moderate-actions .btn { padding: 8px 16px; }
.moderate-actions .btn:disabled { opacity: .6; cursor: progress; }
.moderate-delete { margin-left: auto; }

/* Article editor (/write/) */
.write { display: grid; gap: 24px; }
.write-drafts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.write-drafts-title { font-size: 1.125rem; }
.write-drafts-select { flex: 1 1 320px; width: auto; min-width: 0; }
.write-drafts-select:disabled { opacity: .7; }
.write-drafts .btn { padding: 9px 16px; font-size: .875rem; }
.write-drafts-status { flex-basis: 100%; margin: 0; color: var(--text-muted); font-size: .875rem; }
.write-drafts-status:empty { display: none; }

.write-main { display: grid; gap: 16px; min-width: 0; }
.write-meta { display: grid; gap: 14px; }
.write-meta-row { display: grid; gap: 14px; align-items: end; }
@media (min-width: 640px) { .write-meta-row { grid-template-columns: 1fr 1fr; } }
.write-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.write-check { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; color: var(--text); font-size: .875rem; }
.write-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.write-meta .field-input:disabled { opacity: .7; cursor: not-allowed; }

.editor-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-2);
}
.editor-toolbar[hidden] { display: none; }
.tb-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.tb-group + .tb-group { padding-left: 6px; border-left: 1px solid var(--border-strong); }
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-strong);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
}
.tb-btn:hover { background: var(--surface); border-color: var(--border); }
.tb-btn.is-active { background: var(--btn-bg); color: var(--btn-text); }
.tb-btn:disabled { opacity: .4; cursor: default; background: none; border-color: transparent; }
.tb-btn .icon { width: 18px; height: 18px; }
.tb-btn mark { padding: 0 2px; background: var(--mark-bg); color: inherit; }
.tb-btn code { font-family: var(--font-mono); font-size: .75rem; }
.tb-select {
  height: 30px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-strong);
  font: inherit;
  font-size: .8125rem;
}

.editor-frame {
  margin-top: -16px;
  border: 1px solid var(--border-strong);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}
.editor-frame[hidden] { display: none; }
.editor-surface { min-height: 60vh; padding: 24px clamp(16px, 4vw, 40px) 48px; outline: none; }
.editor-surface:focus-visible { outline: none; }
.editor-surface p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--text-muted);
  pointer-events: none;
}
.editor-surface .editor-figure { position: relative; }
.editor-surface .editor-figure img { cursor: pointer; }
.editor-surface .editor-figure[data-status="uploading"] img { opacity: .45; }
.editor-surface .editor-figure[data-status="uploading"]::after {
  content: "Uploading…";
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-strong);
  font-size: .8125rem;
}
.editor-surface .editor-figure[data-status="error"] { outline: 2px solid var(--warn-accent); outline-offset: 4px; border-radius: 8px; }
.editor-surface .editor-figure[data-status="error"]::after {
  content: "Upload failed — remove and paste again";
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-accent);
  font-size: .8125rem;
}
.editor-surface .ProseMirror-selectednode { outline: 3px solid var(--accent-2); outline-offset: 4px; border-radius: 8px; }
.editor-surface table, .write-preview table { margin-block: 1.75em; border: 1px solid var(--border); }
.editor-surface td, .editor-surface th { position: relative; min-width: 80px; vertical-align: top; }
.editor-surface .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(46, 143, 214, .15); pointer-events: none; }
.editor-surface pre, .write-preview pre { margin: 1.75em 0; border-radius: var(--radius); background: var(--code-bg); }
.write-paste-hint { margin: -8px 0 0; color: var(--text-muted); font-size: .8125rem; }
.write-preview {
  padding: 32px clamp(16px, 4vw, 40px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
}
.write-preview .post-title { color: var(--text-strong); }
.write-preview .post-lede { margin-bottom: 32px; color: var(--text-muted); }
.write-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.write-actions .btn:disabled { opacity: .6; cursor: progress; }
.write-delete { margin-left: auto; }
.write-status { margin: 0; color: var(--text-muted); font-size: .9375rem; }

/* 10. Prose ---------------------------------------------------------------- */
.prose {
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}
@media (min-width: 768px) { .prose { font-size: 1.125rem; } }

.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.25em; }
.prose > p:first-child { color: var(--text-strong); font-size: 1.15em; line-height: 1.65; }

.prose h2 { margin-top: 2.2em; font-size: 1.65em; letter-spacing: -.02em; }
.prose h3 { margin-top: 1.9em; font-size: 1.25em; }
.prose h4 { margin-top: 1.7em; font-size: 1.05em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: .7em; }

.heading-anchor {
  margin-left: .35em;
  color: var(--border-strong);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: var(--accent-2); }

.prose a { font-weight: 500; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { color: var(--text-strong); font-weight: 700; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li, .prose li > ul, .prose li > ol { margin-top: .45em; }
.prose li::marker { color: var(--accent); }
.prose ol > li::marker { font-family: var(--font-mono); font-size: .9em; font-weight: 600; }

.prose blockquote {
  margin-inline: 0;
  padding: 2px 0 2px 22px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}
.prose blockquote > * + * { margin-top: .8em; }

/* Callouts:  > text  followed by  {: .note }  /  {: .tip }  /  {: .warning } */
.prose blockquote.note,
.prose blockquote.tip,
.prose blockquote.warning {
  padding: 16px 20px;
  border: 1px solid var(--note-border);
  border-left: 4px solid var(--note-accent);
  border-radius: var(--radius);
  background: var(--note-bg);
  color: var(--text);
  font-size: .95em;
}
.prose blockquote.tip { border-color: var(--tip-border); border-left-color: var(--tip-accent); background: var(--tip-bg); }
.prose blockquote.warning { border-color: var(--warn-border); border-left-color: var(--warn-accent); background: var(--warn-bg); }
.prose blockquote.note::before,
.prose blockquote.tip::before,
.prose blockquote.warning::before {
  content: "Note";
  display: block;
  margin-bottom: 4px;
  color: var(--note-accent);
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.prose blockquote.tip::before { content: "Tip"; color: var(--tip-accent); }
.prose blockquote.warning::before { content: "Watch out"; color: var(--warn-accent); }

.prose hr { height: 1px; margin-block: 3em; border: 0; background: var(--border); }

.prose img { border-radius: var(--radius); }

/* Theme text colours (set from the /write/ editor); they adapt to dark mode. */
.tc-mint { color: var(--accent-text); }
.tc-sky  { color: var(--link); }
.tc-teal { color: var(--tone-teal-fg); }
.tc-warn { color: var(--warn-accent); }

.prose :not(pre) > code {
  padding: .15em .4em;
  border-radius: 5px;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  font-family: var(--font-mono);
  font-size: .85em;
  font-variant-ligatures: none;
  overflow-wrap: anywhere;
}

.prose .table-wrap {
  margin-block: 1.75em;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.prose table { width: 100%; border-collapse: collapse; font-size: .9em; line-height: 1.5; }
.prose th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.prose td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: top; }
.prose tr:first-child td { border-top: 0; }
.prose tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

.prose kbd {
  padding: .1em .45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .8em;
}

/* 11. Diagrams & lightbox -------------------------------------------------- */
.prose .diagram { margin: 2.25em 0; }
.diagram-frame {
  position: relative;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.diagram img { width: 100%; margin: 0 auto; border-radius: 8px; background: #fff; }
.diagram figcaption {
  max-width: 44em;
  margin: 14px auto 0;
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.55;
  text-align: center;
}
.diagram figcaption strong { color: var(--text-strong); }
.diagram-hint {
  position: absolute;
  top: 20px; right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(11, 24, 36, .82);
  color: #fff;
  font-size: .75rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.diagram-hint .icon { width: 14px; height: 14px; }
.diagram-frame:hover .diagram-hint { opacity: 1; transform: none; }
@media (hover: none) { .diagram-hint { opacity: .9; transform: none; } }

.zoomable { cursor: zoom-in; }

.lightbox {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(9, 17, 26, .95);
  color: #fff;
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgba(9, 17, 26, .7); }
.lightbox-toolbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.lightbox-caption {
  flex: 1;
  overflow: hidden;
  color: rgba(255, 255, 255, .8);
  font-size: .875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: .8125rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.lightbox-btn:hover { border-color: var(--mint-300); background: rgba(142, 221, 185, .1); color: #fff; }
.lightbox-btn .icon { width: 16px; height: 16px; }
.lightbox-close { width: 36px; padding: 0; justify-content: center; }
@media (max-width: 560px) { .lightbox-btn[data-action="open"] { display: none; } }
.lightbox-stage {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  cursor: zoom-in;
  overscroll-behavior: contain;
}
.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-stage.is-actual { display: block; cursor: grab; }
.lightbox-stage.is-actual img { max-width: none; max-height: none; margin: 0 auto; }
.lightbox-stage.is-dragging { cursor: grabbing; }

/* 12. Code blocks & syntax highlighting ------------------------------------ */
.prose div.highlighter-rouge,
.prose figure.highlight {
  position: relative;
  margin: 1.75em 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--radius);
  background: var(--code-bg);
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .03);
  color: #9FB2C2;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  background: transparent;
  color: #C9D6E0;
  font: inherit;
  font-size: .72rem;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.code-copy:hover { border-color: rgba(255, 255, 255, .35); color: #fff; }
.code-copy.is-done { border-color: var(--mint-400); color: var(--mint-300); }
.code-copy .icon { width: 14px; height: 14px; }

.prose pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  background: transparent;
  color: #E3ECF2;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.7;
  tab-size: 2;
  font-variant-ligatures: none;   /* show -> and != exactly as typed */
}
.prose pre code { padding: 0; background: none; color: inherit; font: inherit; }
.prose .highlight { margin: 0; background: transparent; }

/* Rouge token colours (tuned for the dark code background) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cd, .highlight .ch, .highlight .cpf { color: #7E93A6; font-style: italic; }
.highlight .cp { color: #C5B3FF; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv { color: #7CC4FF; }
.highlight .kt, .highlight .kc { color: #7FE0E0; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .sh, .highlight .sx, .highlight .dl, .highlight .sa { color: #8DE3B8; }
.highlight .se, .highlight .si { color: #F5D78A; }
.highlight .sr, .highlight .ss { color: #7FE0E0; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .mb, .highlight .mx, .highlight .il { color: #F5C77A; }
.highlight .nf, .highlight .fm { color: #C5B3FF; }
.highlight .nc, .highlight .nn { color: #FFD58A; }
.highlight .nb, .highlight .bp { color: #7FE0E0; }
.highlight .nd { color: #C5B3FF; }
.highlight .na { color: #8DE3B8; }
.highlight .nt { color: #7CC4FF; }
.highlight .no { color: #F5C77A; }
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .n { color: #E3ECF2; }
.highlight .o, .highlight .ow { color: #A9C7DA; }
.highlight .p { color: #9FB2C2; }
.highlight .err { color: #FF9E8A; background: transparent; }
.highlight .gd { color: #FF9E8A; background: rgba(255, 120, 100, .12); }
.highlight .gi { color: #8DE3B8; background: rgba(141, 227, 184, .1); }
.highlight .gh, .highlight .gu { color: #7CC4FF; font-weight: 600; }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 700; }

/* 13. Listing pages -------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
.filter-chip span { color: var(--text-muted); font-family: var(--font-mono); font-size: .75rem; }
.filter-chip:hover { border-color: var(--accent-2); }
.filter-chip.is-active { border-color: var(--active-bg); background: var(--active-bg); color: var(--active-text); font-weight: 600; }
.filter-chip.is-active span { color: var(--active-text); opacity: .75; }
.filter-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
}
.filter-search .icon { width: 16px; height: 16px; }
.filter-search:hover { color: var(--link); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-group { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 16px); }
.tag-group h2 { color: var(--link); font-family: var(--font-mono); font-size: 1.125rem; font-weight: 600; letter-spacing: 0; }
.tag-group:target h2 { color: var(--accent-text); }
.post-list { display: grid; margin: 12px 0 0; padding: 0; list-style: none; }
.post-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.post-list a:hover { color: var(--link); }
.post-list time { flex: none; color: var(--text-muted); font-family: var(--font-mono); font-size: .8rem; font-weight: 400; }

.search { max-width: 820px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; top: 50%; left: 18px; color: var(--text-muted); transform: translateY(-50%); pointer-events: none; }
.search-input {
  width: 100%;
  padding: 16px 20px 16px 52px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-strong);
  font: inherit;
  font-size: 1.125rem;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--text-muted); opacity: .8; }
.search-input:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--focus-ring); }
.search-status { margin: 16px 0; color: var(--text-muted); font-size: .875rem; }
.search-status:empty { display: none; }
.search-results { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.search-result a {
  display: block;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s;
}
.search-result a:hover, .search-result a:focus-visible { border-color: var(--accent-2); }
.search-result-meta { display: block; color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.search-result-title { display: block; margin: 6px 0; color: var(--text-strong); font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; line-height: 1.35; }
.search-result-snippet { display: block; color: var(--text-muted); font-size: .9375rem; line-height: 1.55; }
.search-browse { margin-top: 40px; }
.search-browse .footer-heading { margin: 28px 0 12px; color: var(--text-muted); }
mark { padding: 0 .1em; border-radius: 3px; background: var(--mark-bg); color: inherit; }

/* 14. Footer --------------------------------------------------------------- */
.site-footer {
  position: relative;
  margin-top: auto;
  padding-top: 64px;
  border-top: 1px solid var(--footer-border);
  background: var(--footer-bg);
  color: var(--footer-text);
}
.site-footer::before {
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 3px;
  background: var(--grad-accent);
}
.site-footer .brand { color: var(--text-strong); }
.footer-grid { display: grid; gap: 40px; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-brand p { max-width: 30em; margin: 16px 0 20px; font-size: .9375rem; }
.footer-heading {
  margin-bottom: 16px;
  color: var(--footer-heading);
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.site-footer ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--footer-link); text-decoration: none; }
.site-footer a:hover { color: var(--link); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 48px;
  padding-block: 24px;
  border-top: 1px solid var(--footer-border);
  color: var(--footer-heading);
  font-size: .8125rem;
}

.social-links { display: flex; flex-wrap: wrap; gap: 8px; }
.social-link,
.site-footer .social-link {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  transition: background-color .15s, border-color .15s, color .15s;
}
.social-link:hover,
.site-footer .social-link:hover { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-text); }
.social-link .icon { width: 18px; height: 18px; }

/* 15. Utilities, motion, print --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .site-header, .site-footer, .reading-progress, .related,
  .comments, .share, .code-toolbar, .diagram-hint, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .band { background: none; color: #000; border: 0; }
  .band::before, .band::after { display: none; }
  .prose a::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
  .prose div.highlighter-rouge { border: 1px solid #ccc; background: #fff; }
  .prose pre, .highlight * { color: #000 !important; }
}
