/* ==========================================================================
   CS285 · Secure Key Exchange — site styles
   Built on the shared shoug-tech project theme, re-cut for discrete maths:
   an integer-lattice background, maths-serif variables and a palette keyed
   to the parties of the Diffie–Hellman protocol.
   Dark-first, with a light theme toggled via [data-theme="light"].
   ========================================================================== */

/* Colour roles follow the protocol: violet is Alice, amber is Bob, green is
   the shared key K, and rose is Eve, the eavesdropper. Charts, the lab and the
   prose all reuse these names so a colour always means the same party. */
:root {
  --bg: #07060d;
  --bg-2: #0c0a16;
  --panel: rgba(15, 13, 27, 0.72);
  --panel-solid: #0f0d1b;
  --panel-2: #151229;
  --line: #1e1a33;
  --line-2: #2c2747;
  --text: #eeecf7;
  --muted: #a3a0bb;
  --dim: #6a6686;
  --accent: #a78bfa;
  --accent-2: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.1);
  --accent-line: rgba(167, 139, 250, 0.36);
  --accent-ink: #12082b;
  --hot: #fbbf24;
  --hot-soft: rgba(251, 191, 36, 0.1);
  --hot-line: rgba(251, 191, 36, 0.34);
  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.1);
  --good-line: rgba(52, 211, 153, 0.34);
  --bad: #fb7185;
  --bad-soft: rgba(251, 113, 133, 0.1);
  --grid: rgba(167, 139, 250, 0.2);
  --glow: 0 0 0 1px rgba(167, 139, 250, 0.22), 0 20px 60px -20px rgba(167, 139, 250, 0.34);

  /* Parties */
  --alice: var(--accent);
  --bob: var(--hot);
  --key: var(--good);
  --eve: var(--bad);

  /* Team palette */
  --m1: #a78bfa;
  --m2: #fbbf24;
  --m3: #34d399;
  --m4: #38bdf8;
  --t1: #a78bfa;
  --p1: #a78bfa;
  --p4: #f472b6;

  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.85);
  --radius: 16px;
  --radius-sm: 10px;
  --max: 1200px;
  --header-h: 68px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", ui-sans-serif, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-math: "STIX Two Text", "Cambria Math", "Times New Roman", serif;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f8f7fc;
  --bg-2: #f0eef8;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-2: #f4f2fb;
  --line: #e3e0ef;
  --line-2: #d0cbe3;
  --text: #120e24;
  --muted: #4e4968;
  --dim: #7e7998;
  --accent: #6d28d9;
  --accent-2: #5b21b6;
  --accent-soft: rgba(109, 40, 217, 0.08);
  --accent-line: rgba(109, 40, 217, 0.3);
  --accent-ink: #ffffff;
  --hot: #b45309;
  --hot-soft: rgba(180, 83, 9, 0.08);
  --hot-line: rgba(180, 83, 9, 0.3);
  --good: #047857;
  --good-soft: rgba(4, 120, 87, 0.08);
  --good-line: rgba(4, 120, 87, 0.3);
  --bad: #be123c;
  --bad-soft: rgba(190, 18, 60, 0.07);
  --grid: rgba(109, 40, 217, 0.17);
  --glow: 0 0 0 1px rgba(109, 40, 217, 0.18), 0 20px 50px -24px rgba(109, 40, 217, 0.32);

  --m1: #7c3aed;
  --m2: #d97706;
  --m3: #059669;
  --m4: #0284c7;
  --t1: #7c3aed;
  --p1: #7c3aed;
  --p4: #db2777;

  --shadow: 0 24px 60px -30px rgba(30, 15, 60, 0.25);
  color-scheme: light;
}

@media (min-width: 1600px) {
  :root { --max: 1320px; }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Integer lattice behind everything, fading toward the bottom */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, var(--grid) 1.1px, transparent 1.6px);
  background-size: 30px 30px;
  mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 25%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 25%, transparent 80%);
}

/* Soft aurora at the top of the page */
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  top: -40vh;
  left: 50%;
  width: 120vw;
  height: 80vh;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side at 32% 55%, rgba(167, 139, 250, 0.17), transparent),
    radial-gradient(closest-side at 72% 45%, rgba(251, 191, 36, 0.07), transparent),
    radial-gradient(closest-side at 52% 70%, rgba(52, 211, 153, 0.05), transparent);
  filter: blur(20px);
  animation: aurora 18s ease-in-out infinite alternate;
}
:root[data-theme="light"] body::after { opacity: 0.55; }

@keyframes aurora {
  0% { transform: translateX(-50%) translateY(0) scale(1); }
  100% { transform: translateX(-46%) translateY(4vh) scale(1.08); }
}

main { flex: 1; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }

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

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}
@media (max-width: 640px) { .container { padding: 0 16px; } }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--alice), var(--key), var(--bob));
}

.grad-text {
  background: linear-gradient(100deg, var(--accent-2) 0%, var(--accent) 40%, var(--key) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradShift 8s ease-in-out infinite alternate;
}
@keyframes gradShift { to { background-position: 100% 0; } }

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   Buttons, chips, kicker
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: 500 14.5px/1 var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--glow); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 10px 30px -12px var(--accent);
}
.btn-primary:hover { background: var(--accent-2); border-color: transparent; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: 500 12.5px/1.5 var(--font-mono);
}
.chip .icon { width: 14px; height: 14px; }
.chip b { color: var(--text); font-weight: 600; }

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--accent);
  font: 500 12.5px/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kicker::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 500 12.5px/1.4 var(--font-mono);
  letter-spacing: 0.04em;
}

.pulse-dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--good);
  animation: ping 2s var(--ease) infinite;
}
@keyframes ping {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font: 500 11px/1 var(--font-mono);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s, backdrop-filter 0.3s;
}
.site-header.scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-color: var(--line);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font: 500 15px/1 var(--font-mono);
  color: var(--text);
  white-space: nowrap;
}
.brand-text > span { color: var(--dim); }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, #b69cff, #7c3aed 58%, #4c1d95);
  color: #fff;
  font: italic 600 17px/1 var(--font-math);
  box-shadow: 0 8px 24px -10px var(--accent);
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
}
.brand-mark .icon { width: 19px; height: 19px; }
.brand-mark sub { position: absolute; right: 5px; bottom: 4px; font-size: 10px; line-height: 1; }
.brand-mark { padding-right: 5px; }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
}
.nav-item { position: relative; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: 500 14px/1 var(--font-sans);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.nav-link .chev { width: 14px; height: 14px; transition: transform 0.25s var(--ease); }
.nav-item:hover .nav-link,
.nav-item.open .nav-link { color: var(--text); background: var(--panel-2); }
.nav-item:hover .chev, .nav-item.open .chev { transform: rotate(180deg); }
.nav-item.is-active .nav-link { color: var(--text); }
.nav-item.is-active .nav-link::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--accent);
}

