/* engram pages. Dark by default: the map is a night sky in both themes, and
   the people who open these pages sit in front of dark editors. The light
   variant follows the system preference or data-theme="light". Every colour
   is a token in OKLCH; the neutrals lean towards the sky hue (262), the one
   accent is a warm ember. Type: Spectral for names and headings, Schibsted
   Grotesk for the rest. Both are vendored, the hub may run offline. */

@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap; src: url("vendor/fonts/spectral-400.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 600; font-display: swap; src: url("vendor/fonts/spectral-600.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap; src: url("vendor/fonts/spectral-italic-400.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 600; font-display: swap; src: url("vendor/fonts/spectral-italic-600.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("vendor/fonts/schibsted-grotesk.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: italic; font-weight: 400 900; font-display: swap; src: url("vendor/fonts/schibsted-grotesk-italic.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --ground: oklch(0.165 0.018 262); --surface: oklch(0.205 0.02 262); --surface-2: oklch(0.24 0.02 262);
  --ink: oklch(0.93 0.01 85); --ink-2: oklch(0.79 0.012 85); --muted: oklch(0.63 0.016 262);
  --line: oklch(0.30 0.02 262); --grid: oklch(0.255 0.018 262); --edge: oklch(0.56 0.02 262); --edge-2: oklch(0.43 0.02 262);
  --accent: oklch(0.80 0.13 65); --accent-ink: oklch(0.86 0.11 72); --accent-soft: oklch(0.30 0.05 65); --on-accent: oklch(0.20 0.03 65);
  --code-bg: oklch(0.215 0.02 262); --tip-bg: oklch(0.27 0.02 262);
  --space: oklch(0.13 0.022 262); --space-ink: oklch(0.92 0.01 85); --space-muted: oklch(0.66 0.018 262);
  --s-repo: #3987e5; --s-stack: #e8683a; --s-group: #22a97a; --s-company: #9a78e8; --s-personal: #8a949f; --s-other: #5b6673;
  --seq-1: #244f8a; --seq-4: #4d95ea;
  --good: #2fb344; --warning: #f0b429; --serious: #ec835a; --critical: #e0524f; --good-text: #4fc35f;
  --display: "Spectral", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ui: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --t-xs: 0.8rem; --t-sm: 0.882rem; --t-md: 1rem; --t-lg: 1.235rem; --t-xl: 1.53rem; --t-2xl: 1.94rem; --t-3xl: 2.41rem; --t-hero: 3.9rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px; --sp-16: 64px;
  --radius: 10px; --radius-sm: 6px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ground: oklch(0.975 0.006 85); --surface: oklch(0.995 0.003 85); --surface-2: oklch(0.955 0.008 85);
    --ink: oklch(0.22 0.02 262); --ink-2: oklch(0.40 0.02 262); --muted: oklch(0.55 0.02 262);
    --line: oklch(0.87 0.012 262); --grid: oklch(0.925 0.008 262); --edge: oklch(0.62 0.02 262); --edge-2: oklch(0.78 0.015 262);
    --accent: oklch(0.58 0.15 50); --accent-ink: oklch(0.48 0.14 45); --accent-soft: oklch(0.93 0.05 70); --on-accent: oklch(0.99 0.01 85);
    --code-bg: oklch(0.95 0.008 85); --tip-bg: oklch(0.99 0.003 85);
    --s-repo: #2a78d6; --s-stack: #e0602c; --s-group: #1a9c6d; --s-company: #7a4fd6; --s-other: #a3adb8;
    --seq-1: #cde2fb; --seq-4: #3987e5;
    --good: #1a9c2e; --critical: #d03b3b; --good-text: #0a6b18;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --ground: oklch(0.975 0.006 85); --surface: oklch(0.995 0.003 85); --surface-2: oklch(0.955 0.008 85);
  --ink: oklch(0.22 0.02 262); --ink-2: oklch(0.40 0.02 262); --muted: oklch(0.55 0.02 262);
  --line: oklch(0.87 0.012 262); --grid: oklch(0.925 0.008 262); --edge: oklch(0.62 0.02 262); --edge-2: oklch(0.78 0.015 262);
  --accent: oklch(0.58 0.15 50); --accent-ink: oklch(0.48 0.14 45); --accent-soft: oklch(0.93 0.05 70); --on-accent: oklch(0.99 0.01 85);
  --code-bg: oklch(0.95 0.008 85); --tip-bg: oklch(0.99 0.003 85);
  --s-repo: #2a78d6; --s-stack: #e0602c; --s-group: #1a9c6d; --s-company: #7a4fd6; --s-other: #a3adb8;
  --seq-1: #cde2fb; --seq-4: #3987e5;
  --good: #1a9c2e; --critical: #d03b3b; --good-text: #0a6b18;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--ui); font-size: var(--t-md); line-height: 1.55; padding-block: 0 var(--sp-16); padding-inline: clamp(16px, 4vw, 48px); -webkit-font-smoothing: antialiased; }
/* Tabular figures line up in columns, but they also widen the comma and the
   full stop, so they stay on figures and tables, never on prose. */
.hero-num, .figure .value, .num, table, .history time, .audit td:first-child, .meter-label { font-variant-numeric: tabular-nums; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
.page { max-width: 1280px; margin: 0 auto; }
h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: -0.005em; }
h2 { font-size: var(--t-2xl); line-height: 1.15; }
h3 { font-size: var(--t-lg); line-height: 1.3; }
.sub { color: var(--muted); font-size: var(--t-sm); margin: var(--sp-1) 0 0; max-width: 70ch; }
.caption { font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---------- top bar and tabs ---------- */
.top { display: flex; align-items: baseline; gap: var(--sp-4); padding: var(--sp-6) 0 var(--sp-4); flex-wrap: wrap; }
.brand { font-family: var(--display); font-style: italic; font-weight: 600; font-size: var(--t-xl); letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--ink); }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); transform: translateY(1px); }
.pill { font: 600 var(--t-xs) var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; text-decoration: none; }
.pill.accent { color: var(--accent-ink); }
a.pill { color: var(--ink-2); letter-spacing: 0; text-transform: none; font-weight: 500; font-size: var(--t-sm); }
a.pill:hover { color: var(--ink); }
.spacer { flex: 1; }
.who { font-size: var(--t-sm); color: var(--ink-2); }
nav.tabs { display: flex; gap: var(--sp-1); margin: 0 0 var(--sp-8); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: var(--sp-3) var(--sp-4); margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; transition: color .15s; }
nav.tabs a:hover { color: var(--ink-2); }
nav.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
nav.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-xs); font-weight: 600; text-align: center; line-height: 1.6; }
.notice { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: var(--sp-4); color: var(--ink-2); }
.notice.err { border-color: var(--critical); color: var(--critical); }

