/* Joined Up — integration.rmurphy.dev
   One stylesheet, system fonts, no frameworks. Each era section sets --hue;
   the order travelling through the diagrams is always --token. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #ebe8e1;
  --text: #1b2028;
  --muted: #555d69;          /* 6.3:1 on --bg */
  --faint: #8a9099;
  --rule: #d8d4ca;
  --link: #1f5fa8;
  --token: #e0560b;          /* the order */
  --token-soft: rgba(224, 86, 11, 0.16);
  --ok: #2b7d47;
  --bad: #c2362f;
  --bad-soft: rgba(194, 54, 47, 0.12);
  --warn: #b7791f;
  --warn-text: #8a5a12;      /* 5.6:1 on --surface */
  --node-fill: #ffffff;
  --node-stroke: #9aa1ab;
  --edge: #9aa1ab;
  --edge-quiet: #cdc8bd;
  --era-l: 36%;              /* lightness of era colours used as text */
  --era-s: 52%;
  --era-bar-l: 52%;
  --shadow: 0 1px 2px rgba(27, 32, 40, 0.06), 0 8px 24px rgba(27, 32, 40, 0.06);
  --radius: 14px;
  --measure: 42rem;
  --wide: 60rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --surface: #181d25;
    --surface-2: #202631;
    --text: #e8ebf0;
    --muted: #a7aeb9;
    --faint: #737b87;
    --rule: #2c333e;
    --link: #8ab8f0;
    --token: #ff8a3d;
    --token-soft: rgba(255, 138, 61, 0.18);
    --ok: #5cc08a;
    --bad: #ff6b61;
    --bad-soft: rgba(255, 107, 97, 0.14);
    --warn: #f0b552;
    --warn-text: #f0b552;
    --node-fill: #1c222b;
    --node-stroke: #5d6673;
    --edge: #5d6673;
    --edge-quiet: #3e4754;
    --era-l: 72%;
    --era-s: 60%;
    --era-bar-l: 58%;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11151b;
  --surface: #181d25;
  --surface-2: #202631;
  --text: #e8ebf0;
  --muted: #a7aeb9;
  --faint: #737b87;
  --rule: #2c333e;
  --link: #8ab8f0;
  --token: #ff8a3d;
  --token-soft: rgba(255, 138, 61, 0.18);
  --ok: #5cc08a;
  --bad: #ff6b61;
  --bad-soft: rgba(255, 107, 97, 0.14);
  --warn: #f0b552;
  --warn-text: #f0b552;
  --node-fill: #1c222b;
  --node-stroke: #5d6673;
  --edge: #5d6673;
  --edge-quiet: #3e4754;
  --era-l: 72%;
  --era-s: 60%;
  --era-bar-l: 58%;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--sans);
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.6rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.7rem, 1.3rem + 1.8vw, 2.4rem); }
h3 { font-size: 1.3rem; margin-top: 2rem; }
.h-small {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2rem 0 0.8rem;
}

p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
cite { font-style: italic; }
strong { font-weight: 650; }

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

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.skip:focus { top: 1rem; }

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