.dropdown {
  position: absolute;
  top: 100%;
  left: -10px;
  padding-top: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.25s var(--ease), visibility 0.2s;
}
.nav-item:hover .dropdown,
.nav-item.open .dropdown,
.nav-item:focus-within .dropdown { opacity: 1; visibility: visible; transform: none; }
.dropdown-inner {
  width: 330px;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}
.dropdown-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 10px;
  color: var(--dim);
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dropdown-label .icon { width: 14px; height: 14px; color: var(--accent); }
.dd-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  transition: background 0.2s;
}
.dd-link:hover, .dd-link.is-current { background: var(--panel-2); }
.dd-link b { display: block; font-size: 14px; font-weight: 500; line-height: 1.35; }
.dd-link small { display: block; margin-top: 2px; color: var(--dim); font-size: 12.5px; line-height: 1.45; }
.dd-link.is-current b { color: var(--accent); }
.dd-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-2);
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.dd-icon .icon { width: 16px; height: 16px; }
.dd-link:hover .dd-icon { color: var(--accent); border-color: var(--accent-line); }

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

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--dim);
  font: 400 13.5px/1 var(--font-sans);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.search-trigger:hover { border-color: var(--line-2); color: var(--muted); }
.search-trigger span { min-width: 90px; text-align: left; }
.search-trigger .icon { width: 16px; height: 16px; }

.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }
.theme-toggle:active .icon { transform: rotate(-30deg); }
.theme-toggle .icon { transition: transform 0.3s var(--ease); }

.menu-btn { display: none; }
.menu-btn .bars,
.menu-btn .bars::before,
.menu-btn .bars::after {
  display: block;
  width: 16px;
  height: 1.8px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.3s var(--ease), opacity 0.2s;
}
.menu-btn .bars { position: relative; }
.menu-btn .bars::before, .menu-btn .bars::after { content: ""; position: absolute; left: 0; }
.menu-btn .bars::before { top: -5px; }
.menu-btn .bars::after { top: 5px; }
.menu-open .menu-btn .bars { background: transparent; }
.menu-open .menu-btn .bars::before { transform: translateY(5px) rotate(45deg); }
.menu-open .menu-btn .bars::after { transform: translateY(-5px) rotate(-45deg); }

.mobile-nav {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 99;
  padding: 12px 20px 40px;
  overflow-y: auto;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.3s var(--ease), visibility 0.25s;
}
.menu-open .mobile-nav { opacity: 1; visibility: visible; transform: none; }
.menu-open { overflow: hidden; }
.m-group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.m-label {
  margin-bottom: 6px;
  color: var(--dim);
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mobile-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 15.5px;
}
.mobile-nav a[aria-current="page"] { color: var(--accent); }

@media (max-width: 1080px) {
  .hide-md { display: none; }
  .search-trigger { padding: 0; width: 38px; justify-content: center; }
}
@media (max-width: 920px) {
  .nav { display: none; }
  .menu-btn { display: inline-grid; }
}
@media (max-width: 560px) {
  .hide-sm { display: none !important; }
  .brand-text > span { display: none; }
}

/* --------------------------------------------------------------------------
   Reveal animations
   -------------------------------------------------------------------------- */
.js .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Home hero
   -------------------------------------------------------------------------- */
.hero { padding: 72px 0 56px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.02fr 1fr;
  gap: 56px;
  align-items: center;
}
.hero h1 {
  margin: 0 0 24px;
  font: 600 clamp(40px, 6.2vw, 74px)/1.02 var(--font-display);
  letter-spacing: -0.035em;
}
.hero h1 .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.hero h1 .line > span {
  display: inline-block;
  transform: translateY(105%);
  animation: lineUp 1s var(--ease) forwards;
  animation-delay: calc(var(--i) * 110ms + 120ms);
}
@keyframes lineUp { to { transform: none; } }

.lead {
  max-width: 560px;
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 17.5px;
  line-height: 1.7;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

.byline {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 36px;
  color: var(--dim);
  font-size: 13.5px;
}
.byline b { color: var(--muted); font-weight: 500; }
.avatars { display: flex; }
.avatars span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: linear-gradient(140deg, var(--c, var(--accent)), color-mix(in srgb, var(--c, var(--accent)) 45%, #000));
  color: #fff;
  font: 600 11px/1 var(--font-mono);
}
.avatars span:first-child { margin-left: 0; }

/* Terminal "machine" in the hero */
.hero-visual { position: relative; }
.machine {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
}
.machine::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px 200px at 80% 0%, var(--accent-soft), transparent 70%);
}
.machine-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font: 500 12.5px/1 var(--font-mono);
  color: var(--dim);
}
.dots { display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.dots i:nth-child(1) { background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.machine-bar .file { color: var(--muted); }
.machine-bar .phase {
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  text-transform: lowercase;
}
.term {
  height: 260px;
  margin: 0;
  padding: 18px 20px;
  overflow: hidden;
  font: 400 13px/1.7 var(--font-mono);
  color: var(--muted);
  white-space: pre;
}
.term .p { color: var(--good); }
.term .c { color: var(--text); }
.term .o { color: var(--muted); }
.term .h { color: var(--hot); }
.term .a { color: var(--accent); }
.term .b { color: var(--bad); }
.term .cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.float-tag {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  font: 500 12.5px/1 var(--font-mono);
  color: var(--text);
  animation: float 6s ease-in-out infinite;
}
.float-tag .icon { width: 15px; height: 15px; color: var(--hot); }
.float-tag.t1 { top: -18px; right: 28px; }
.float-tag.t2 { bottom: 70px; left: -34px; animation-delay: -3s; }
.float-tag.t2 .icon { color: var(--good); }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 48px; }
  .hero { padding-top: 48px; }
  .float-tag.t2 { left: 12px; }
}
@media (max-width: 560px) {
  .term { font-size: 11.5px; height: 240px; padding: 14px; }
  .float-tag { display: none; }
}

/* --------------------------------------------------------------------------
   Stats, marquee
   -------------------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.stat { padding: 26px 26px 24px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font: 600 clamp(30px, 3.6vw, 42px)/1 var(--font-display);
  letter-spacing: -0.03em;
}
.stat-value small { color: var(--accent); font-size: 0.5em; font-weight: 500; }
.stat-label { margin-top: 10px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.marquee {
  position: relative;
  overflow: hidden;
  padding: 22px 0;
  border-block: 1px solid var(--line);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.marquee-track {
  display: flex;
  gap: 48px;
  width: max-content;
  animation: marquee 42s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span {
  display: inline-flex;
  align-items: center;
  gap: 48px;
  color: var(--dim);
  font: italic 400 19px/1 var(--font-math);
  white-space: nowrap;
}
.marquee-track span::after { content: "∘"; font: 400 18px/1 var(--font-math); color: var(--accent); opacity: 0.8; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* --------------------------------------------------------------------------
   Sections & cards
   -------------------------------------------------------------------------- */