/* ---------- views ---------- */
.view[hidden] { display: none; }
.view { display: flex; flex-direction: column; gap: var(--sp-8); animation: rise .38s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; align-items: flex-end; }
.col { display: flex; flex-direction: column; gap: var(--sp-4); }
.grid { display: grid; gap: var(--sp-6); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: var(--sp-8) var(--sp-12); }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; padding-bottom: var(--sp-3); margin-bottom: var(--sp-3); border-bottom: 1px solid var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.card header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.card.tight { padding: var(--sp-2); }

/* ---------- overview ---------- */
.instrument { display: grid; grid-template-columns: minmax(220px, auto) 1fr; gap: var(--sp-4) var(--sp-12); align-items: end; padding: var(--sp-6) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (max-width: 700px) { .instrument { grid-template-columns: 1fr; } }
.hero-num { font-family: var(--display); font-weight: 400; font-size: var(--t-hero); line-height: 0.95; letter-spacing: -0.03em; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.hero-num small { font-size: var(--t-xl); color: var(--muted); font-weight: 400; margin-left: 2px; }
.instrument .caption { margin-top: var(--sp-2); }
.gauge { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: 6px; }
.meter { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); position: relative; overflow: visible; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--seq-4); transition: width .6s var(--ease-out); }
.meter .th { position: absolute; top: -6px; width: 2px; height: 20px; background: var(--accent); }
.meter-label { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--muted); }
.delta { font-size: var(--t-sm); color: var(--muted); margin: 0; }
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4) 0; }
.figure { padding: 0 var(--sp-4); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; animation: rise .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.figure .value { font-family: var(--ui); font-weight: 500; font-size: var(--t-2xl); line-height: 1.1; letter-spacing: -0.02em; color: var(--ink); }
.figure .label { order: -1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 500; }
.status i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status.good i { background: var(--good); } .status.warn i { background: var(--warning); } .status.crit i { background: var(--critical); }
.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 12.5px; font-family: var(--ui); }
svg.chart .grid line { stroke: var(--grid); }
svg.chart .axis { stroke: var(--line); }
.tip { position: fixed; pointer-events: none; background: var(--tip-bg); color: var(--ink); border: 1px solid var(--line); font-size: var(--t-xs); padding: 6px 10px; border-radius: var(--radius-sm); transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; z-index: 10; box-shadow: 0 6px 20px oklch(0 0 0 / .25); }
details.table { font-size: var(--t-sm); margin-top: var(--sp-2); } details.table summary { cursor: pointer; color: var(--muted); } details.table summary:hover { color: var(--ink-2); }
table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-3) var(--sp-2) 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
.wide { overflow-x: auto; }