.wrap { max-width: calc(var(--measure) + 2rem); margin: 0 auto; padding: 0 1rem; }
.wrap--wide { max-width: calc(var(--wide) + 2rem); }
.wrap--full { max-width: 78rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

/* ── Sticky era bar ───────────────────────────────────────────────── */

.era-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
  transform: translateY(-110%);
  transition: transform 0.25s ease;
}
.era-nav.is-shown { transform: none; }
.era-nav:focus-within { transform: none; }
.era-nav-inner { display: flex; align-items: center; gap: 0.75rem; max-width: 78rem; margin: 0 auto; padding: 0 0 0 1rem; }
.era-nav-brand {
  flex: none;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.era-nav-list {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0.5rem 1rem 0.5rem 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 1rem, #000 calc(100% - 2rem), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 1rem, #000 calc(100% - 2rem), transparent);
  padding-left: 1rem;
}
.era-nav-list::-webkit-scrollbar { display: none; }
.era-nav-list a {
  display: block;
  white-space: nowrap;
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}
.era-nav-list a:hover { background: var(--surface-2); color: var(--text); }
.era-nav-list a.is-active {
  background: hsl(var(--hue) var(--era-s) var(--era-l) / 0.14);
  color: hsl(var(--hue) var(--era-s) var(--era-l));
  font-weight: 650;
}
.era-nav-num { font-family: var(--mono); font-size: 0.75em; opacity: 0.7; }
.era-nav-progress { height: 2px; }
.era-nav-progress span {
  display: block;
  height: 100%;
  background: var(--token);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ── Hero ─────────────────────────────────────────────────────────── */

.hero { padding: clamp(3rem, 8vw, 6rem) 0 3rem; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 38rem; }

.follow {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 2rem 0 0;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.follow p { margin: 0; font-size: 0.97rem; }
.follow .follow-title { font-weight: 650; margin-bottom: 0.25rem; font-size: 1rem; }
.follow-token {
  flex: none;
  width: 18px; height: 18px;
  margin-top: 0.2rem;
  border-radius: 50%;
  background: var(--token);
  box-shadow: 0 0 0 5px var(--token-soft);
}

.timeline-wrap { margin-top: 3rem; }
.timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; }
.timeline-head .h-small { margin: 0 0 0.6rem; }
.timeline-key { font-size: 0.82rem; color: var(--muted); margin: 0 0 0.6rem; display: flex; align-items: center; gap: 0.4rem; }
.key { display: inline-block; width: 1.4rem; height: 0.55rem; border-radius: 3px; }
.key--peak { background: hsl(220 var(--era-s) var(--era-bar-l)); }
.key--still { background: hsl(220 var(--era-s) var(--era-bar-l) / 0.22); margin-left: 0.8rem; }

.toc { columns: 2 16rem; padding-left: 1.4rem; margin: 0; }
.toc li { break-inside: avoid; }
.has-timeline .toc { display: none; }

.timeline {
  --label: 12.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 0.75rem;
  box-shadow: var(--shadow);
}
.timeline:empty { display: none; }
.tl-axis {
  position: relative;
  height: 1.4rem;
  margin-left: var(--label);
  margin-right: 1.4rem;
  font: 0.72rem var(--mono);
  color: var(--faint);
}
.tl-tick { position: absolute; top: 0; transform: translateX(-50%); }
.tl-tick--now { color: var(--token); font-weight: 700; }
.tl-rows { list-style: none; margin: 0; padding: 0; }
.tl-row {
  display: grid;
  grid-template-columns: var(--label) 1fr;
  align-items: center;
  min-height: 2rem;
  padding-right: 1.4rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background-image: linear-gradient(90deg, transparent var(--label), transparent);
}
.tl-row:hover, .tl-row.is-active { background: var(--surface-2); }
.tl-label { display: flex; align-items: baseline; gap: 0.5rem; padding-left: 0.4rem; min-width: 0; }
.tl-num { font: 0.72rem var(--mono); color: hsl(var(--hue) var(--era-s) var(--era-l)); }
.tl-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; }
.tl-years { font-size: 0.75rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track {
  position: relative;
  height: 0.7rem;
  background-image: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px calc(100% / 6.6));
  background-size: 100% 100%;
}
.tl-still, .tl-peak { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.tl-still { background: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.22); }
.tl-peak { background: hsl(var(--hue) var(--era-s) var(--era-bar-l)); }
.tl-row:hover .tl-peak, .tl-row.is-active .tl-peak { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.5); }

@media (max-width: 40rem) {
  .timeline { --label: 7.6rem; padding: 0.6rem 0.5rem; }
  .tl-row { padding-right: 0.8rem; min-height: 2.6rem; }
  .tl-axis { margin-right: 0.8rem; }
  .tl-tick:nth-child(even):not(.tl-tick--now), .tl-tick:nth-child(7) { visibility: hidden; }
  .tl-label { flex-direction: column; gap: 0; line-height: 1.2; }
  .tl-num { display: none; }
  .tl-name { font-size: 0.85rem; }
  .tl-years { font-size: 0.7rem; max-width: 100%; }
}

