/* ───────── Tokens ───────── */
:root,
[data-theme='dark'] {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-hero: clamp(2.5rem, 1rem + 6vw, 5.5rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Dark (default) - deep charcoal + terminal-green accent */
  --color-bg: #0d0f0e;
  --color-surface: #161a18;
  --color-surface-2: #1f2421;
  --color-border: #3a423d;
  --color-border-strong: #4a544e;
  --color-divider: #2a302d;
  --color-text: #e6ebe8;
  --color-text-muted: #97a19b;
  --color-text-faint: #5a635e;
  --color-primary: #4ce296;          /* terminal green */
  --color-primary-hover: #66f0a6;
  --color-primary-dim: #1f3c2d;
  --color-primary-highlight: rgba(76, 226, 150, 0.12);

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);

  --container-wide: 1180px;
  --container-default: 980px;
  --container-narrow: 680px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; scroll-behavior: smooth; scroll-padding-top: var(--space-16); }
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 80% -10%, var(--color-primary-highlight), transparent 60%),
    radial-gradient(ellipse 600px 400px at -10% 20%, rgba(76, 226, 150, 0.05), transparent 60%);
  background-attachment: fixed;
}
img, svg, video, canvas, picture { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, h5 { line-height: 1.15; text-wrap: balance; font-weight: 650; letter-spacing: -0.015em; }
p, li, blockquote { text-wrap: pretty; }
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-interactive); }
a:hover { color: var(--color-primary-hover); }
::selection { background: var(--color-primary-highlight); color: var(--color-text); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.container { max-width: var(--container-wide); margin: 0 auto; padding: 0 var(--space-6); }
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--space-6); }

/* ───────── Header ───────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  background: color-mix(in oklab, var(--color-bg) 75%, transparent);
  border-bottom: 1px solid var(--color-border);
}
.header-inner { display: flex; align-items: center; gap: var(--space-6); padding: var(--space-4) var(--space-6); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--color-text); font-weight: 650; letter-spacing: -0.01em; }
.brand:hover { color: var(--color-text); }
.brand-mark { color: var(--color-primary); }
.brand-text { font-size: var(--text-sm); font-family: var(--font-mono); }
/* Desktop nav lives inside the header. Mobile nav is a sibling of header so it can
   escape the header's backdrop-filter containing block when fixed to the viewport. */
.nav-desktop { display: flex; gap: var(--space-5); margin-left: auto; flex-wrap: wrap; }
.nav-desktop a { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 500; }
.nav-desktop a:hover, .nav-desktop a[aria-current='page'] { color: var(--color-text); }
.nav-desktop a[aria-current='page'] { position: relative; }
.nav-desktop a[aria-current='page']::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -22px; height: 2px; background: var(--color-primary);
}
/* Hide the full-screen mobile menu by default; the @media block below activates it. */
.nav-mobile { display: none; }
a.nav-home {
  display: inline-flex; align-items: center; gap: 0.35em;
  margin-left: var(--space-4);
  padding: 0.25em 0.7em;
  border: 1px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
  border-radius: 999px;
  color: var(--color-primary);
  font-size: var(--text-sm); font-weight: 500;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
a.nav-home:hover {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  border-color: var(--color-primary);
}
a.nav-home span { font-family: var(--font-mono); line-height: 1; }

/* Hamburger toggle (mobile only) */
.nav-toggle {
  display: none;
  position: relative;
  width: 40px; height: 40px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text);
  transition: border-color var(--transition-interactive), background-color var(--transition-interactive);
}
.nav-toggle:hover { border-color: var(--color-primary); }
.nav-toggle-bar {
  position: absolute;
  left: 9px; right: 9px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 180ms ease, opacity 140ms ease, top 180ms ease;
}
.nav-toggle-bar:nth-child(1) { top: 13px; }
.nav-toggle-bar:nth-child(2) { top: 19px; }
.nav-toggle-bar:nth-child(3) { top: 25px; }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar:nth-child(1) { top: 19px; transform: rotate(45deg); }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar:nth-child(3) { top: 19px; transform: rotate(-45deg); }