/* ---------- controls ---------- */
.chips { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.chip { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 5px 12px; font-size: var(--t-sm); cursor: pointer; color: var(--muted); transition: color .15s, background .15s; }
.chip:hover { color: var(--ink-2); background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 6px 12px; font-size: var(--t-sm); font-weight: 500; cursor: pointer; color: var(--ink-2); transition: border-color .15s, color .15s; }
.btn:hover { border-color: var(--edge); color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); color: var(--on-accent); }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .45; cursor: default; }
.badge { font-family: var(--mono); font-size: var(--t-xs); padding: 1px 7px; border-radius: 4px; background: var(--code-bg); color: var(--ink-2); }
.badge.repo { color: var(--s-repo); } .badge.stack { color: var(--s-stack); } .badge.group { color: var(--s-group); } .badge.company { color: var(--s-company); }
.kind { font-size: var(--t-xs); padding: 1px 7px; border-radius: 4px; background: var(--code-bg); white-space: nowrap; }
.kind.deny { color: var(--critical); } .kind.ok { color: var(--good-text); } .kind.warn { color: var(--serious); }
input[type="search"], input#propose-note, textarea, select { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 7px 12px; color: var(--ink); }
input[type="search"] { border-radius: 999px; min-width: 220px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); }
.empty { color: var(--muted); font-size: var(--t-sm); padding: var(--sp-3) 0; max-width: 60ch; }

/* ---------- review queue ---------- */
.reason { font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.reason i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--s-other); }
.reason.quarantine i { background: var(--warning); } .reason.promotion i { background: var(--s-group); } .reason.refutation i { background: var(--serious); } .reason.scanner i { background: var(--critical); }
.reason.publication i { background: var(--accent); } .reason.waiting i { background: var(--muted); } .reason.replacement i { background: var(--s-repo); } .reason.possible_update i { background: var(--s-company); }
.queue { display: flex; flex-direction: column; }
.q-group { border-top: 1px solid var(--line); }
.q-group > summary { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) 0; cursor: pointer; }
.q-group > summary::-webkit-details-marker { display: none; }
.q-group > summary::before { content: "\25b8"; color: var(--muted); }
.q-group[open] > summary::before { content: "\25be"; }
.q-group > summary .btn { margin-left: auto; }
.q-group-name { font-weight: 600; }
.q-group .q-item:first-of-type { border-top: 0; }
.q-item { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-8); padding: var(--sp-6) 0; border-top: 1px solid var(--line); }
.q-title { font-family: var(--display); font-size: var(--t-lg); line-height: 1.3; margin: var(--sp-1) 0; }
.q-body { color: var(--ink-2); font-size: var(--t-md); max-width: 70ch; white-space: pre-wrap; }
.q-meta { display: flex; gap: var(--sp-3); flex-wrap: wrap; font-size: var(--t-xs); color: var(--muted); margin-top: var(--sp-1); }
.q-actions { display: flex; gap: var(--sp-1); align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .q-item { grid-template-columns: 1fr; } .q-actions { justify-content: flex-start; } }

/* ---------- map & graph ---------- */
/* Two columns: the stage and the fact table in one block on the left, the
   detail panel on the right. The detail is its own grid item, so a long
   fact grows it without moving the map or the table. */