/* ── Chapters and eras ────────────────────────────────────────────── */

.chapter, .era { padding: clamp(3rem, 7vw, 5rem) 0; border-top: 1px solid var(--rule); }

.pressures { padding-left: 1.2rem; }
.pressures li { margin-bottom: 0.4rem; }

.questions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}
@media (max-width: 48rem) { .questions { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 30rem) { .questions { grid-template-columns: 1fr; } }
.questions div {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.questions dt { font: 700 0.78rem var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--token); margin-bottom: 0.2rem; }
.questions dd { margin: 0; font-size: 0.95rem; }

.math { font-family: var(--mono); font-size: 0.92em; white-space: nowrap; }

.era-num {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font: 0.85rem var(--mono);
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.era-num span {
  display: inline-grid;
  place-items: center;
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: hsl(var(--hue) var(--era-s) var(--era-l));
  background: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.14);
}
.era h2 { margin-bottom: 0.4rem; }
.era-lede {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.45;
  color: hsl(var(--hue) var(--era-s) var(--era-l));
  margin-bottom: 1.2rem;
}

.ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1rem;
  margin: 1.75rem auto;
}
.ledger-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 0.5rem;
  border-top: 4px solid var(--ok);
}
.ledger-card--broke { border-top-color: var(--bad); }
.ledger-card h3 { font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0.07em; text-transform: uppercase; margin: 0 0 0.7rem; color: var(--ok); }
.ledger-card--broke h3 { color: var(--bad); }
.ledger-card ul { margin: 0 0 0.75rem; padding-left: 1.1rem; }
.ledger-card li { margin-bottom: 0.45rem; font-size: 0.97rem; }

.milestones { list-style: none; margin: 0; padding: 0; border-left: 2px solid hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.35); }
.milestones li { position: relative; padding: 0 0 0.75rem 1.2rem; font-size: 0.97rem; }
.milestones li::before {
  content: "";
  position: absolute;
  left: -6px; top: 0.55em;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid hsl(var(--hue) var(--era-s) var(--era-bar-l));
}
.milestones b { font-family: var(--mono); font-size: 0.88em; margin-right: 0.4rem; color: hsl(var(--hue) var(--era-s) var(--era-l)); }