/* Backdrop behind open mobile nav (kept for the JS click-to-close target; visually the
   nav itself is now full-bleed so the backdrop just lives behind it). */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
  opacity: 0;
  transition: opacity 160ms ease;
}
.nav-backdrop:not([hidden]) { opacity: 1; }

@media (max-width: 740px) {
  .header-inner { flex-wrap: nowrap; }
  /* Drop the backdrop-filter on mobile so it doesn't form a containing block that
     traps position:fixed children (toggle) inside the header. */
  .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--color-bg);
  }
  /* Pin the toggle to the viewport on mobile so it escapes the header's stacking
     context and stays clickable above the full-screen menu. */
  .nav-toggle {
    display: inline-block;
    position: fixed;
    top: calc(var(--space-4) + env(safe-area-inset-top, 0px));
    right: var(--space-6);
    z-index: 80;
    background: var(--color-bg);
  }
  .nav-desktop { display: none; }
  /* Full-screen terminal-style mobile menu. Lives outside <header> so the header's
     backdrop-filter doesn't trap position:fixed in the header's containing block. */
  .nav-mobile {
    display: flex;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0;
    padding: calc(var(--space-16) + env(safe-area-inset-top, 0px)) var(--space-6) calc(var(--space-10) + env(safe-area-inset-bottom, 0px));
    background: var(--color-bg);
    /* Faint terminal scanlines, matching the hero card. */
    background-image: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.018) 50%,
      rgba(255, 255, 255, 0) 50%
    );
    background-size: 100% 3px;
    border-bottom: 0;
    box-shadow: none;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 200ms ease;
    z-index: 65;
    overflow-y: auto;
  }
  .nav-mobile.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  /* Header bar inside the menu: small prompt label so it feels like a fresh terminal session. */
  .nav-mobile::before {
    content: '~$ menu --list';
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-text-faint);
    letter-spacing: 0.04em;
    margin-bottom: var(--space-6);
  }
  .nav-mobile a {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: 1.625rem;            /* 26px - large, easy tap target */
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: var(--color-text);
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
  }
  .nav-mobile a::before {
    content: '~$';
    color: var(--color-text-faint);
    font-size: 0.85em;
    flex: 0 0 auto;
  }
  .nav-mobile a:hover, .nav-mobile a:focus-visible { color: var(--color-primary); }
  .nav-mobile a:last-child { border-bottom: 0; }
  .nav-mobile a[aria-current='page'] { color: var(--color-primary); }
  .nav-mobile a[aria-current='page']::before { color: var(--color-primary); }
}
.body-nav-open { overflow: hidden; }

/* ───────── Footer ───────── */
.site-footer { border-top: 1px solid var(--color-border); margin-top: var(--space-24); }
.footer-inner { padding: var(--space-8) var(--space-6); display: flex; gap: var(--space-6); align-items: center; flex-wrap: wrap; }
.foot-brand { color: var(--color-text-muted); font-size: var(--text-sm); }
.foot-nav { margin-left: auto; display: flex; gap: var(--space-6); flex-wrap: wrap; }
.foot-nav a { color: var(--color-text-muted); font-size: var(--text-sm); }
.foot-nav a:hover { color: var(--color-primary); }