.maplayout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-6); align-items: start; }
.mapmain { display: flex; flex-direction: column; gap: var(--sp-6); min-width: 0; }
@media (max-width: 960px) {
  .maplayout { grid-template-columns: 1fr; }
}
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
canvas { width: 100%; height: auto; display: block; border-radius: calc(var(--radius) - 3px); background: var(--surface-2); touch-action: none; max-width: 100%; }
.graph-controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) var(--sp-2) 0; align-items: center; }
.graph-controls[hidden] { display: none; }
.graph-controls p { margin: 0; max-width: none; }
.graph-controls output { font-size: var(--t-xs); color: var(--muted); min-width: 3.5ch; text-align: right; }

/* Facts in view: the reading order the canvas cannot give. Sorted by last
   update by default, so what just arrived is on top. */
.facts { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.facts > header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.factscroll { max-height: 22rem; overflow-y: auto; }
.facts table { font-size: var(--t-sm); table-layout: fixed; width: 100%; }
/* Fixed columns: the fact title takes what is left and truncates, the rest
   keep their own width so the row stays one line. */
.facts th:nth-child(2), .facts td:nth-child(2) { width: 5.5rem; }
.facts th:nth-child(3), .facts td:nth-child(3) { width: 9rem; }
.facts th:nth-child(4), .facts td:nth-child(4) { width: 8rem; }
.facts th:nth-child(5), .facts td:nth-child(5) { width: 5.5rem; }
.facts th:nth-child(6), .facts td:nth-child(6) { width: 6rem; }
@media (max-width: 1100px) {
  .facts th:nth-child(3), .facts td:nth-child(3), .facts th:nth-child(4), .facts td:nth-child(4) { display: none; }
}
.facts thead th { position: sticky; top: 0; background: var(--ground); z-index: 1; padding: 0 var(--sp-3) var(--sp-2) 0; }
.sortbtn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--t-xs); font-weight: 600; }
.sortbtn:hover { color: var(--ink-2); }
th[aria-sort] .sortbtn { color: var(--ink); }
th[aria-sort="descending"] .sortbtn::after { content: " \2193"; }
th[aria-sort="ascending"] .sortbtn::after { content: " \2191"; }
.facts tbody tr { cursor: pointer; }
.facts tbody tr:hover td { background: var(--surface); }
.facts tbody tr[aria-selected="true"] td { background: var(--accent-soft); }
.facts tbody tr[aria-selected="true"] td:first-child { color: var(--accent-ink); }
.facts td { padding: var(--sp-2) var(--sp-3) var(--sp-2) 0; white-space: nowrap; }
.facts td:first-child { min-width: 0; }
.facts .fauthor { display: inline-block; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.facts .ftitle { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts .fmark { font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-left: var(--sp-2); }
.facts .fmark.new { color: var(--accent-ink); }
.facts .fmark.warn { color: var(--warning); }
.facts .fdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }
.facts .fpos { color: var(--good-text); } .facts .fneg { color: var(--critical); }
.mapfoot { padding: var(--sp-1) var(--sp-2) var(--sp-1); }
/* One fixed line: the status swaps between a count and a fact title, and
   the two must not resize the stage. */
.mapfoot .status { font-size: var(--t-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.6rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.mapfoot .status em { font-family: var(--display); font-style: italic; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: var(--t-sm); line-height: 1; color: var(--ink-2); }
.topics { margin-top: calc(-1 * var(--sp-4)); }
.topics .chip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.topics:empty { display: none; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; position: sticky; top: var(--sp-4); max-height: calc(100vh - var(--sp-8)); overflow-y: auto; }
@media (max-width: 960px) { .detail { position: static; max-height: none; } }
.detail h3 { font-size: var(--t-xl); line-height: 1.25; }
.detail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--sp-4); font-size: var(--t-sm); }
.detail dt { color: var(--muted); } .detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail code { font-family: var(--mono); font-size: var(--t-xs); }
.derivation { padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--t-sm); display: flex; flex-direction: column; gap: 6px; }
.derivation b { color: var(--ink-2); font-weight: 600; }
.untrusted { font-size: var(--t-xs); color: var(--muted); font-style: italic; }
.body { white-space: pre-wrap; font-size: var(--t-md); color: var(--ink-2); }