.deeper {
  margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.deeper summary {
  cursor: pointer;
  padding: 0.85rem 1.1rem;
  font-weight: 650;
  list-style: none;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}
.deeper summary::-webkit-details-marker { display: none; }
.deeper summary::before {
  content: "+";
  font-family: var(--mono);
  color: hsl(var(--hue) var(--era-s) var(--era-l));
  width: 1ch;
}
.deeper[open] summary::before { content: "−"; }
.deeper > p { padding: 0 1.1rem; font-size: 0.97rem; }
.deeper > p:last-child { padding-bottom: 0.4rem; }

.today {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.today h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin: 0 0 0.6rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
}
.today p { font-size: 0.97rem; }
.today-when { color: var(--muted); }
.today-when strong { color: var(--text); }
.verdict {
  font: 700 0.72rem var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
}
.verdict--yes { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.verdict--niche { color: var(--warn-text); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.verdict--legacy { color: var(--muted); background: var(--surface-2); }
.verdict--now { color: var(--token); background: var(--token-soft); }
.matrix .verdict { display: inline-block; justify-self: start; align-self: start; font-size: 0.68rem; line-height: 1.4; }
.matrix th[data-col="today"] { width: 10.5rem; }

.led-to { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--rule); color: var(--muted); }
.led-to strong { color: var(--text); }
.led-to a { font-weight: 650; white-space: nowrap; }

/* ── Diagrams ─────────────────────────────────────────────────────── */

.diagram, .spaghetti, .gantt { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.diagram-svg, .gantt-svg, .spaghetti-svg { display: block; width: 100%; height: auto; }
.diagram-svg {
  max-width: 40rem;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.diagram figcaption, .spaghetti figcaption, .gantt figcaption {
  max-width: 40rem;
  margin: 0.6rem auto 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.node .shape { fill: var(--node-fill); stroke: var(--node-stroke); stroke-width: 1.5; transition: fill 0.25s, stroke 0.25s; }
.node .shape-fold { fill: none; stroke: var(--node-stroke); stroke-width: 1.5; }
.node-label { font-size: 15px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.node-sub { font: 11px var(--mono); fill: var(--muted); text-anchor: middle; }
.node-sub--side { text-anchor: end; }
.node--hub .shape, .node--bus .shape, .node--gateway .shape {
  /* opaque, so the order's path is hidden while it passes through */
  fill: color-mix(in srgb, hsl(var(--hue) var(--era-s) var(--era-bar-l)) 14%, var(--node-fill));
  stroke: hsl(var(--hue) var(--era-s) var(--era-bar-l));
}
.node--fn .shape { stroke: hsl(var(--hue) var(--era-s) var(--era-bar-l)); stroke-dasharray: 4 3; }
.node--fn .node-label { font-family: var(--mono); font-size: 13px; }
.node--file .shape, .node--db .shape { fill: var(--surface-2); }
.node--adapter .shape { fill: var(--surface-2); }
.node--adapter .node-sub { font-weight: 700; }
.node--queue .shape, .node--log .shape { fill: var(--surface-2); }
.node--queue .node-sub--side { font-size: 11px; }
.cell { fill: var(--node-stroke); opacity: 0.35; }
.cell--on { fill: var(--token); opacity: 0.9; }

.edge { fill: none; stroke: var(--edge); stroke-width: 1.75; transition: stroke 0.25s; }
.edge--quiet { stroke: var(--edge-quiet); stroke-width: 1.25; stroke-dasharray: 3 4; }
.arrowhead { fill: var(--edge); }
.edge-label rect { fill: var(--surface); stroke: var(--rule); }
.edge-label text { font: 11px var(--mono); fill: var(--muted); text-anchor: middle; }

.zone rect { fill: var(--surface-2); fill-opacity: 0.55; stroke: var(--rule); }
.zone--layer rect { fill: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.06); stroke: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.3); }
.zone--layer { cursor: pointer; }
.zone--layer.is-selected rect { fill: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.18); stroke: hsl(var(--hue) var(--era-s) var(--era-bar-l)); stroke-width: 1.5; }
.zone-label { font: 600 10.5px var(--mono); letter-spacing: 0.08em; fill: var(--muted); }
.firewall line { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 8 5; opacity: 0.7; }

/* while the order travels */
.edge.is-lit { stroke: var(--token); }
.edge.is-fail { stroke: var(--bad); stroke-dasharray: 5 4; }
.node.is-hit .shape { stroke: var(--token); fill: color-mix(in srgb, var(--token) 10%, var(--node-fill)); }
.node.is-waiting .shape { stroke: var(--token); animation: pulse 1.2s ease-in-out infinite; }
.node.is-down .shape { stroke: var(--bad); fill: var(--bad-soft); stroke-dasharray: 6 4; stroke-width: 2; }
.node.is-down .node-label { fill: var(--bad); text-decoration: line-through; }
.node.is-fail .shape { stroke: var(--bad); fill: var(--bad-soft); stroke-width: 2; }
.node.is-delayed .shape { stroke: var(--warn); }
.node.is-breakable { cursor: pointer; }
.node.is-breakable:hover .shape { stroke-width: 2.5; }
.token { fill: var(--token); stroke: var(--surface); stroke-width: 2.5; filter: drop-shadow(0 0 4px var(--token-soft)); }
.token--fail { fill: var(--bad); }
.token--wait { fill: var(--warn); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.45; } }

.diagram-bar {
  max-width: 40rem;
  margin: 0.75rem auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
}
.play, .break, .seg button {
  font: inherit;
  font-size: 0.92rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 2.5rem;
}
.play {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 1.05rem 0.45rem 0.8rem;
  border: 0;
  background: var(--token);
  color: #fff;
  font-weight: 650;
}
.play:hover { filter: brightness(1.06); }
.play:disabled { opacity: 0.55; cursor: progress; }
.play-icon { width: 0; height: 0; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent currentColor; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .play { color: #1a1205; } }
:root[data-theme="dark"] .play { color: #1a1205; }

.breaks { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.breaks-label { font-size: 0.85rem; color: var(--muted); }
.break {
  padding: 0.3rem 0.85rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--rule);
}
.break:hover { border-color: var(--bad); }
.break[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.diagram-status {
  flex: 1 0 100%;
  margin: 0;
  min-height: 3.2em;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--token);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  font-size: 0.95rem;
}
.is-broken .diagram-status { border-left-color: var(--bad); }

/* ── Spaghetti calculator ─────────────────────────────────────────── */

.spaghetti-control {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 30rem;
  margin: 0 auto 1rem;
  font-weight: 600;
}
.spaghetti-control input { flex: 1; accent-color: var(--token); min-height: 2rem; }
.spaghetti-control output { font: 700 1.2rem var(--mono); min-width: 2ch; text-align: right; }
.no-js .spaghetti-control, .no-js .spaghetti-pair { display: none; }
.spaghetti-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.spaghetti-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.spaghetti-count { margin: 0; font-family: var(--serif); font-size: 1.15rem; }
.spaghetti-count output { font: 700 2rem var(--mono); color: var(--token); }
.spaghetti-name { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); }
.spaghetti-svg { max-width: 15rem; margin: 0 auto; }
.sp-links line { stroke: var(--edge); stroke-width: 1; opacity: 0.75; }
.sp-node { fill: var(--node-fill); stroke: var(--text); stroke-width: 2; }
.sp-hub { fill: var(--token); }
@media (max-width: 30rem) {
  .spaghetti-pair { gap: 0.5rem; }
  .spaghetti-panel { padding: 0.75rem 0.5rem; }
  .spaghetti-count output { font-size: 1.6rem; }
}

/* ── Calls or events ──────────────────────────────────────────────── */

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  border-radius: 999px;
}
.seg button { border: 0; padding: 0.3rem 1rem; background: transparent; color: var(--muted); min-height: 2.2rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow); }
.gantt { max-width: calc(40rem + 2rem); }
.gantt .seg { display: flex; width: fit-content; }
.gantt-panel h4 { margin-top: 0; }
.js .gantt-panel h4 { display: none; }
.no-js .gantt-panel + .gantt-panel { margin-top: 2rem; }
.gantt-svg {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--sans);
}
.gantt-grid { stroke: var(--rule); stroke-width: 1; }
.gantt-tick { font: 10px var(--mono); fill: var(--faint); text-anchor: middle; }
.gantt-tick--unit { text-anchor: end; }
.gantt-label { font-size: 13px; fill: var(--text); text-anchor: end; }
.gantt-bar--work { fill: hsl(var(--hue) var(--era-s) var(--era-bar-l)); }
.gantt-bar--busy { fill: hsl(var(--hue) var(--era-s) var(--era-bar-l) / 0.2); stroke: hsl(var(--hue) var(--era-s) var(--era-bar-l)); stroke-dasharray: 3 3; }
.gantt-bar--wait { fill: var(--token); }
.gantt-done { stroke: var(--token); stroke-width: 2; }
.gantt-done-label { font: 600 11px var(--sans); fill: var(--token); }
.gantt-summary { margin: 0.75rem 0 0; font-size: 0.95rem; }

/* ── API-led layers ───────────────────────────────────────────────── */

.layers { max-width: calc(40rem + 2rem); }
.layer-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid hsl(var(--hue) var(--era-s) var(--era-bar-l));
  border-radius: 0 12px 12px 0;
  padding: 1rem 1.2rem 0.2rem;
  margin-bottom: 0.75rem;
}
.layer-panel h3 { margin-top: 0; font-size: 1.1rem; }
.layer-panel .eg { color: var(--muted); font-size: 0.95rem; }