/* ───────── Hero ───────── */
.hero { padding: var(--space-10) 0 var(--space-16); }
/* Wide (default): 3-col grid. Top row = copy (spans cols 1-2) | card. Bottom row = avatar | lede (spans cols 2-3). */
.hero-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 0;
  row-gap: var(--space-10);
  align-items: center;
}
.hero-copy { grid-column: 1 / 3; grid-row: 1; padding-right: var(--space-12); }
.hero-grid > .hero-card { grid-column: 3; grid-row: 1; align-self: center; }
.hero-grid > .hero-avatar {
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
  width: 120px; height: 120px;
  margin-right: 60px;
}
.hero-lede-block {
  grid-column: 2 / 4;
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.hero-lede-block .hero-eyebrow { align-self: flex-start; }
.hero p.hero-lede {
  margin: 0;
  font-size: var(--text-base);
  max-width: none;
}
/* The .lede typography rule below caps width at 58ch; in the hero we want the lede to stretch the full window. */
.hero .hero-lede-block p.hero-lede { max-width: none; }
/* Mid widths: copy spans the top, avatar + terminal card share the middle row, lede spans below. */
@media (max-width: 1100px) and (min-width: 821px) {
  .hero-grid {
    /* Use a third 1fr column so the lede block has a full-width track to span. */
    grid-template-columns: auto auto 1fr;
    justify-content: start;
    column-gap: var(--space-6);
    row-gap: var(--space-8);
  }
  .hero-copy { grid-column: 1 / 4; grid-row: 1; padding-right: 0; }
  .hero-grid > .hero-avatar { grid-column: 1; grid-row: 2; width: 140px; height: 140px; justify-self: end; margin-right: 0; }
  .hero-grid > .hero-card { grid-column: 2; grid-row: 2; align-self: center; justify-self: start; width: max-content; max-width: 100%; }
  .hero-lede-block { grid-column: 1 / 4; grid-row: 3; width: 100%; }
  .hero p.hero-lede { max-width: none; }
}
.hero-eyebrow { color: var(--color-primary); font-family: var(--font-mono); font-size: var(--text-sm); letter-spacing: 0.02em; display: inline-flex; align-items: center; gap: var(--space-2); }
.hero-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--color-border); box-shadow: var(--shadow-md); }
.hero-eyebrow::before { content: '~$'; color: var(--color-text-faint); }
.hero h1 { font-size: var(--text-hero); letter-spacing: -0.03em; margin: var(--space-4) 0 var(--space-6); }
.hero h1 .accent { color: var(--color-primary); }
.hero p.lede { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 58ch; }
/* macOS-Terminal-app inspired window chrome */
.hero-card.term {
  --term-titlebar-h: 28px;
  --term-titlebar-bg: #2a2d2c;
  --term-titlebar-border: rgba(0, 0, 0, 0.45);
  --term-body-bg: #0e1110;
  background: var(--term-body-bg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0;
  font-family: 'SF Mono', 'JetBrains Mono', Menlo, Monaco, Consolas, var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  position: relative;
  overflow: hidden;
  /* Layered shadow: ambient floor + soft drop + 1px inner highlight on top edge */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 14px 30px rgba(0, 0, 0, 0.45),
    0 4px 10px rgba(0, 0, 0, 0.35);
}
.term-titlebar {
  height: var(--term-titlebar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
  /* Soft brushed-metal gradient that reads as a Big Sur / Sonoma title bar */
  background: linear-gradient(to bottom, #3a3d3c 0%, #2a2d2c 100%);
  border-bottom: 1px solid var(--term-titlebar-border);
  user-select: none;
}
.term-traffic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
}
.term-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 0.5px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 -0.5px 0 rgba(0, 0, 0, 0.18) inset;
}
.term-dot-close { background: radial-gradient(circle at 35% 30%, #ff7a72, #ff5f57 70%); }
.term-dot-min   { background: radial-gradient(circle at 35% 30%, #ffd46a, #febc2e 70%); }
.term-dot-zoom  { background: radial-gradient(circle at 35% 30%, #5fe07a, #28c840 70%); }
.term-title {
  justify-self: center;
  color: rgba(235, 235, 235, 0.72);
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.term-body {
  padding: var(--space-5) var(--space-6) var(--space-5);
  /* Subtle CRT-style scanlines, very faint */
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 50%,
    rgba(255, 255, 255, 0) 50%
  );
  background-size: 100% 3px;
}
.term-body pre {
  margin: 0;
  white-space: pre-wrap;
  color: rgba(220, 230, 224, 0.92);
  text-shadow: 0 0 1px rgba(76, 226, 150, 0.04);
}
.hero-card .k { color: var(--color-primary); display: inline-block; width: 6ch; }
.hero-card .v { color: rgba(235, 240, 237, 0.95); }
/* Blinking block cursor at the end of the prompt */
.term-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--color-primary);
  vertical-align: -0.15em;
  margin-left: 4px;
  border-radius: 1px;
  animation: term-blink 1.05s steps(2, end) infinite;
  box-shadow: 0 0 6px rgba(76, 226, 150, 0.55);
}
@keyframes term-blink {
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .term-cursor { animation: none; }
}
.hero-cta { display: inline-flex; gap: var(--space-3); margin-top: var(--space-8); flex-wrap: wrap; }
/* Mobile: same bones as mid - copy on top, avatar + card side by side, lede below. Scaled down. */
@media (max-width: 820px) {
  .hero { padding: var(--space-6) 0 var(--space-10); }
  .hero-grid {
    /* Trailing 1fr track lets the lede block stretch to full container width. */
    grid-template-columns: auto auto 1fr;
    justify-content: start;
    column-gap: var(--space-4);
    row-gap: var(--space-6);
  }
  .hero-copy { grid-column: 1 / 4; grid-row: 1; padding-right: 0; }
  .hero-grid > .hero-avatar { grid-column: 1; grid-row: 2; width: 96px; height: 96px; justify-self: start; margin-right: 0; align-self: center; }
  .hero-grid > .hero-card { grid-column: 2; grid-row: 2; align-self: center; justify-self: start; width: max-content; max-width: 100%; font-size: var(--text-xs); }
  .hero-grid > .hero-card .term-body { padding: var(--space-4); }
  .hero-lede-block { grid-column: 1 / 4; grid-row: 3; width: 100%; }
  .hero p.hero-lede { max-width: none; }
}
/* Narrow mobile: stack, and tuck the avatar into the upper-right corner of the terminal card (overlap via shared grid cell). */
@media (max-width: 560px) {
  .hero-grid {
    grid-template-columns: 1fr;
    justify-content: stretch;
    justify-items: stretch;
    text-align: left;
  }
  .hero-copy { grid-column: 1; grid-row: 1; text-align: left; }
  .hero-grid > .hero-card {
    grid-column: 1; grid-row: 2;
    width: 100%; justify-self: stretch;
    text-align: left;
    /* Shrink the terminal font on phones so content fits within the card without wrapping */
    font-size: 12px;
    position: relative;
  }
  .hero-grid > .hero-card .term-body {
    padding: var(--space-4) var(--space-5);
  }
  /* Don't wrap terminal lines on mobile - scroll instead if a line is too wide */
  .hero-grid > .hero-card .term-body pre {
    white-space: pre;
    overflow-x: auto;
  }
  /* Avatar sits as a profile pip overlapping the title-bar / body boundary on the right side */
  .hero-grid > .hero-avatar {
    grid-column: 1; grid-row: 2;
    width: 44px; height: 44px;
    margin: 0;
    justify-self: end;
    align-self: start;
    /* Title bar is 28px; centered vertically across its baseline with the body */
    transform: translate(-12px, 6px);
    border-width: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    z-index: 3;
  }
  .hero-lede-block { grid-column: 1; grid-row: 3; align-items: stretch; }
  .hero-lede-block .hero-eyebrow { align-self: flex-start; }
  .hero p.hero-lede { text-align: left; }
  .hero-cta { justify-content: flex-start; }
}

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-primary { background: var(--color-primary); color: #0a1a12; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); color: #0a1a12; border-color: var(--color-primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { color: var(--color-primary); background: var(--color-primary-highlight); border-color: transparent; }

/* ───────── Sections ───────── */
.section { padding: var(--space-16) 0; }
.section + .section { border-top: 1px solid var(--color-divider); }
.section-title { font-size: var(--text-xl); margin-bottom: var(--space-8); display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-6); }
.section-title .more { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 500; }
.section-title .more:hover { color: var(--color-primary); }
.section-lede { color: var(--color-text-muted); max-width: 65ch; margin-top: calc(-1 * var(--space-4)); margin-bottom: var(--space-8); }

/* ───────── Cards ───────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-6); }
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform var(--transition-interactive), border-color var(--transition-interactive), box-shadow var(--transition-interactive);
  display: flex; flex-direction: column; gap: var(--space-3);
  text-decoration: none;
}
.card:hover { transform: translateY(-2px); border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.card .meta { display: flex; gap: var(--space-3); color: var(--color-text-muted); font-size: var(--text-xs); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.card h3 { font-size: var(--text-lg); color: var(--color-text); }
.card p { color: var(--color-text-muted); font-size: var(--text-sm); }
.card .tags { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: auto; padding-top: var(--space-3); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-family: var(--font-mono); background: var(--color-surface-2); color: var(--color-text-muted); border: 1px solid var(--color-border); text-transform: uppercase; letter-spacing: 0.04em; }

/* ───────── Link list (gear/apps/services) ───────── */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.link-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  transition: border-color var(--transition-interactive), transform var(--transition-interactive);
}
.link-card:hover { border-color: var(--color-primary); transform: translateY(-1px); }
.link-card .name { color: var(--color-text); font-weight: 600; font-size: var(--text-sm); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.link-card .name .out { color: var(--color-text-faint); font-size: 12px; }
.link-card .desc { color: var(--color-text-muted); font-size: var(--text-sm); }
.link-card .cat { color: var(--color-primary); font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }

/* ───────── Article ───────── */
.article { padding: var(--space-16) 0 var(--space-12); }
.article-hero { margin-bottom: var(--space-12); border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-8); }
.article-hero .eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--color-primary); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.1em; }
.article-hero h1 { font-size: var(--text-2xl); margin: var(--space-4) 0 var(--space-4); letter-spacing: -0.02em; }
.article-hero .summary { color: var(--color-text-muted); font-size: var(--text-lg); max-width: 62ch; }
.article-hero .meta-row { margin-top: var(--space-5); color: var(--color-text-faint); font-size: var(--text-sm); display: flex; gap: var(--space-4); flex-wrap: wrap; }
.article-body { max-width: 68ch; }
.article-body p, .article-body li, .article-body blockquote { font-size: var(--text-base); color: var(--color-text); }
.article-body p + p, .article-body ul, .article-body ol, .article-body blockquote, .article-body pre, .article-body h2, .article-body h3, .article-body hr { margin-top: var(--space-5); }
.article-body h2 { font-size: var(--text-xl); margin-top: var(--space-10); }
.article-body h3 { font-size: var(--text-lg); margin-top: var(--space-8); }
.article-body ul, .article-body ol { padding-left: var(--space-6); }
.article-body li + li { margin-top: var(--space-1); }
.article-body blockquote { border-left: 3px solid var(--color-primary); padding: var(--space-2) var(--space-5); background: var(--color-surface); color: var(--color-text-muted); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.article-body a { border-bottom: 1px dotted currentColor; }
.article-body code { font-family: var(--font-mono); font-size: 0.9em; background: var(--color-surface-2); padding: 2px 6px; border-radius: 4px; color: var(--color-text); }
.article-body hr { border: 0; border-top: 1px solid var(--color-border); }

/* ───────── Code blocks ───────── */
.code-block, pre.script-source {
  background: #0a0d0b;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  padding-right: calc(var(--space-5) + 70px); /* room for the copy button */
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #d6ede0;
  line-height: 1.55;
  position: relative;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}
.code-block code, pre.script-source code { font-family: inherit; color: inherit; background: transparent; padding: 0; }

.script-header { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: var(--space-3); }
.script-header .lang { font-family: var(--font-mono); color: var(--color-text-faint); font-size: var(--text-xs); letter-spacing: 0.05em; text-transform: uppercase; }
.copy-btn {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4); font-size: var(--text-xs); font-family: var(--font-mono); cursor: pointer; color: var(--color-text-muted);
}
.copy-btn:hover { color: var(--color-primary); border-color: var(--color-primary); }
.copy-btn.copied { color: var(--color-primary); border-color: var(--color-primary); }
/* Pin the copy button to the far right of a code block. */
.code-block > .copy-btn,
pre.script-source > .copy-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 1;
}

.iwr-box { background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); margin: var(--space-6) 0; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text-muted); overflow-x: auto; }
.iwr-box .prompt { color: var(--color-primary); }