/* ---------- guardrails ---------- */
.policy { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); gap: var(--sp-6); align-items: start; }
@media (max-width: 960px) { .policy { grid-template-columns: 1fr; } }
.rule { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); align-items: center; }
.rule:last-child { border-bottom: 0; }
.name { font-weight: 500; } .rule .desc { color: var(--muted); font-size: var(--t-sm); grid-column: 1; }
.switch { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--line); border: 0; cursor: pointer; grid-column: 2; grid-row: 1 / span 2; justify-self: end; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: left .2s var(--ease-out); }
.switch[aria-checked="true"] { background: var(--critical); } .switch[aria-checked="true"]::after { left: 19px; background: var(--surface); }
pre { margin: 0; background: var(--code-bg); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); font-family: var(--mono); font-size: var(--t-xs); line-height: 1.6; overflow-x: auto; color: var(--ink-2); }
textarea { width: 100%; font-family: var(--mono); font-size: var(--t-xs); line-height: 1.6; background: var(--surface-2); }
input#propose-note { width: 100%; }
.policy-mode { margin-bottom: var(--sp-3); }
#policy-form { display: grid; gap: var(--sp-5); margin-bottom: var(--sp-4); }
#policy-form[hidden] { display: none; }
.policy-field { min-width: 0; display: grid; gap: 5px; padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.policy-field-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px var(--sp-2); }
.policy-field > summary { cursor: pointer; }
.policy-field > summary::before { content: '▸'; color: var(--accent); margin-right: var(--sp-2); }
.policy-field[open] > summary::before { content: '▾'; }
.policy-field-meta { color: var(--muted); font-size: var(--t-xs); }
.policy-help { margin: 0 0 2px; max-width: 58ch; }
.policy-field > input:not([type="checkbox"]), .policy-field > select, .policy-map-entry > input { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 7px 12px; }
.policy-field > input[type="checkbox"] { justify-self: start; width: 20px; height: 20px; accent-color: var(--accent); }
.policy-field [aria-invalid="true"] { border-color: var(--critical); }
.policy-object { display: grid; gap: var(--sp-3); padding: 0 0 var(--sp-2) var(--sp-3); }
.policy-entry { display: flex; align-items: end; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.policy-entry > .policy-field { flex: 1; }
.policy-entry > .policy-remove { flex: 0 0 auto; margin-bottom: 2px; }
.policy-map-entry { flex-wrap: wrap; }
.policy-map-entry > input { flex: 1 1 130px; }
.policy-map-entry > .policy-field { flex: 2 1 160px; }
.policy-errors { color: var(--critical); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-6); border: 1px solid var(--critical); border-radius: var(--radius-sm); }
#policy-yaml-editor { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
#policy-yaml-editor[hidden] { display: none; }
#propose-note { margin: var(--sp-2) 0 var(--sp-4); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.history li:last-child { border-bottom: 0; }
.history time { color: var(--muted); min-width: 82px; }
.proposal { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.proposal:last-child { border-bottom: 0; }

/* ---------- audit ---------- */
.audit td:first-child { font-size: var(--t-xs); white-space: nowrap; color: var(--muted); }
.audit td { font-size: var(--t-sm); }

@media (prefers-reduced-motion: reduce) {
  .view, .figure { animation: none; }
  .switch::after, .meter > i, .chip, .btn, nav.tabs a { transition: none; }
}

/* ---------- settings ----------
   One question per section, read top to bottom: a quiet rail on the left, one
   section at a time on the right. Hairlines and spacing carry the structure;
   the ember accent is spent only on the current section and the one action a
   row needs. */
.settings { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: var(--sp-12); align-items: start; }
.settings-rail { position: sticky; top: var(--sp-6); display: flex; flex-direction: column; gap: 2px; }
.settings-rail { padding-top: 6px; }
.settings-rail a { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 7px 10px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: var(--t-sm); transition: color .15s, background .15s; }
.settings-rail a:hover { color: var(--ink-2); background: var(--surface); }
.settings-rail a[aria-current="page"] { color: var(--ink); background: var(--surface); }
.settings-rail a[aria-current="page"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: -2px; order: -1; }
.settings-rail a[aria-current="page"] { justify-content: flex-start; }
.settings-rail a[aria-current="page"] .count { margin-left: auto; }
.settings-rail .count, nav.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-xs); font-weight: 600; text-align: center; line-height: 1.6; }
.settings-body { min-width: 0; max-width: 780px; }
.settings-section { display: flex; flex-direction: column; gap: var(--sp-6); }
.section-head { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-2); }
.section-head h3 { font-size: var(--t-2xl); line-height: 1.15; }
.lede { margin: 0; color: var(--ink-2); max-width: 62ch; line-height: 1.6; }
.aside { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.aside a, .held a { color: var(--accent-ink); }
.mono { font-family: var(--mono); font-size: var(--t-xs); color: var(--ink-2); overflow-wrap: anywhere; }
.btn.quiet { border-color: transparent; background: transparent; padding-left: 8px; padding-right: 8px; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); border-color: transparent; background: var(--surface); }
.btn.quiet.danger { color: var(--critical); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* Needs you */
.attention { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.attention .item, .attention .calm { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-4); align-items: center; padding: var(--sp-4) 0; border-bottom: 1px solid var(--line); }
.attention .dot, .state .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.attention .item.warn { color: var(--serious); } .attention .item.deny { color: var(--critical); }
.item-text { color: var(--ink); font-weight: 500; }
.attention .sub { margin: 2px 0 0; }
.attention .calm { grid-template-columns: 40px minmax(0, 1fr); padding: var(--sp-8) 0; }
.calm-mark { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--good-text); position: relative; }
.calm-mark::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--good-text); }
.attention .calm .item-text { font-family: var(--display); font-style: italic; font-size: var(--t-xl); font-weight: 400; }