.section { padding: 96px 0; }
.section-tight { padding: 40px 0; }
@media (max-width: 640px) { .section { padding: 64px 0; } }

.section-head { max-width: 720px; margin-bottom: 44px; }
.section-head h2 {
  margin: 0 0 16px;
  font: 600 clamp(28px, 3.6vw, 44px)/1.12 var(--font-display);
  letter-spacing: -0.03em;
}
.section-head p { margin: 0; color: var(--muted); font-size: 16.5px; }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head.center .kicker { justify-content: center; }

.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.gap-lg { gap: 48px; }
@media (max-width: 980px) { .g-4 { grid-template-columns: repeat(2, 1fr); } .g-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } .gap-lg { gap: 32px; } }

.card {
  position: relative;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s, transform 0.35s var(--ease), box-shadow 0.35s;
  overflow: hidden;
}
.card::before {
  /* Pointer-following spotlight, driven by --mx / --my from site.js */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 60%);
  transition: opacity 0.3s;
}
.card:hover::before { opacity: 1; }
.card h3 { margin: 0 0 8px; font: 600 18px/1.3 var(--font-display); letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.card-link:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--glow); }
.card-link .go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  color: var(--accent);
  font: 500 13px/1 var(--font-mono);
}
.card-link .go .icon { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.card-link:hover .go .icon { transform: translateX(4px); }
.card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card-icon.hot { border-color: var(--hot-line); background: var(--hot-soft); color: var(--hot); }
.card-index {
  position: absolute;
  top: 22px;
  right: 24px;
  color: var(--dim);
  font: 500 12px/1 var(--font-mono);
}

/* Phase cards on the home page */
.phase-card { padding: 34px; display: flex; flex-direction: column; }
.phase-card h3 { font-size: 26px; margin-bottom: 12px; }
.phase-card .tagline { color: var(--muted); margin-bottom: 26px; }
.phase-card .kv {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 0 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
  overflow: hidden;
}
.phase-card .kv div { padding: 14px; background: var(--panel-solid); }
.phase-card .kv dt { color: var(--dim); font: 500 11px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.phase-card .kv dd { margin: 6px 0 0; font: 600 20px/1.1 var(--font-display); }
.phase-card .kv dd.bad { color: var(--bad); }
.phase-card .kv dd.good { color: var(--good); }
.phase-card .links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.phase-card .verdict {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
  padding: 14px 16px;
  border-left: 2px solid var(--c, var(--accent));
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--c, var(--accent)) 8%, transparent);
  font-size: 14.5px;
  color: var(--text);
}
@media (max-width: 560px) { .phase-card { padding: 24px; } .phase-card .kv dd { font-size: 17px; } }

