:root {
  --paper: #fbfaf7;
  --ink: #111110;
  --ink-2: #55534e;
  --ink-3: #8e8b84;
  --rule: #d9d6cf;
  --stage: #0d0d0c;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  /* One colour per kind of data; readable on the dark stage and on paper. */
  --k-trade: #e9b949; --k-talk: #f08a5d; --k-signal: #5ec8e5; --k-digital: #9b8cf8;
  --k-coordination: #7bd389; --k-record: #c9a27e; --k-living: #e07fbf; --k-physical: #a7b0c2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f0f0e; --ink: #ecebe7; --ink-2: #a9a69f; --ink-3: #75726c; --rule: #2a2927;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f0f0e; --ink: #ecebe7; --ink-2: #a9a69f; --ink-3: #75726c; --rule: #2a2927;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font-family: var(--serif); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 16px 24px; }

header.mast { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 22px 0 14px; border-bottom: 1px solid var(--ink); flex-wrap: wrap; }
.mast h1 { font-weight: 400; font-size: 30px; letter-spacing: -0.01em; margin: 0; }
.mast h1 em { font-style: italic; }
.mast .kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.mast a, .lede a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
.lede { color: var(--ink-2); font-size: 18px; max-width: 780px; margin: 14px 0 6px; }
.overview { font-size: 18px; max-width: 780px; margin: 10px 0 8px; font-style: italic; }
.overview:empty { display: none; }
.stats { font-family: var(--mono); font-size: 11.5px; letter-spacing: .05em; color: var(--ink-2);
  display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; }
.stats b { color: var(--ink); font-weight: 500; }

/* Whose street: your country by default, any other on request (place.js). */
.place { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 4px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.place[hidden] { display: none; }
.place-k { letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.place select { font: inherit; font-size: 13px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; min-height: 36px; max-width: 100%; }
.place-note { color: var(--ink-3); }
.place-back { font: inherit; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 1px solid var(--rule); }

/* ── Stage: the lens's image, its highlighted things, and the flows between them ── */
.stage { position: relative; background: var(--stage); line-height: 0; user-select: none; overflow: hidden; }
.stage img { display: block; width: 100%; height: auto; filter: saturate(.7) brightness(.72); }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.status { position: absolute; inset: 0; display: grid; place-items: center; line-height: 1.4;
  color: #e9e7e1; font-style: italic; font-size: 19px; text-align: center; padding: 24px;
  background: rgba(13,13,12,.6); transition: opacity 400ms; min-height: 200px; }
.status.off { opacity: 0; pointer-events: none; }

/* Things the E8 Lens highlighted: same white outline + mono E-label. */
.thing { fill: none; stroke: #fff; stroke-width: 1.2; opacity: .35; rx: 4; transition: opacity 250ms; }
.thing.on { opacity: .95; stroke-width: 1.6; }
.thing-hit { fill: transparent; stroke: none; cursor: pointer; }
.thing-label { font-family: var(--mono); font-size: 11px; fill: #fff; letter-spacing: .04em;
  paint-order: stroke; stroke: rgba(0,0,0,.75); stroke-width: 3px; pointer-events: none; opacity: .55; }
.thing-label.on { opacity: 1; }

.flow { fill: none; stroke-width: 2; opacity: .75; stroke-linecap: round; transition: opacity 250ms; }
.flow.dim { opacity: .07; }
.flow.sel { stroke-width: 3.6; opacity: 1; }
.flow.inferred { stroke-dasharray: 2 6; }
.flow.implied { stroke-dasharray: 9 5; }
.flow-hit { fill: none; stroke: transparent; stroke-width: 18; cursor: pointer; }
.packet { pointer-events: none; }
.packet.dim { opacity: 0; }

.exits { position: absolute; inset: 0; pointer-events: none; line-height: 1.2; }
.exit { position: absolute; transform: translate(-50%, -50%); font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .03em; color: #fff; background: rgba(13,13,12,.82); border: 1px solid currentColor;
  border-radius: 999px; padding: 3px 8px; white-space: nowrap; max-width: 46%; overflow: hidden;
  text-overflow: ellipsis; transition: opacity 250ms; }
.exit::before { content: "↗ "; }
.exit.dim { opacity: .12; }

/* ── Filters ─────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 12px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; min-height: 36px; padding: 5px 12px;
  border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--c, var(--ink-3)); }
.chip small { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.chip[aria-pressed="false"] { opacity: .45; }
.evidence .chip i { background: none; border-top: 2px solid var(--ink-2); border-radius: 0; height: 0; width: 18px; }
.evidence .chip[data-ev="implied"] i { border-top-style: dashed; }
.evidence .chip[data-ev="inferred"] i { border-top-style: dotted; }

/* ── Ladder: how many flows live at each E-level ─────── */
.ladder { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; margin: 10px 0 4px;
  border-top: 1px solid var(--rule); padding-top: 10px; }
.rung { display: flex; flex-direction: column-reverse; align-items: stretch; gap: 1px; min-height: 92px;
  background: none; border: 0; padding: 0; cursor: pointer; }
.rung .bar { display: flex; flex-direction: column-reverse; gap: 1px; flex: 1; justify-content: flex-start; }
.rung .bar span { display: block; height: 9px; border-radius: 2px; }
.rung .lv { font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); text-align: center; padding-top: 4px;
  border-top: 2px solid transparent; }
.rung[aria-pressed="true"] .lv { color: var(--ink); border-top-color: var(--ink); }
.rung.empty { cursor: default; }
.rung.empty .lv { color: var(--ink-3); opacity: .6; }
.ladder-note { grid-column: 1 / -1; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  letter-spacing: .05em; display: flex; justify-content: space-between; }

/* ── Detail + feed ───────────────────────────────────── */
.panes { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; margin-top: 12px; align-items: start; }
.detail { padding: 14px 16px; border-left: 3px solid var(--c, var(--ink));
  background: color-mix(in srgb, var(--paper) 92%, var(--ink)); font-size: 15.5px; line-height: 1.45; }
.detail .k { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.detail h2 { font-weight: 400; font-size: 22px; margin: 2px 0 8px; line-height: 1.25; }
.detail .route { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.detail .payload { font-size: 17px; margin: 0 0 8px; }
.detail .snippet { font-style: italic; font-size: 18px; margin: 0 0 8px; }
.detail .snippet small { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: .05em; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; }
.detail dt { font-family: var(--mono); font-size: 11px; color: var(--ink-3); padding-top: 3px; }
.detail dd { margin: 0; }
.after { list-style: none; margin: 6px 0 0; padding: 0; }
.after li { display: flex; gap: 10px; align-items: baseline; padding: 3px 0 3px 12px; border-left: 1px solid var(--rule); position: relative; }
.after li::before { content: ""; position: absolute; left: -4px; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink)); }
.after b { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-2); min-width: 30px; }
.detail .hint { color: var(--ink-2); font-style: italic; }

.feed { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); max-height: 520px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 42px 1fr; gap: 2px 10px; padding: 8px 4px; border-bottom: 1px solid var(--rule);
  cursor: pointer; font-size: 15px; line-height: 1.35; }
.feed li:hover, .feed li.sel { background: color-mix(in srgb, var(--paper) 90%, var(--ink)); }
.feed li.hide { display: none; }
.feed .e { font-family: var(--mono); font-size: 12px; color: var(--c); padding-top: 1px; }
.feed .t { color: var(--ink); }
.feed .m { grid-column: 2; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

.note { color: var(--ink-2); font-size: 14.5px; max-width: 780px; margin: 18px 0 0; }
.embed-credit { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; margin: 14px 0 4px; }
.embed-credit a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule); }