/* Publishing */
.bot { margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; color: var(--ink-2); font-size: var(--t-sm); }
/* A sentence with a setting name inside it flows as text, not as flex items. */
.bot.prose { display: block; }
.bot code { font-family: var(--mono); font-size: var(--t-xs); padding: 1px 6px; border-radius: 4px; background: var(--code-bg); color: var(--ink); }
.destinations { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.destination { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6) 0; border-bottom: 1px solid var(--line); }
.dest-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.dest-head h4 { margin: 0; font-family: var(--display); font-style: italic; font-weight: 400; font-size: var(--t-xl); line-height: 1.2; color: var(--ink); }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-sm); font-weight: 600; white-space: nowrap; }
.state.ok { color: var(--good-text); } .state.warn { color: var(--serious); } .state.deny { color: var(--critical); }
.dest-text { margin: 0; color: var(--ink-2); font-size: var(--t-sm); }
.facts { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 6px var(--sp-4); margin: 0; font-size: var(--t-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink-2); }
.facts .public { color: var(--critical); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding-top: var(--sp-1); }
.drawer { padding: var(--sp-4); background: var(--surface); border-radius: var(--radius-sm); }
.token-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.token-form input { flex: 1 1 200px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--ground); padding: 7px 12px; color: var(--ink); }
.token-form .sub { flex-basis: 100%; margin: 0; }
.projects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.projects li { display: flex; align-items: center; gap: var(--sp-3); padding: 6px 0; border-top: 1px solid var(--grid); }
.projects li .sub { margin: 0; flex: 1; }

/* Client names */
.held { margin: 0; padding: var(--sp-4); background: var(--surface); border-radius: var(--radius-sm); color: var(--ink); }
.name-group { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.name-group h4 { margin: 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.names { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.names li { padding: 3px 10px; border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: var(--t-sm); border: 1px solid var(--line); }
.names.client li { color: var(--ink); border-color: var(--edge-2); }
.names.open li { border-style: dashed; color: var(--muted); }

/* Rules */
.rules { display: grid; grid-template-columns: minmax(180px, 34%) minmax(0, 1fr); margin: 0; border-top: 1px solid var(--line); }
.rules dt, .rules dd { padding: var(--sp-4) 0; border-bottom: 1px solid var(--line); margin: 0; }
.rules dt { color: var(--ink); font-weight: 500; padding-right: var(--sp-4); display: flex; flex-direction: column; gap: 2px; }
.rules dt code { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); font-weight: 400; }
.rules dd { color: var(--ink-2); overflow-wrap: anywhere; }
.editor { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6); background: var(--surface); border-radius: var(--radius); }
.editor input#propose-note { width: 100%; }
details.file, details.more { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
details.file summary, details.more summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); }
details.file summary:hover, details.more summary:hover { color: var(--ink-2); }
details.file pre { margin-top: var(--sp-3); max-height: 60vh; overflow: auto; }