/* --------------------------------------------------------------------------
   Panels & charts
   -------------------------------------------------------------------------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.panel-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font: 500 12.5px/1 var(--font-mono);
}
.panel-title .icon { width: 15px; height: 15px; color: var(--accent); }
.panel-body { padding: 24px; }
@media (max-width: 560px) { .panel-body { padding: 18px 14px; } }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--dim); font: 500 12px/1 var(--font-mono); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend i.dash { height: 0; border-top: 2px dashed var(--c); border-radius: 0; background: none; }

.bars { display: grid; gap: 14px; }
.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 14px;
}
.bar-label { color: var(--muted); font: 500 13px/1.3 var(--font-mono); }
.bar-label b { color: var(--text); font-weight: 600; }
.bar-track {
  position: relative;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-2);
}
.bar-fill {
  height: 100%;
  width: calc(var(--v) * 1%);
  border-radius: 8px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 1.2s var(--ease);
  transition-delay: calc(var(--i, 0) * 110ms);
}
.bar-value {
  position: absolute;
  top: 50%;
  left: calc(var(--v) * 1% + 10px);
  transform: translateY(-50%);
  color: var(--text);
  font: 600 12.5px/1 var(--font-mono);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.6s 0.8s;
}
.bar-value small { color: var(--dim); font-weight: 500; }
.in .bar-fill, .bars.in .bar-fill { transform: scaleX(1); }
.in .bar-value { opacity: 1; }
.no-js .bar-fill { transform: none; }
.no-js .bar-value { opacity: 1; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 78px 1fr; gap: 10px; } }

/* SVG charts built by viz.js */
.chart { position: relative; width: 100%; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .axis line, .chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .axis text, .chart .tick { fill: var(--dim); font: 500 13px var(--font-mono); }
.chart .axis-title { fill: var(--muted); font: 500 13px var(--font-mono); }
.chart .ideal { fill: none; stroke: var(--dim); stroke-width: 1.5; stroke-dasharray: 5 6; }
.chart .baseline { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .series {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .area { fill: url(#areaGrad); opacity: 0.9; }
.chart .dot { stroke: var(--panel-solid); stroke-width: 3; transition: r 0.2s; }
.chart .dot:hover { r: 8; }
.chart .dot-label { fill: var(--text); font: 600 14px var(--font-mono); }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); transition: stroke-dashoffset 1.8s var(--ease); }
.chart.in .draw { stroke-dashoffset: 0; }
.chart .pop { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0.4); transition: opacity 0.4s, transform 0.5s var(--ease); transition-delay: calc(0.4s + var(--i) * 0.18s); }
.chart.in .pop { opacity: 1; transform: none; }
.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  font: 500 12px/1.55 var(--font-mono);
  color: var(--muted);
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.15s;
  white-space: nowrap;
}
.chart-tip b { color: var(--text); }
.chart-tip.show { opacity: 1; }

/* --------------------------------------------------------------------------
   Key exchange lab (interactive)
   -------------------------------------------------------------------------- */
.lab { display: grid; grid-template-columns: 1.35fr 1fr; }
.lab-main { padding: 24px; border-right: 1px solid var(--line); }
.lab-side { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 900px) { .lab { grid-template-columns: 1fr; } .lab-main { border-right: 0; border-bottom: 1px solid var(--line); } }
@media (max-width: 560px) { .lab-main, .lab-side { padding: 18px 14px; } }

.seg {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.seg button {
  position: relative;
  min-width: 44px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: 600 13px/1 var(--font-mono);
  cursor: pointer;
  transition: color 0.2s, background 0.25s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 0 0 1px var(--line-2), 0 6px 16px -8px rgba(0,0,0,.5); }
.seg button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 14px;
  height: 2px;
  margin-left: -7px;
  border-radius: 2px;
  background: var(--c);
}

.lab-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.lab-label { color: var(--dim); font: 500 12px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }

.readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); overflow: hidden; }
.readout div { padding: 14px; background: var(--panel-solid); }
.readout dt { color: var(--dim); font: 500 10.5px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.readout dd { margin: 8px 0 0; font: 600 22px/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout dd small { font-size: 0.55em; color: var(--dim); font-weight: 500; margin-left: 2px; }
.lab-note {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--c, var(--accent));
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  min-height: 96px;
}
.lab-note b { color: var(--text); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.race-btn { align-self: flex-start; }

/* --------------------------------------------------------------------------
   Diagram helpers
   -------------------------------------------------------------------------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .compare { grid-template-columns: 1fr; } }
.diagram { margin: 20px 0 6px; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .box { fill: var(--panel-2); stroke: var(--line-2); }
.diagram .box.hl { stroke: var(--c); fill: color-mix(in srgb, var(--c) 10%, var(--panel-2)); }
.diagram text { fill: var(--muted); font: 500 11px var(--font-mono); }
.diagram text.t { fill: var(--text); font-weight: 600; }
.diagram .wire { fill: none; stroke: var(--line-2); stroke-width: 1.5; }
.diagram .flow { fill: none; stroke: var(--c); stroke-width: 1.8; stroke-dasharray: 4 6; animation: dash 1.4s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -20; } }

/* --------------------------------------------------------------------------
   Team strip (home) + team page
   -------------------------------------------------------------------------- */
.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1000px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .team-grid { grid-template-columns: 1fr; } }
.member {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 22px 20px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
}
.avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--c), color-mix(in srgb, var(--c) 40%, #000));
  color: #fff;
  font: 600 16px/1 var(--font-display);
  box-shadow: 0 10px 28px -12px var(--c);
  transition: transform 0.4s var(--ease), border-radius 0.4s var(--ease);
}
.member:hover .avatar { transform: rotate(-6deg) scale(1.05); border-radius: 50%; }
.member b { font: 600 15.5px/1.3 var(--font-display); }
.member .role { color: var(--muted); font-size: 13px; line-height: 1.45; }
.member .sid { margin-top: 10px; color: var(--dim); font: 500 11.5px/1 var(--font-mono); }
.member .more { margin-top: 14px; color: var(--accent); font: 500 12px/1 var(--font-mono); display: inline-flex; gap: 6px; align-items: center; }
.member .more .icon { width: 13px; height: 13px; transition: transform 0.3s var(--ease); }
.member:hover .more .icon { transform: translateX(3px); }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  visibility: hidden;
}
.drawer.open { visibility: visible; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(6, 3, 14, 0.6); backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: relative;
  width: min(480px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 28px;
  border-left: 1px solid var(--line-2);
  background: var(--panel-solid);
  transform: translateX(100%);
  transition: transform 0.45s var(--ease);
}
.drawer.open .drawer-panel { transform: none; }
.drawer-close { position: absolute; top: 20px; right: 20px; }
.drawer .avatar { width: 64px; height: 64px; font-size: 20px; margin-bottom: 18px; border-radius: 18px; }
.drawer h3 { margin: 0; font: 600 26px/1.2 var(--font-display); letter-spacing: -0.02em; }
.drawer .dept { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.drawer h4 { margin: 28px 0 12px; color: var(--dim); font: 500 11.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.drawer ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.drawer li { position: relative; padding: 12px 14px 12px 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); color: var(--muted); font-size: 14px; line-height: 1.55; }
.drawer li::before { content: ""; position: absolute; left: 14px; top: 19px; width: 7px; height: 7px; border-radius: 2px; background: var(--c, var(--accent)); transform: rotate(45deg); }
.drawer li b { color: var(--text); font-weight: 600; }
.drawer .links { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------------------------------
   CTA
   -------------------------------------------------------------------------- */
.cta {
  position: relative;
  padding: 72px 32px;
  border: 1px solid var(--line-2);
  border-radius: 24px;
  background:
    radial-gradient(600px 240px at 50% 0%, var(--accent-soft), transparent 70%),
    var(--panel);
  text-align: center;
  overflow: hidden;
}
.cta::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(closest-side, #000, transparent);
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent);
}
.cta > * { position: relative; z-index: 1; }
.cta .kicker { justify-content: center; }
.cta h2 { margin: 0 auto 16px; max-width: 700px; font: 600 clamp(28px, 4vw, 46px)/1.1 var(--font-display); letter-spacing: -0.03em; }
.cta p { max-width: 560px; margin: 0 auto 30px; color: var(--muted); }
.cta .hero-actions { justify-content: center; }
@media (max-width: 560px) { .cta { padding: 52px 20px; } }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  margin-top: 40px;
  padding: 64px 0 0;
  border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, transparent, var(--bg-2));
  overflow: hidden;
}
.footer-grid { display: grid; grid-template-columns: 1fr 2.2fr; gap: 56px; }
.footer-brand p { max-width: 320px; margin: 18px 0; color: var(--muted); font-size: 14px; }
.footer-mail { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font: 500 13px/1 var(--font-mono); }
.footer-mail .icon { width: 15px; height: 15px; }
.footer-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.footer-col h4 { margin: 0 0 14px; color: var(--dim); font: 500 11.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.footer-col a { display: block; padding: 5px 0; color: var(--muted); font-size: 14px; transition: color 0.2s, transform 0.2s; }
.footer-col a:hover { color: var(--text); transform: translateX(3px); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font: 500 12.5px/1.5 var(--font-mono);
}
.footer-bottom a:hover { color: var(--text); }
.footer-bottom .status { display: inline-flex; align-items: center; gap: 10px; }
.footer-word sup { font-size: 0.45em; }
.footer-word {
  margin: 0 0 -0.26em;
  padding: 0 16px;
  text-align: center;
  font: italic 500 clamp(56px, 13vw, 190px)/1 var(--font-math);
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(to bottom, var(--line-2), transparent 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}
@media (max-width: 1000px) {
  .footer-grid { grid-template-columns: 1fr; gap: 40px; }
  .footer-cols { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) { .footer-cols { grid-template-columns: repeat(2, 1fr); } }

.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  background: var(--panel-solid);
  transition: opacity 0.3s, transform 0.3s var(--ease), visibility 0.3s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }

/* --------------------------------------------------------------------------
   Inner pages
   -------------------------------------------------------------------------- */
.page-hero { padding: 64px 0 40px; }
.page-hero h1 {
  max-width: 900px;
  margin: 0 0 20px;
  font: 600 clamp(34px, 5vw, 60px)/1.06 var(--font-display);
  letter-spacing: -0.035em;
}
.page-hero .lead { max-width: 720px; margin-bottom: 26px; }
.page-hero .kicker { margin-top: 26px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.page-hero .hero-actions { margin-top: 28px; }
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font: 500 13px/1 var(--font-mono);
}
.crumbs a { color: var(--accent); }
.crumbs .here { color: var(--text); }

.page-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 64px;
  align-items: start;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.page-body.no-toc { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1080px) { .page-body { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }

.toc { position: sticky; top: calc(var(--header-h) + 28px); padding-top: 28px; }
.toc-title { margin-bottom: 14px; color: var(--dim); font: 500 11.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.toc nav { display: grid; border-left: 1px solid var(--line); }
.toc nav a {
  position: relative;
  padding: 7px 0 7px 16px;
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.4;
  transition: color 0.2s;
}
.toc nav a:hover { color: var(--text); }
.toc nav a.active { color: var(--text); }
.toc nav a.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.toc-top { display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; color: var(--dim); font: 500 12px/1 var(--font-mono); }
.toc-top .icon { width: 13px; height: 13px; }
.toc-top:hover { color: var(--accent); }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 72px;
  margin-bottom: 40px;
}
.pager a {
  display: grid;
  gap: 8px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 0.25s, transform 0.3s var(--ease), box-shadow 0.3s;
}
.pager a:hover { border-color: var(--accent-line); transform: translateY(-3px); box-shadow: var(--glow); }
.pager .next { text-align: right; grid-column: 2; }
.pager .dir { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font: 500 12px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.pager .next .dir { justify-content: flex-end; }
.pager .dir .icon { width: 14px; height: 14px; }
.pager b { font: 600 18px/1.3 var(--font-display); }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; } }

/* --------------------------------------------------------------------------
   Prose (Markdown content)
   -------------------------------------------------------------------------- */
.prose { counter-reset: sec; padding-top: 12px; min-width: 0; }
.prose > * { max-width: 100%; }
.prose p, .prose li { color: var(--muted); font-size: 16px; line-height: 1.8; }
.prose p { margin: 0 0 18px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a:not(.btn):not(.card):not(.headerlink) {
  color: var(--accent);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.3s var(--ease);
}
.prose a:not(.btn):not(.card):not(.headerlink):hover { background-size: 100% 1px; }

.prose h2 {
  counter-increment: sec;
  margin: 72px 0 22px;
  font: 600 clamp(24px, 2.8vw, 32px)/1.2 var(--font-display);
  letter-spacing: -0.025em;
  color: var(--text);
}
.prose h2::before {
  content: "§ " counter(sec, decimal-leading-zero);
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font: 500 12.5px/1 var(--font-mono);
  letter-spacing: 0.08em;
}
.prose > h2:first-child, .prose > .toc-anchor + h2 { margin-top: 36px; }
.prose h3 { margin: 40px 0 14px; font: 600 19px/1.35 var(--font-display); color: var(--text); letter-spacing: -0.01em; }
.prose h4 { margin: 28px 0 10px; font: 600 16px/1.4 var(--font-sans); color: var(--text); }
.prose .headerlink {
  margin-left: 10px;
  color: var(--dim);
  opacity: 0;
  font-family: var(--font-mono);
  font-size: 0.8em;
  transition: opacity 0.2s, color 0.2s;
}
.prose :is(h2, h3, h4):hover .headerlink { opacity: 1; }
.prose .headerlink:hover { color: var(--accent); }

.prose ul, .prose ol { margin: 0 0 22px; padding-left: 0; list-style: none; }
.prose li { position: relative; padding-left: 26px; margin-bottom: 8px; }
.prose ul > li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.78em;
  width: 7px;
  height: 7px;
  border: 1.6px solid var(--accent);
  border-radius: 50%;
  background: transparent;
}
.prose ol { counter-reset: li; }
.prose ol > li { counter-increment: li; padding-left: 34px; }
.prose ol > li::before {
  content: counter(li, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.2em;
  color: var(--accent);
  font: 600 12.5px/1.8 var(--font-mono);
}
.prose li > ul, .prose li > ol { margin: 8px 0 0; }

.prose hr { margin: 56px 0; border: 0; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.prose blockquote {
  margin: 0 0 24px;
  padding: 16px 20px;
  border-left: 2px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--accent-soft);
}
.prose blockquote p:last-child { margin: 0; }
.prose img { border-radius: 12px; border: 1px solid var(--line); }

:not(pre) > code {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: 500 0.86em/1.5 var(--font-mono);
  white-space: nowrap;
}

/* Tables */
.table-wrap {
  margin: 0 0 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose thead th {
  position: sticky;
  top: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--dim);
  font: 500 11.5px/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.prose td { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr { transition: background 0.2s; }
.prose tbody tr:hover { background: var(--accent-soft); }
.prose td:first-child { color: var(--text); font-weight: 500; }
.prose td[align="right"], .prose th[align="right"] { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.prose table.dense th, .prose table.dense td { padding: 10px 9px; font-size: 12.5px; }
.prose tr.best td { background: color-mix(in srgb, var(--good) 8%, transparent); }
.status-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--good) 12%, transparent);
  color: var(--good);
  font: 500 12px/1.6 var(--font-mono);
  white-space: nowrap;
}
.status-done::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.neg { color: var(--bad) !important; }
.pos { color: var(--good) !important; }

/* Cards inside prose */
.prose .grid { margin: 0 0 28px; }
.prose .card p { font-size: 14.5px; line-height: 1.65; margin: 0; }
.prose .card p + p { margin-top: 10px; }
.prose .card h3 { margin: 0 0 8px; }
.prose .card ul { margin: 10px 0 0; }
.prose .card li { font-size: 14px; margin-bottom: 4px; }
.prose .card .highlight { margin: 12px 0 0; }
.prose .card .card-icon { margin-bottom: 16px; }
.prose .card > :last-child { margin-bottom: 0; }

/* Big figure numbers inside prose */
.prose .stats { margin: 8px 0 32px; }
.prose .stat-label { font-size: 13px; }

/* Admonitions → callouts */
.admonition, details {
  --c: var(--accent);
  position: relative;
  margin: 0 0 24px;
  padding: 18px 20px 18px 54px;
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 6%, var(--panel));
}
.admonition::before, details > summary::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 20px;
  width: 20px;
  height: 20px;
  background: var(--c);
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}
.admonition { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.admonition.tip, .admonition.success { --c: var(--good); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpath d='M22 4 12 14.01l-3-3'/%3E%3C/svg%3E"); }
.admonition.warning, .admonition.danger { --c: var(--hot); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.admonition.danger { --c: var(--bad); }
.admonition.quote, .admonition.abstract { --c: var(--p1); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z'/%3E%3C/svg%3E"); }
.admonition-title {
  margin: 0 0 6px !important;
  color: var(--text) !important;
  font: 600 15px/1.5 var(--font-sans) !important;
}
.admonition p { font-size: 15px; line-height: 1.7; }
.admonition > :last-child { margin-bottom: 0; }

details { padding: 0; --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 18 6-6-6-6'/%3E%3Cpath d='m8 6-6 6 6 6'/%3E%3C/svg%3E"); }
details > summary {
  position: relative;
  padding: 16px 52px 16px 54px;
  color: var(--text);
  font: 600 15px/1.5 var(--font-sans);
  list-style: none;
  cursor: pointer;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { top: 17px; }
details > summary::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 1.8px solid var(--dim);
  border-bottom: 1.8px solid var(--dim);
  transform: rotate(45deg);
  transition: transform 0.3s var(--ease);
}
details[open] > summary::after { transform: rotate(225deg); margin-top: -2px; }
details > :not(summary) { margin: 0 20px 20px !important; }
details .highlight { margin-left: 20px; margin-right: 20px; }

/* Code blocks */
.highlight {
  position: relative;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
  overflow: hidden;
}
:root[data-theme="light"] .highlight { background: #110e1f; border-color: #231e38; }
.highlight .filename, .code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: 500 12px/1.4 var(--font-mono);
}
:root[data-theme="light"] .highlight .filename,
:root[data-theme="light"] .code-head { background: #17132a; border-color: #231e38; color: #b3aec9; }
.code-head .lang { margin-left: auto; color: var(--dim); text-transform: lowercase; }
.code-head .dots i { width: 9px; height: 9px; }
.highlight pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font: 400 13.5px/1.7 var(--font-mono);
  color: #d7deea;
  tab-size: 4;
}
.highlight code { font: inherit; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid #263043;
  border-radius: 7px;
  background: transparent;
  color: #8a96aa;
  font: 500 11.5px/1 var(--font-mono);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.copy-btn:hover { color: #e8edf5; border-color: #3a4760; }
.copy-btn.done { color: #34d399; border-color: rgba(52, 211, 153, 0.4); }
.copy-btn .icon { width: 13px; height: 13px; }

/* Pygments tokens (one palette for both themes; code panels stay dark) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .ch, .highlight .cs { color: #647088; font-style: italic; }
.highlight .cp, .highlight .cpf { color: #f472b6; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kc { color: #c792ea; }
.highlight .kt { color: #fcd34d; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .sh { color: #a5e3a0; }
.highlight .se, .highlight .si { color: #fbbf24; }
.highlight .mi, .highlight .mf, .highlight .m, .highlight .il, .highlight .mh { color: #fbbf24; }
.highlight .nf, .highlight .fm { color: #7dd3fc; }
.highlight .nc, .highlight .nn { color: #fcd34d; }
.highlight .nb, .highlight .bp { color: #7dd3fc; }
.highlight .na, .highlight .nd { color: #fda4af; }
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi { color: #e8edf5; }
.highlight .o, .highlight .ow { color: #89ddff; }
.highlight .p { color: #9aa6ba; }
.highlight .gp { color: #34d399; user-select: none; }
.highlight .go { color: #8a96aa; }
.highlight .err { color: inherit; background: none; }

/* Screenshot gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 0 0 28px;
}
.gallery p { margin: 0; }
.gallery figure, .shot {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform 0.35s var(--ease), border-color 0.25s, box-shadow 0.35s;
}
.gallery figure:hover, .shot:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: var(--glow); }
.gallery img, .shot img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; border: 0; border-radius: 0; transition: transform 0.6s var(--ease); }
.gallery figure:hover img { transform: scale(1.04); }
.gallery figcaption, .shot figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 500 12.5px/1.4 var(--font-mono);
}
.gallery figcaption::after, .shot figcaption::after { content: "⤢"; color: var(--dim); }
.gallery.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.gallery.contain img { object-fit: contain; background: #fff; }
.gallery.single { grid-template-columns: minmax(0, 560px); }
.gallery.single img { aspect-ratio: auto; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 64px 24px 32px;
  background: rgba(2, 5, 10, 0.88);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.25s;
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }
.lightbox img { max-width: min(1200px, 100%); max-height: calc(100vh - 120px); border-radius: 12px; box-shadow: var(--shadow); transform: scale(0.96); transition: transform 0.35s var(--ease); }
.lightbox.open img { transform: none; }
.lightbox-close { position: absolute; top: 16px; right: 16px; }
.lightbox-cap { position: absolute; top: 24px; left: 24px; right: 72px; color: #c9d2e0; font: 500 13px/1.4 var(--font-mono); }

/* Embedded report frame */
.embed {
  margin: 0 0 28px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.embed .machine-bar a { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.embed .machine-bar a .icon { width: 13px; height: 13px; }
.embed iframe { display: block; width: 100%; height: min(1100px, 80vh); border: 0; background: #fff; }

/* Filter box (commands, glossary) */
.filter {
  position: sticky;
  top: calc(var(--header-h) + 10px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
  padding: 0 14px;
  height: 48px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  backdrop-filter: blur(12px);
  color: var(--dim);
}
.filter input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--text); font: 400 15px/1 var(--font-sans); outline: none; }
.filter .count { font: 500 12px/1 var(--font-mono); white-space: nowrap; }
.filter-empty { display: none; padding: 32px; border: 1px dashed var(--line-2); border-radius: 14px; color: var(--dim); text-align: center; font-family: var(--font-mono); font-size: 13px; }
.filter-empty.show { display: block; }
.is-filtered-out { display: none !important; }

/* Glossary */
.prose dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 0 0 28px; }
@media (max-width: 720px) { .prose dl { grid-template-columns: 1fr; } }
.prose .gloss {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color 0.25s;
}
.prose .gloss:hover { border-color: var(--accent-line); }
.prose dt { margin-bottom: 6px; color: var(--text); font: 600 16px/1.35 var(--font-display); }
.prose dd { margin: 0; }
.prose dd p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.65; }
.prose dd p:last-child { margin: 0; }

/* Timeline / steps */
.steps { display: grid; gap: 0; margin: 0 0 28px; counter-reset: step; }
.step { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 18px; padding-bottom: 26px; }
.step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 13px/1 var(--font-mono);
}
.step::after { content: ""; position: absolute; left: 22px; top: 50px; bottom: 4px; width: 1px; background: linear-gradient(var(--line-2), transparent); }
.step:last-child::after { display: none; }
.step h4 { margin: 10px 0 4px !important; }
.step p { margin: 0 !important; font-size: 15px !important; }
.step .highlight { margin: 12px 0 0; }

/* 404 */
.nf { padding: 120px 0 40px; text-align: center; }
.nf .code { font: 700 clamp(96px, 20vw, 200px)/1 var(--font-display); letter-spacing: -0.06em; }
.nf p { color: var(--muted); max-width: 460px; margin: 16px auto 32px; }
.nf .hero-actions { justify-content: center; }

/* --------------------------------------------------------------------------
   Search palette
   -------------------------------------------------------------------------- */
.palette { position: fixed; inset: 0; z-index: 190; display: flex; justify-content: center; padding: 12vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(2, 5, 10, 0.6); backdrop-filter: blur(6px); animation: fadeIn 0.2s; }
.palette-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: 70vh;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
  animation: popIn 0.3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); color: var(--dim); }
.palette-input input { flex: 1; height: 58px; border: 0; background: none; color: var(--text); font: 400 16px/1 var(--font-sans); outline: none; }
.palette-input input::-webkit-search-cancel-button { display: none; }
.palette-results { overflow-y: auto; padding: 8px; }
.palette-results a { display: block; padding: 12px 14px; border-radius: 10px; }
.palette-results a b { display: block; color: var(--text); font-weight: 500; font-size: 14.5px; }
.palette-results a small { display: block; margin-top: 3px; color: var(--dim); font: 500 11.5px/1.4 var(--font-mono); }
.palette-results a span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.palette-results a mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }
.palette-results a.sel { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.palette-empty { padding: 28px; color: var(--dim); text-align: center; font: 500 13px/1.5 var(--font-mono); }
.palette-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.palette-foot kbd { margin-right: 4px; }

/* ==========================================================================
   Discrete maths layer
   ========================================================================== */

/* Maths typography: italic serif variables, like a textbook */
.m, .prose .m {
  font-family: var(--font-math);
  font-style: italic;
  font-size: 1.08em;
  letter-spacing: 0;
  white-space: nowrap;
}
.m.up { font-style: normal; }
.m sub, .m sup { font-size: 0.68em; line-height: 0; }
.m.a { color: var(--alice); }
.m.b { color: var(--bob); }
.m.k { color: var(--key); }
.m.e { color: var(--eve); }

mjx-container { color: inherit; }
.prose mjx-container[display="true"],
.prose div.arithmatex {
  margin: 0 0 24px !important;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow-x: auto;
}
.prose div.arithmatex mjx-container[display="true"] { margin: 0 !important; padding: 0; border: 0; background: none; }

/* Party chips and badges */
.party {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 4px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--text);
  font: 500 12.5px/1.5 var(--font-mono);
}
.party i {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--c);
  color: var(--bg);
  font: italic 600 12px/1 var(--font-math);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--good)) 12%, transparent);
  color: var(--c, var(--good));
  font: 500 12px/1.6 var(--font-mono);
  white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }

/* --------------------------------------------------------------------------
   The modular ring (hero + lab): residues of Z_q on a circle, with the
   powers of alpha joined in order. A primitive root visits every node.
   -------------------------------------------------------------------------- */
.ring-card .machine-bar .phase { transition: color 0.3s, border-color 0.3s, background 0.3s; }
.ring-card .machine-bar .phase[data-p="alice"] { color: var(--alice); border-color: var(--accent-line); background: var(--accent-soft); }
.ring-card .machine-bar .phase[data-p="bob"] { color: var(--bob); border-color: var(--hot-line); background: var(--hot-soft); }
.ring-card .machine-bar .phase[data-p="shared"] { color: var(--key); border-color: var(--good-line); background: var(--good-soft); }
.ring-stage { position: relative; padding: 10px 18px 0; }
.ring { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; overflow: visible; }
.ring .track { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 5; }
.ring .chord {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.55;
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: chordIn 0.42s var(--ease) forwards;
}
.ring .chord.static { animation: none; stroke-dashoffset: 0; }
@keyframes chordIn { to { stroke-dashoffset: 0; } }
.ring .node circle { fill: var(--panel-2); stroke: var(--line-2); stroke-width: 1.2; transition: fill 0.35s, stroke 0.35s, r 0.35s; }
.ring .node text { fill: var(--dim); font: 500 10px var(--font-mono); text-anchor: middle; dominant-baseline: central; transition: fill 0.35s; }
.ring .node.on circle { fill: color-mix(in srgb, var(--accent) 30%, var(--panel-2)); stroke: var(--accent); }
.ring .node.on text { fill: var(--text); }
.ring .node.zero circle { fill: none; stroke-dasharray: 2 2; }
.ring .node.is-a circle { fill: var(--alice); stroke: var(--alice); }
.ring .node.is-b circle { fill: var(--bob); stroke: var(--bob); }
.ring .node.is-k circle { fill: var(--key); stroke: var(--key); }
.ring .node.is-a text, .ring .node.is-b text, .ring .node.is-k text { fill: var(--text); font-weight: 700; }
.ring .halo { fill: none; stroke-width: 1.5; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ring .node.is-a .halo { stroke: var(--alice); opacity: 1; }
.ring .node.is-b .halo { stroke: var(--bob); opacity: 1; }
.ring .node.is-k .halo { stroke: var(--key); opacity: 1; animation: halo 1.8s var(--ease) infinite; }
@keyframes halo { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(2.1); opacity: 0; } }
.ring .center-big { fill: var(--text); font: italic 500 40px var(--font-math); text-anchor: middle; }
.ring .center-sub { fill: var(--muted); font: 500 12px var(--font-mono); text-anchor: middle; }
.ring .center-big, .ring .center-sub { paint-order: stroke; stroke: var(--panel-solid); stroke-width: 6px; stroke-linejoin: round; }
.ring .tag { font: italic 600 15px var(--font-math); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: var(--panel-solid); stroke-width: 5px; stroke-linejoin: round; }
.ring .tag.a { fill: var(--alice); }
.ring .tag.b { fill: var(--bob); }
.ring .tag.k { fill: var(--key); }
.no-js .ring .chord { animation: none; stroke-dashoffset: 0; }

.eqline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font: 400 17px/1.4 var(--font-math);
  text-align: center;
}
.eqline i { font-style: italic; }
.eqline b { color: var(--text); font-weight: 600; }
.eqline .a { color: var(--alice); }
.eqline .b { color: var(--bob); }
.eqline .k { color: var(--key); }
.eqline sub, .eqline sup { font-size: 0.68em; }
.eqline.swap { animation: eqIn 0.4s var(--ease); }
@keyframes eqIn { from { opacity: 0; transform: translateY(6px); } }