/* ── Embedded in an essay: the essay carries the introduction ── */
.embed body { background: transparent; }
:root.embed[data-theme="dark"] { --paper: #1b1b1b; --ink: #e2e2e2; --ink-2: #a8a8a8; --ink-3: #7c7c7c; --rule: #343434; }
.embed .wrap { padding: 0; max-width: none; }
.embed header.mast, .embed .intro { display: none; }

/* Phone width: the picture is small, so off-picture ends become arrow markers
   (their names are in the detail card and the list) and things keep only outlines. */
@media (max-width: 600px) {
  .exit { padding: 1px 5px; font-size: 10px; }
  .exit span { display: none; }
  .exit::before { content: "↗"; }
  .thing-label { display: none; }
}
@media (max-width: 860px) {
  .panes { grid-template-columns: 1fr; }
  .feed { max-height: none; }
  .ladder { gap: 2px; }
  .rung { min-height: 70px; }
  .rung .lv { font-size: 10.5px; }
  .thing-label { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .packet { display: none; } }

/* Mobile: a real tap area for 'back to your country'. */
.place-back { padding: 8px 2px; }
/* Phones: the 15-rung ladder in two rows, so each bar is wide enough to tap. */
@media (max-width: 600px) {
  .ladder { grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: 8px; }
  .rung { min-height: 64px; }
}

/* The overview, in short paragraphs. */
.overview .ov-p { display: block; }
.overview .ov-p + .ov-p { margin-top: .6em; }