/* Pause and maintenance */
.toggle { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-4); align-items: center; padding: var(--sp-4) 0; border-bottom: 1px solid var(--line); }
.toggle .switch { grid-column: 2; grid-row: 1; }
#pause-all .toggle { border-top: 1px solid var(--line); padding: var(--sp-6) 0; }
#pause-all .name { font-family: var(--display); font-size: var(--t-xl); font-weight: 400; }
details.more > div { padding-top: var(--sp-2); }
.maintenance { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-6); padding-top: var(--sp-6); border-top: 1px solid var(--line); }
.maintenance .sub { margin-top: 2px; }

/* History */
.history-head { padding-top: var(--sp-4); border-top: 1px solid var(--line); flex-wrap: wrap; gap: var(--sp-3); }
.history-head h4 { margin: 0; font-size: var(--t-md); font-weight: 600; }
article.proposal { padding: var(--sp-4); background: var(--surface); border-radius: var(--radius-sm); border-bottom: 0; }

@media (max-width: 860px) {
  .settings { grid-template-columns: 1fr; gap: var(--sp-6); }
  .settings-rail { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: var(--sp-1); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line); }
  .settings-rail h2 { display: none; }
  .settings-rail a { white-space: nowrap; }
  .rules { grid-template-columns: 1fr; }
  .rules dt { border-bottom: 0; padding-bottom: 0; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: var(--sp-2); }
}
@media (prefers-reduced-motion: reduce) { .settings-rail a { transition: none; } }

#settings-history .audit td { vertical-align: top; }
#settings-history .audit td:first-child, #settings-history .audit .who { white-space: nowrap; }
#settings-history .audit .detail { color: var(--muted); max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pause-all .toggle { border-bottom: 0; }
.name-group { padding-bottom: var(--sp-2); }

/* The rule editor: group titles read left to right, the arrow beside them. */
.policy-field > summary.policy-field-heading { justify-content: flex-start; }
.policy-field > summary.policy-field-heading .name { flex: 1; text-align: left; font-weight: 500; }
.policy-field > summary .policy-field-meta:empty { display: none; }
.policy-version { margin: 0; }
.policy-advanced { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.policy-advanced > summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); }
.policy-advanced[open] > summary { margin-bottom: var(--sp-2); }