/* ───────── Landing sections ───────── */
.three-up { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); margin-top: var(--space-8); }
.three-up .pillar { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); padding-right: var(--space-10); padding-bottom: var(--space-10); position: relative; }
.three-up .pillar h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); color: var(--color-text); }
.three-up .pillar p { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: 0; }
.three-up .pillar .mono-label { color: var(--color-primary); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.three-up .pillar-link { display: block; color: inherit; text-decoration: none; transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.three-up .pillar-link:hover,
.three-up .pillar-link:focus-visible { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.three-up .pillar-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.three-up .pillar-arrow {
  position: absolute;
  right: var(--space-5);
  bottom: var(--space-4);
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  font-size: 18px;
  line-height: 1;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.three-up .pillar-link:hover .pillar-arrow,
.three-up .pillar-link:focus-visible .pillar-arrow {
  transform: translateX(3px);
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg, #0c0f0f);
}
@media (max-width: 780px) { .three-up { grid-template-columns: 1fr; } }

/* ───────── Empty / notice ───────── */
.empty-state { border: 1px dashed var(--color-border); border-radius: var(--radius-lg); padding: var(--space-12); text-align: center; color: var(--color-text-muted); }

/* ───────── Flash messages ───────── */
.flash { padding: var(--space-4) var(--space-5); border-radius: var(--radius-md); margin-bottom: var(--space-6); border: 1px solid; }
.flash-ok { background: var(--color-primary-highlight); border-color: var(--color-primary); color: var(--color-text); }
.flash-err { background: rgba(230, 80, 110, 0.12); border-color: #ea6279; color: var(--color-text); }
.flash-warn { background: rgba(255, 196, 79, 0.1); border-color: #d9a441; color: var(--color-text); }
.flash-warn code { background: rgba(0,0,0,0.2); padding: 0.05em 0.35em; border-radius: var(--radius-sm); font-size: 0.9em; }

/* ───────── Admin ───────── */
.admin-wrap { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.admin-sidebar { border-right: 1px solid var(--color-border); padding: var(--space-6) var(--space-4); background: var(--color-surface); position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.admin-sidebar .brand { margin-bottom: var(--space-8); }
.admin-sidebar nav { display: flex; flex-direction: column; gap: var(--space-1); }
.admin-sidebar nav a { color: var(--color-text-muted); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { background: var(--color-surface-2); color: var(--color-text); }
.admin-sidebar .who { margin-top: auto; padding-top: var(--space-6); font-size: var(--text-xs); color: var(--color-text-faint); border-top: 1px solid var(--color-border); }
.admin-main { padding: var(--space-8); overflow-x: auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-8); flex-wrap: wrap; }
.admin-head h1 { font-size: var(--text-xl); }

.form-stack { display: flex; flex-direction: column; gap: var(--space-5); max-width: 720px; }
.form-row { display: grid; grid-template-columns: 180px 1fr; gap: var(--space-4); align-items: start; }
.form-row label { color: var(--color-text-muted); font-size: var(--text-sm); padding-top: var(--space-2); font-family: var(--font-mono); }
.form-row .hint { color: var(--color-text-faint); font-size: var(--text-xs); margin-top: var(--space-2); }
.input, .textarea, select {
  background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); font-size: var(--text-sm);
  font-family: var(--font-body); width: 100%;
}
.textarea { font-family: var(--font-mono); line-height: 1.55; }
.textarea.code { min-height: 320px; }
.textarea.body { min-height: 260px; }
.input:focus, .textarea:focus, select:focus { border-color: var(--color-primary); outline: none; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); }
@media (max-width: 740px) {
  .admin-wrap { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .form-row { grid-template-columns: 1fr; }
}

/* ───────── Tables ───────── */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th, .data-table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table th { color: var(--color-text-muted); font-weight: 600; font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.data-table tr:hover td { background: var(--color-surface); }
.data-table .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-family: var(--font-mono); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.data-table .badge.pub { color: var(--color-primary); border-color: var(--color-primary); }
/* Right-align numeric and action columns. Use text-align on the cell instead */
/* of flexbox so the row baseline stays aligned and the row border stays solid. */
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions, .data-table th.actions { text-align: right; white-space: nowrap; }
.data-table .actions a, .data-table .actions button { font-size: var(--text-xs); }
.data-table .actions a + a, .data-table .actions a + button, .data-table .actions button + a { margin-left: var(--space-3); }

.kind-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); flex-wrap: wrap; }
.kind-tabs a { padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-sm); border: 1px solid var(--color-border); }
.kind-tabs a.active, .kind-tabs a:hover { color: var(--color-primary); border-color: var(--color-primary); }

.danger { color: #ea6279; }
.muted { color: var(--color-text-muted); }

/* ───────── Journal / lists ───────── */
.page-intro { padding: var(--space-16) 0 var(--space-8); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-12); }
.page-intro .eyebrow { color: var(--color-primary); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.12em; }
.page-intro h1 { font-size: var(--text-2xl); margin: var(--space-4) 0 var(--space-4); letter-spacing: -0.02em; }
.page-intro p { color: var(--color-text-muted); font-size: var(--text-lg); max-width: 62ch; }

.post-list { display: flex; flex-direction: column; gap: var(--space-1); }
.post-row { display: grid; grid-template-columns: 120px 1fr auto; gap: var(--space-6); padding: var(--space-5) 0; border-bottom: 1px solid var(--color-border); align-items: baseline; }
.post-row:hover h3 { color: var(--color-primary); }
.post-row .date { color: var(--color-text-faint); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.post-row h3 { font-size: var(--text-lg); color: var(--color-text); transition: color var(--transition-interactive); }
.post-row .summary { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-2); max-width: 70ch; }
.post-row .arrow { color: var(--color-text-faint); }
.post-row:hover .arrow { color: var(--color-primary); }
@media (max-width: 720px) { .post-row { grid-template-columns: 1fr; gap: var(--space-2); } .post-row .arrow { display: none; } }

/* ───────── Changelog ───────── */
.changelog-list { display: flex; flex-direction: column; gap: var(--space-8); }
.changelog-entry {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  background: var(--color-surface);
}
.changelog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.changelog-title { font-size: var(--text-lg); margin: 0 0 var(--space-3); }
.changelog-title a { color: inherit; text-decoration: none; }
.changelog-title a:hover { color: var(--color-primary); }
.changelog-body { font-size: var(--text-sm); }
.changelog-body :is(p, ul, ol) { margin: 0 0 var(--space-3); }
.changelog-legend { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.changelog-legend .impact { margin-right: calc(-1 * var(--space-1)); }

.impact {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.85em;
  letter-spacing: 0.05em;
}
.impact-dots { letter-spacing: 0.15em; }
.impact-1 .impact-dots { color: #7a8a84; }
.impact-2 .impact-dots { color: #79b8ff; }
.impact-3 .impact-dots { color: #ffd479; }
.impact-4 .impact-dots { color: #ff9c6b; }
.impact-5 .impact-dots { color: #ff6b9c; }

/* ───────── Admin settings ───────── */
.settings-group {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}
.settings-group:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.settings-group-title {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  margin: 0 0 var(--space-4);
}
.settings-form textarea.input { font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.45; }

/* ───────── Passkeys admin page ───────── */
.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.admin-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  vertical-align: middle;
}
.admin-table th {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--color-surface-2); }

.pk-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-5);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.pk-dialog::backdrop { background: rgba(0,0,0,0.55); }

/* ───────── Admin: Links (gear / apps / services) ───────── */
.link-add-form {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(180px, 1.6fr) minmax(120px, 0.9fr) minmax(160px, 1.4fr) auto;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-5);
}
.link-add-form .input { min-width: 0; }
@media (max-width: 820px) {
  .link-add-form { grid-template-columns: 1fr 1fr; }
  .link-add-form button { grid-column: 1 / -1; }
}

.link-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
  overflow: hidden;
}
.link-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.link-group-head h2 {
  margin: 0;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
}

ul.sortable {
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 12px;
}

li.link-row {
  display: grid;
  grid-template-columns: auto minmax(0, 2.4fr) minmax(0, 1.6fr) auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: background-color 120ms ease;
}
li.link-row:last-child { border-bottom: 0; }
li.link-row:hover { background: var(--color-surface-2); }

.drag-handle {
  cursor: grab;
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  padding: 0 var(--space-1);
  user-select: none;
  line-height: 1;
}
.drag-handle:hover { color: var(--color-primary); }
.drag-handle-demo {
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  padding: 0 2px;
}

.row-main { min-width: 0; }
.row-name {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-desc {
  font-size: var(--text-xs);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-url {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.row-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}
.btn-danger {
  color: var(--color-text-muted);
}
.btn-danger:hover {
  color: #ff8080;
  border-color: #ff8080;
}

/* Drag feedback */
.link-row-ghost {
  opacity: 0.35;
  background: var(--color-primary-highlight, rgba(120, 220, 180, 0.08)) !important;
}
.link-row-chosen { background: var(--color-surface-2) !important; }
.link-row-drag { cursor: grabbing; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }

/* Narrow layout: collapse URL under name */
@media (max-width: 720px) {
  li.link-row {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--space-2) var(--space-3);
  }
  .row-url {
    grid-column: 2 / -1;
    grid-row: 2;
  }
  .row-actions { grid-column: 3; grid-row: 1; }
}

/* ------ Toggle switch (accessible, keyboardable) --------------------------- */
/* Layout container: title/desc on the left, switch on the right. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.switch-text { flex: 1 1 260px; min-width: 0; }

/* The switch itself. Hide the native checkbox but keep it focusable. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.switch-track {
  display: inline-block;
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-surface-3, #3a3a3a);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex: 0 0 auto;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .switch-track {
  background: var(--color-primary, #4a9eff);
  border-color: var(--color-primary, #4a9eff);
}
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--color-primary, #4a9eff);
  outline-offset: 2px;
}
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }
.switch-label { font-size: var(--text-sm); min-width: 2ch; }

/* ------ Category group header controls ------------------------------------ */
.link-group-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.group-drag-handle {
  color: var(--color-text-muted);
  cursor: grab;
  padding: 0 var(--space-1);
  font-size: 14px;
  line-height: 1;
  user-select: none;
  opacity: 0.55;
  transition: opacity 0.12s ease;
}
.group-drag-handle:hover { opacity: 1; }
.group-drag-handle:active { cursor: grabbing; }

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm, 4px);
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn-icon:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-icon:focus-visible {
  outline: 2px solid var(--color-primary, #4a9eff);
  outline-offset: 1px;
}

/* Ghost / chosen states for the category-level drag. */
.link-group-ghost {
  opacity: 0.4;
  background: var(--color-surface-2);
}
.link-group-chosen { cursor: grabbing; }
.link-group-drag {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