.float-tag .m { font-size: 14px; }
.float-tag.t1 .icon { color: var(--key); }
.float-tag.t2 .icon { color: var(--alice); }

/* --------------------------------------------------------------------------
   Protocol diagram: Alice | public channel | Bob
   -------------------------------------------------------------------------- */
.proto {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.proto-row { display: grid; grid-template-columns: 1fr 1.15fr 1fr; }
.proto-row + .proto-row { border-top: 1px solid var(--line); }
.proto-row > div { padding: 20px 22px; min-width: 0; }
.proto-row > .mid {
  position: relative;
  border-inline: 1px dashed var(--line-2);
  background: var(--bg-2);
  text-align: center;
}
.proto-head > div { display: flex; align-items: center; gap: 12px; padding-block: 16px; background: var(--panel-2); }
.proto-head > .mid { justify-content: center; }
.proto-head .who { display: grid; gap: 2px; }
.proto-head .who b { font: 600 15px/1.2 var(--font-display); }
.proto-head .who small { color: var(--dim); font: 500 11.5px/1.3 var(--font-mono); }
.proto-head .pb { flex-direction: row-reverse; text-align: right; }
.proto .ava {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--c), color-mix(in srgb, var(--c) 45%, #000));
  color: #fff;
  font: italic 600 18px/1 var(--font-math);
  box-shadow: 0 10px 24px -12px var(--c);
}
.proto .ava .icon { width: 18px; height: 18px; }
.proto .stage {
  display: block;
  margin-bottom: 8px;
  color: var(--dim);
  font: 500 11px/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.proto .val { color: var(--text); font: 400 17px/1.55 var(--font-math); }
.proto .val i { font-style: italic; }
.proto .val sub, .proto .val sup { font-size: 0.68em; }
.proto .note { margin-top: 6px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.proto .pb { text-align: right; }
.proto .secret {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--dim);
  font: 500 11.5px/1 var(--font-mono);
}
.proto .secret .icon { width: 12px; height: 12px; }
.proto .wire {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font: 400 16px/1.4 var(--font-math);
  color: var(--text);
}
.proto .wire::before, .proto .wire::after { content: ""; flex: 1; height: 1.5px; background: var(--c); opacity: 0.8; }
.proto .wire > span:not(.arrow) { white-space: nowrap; }
.proto .wire .arrow { color: var(--c); font: 500 15px/1 var(--font-mono); }
.proto .cipher {
  display: inline-block;
  max-width: 100%;
  margin-top: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--muted);
  font: 500 12px/1.4 var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proto .eve { color: var(--eve); }
.proto .k { color: var(--key); }
@media (max-width: 820px) {
  .proto-row { grid-template-columns: 1fr; }
  .proto-row > .mid { border-inline: 0; border-block: 1px dashed var(--line-2); }
  .proto-row > .pb, .proto-head .pb { text-align: left; flex-direction: row; }
  .proto-head { display: none; }
  .proto-row > div[data-who]::before {
    content: attr(data-who);
    display: block;
    margin-bottom: 6px;
    color: var(--c);
    font: 600 11px/1 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}

/* --------------------------------------------------------------------------
   Concept cards with a large maths glyph
   -------------------------------------------------------------------------- */
.concept { display: flex; flex-direction: column; }
.concept .glyph {
  display: flex;
  align-items: center;
  height: 64px;
  margin-bottom: 14px;
  color: var(--accent);
  font: italic 400 44px/1 var(--font-math);
  letter-spacing: -0.01em;
}
.concept .glyph sub, .concept .glyph sup { font-size: 0.5em; }
.concept .glyph.hot { color: var(--bob); }
.concept .glyph.good { color: var(--key); }
.concept .where { margin-top: auto; padding-top: 18px; display: flex; flex-wrap: wrap; gap: 6px; }
.concept .where code { font-size: 11.5px; }

/* --------------------------------------------------------------------------
   Class dependency graph (V = classes, E = "uses")
   -------------------------------------------------------------------------- */
.cgraph svg { display: block; width: 100%; height: auto; overflow: visible; }
.cgraph .edge { fill: none; stroke: color-mix(in srgb, var(--dim) 75%, transparent); stroke-width: 1.6; }
.cgraph .edge.ext { stroke: var(--accent); stroke-dasharray: 5 5; }
.cgraph .edge.flow { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 3 9; opacity: 0.8; animation: dash 1.4s linear infinite; }
.cgraph .arrowhead { fill: color-mix(in srgb, var(--dim) 75%, transparent); }
.cgraph .arrowhead.ext { fill: var(--accent); }
.cgraph .elabel { fill: var(--dim); font: 500 10.5px var(--font-mono); text-anchor: middle; paint-order: stroke; stroke: var(--panel-solid); stroke-width: 4px; }
.cgraph .vx rect { fill: var(--panel-solid); stroke: var(--line-2); stroke-width: 1.2; transition: stroke 0.25s, fill 0.25s; }
.cgraph .vx text { fill: var(--text); font: 600 13px var(--font-mono); text-anchor: middle; }
.cgraph .vx .sub { fill: var(--dim); font: 500 10.5px var(--font-mono); }
.cgraph .vx .deg { fill: var(--accent); font: italic 500 12px var(--font-math); }
.cgraph a.vx:hover rect, .cgraph a.vx:focus-visible rect { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 8%, var(--panel-solid)); }
.cgraph .vx.root rect { stroke: var(--accent); }
.cgraph .vx.iso rect { stroke-dasharray: 4 4; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.graph-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); overflow: hidden; }
.graph-facts div { padding: 14px 16px; background: var(--panel-solid); }
.graph-facts dt { color: var(--dim); font: 500 10.5px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.graph-facts dd { margin: 6px 0 0; font: italic 500 20px/1.2 var(--font-math); }
@media (max-width: 560px) { .graph-facts { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   Lab controls
   -------------------------------------------------------------------------- */
.lab { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.lab-side { align-items: stretch; }
.lab-side .ring { max-width: 360px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; margin-bottom: 22px; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.field { display: grid; gap: 9px; min-width: 0; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-name { color: var(--dim); font: 500 11.5px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.field-name .m { text-transform: none; color: var(--c, var(--text)); font-size: 15px; margin-right: 4px; }
.field-val { color: var(--text); font: 600 15px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; margin: 0; accent-color: var(--c, var(--accent)); cursor: pointer; }
.field select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-solid);
  color: var(--text);
  font: 500 14px/1 var(--font-mono);
  cursor: pointer;
}
.lab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.readout.r4 { grid-template-columns: repeat(4, 1fr); }
.readout.r3 { grid-template-columns: repeat(3, 1fr); margin-top: 1px; }
@media (max-width: 640px) { .readout.r4 { grid-template-columns: repeat(2, 1fr); } .readout.r3 { grid-template-columns: 1fr; } }
.readout dt .m { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--muted); }
.readout dd.a { color: var(--alice); }
.readout dd.b { color: var(--bob); }
.readout dd.k { color: var(--key); }
.readout dd.e { color: var(--eve); }
.readout dd .ok { color: var(--key); font-size: 0.6em; margin-left: 6px; }
.readout dd .no { color: var(--eve); font-size: 0.6em; margin-left: 6px; }
.trace {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--muted);
  font: 400 15px/1.9 var(--font-math);
}
.trace .lbl { display: block; margin-bottom: 4px; color: var(--dim); font: 500 10.5px/1.3 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.trace i { font-style: italic; }
.trace b { color: var(--text); font-weight: 600; }
.trace sub, .trace sup { font-size: 0.68em; }
.trace .bit { display: inline-block; padding: 0 5px; margin: 0 1px; border-radius: 5px; background: var(--panel-2); font: 500 12.5px/1.6 var(--font-mono); color: var(--dim); }
.trace .bit.on { background: var(--accent-soft); color: var(--accent); }
.lab-note .m { font-size: 1.05em; }
.lab-side .chip-row { justify-content: center; }

/* Screenshot evidence on the home page */
.shot { display: block; }
.shot img { aspect-ratio: 16 / 7; object-fit: cover; object-position: left top; background: #e9f1ec; }
.shot figcaption b { color: var(--text); font-weight: 600; }

/* Purpose note at the top of pages and other callouts reuse admonitions */
.prose .lead-in { font-size: 17px; color: var(--text); }