/* ---------- publication flow and merge request preview ---------- */
.flow { list-style: none; margin: 0 0 var(--sp-6); padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-4); counter-reset: none; }
.flow-step { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--sp-2); align-items: start; padding-top: var(--sp-3); border-top: 2px solid var(--line); color: var(--muted); }
.flow-n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--edge-2); display: inline-flex; align-items: center; justify-content: center; font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.flow-title { color: var(--ink); font-weight: 500; font-size: var(--t-sm); display: flex; gap: 6px; align-items: center; }
.flow-step .sub { font-size: var(--t-xs); margin-top: 2px; }
.flow-step .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: var(--t-xs); text-align: center; line-height: 1.6; }
.flow-step.done { border-top-color: var(--good-text); }
.flow-step.done .flow-n { background: var(--good-text); border-color: var(--good-text); color: var(--surface); }
.flow-step.here { border-top-color: var(--accent); }
.flow-step.here .flow-n { border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.flow-step.here .flow-title { color: var(--accent-ink); }
.mr-slot { margin-top: var(--sp-3); }
.mr-toggle { padding-left: 0; }
.mr-toggle::after { content: " \25be"; }
.mr-toggle[aria-expanded="true"]::after { content: " \25b4"; }
.mr { display: flex; flex-direction: column; gap: var(--sp-6); padding: var(--sp-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mr .flow { margin: 0; }
.mr-head { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--line); }
.mr-title { font-family: var(--display); font-size: var(--t-xl); line-height: 1.25; color: var(--ink); }
.mr-branches { color: var(--ink-2); font-size: var(--t-sm); line-height: 1.7; }
.mr-branches code, .diff-file code { font-family: var(--mono); font-size: var(--t-xs); padding: 1px 6px; border-radius: 4px; background: var(--code-bg); color: var(--ink); overflow-wrap: anywhere; }
.mr-branches a { color: var(--accent-ink); }
.mr h5 { margin: 0 0 var(--sp-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink); display: flex; gap: var(--sp-2); align-items: baseline; flex-wrap: wrap; }
.mr h5 .sub { margin: 0; font-weight: 400; }
.mr-text { white-space: pre-wrap; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.6; max-width: 72ch; }
.diff { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--ground); }
.diff-file { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.diff-lines { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.78rem; line-height: 1.55; }
.diff-lines td { padding: 0 var(--sp-2); border: 0; vertical-align: top; }
.diff-lines tr { background: color-mix(in oklch, var(--good-text) 9%, transparent); }
.diff-lines .ln { width: 1%; color: var(--muted); text-align: right; user-select: none; white-space: nowrap; }
.diff-lines .sign { width: 1%; color: var(--good-text); user-select: none; }
.diff-lines .code { white-space: pre-wrap; color: var(--ink); overflow-wrap: anywhere; }
.mr-sources ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mr-sources li { display: flex; gap: var(--sp-3); align-items: baseline; font-size: var(--t-sm); }
.mr-sources a { color: var(--ink); }
.mr-sources .sub { margin: 0; }

/* Client names asked one by one */
.ask { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ask li { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--grid); }
.ask-name { flex: 1; font-family: var(--display); font-style: italic; font-size: var(--t-lg); color: var(--ink); }

@media (max-width: 860px) {
  .flow { grid-template-columns: 1fr; gap: 0; }
  .flow-step { border-top: 0; border-left: 0; padding: var(--sp-2) 0; }
  .mr { padding: var(--sp-4); }
}
/* The main tabs scroll sideways on a phone, with a fade that says so. */
@media (max-width: 640px) {
  nav.tabs { scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); scroll-snap-type: x proximity; }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs a { padding: var(--sp-3) var(--sp-3); scroll-snap-align: start; }
  .ask li { flex-wrap: wrap; }
  .ask-name { flex-basis: 100%; }
}

#pub-table tr.mr-row > td { padding: 0 0 var(--sp-6); border-bottom: 0; }
.diff-more { margin: var(--sp-2); }
.mr, .mr-row td { font-variant-numeric: normal; }
.diff-lines .ln, .flow-n { font-variant-numeric: tabular-nums; }
#settings-history .audit td:first-child { font-variant-numeric: normal; }

/* Loading: a thin bar across the top while a request is out, and a quiet
   placeholder the first time a view loads, so a slow answer never reads as
   an empty page. */
.busy { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 3px; z-index: 60; overflow: hidden; pointer-events: none; }
.busy::after { content: ""; position: absolute; inset: 0; width: 38%; background: var(--accent); border-radius: 0 2px 2px 0; animation: busy 1.1s cubic-bezier(.65, 0, .35, 1) infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(270%); } }
/* Out of the flow, so the top bar and tabs keep their place while it shows. */
.boot { position: fixed; inset: 0; margin: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.view.loading { position: relative; min-height: 40vh; }
.view.loading > * { opacity: .3; transition: opacity .2s ease-out; }
.view.loading::after { content: "Loading…"; position: absolute; top: 96px; left: 50%; transform: translateX(-50%); color: var(--muted); letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) { .busy::after { animation: none; width: 100%; opacity: .6; } }

/* An update's diff: context stays plain, additions and removals are tinted. */
.diff-lines.hunks tr { background: transparent; }
.diff-lines.hunks tr.add { background: color-mix(in oklch, var(--good-text) 9%, transparent); }
.diff-lines.hunks tr.del { background: color-mix(in oklch, var(--critical) 12%, transparent); }
.diff-lines.hunks tr.del .sign { color: var(--critical); }
.diff-lines.hunks tr:not(.add):not(.del) .sign { color: var(--muted); }
.diff-lines.hunks tr.fold td { padding-block: var(--sp-1); color: var(--muted); font-style: italic; }

/* Deciding a waiting publication from its row. */
.pub-decide { gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