/* ── Comparison table ─────────────────────────────────────────────── */

.matrix-wrap { overflow-x: auto; }
.matrix {
  width: 100%;
  min-width: 70rem;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.matrix th, .matrix td { text-align: left; vertical-align: top; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--rule); }
.matrix tbody tr:last-child > * { border-bottom: 0; }
.matrix thead th { background: var(--surface-2); padding: 0.4rem; font-weight: 600; }
.matrix thead th.col-era { padding-left: 0.8rem; font-size: 0.85rem; }
.matrix thead button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.matrix thead button:hover { border-color: var(--rule); background: var(--surface); }
.matrix thead button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.matrix .col-era { width: 11rem; }
.matrix tbody th a { display: grid; grid-template-columns: auto 1fr; column-gap: 0.5rem; text-decoration: none; color: var(--text); }
.matrix-num { font: 700 0.75rem var(--mono); color: hsl(var(--hue) var(--era-s) var(--era-l)); grid-row: span 2; padding-top: 0.15rem; }
.matrix-name { font-weight: 650; }
.matrix-years { font-size: 0.78rem; color: var(--faint); font-weight: 400; }
.matrix tbody th a:hover .matrix-name { text-decoration: underline; }
.matrix.has-lit td:not(.is-lit) { color: var(--faint); }
.matrix td.is-lit { background: color-mix(in srgb, var(--token) 8%, var(--surface)); color: var(--text); }
.coupling { display: grid; gap: 0.3rem; }
.dots { display: inline-flex; gap: 3px; }
.dots span { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--node-stroke); }
.dots span.on { background: var(--text); border-color: var(--text); }
.coupling-note { font-size: 0.85rem; }

/* Cards on phones: one era per card, each value labelled. */
@media (max-width: 48rem) {
  .matrix-wrap { overflow: visible; }
  .matrix { min-width: 0; background: none; border: 0; border-radius: 0; overflow: visible; }
  .matrix thead { display: block; }
  .matrix thead tr { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
  .matrix thead th { background: none; padding: 0; border: 0; }
  .matrix thead th.col-era { display: none; }
  .matrix thead button { width: auto; border: 1px solid var(--rule); border-radius: 999px; padding: 0.35rem 0.8rem; background: var(--surface); min-height: 2.4rem; }
  .matrix tbody, .matrix tr, .matrix th, .matrix td { display: block; }
  .matrix tbody tr {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-top: 4px solid hsl(var(--hue) var(--era-s) var(--era-bar-l));
    border-radius: 12px;
    margin-bottom: 0.9rem;
    overflow: hidden;
  }
  .matrix .col-era { width: auto; }
  .matrix tbody th { border-bottom: 1px solid var(--rule); font-size: 1rem; }
  .matrix td { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--rule); }
  .matrix tbody tr > td:last-child { border-bottom: 0; }
  .matrix td::before { content: attr(data-label); font-size: 0.75rem; font-weight: 650; color: var(--muted); padding-top: 0.1rem; }
}

/* ── Closing ──────────────────────────────────────────────────────── */

.tensions { list-style: none; padding: 0; margin: 1rem 0 1.5rem; display: grid; gap: 0.5rem; }
.tensions li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}
.tensions li::after {
  content: "";
  grid-column: 2;
  grid-row: 1;
  width: clamp(3rem, 14vw, 8rem);
  height: 2px;
  background: linear-gradient(90deg, var(--node-stroke), var(--token), var(--node-stroke));
}
.tensions span:first-child { text-align: right; grid-column: 1; grid-row: 1; }
.tensions span:last-child { grid-column: 3; grid-row: 1; }

.checklist { padding-left: 1.4rem; }
.checklist li { margin-bottom: 0.8rem; }
.checklist li::marker { font-family: var(--mono); color: var(--token); font-weight: 700; }

.chapter--sources { font-size: 0.95rem; }
.sources { padding-left: 1.2rem; }
.sources li { margin-bottom: 0.5rem; }
.note { color: var(--muted); font-size: 0.9rem; }

.site-footer { border-top: 1px solid var(--rule); padding: 2rem 0 3rem; color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0 0 0.4rem; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 404 */
.lost { min-height: 70vh; display: grid; align-content: center; padding: 4rem 0; }
.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--token);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .era-nav, .diagram-bar, .seg, .skip { display: none !important; }
  .gantt-panel[hidden], .layer-panel[hidden] { display: block !important; }
  .deeper { border: 0; }
  body { background: #fff; }
}
