/* Manifold console.
 *
 * One stylesheet, no build step, embedded in the binary (ADR-0005). The rules of
 * the design, so the next change does not relitigate them:
 *
 *  - Monochrome. Greys do all the work and white is the only accent. Colour
 *    appears where it *is* the information — a status dot, a failing delivery, the
 *    mode badge — and nowhere else.
 *  - Flat. A surface is a fill and a hairline. No gradients, glows or grid
 *    backgrounds: decoration competes with the one red thing an operator is
 *    looking for.
 *  - Type carries hierarchy. One sans, one mono, tabular numerals for anything
 *    counted, and upper-case micro-labels only where the text *is* a label.
 *  - Every layout rule is enhancement. The page is a plain document with
 *    JavaScript off; a script may add a preview or a generated secret, never a
 *    control the form depends on.
 */

:root {
  color-scheme: dark;

  /* surfaces, darkest to lightest */
  --bg: #09090b;
  --panel: #0e0e10;
  --panel-2: #121214;
  --raised: #17171a;
  --hover: #1e1e22;

  /* hairlines */
  --line: #232327;
  --line-soft: #18181b;
  --line-strong: #333338;

  /* text */
  --fg: #fafafa;
  --fg-2: #c9c9cf;
  --muted: #8e8e96;
  --faint: #5e5e66;

  /* the accent is white; these are the only saturated values on the page */
  --accent: #fafafa;
  --accent-ink: #09090b;
  --accent-hover: #e4e4e8;
  --ok: #3fcf8e;
  --warn: #e6ad45;
  --err: #f0616d;

  --radius: 10px;
  --radius-sm: 6px;
  --gap: 20px;
  --side-w: 232px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 13.5px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 10;
  font-weight: 600;
}
.skip:focus { left: 0; }

/* ─────────────────────────────── shell ────────────────────────────────── */

/* Two columns: a fixed sidebar that owns navigation and the two primary actions,
 * and a content column. The sidebar is the reason the console reads as an
 * application rather than a page: where you are, and what you can do from here,
 * are the same two questions at every URL. */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px 16px;
  border-right: 1px solid var(--line-soft);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--fg);
  padding: 0 6px;
  min-width: 0;
}
.brand-mark {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
  border-radius: 5px;
}
.brand-name {
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 14.5px;
}

.mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  margin: 0 6px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
  padding: 4px 9px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  white-space: nowrap;
}
.mode .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.mode-durable { color: var(--fg-2); }
.mode-durable .dot { background: var(--ok); }
.mode-volatile { color: var(--fg-2); }
.mode-volatile .dot { background: var(--warn); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 100ms ease, background 100ms ease;
}
.nav-item:hover { color: var(--fg); background: var(--panel-2); }
.nav-item.is-current { color: var(--fg); background: var(--panel-2); }
.nav-icon { width: 15px; height: 15px; flex: none; color: var(--faint); }
.nav-item.is-current .nav-icon { color: var(--fg-2); }

.side-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.side-actions .btn { justify-content: center; }

.side-foot {
  margin-top: auto;
  padding: 0 6px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}

.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 36px 56px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
}
/* Flex items default to a content-sized minimum, so one long ingest path would push
 * the whole page wider than the viewport instead of scrolling inside its own panel. */
main > * { min-width: 0; }

footer {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 36px 32px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 11.5px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: baseline;
}
.foot-note::before { content: "· "; }

/* ─────────────────────────────── flashes ─────────────────────────────── */

.flash {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-2);
}
.flash-mark {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--muted);
}
.flash-ok .flash-mark { background: var(--ok); }
.flash-error { border-color: color-mix(in srgb, var(--err) 40%, transparent); color: var(--fg); }
.flash-error .flash-mark { background: var(--err); }

/* ───────────────────────────── page head ─────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.page-sub { margin: 5px 0 0; color: var(--muted); font-size: 13px; max-width: 64ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}
.crumb:hover { color: var(--fg); }

/* ─────────────────────────────── stats ───────────────────────────────── */

/* The four numbers an operator checks first, as one strip rather than four chips that
 * wrap: the counts are read against each other, so they belong on one line. */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.stat { padding: 14px 16px 13px; border-right: 1px solid var(--line-soft); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.stat-label {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─────────────────────────────── cards ───────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-sub { margin: 2px 0 0; color: var(--faint); font-size: 12px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; align-items: center; }

.count-pill {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 3px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The stage a card belongs to in the pipeline's own numbering: a label on a diagram
 * section, small and monospaced, not a heading. */
.stage-index {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--faint);
  white-space: nowrap;
}

.empty { color: var(--muted); margin: 0; padding: 22px 18px; font-size: 13px; }

/* An empty stream is the first screen a new instance shows, so it explains the product
 * rather than reporting an absence. */
.empty-stream { margin: 14px 18px 18px; padding: 18px 20px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.empty-stream-title { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--fg); }
.empty-stream-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; max-width: 74ch; }

/* ─────────────────────────── getting started ─────────────────────────── */

.onboard h2 { margin: 0; font-size: 14px; font-weight: 600; }
.onboard-sub { margin: 4px 0 16px; color: var(--muted); font-size: 12.5px; }
.onboard { padding: 18px 20px 20px; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  position: relative;
}
.step-done { border-style: dashed; }
.step-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
}
.step-done .step-num { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }
.step h3 { margin: 1px 0 3px; font-size: 13px; font-weight: 600; }
.step p { margin: 0 0 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.step-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--faint);
}

/* ─────────────────────────── wiring diagram ──────────────────────────── */

.canvas { padding: 12px 16px 16px; }
.graph { display: block; width: 100%; height: auto; overflow: visible; }
.graph-wide { display: block; }
.graph-tall { display: none; }

/* Monochrome on purpose: the diagram answers "what is wired to what", and a wire is
 * either carrying or not. A per-source palette made that a second question. */
.gnode .box { fill: var(--panel-2); stroke: var(--line-strong); stroke-width: 1; }
.gnode-provider .box { fill: var(--raised); }
.gnode-hub .box { fill: var(--panel); stroke: var(--fg); stroke-width: 1.2; }
.gnode.is-off .box { stroke-dasharray: 3 3; fill: var(--panel); }
.gnode.is-off { opacity: 0.55; }

.gnode .mark { fill: var(--panel); stroke: var(--line); stroke-width: 1; }
.gnode-provider .mark { fill: var(--panel); stroke: var(--line-strong); }
.mark-glyph, .gnode-mark { fill: var(--fg-2); stroke: var(--fg-2); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.gnode-integration .gnode-mark { fill: none; }

.gnode .node-name { fill: var(--fg); font-size: 11.5px; font-weight: 600; font-family: var(--sans); }
.gnode .node-sub { fill: var(--faint); font-size: 9.5px; font-family: var(--mono); letter-spacing: 0.01em; }

.gnode-hub .hub-mark path { stroke: var(--fg); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.gnode-hub .hub-mark circle { fill: var(--fg); }
.gnode-hub .hub-name { fill: var(--fg); font-size: 13px; font-weight: 650; font-family: var(--mono); letter-spacing: 0.01em; }
.gnode-hub .hub-sub { fill: var(--fg-2); font-size: 9.5px; font-family: var(--mono); }

/* The four things the relay does to an event, drawn inside its box: a process, not
 * four statuses, so they are the plainest thing on the page. */
.engine-step rect { fill: var(--raised); stroke: var(--line); stroke-width: 0.9; }
.engine-step text { fill: var(--fg-2); font-family: var(--mono); font-size: 8.5px; font-weight: 550; letter-spacing: 0.01em; }

/* An edge: a curve with an arrowhead at the receiving end so direction is never a
 * guess. Carrying: light. Off: dashed and faint. */
.gedge {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-opacity: 0.75;
  stroke-linecap: round;
  transition: stroke-opacity 140ms ease, stroke-width 140ms ease;
}
.gedge.is-off { stroke: var(--line-strong); stroke-dasharray: 4 3; stroke-opacity: 1; }
.gedge:hover { stroke-opacity: 1; stroke-width: 2; stroke: var(--fg); }
.gedge + .gedge { pointer-events: none; }
.head { fill: var(--muted); }
.head.off { fill: var(--line-strong); }
.edge-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}

.legend { display: inline-flex; gap: 14px; align-items: center; font-size: 11.5px; color: var(--muted); }
.legend-item { display: inline-flex; gap: 6px; align-items: center; }
.swatch { width: 16px; height: 0; border-top: 2px solid var(--muted); display: inline-block; }
.swatch-off { border-top-style: dashed; border-color: var(--line-strong); }

/* ──────────────────────────── routing matrix ──────────────────────────── */

.matrix th, .matrix td { vertical-align: middle; }
.matrix-col {
  text-align: center !important;
  font-family: var(--sans);
  font-size: 11.5px !important;
  letter-spacing: 0;
  text-transform: none !important;
  color: var(--fg-2) !important;
  border-left: 1px solid var(--line-soft);
  min-width: 96px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matrix-row {
  text-align: left;
  font-weight: 400;
  padding: 12px 18px;
  background: transparent !important;
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--fg);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.matrix-row .chip { margin-left: 8px; }
.matrix-cell { text-align: center; border-left: 1px solid var(--line-soft); padding: 10px; }
.matrix tbody tr:hover .matrix-cell { background: var(--panel-2); }

.cell-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  vertical-align: middle;
}
.cell-dot.on { background: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 14%, transparent); }

/* ─────────────────────────────── tables ──────────────────────────────── */

.table-wrap { overflow-x: auto; }
/* A count that is also a column of the matrix below does not need a table cell of its own on a
 * phone, where it is the label the row was padded for. */
@media (max-width: 1280px) {
  .col-optional { display: none; }
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  background: var(--panel-2);
}

td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
/* The first and last cells get the card's own inset, so a row reads as one line across the
 * panel instead of floating inside it. */
td:first-child, th:first-child { padding-left: 18px; }
td:last-child, th:last-child { padding-right: 18px; }

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 100ms ease; }
tbody tr:hover { background: var(--panel-2); }
tr.is-off td { color: var(--muted); }
tr.is-off td .strong { color: var(--muted); }

/* A label is a name, not a paragraph: wrapping it to two lines makes a table row twice as
 * tall as its neighbours and reads as four ragged rows instead of one column. */
td.strong { white-space: nowrap; }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.actions, td.actions { white-space: nowrap; text-align: right; }
td.actions .inline, td.actions .rotate { flex: none; }
.action-row { gap: 6px; }

.strong { font-weight: 550; color: var(--fg); }
.dim { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; color: var(--fg-2); }
td.mono { white-space: nowrap; }
.trunc { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A webhook URL is long and its whole job is being read and copied, so it gets as much room as
 * the row can spare. Truncation is the last resort: the full value is in `data-copy` and the
 * cell's `title`, so a cut URL is still one click from correct rather than a typo waiting to
 * happen. 34ch clears the common `https://host/ingest/<uuid>` at the table's mono size. */
td .copy-row code { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
/* The table's own mono runs a touch smaller than the page's, which is what buys the extra
 * characters: a URL is scanned, not read. */
td .copy-row code.mono { font-size: 11.5px; }
/* The cell that holds it may grow; every other column is content-sized, so the URL takes the
 * slack instead of being the thing that gives way. */
td:has(.copy-row) { width: 100%; }
td .copy-row { max-width: 100%; }

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--fg-2);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.copy-row { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
td .copy-row code { overflow: hidden; text-overflow: ellipsis; }
.hint { color: var(--faint); font-size: 12px; margin: 0; padding: 10px 18px; }

/* ───────────────────────── pills, chips, dots ───────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-2);
  white-space: nowrap;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); flex: none; }
.pill-ok .dot { background: var(--ok); }
.pill-off { color: var(--muted); }
/* A failing delivery is the one thing on the page that must beat every other pixel to
 * the operator's eye, so it is the one place colour is allowed to be loud. */
.pill-err {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: color-mix(in srgb, var(--err) 10%, transparent);
}
.pill-err .dot { background: var(--err); }
tr.has-error td { background: color-mix(in srgb, var(--err) 5%, transparent); }
tr.has-error:hover td { background: color-mix(in srgb, var(--err) 9%, transparent); }

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  background: var(--raised);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ────────────────────────────── controls ─────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--fg-2);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}
.btn:hover { color: var(--fg); border-color: var(--line-strong); background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}
.btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); border-color: transparent; background: var(--hover); }
.btn-ghost.copied { color: var(--ok); }
.btn-sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn-lg { height: 34px; padding: 0 14px; font-size: 13px; }

.input, input, select {
  font: inherit;
  font-size: 13.5px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 34px;
  min-width: 0;
  width: 100%;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.input:hover, input:hover, select:hover { border-color: var(--line-strong); }
.input:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--fg-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 10%, transparent);
}
input::placeholder { color: var(--faint); }
input[type="radio"] { width: auto; height: auto; accent-color: var(--fg); }

form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.action-row { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }

/* Rotation needs a secret typed into it, so it is a disclosure rather than a permanent
 * password field hanging off every row. The form is in the HTML and works with
 * JavaScript off. */
.rotate { display: inline-block; text-align: left; }
.rotate summary {
  list-style: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--fg-2);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}
.rotate summary::-webkit-details-marker { display: none; }
.rotate summary:hover { color: var(--fg); border-color: var(--line-strong); background: var(--hover); }
.rotate[open] summary { color: var(--fg); border-color: var(--fg-2); }
.rotate-form { margin-top: 6px; flex-wrap: wrap; }
.rotate-form input { width: 14rem; max-width: 100%; height: 28px; font-size: 12.5px; }
.rotate-form .btn { height: 28px; }

/* ─────────────────────────── setup pages ─────────────────────────────── */

/* A creation page is a form on the left and the context that makes its fields
 * meaningful on the right: what the provider verifies with, what the receiver will
 * see, what to do afterwards. The aside is sticky because it is read *while* filling
 * the form, not before. */
.setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: var(--gap);
  align-items: start;
}
.setup-form { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.setup-aside { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.step-index {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--fg);
}
/* A card header that carries a step number: a two-column grid, so the number never wraps
 * away from the title it belongs to. Flex with `wrap` did exactly that as soon as the
 * subtitle was long enough to need the whole row. */
.card-head:has(.step-index) {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}
.card-head .step-index { margin-top: 1px; }

/* A code sample is a fixed-width block that scrolls sideways rather than wrapping: a wrapped
 * `crypto.timingSafeEqual` line is not runnable, and copying it is what the block is for. */
.sample { max-width: 100%; }
.sample code { white-space: pre; }

.providers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 18px 18px; }
.provider-card {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
}
.provider-card:hover { border-color: var(--line-strong); background: var(--raised); }
.provider-card:has(input:checked) { border-color: var(--fg); background: var(--raised); }
.provider-radio { position: absolute; top: 11px; right: 10px; width: 14px; height: 14px; margin: 0; }
.provider-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
}
.provider-mark .logo { display: grid; place-items: center; }
.provider-mark .logo svg { width: 15px; height: 15px; fill: var(--fg-2); }
.provider-name { display: block; font-size: 13px; font-weight: 600; color: var(--fg); line-height: 1.3; }
.provider-scheme {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; padding: 16px 18px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; font-weight: 550; color: var(--fg-2); }
.field-help { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.field-help a, .aside-card a, .page-sub a { color: var(--fg-2); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.field-help a:hover, .aside-card a:hover, .page-sub a:hover { color: var(--fg); border-color: var(--fg-2); }
.secret-row { display: flex; gap: 8px; }
.secret-row .input { flex: 1 1 auto; }
.secret-row .btn { flex: none; }
.input.mono { font-family: var(--mono); font-size: 12.5px; }

.preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 4px 4px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.preview code { background: transparent; border: 0; padding: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.preview.is-live { border-style: solid; border-color: var(--line-strong); }
.preview .btn { flex: none; }

.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 18px 18px; }
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
}
.choice-card:hover { border-color: var(--line-strong); background: var(--raised); }
.choice-card:has(input:checked) { border-color: var(--fg); background: var(--raised); }
.choice-radio { position: absolute; top: 11px; right: 10px; width: 14px; height: 14px; margin: 0; }
.choice-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.choice-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.setup-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.setup-foot-note { font-size: 12px; color: var(--faint); }

.aside-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.aside-card h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}
.kv { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.kv dt { font-size: 11.5px; color: var(--faint); }
.kv dd { margin: 0; font-size: 12.5px; color: var(--fg-2); line-height: 1.45; word-break: break-word; }
.aside-card .link { font-size: 12.5px; }

.steps-ol { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.steps-ol li { position: relative; padding-left: 28px; font-size: 12.5px; color: var(--fg-2); line-height: 1.5; counter-increment: step; }
.steps-ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}
.steps-ol li code { font-size: 11px; padding: 1px 5px; }

.sample {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--fg-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}
.sample .h { color: var(--faint); }
.sample .k { color: var(--fg); }
.sample .v { color: var(--muted); }

/* ───────────────────────── test-send verdict ─────────────────────────── */

/* The answer to "would this work", as one sentence. Colour is information here and nowhere
 * else on the page: green means a delivery was accepted, and the block is the loudest thing
 * on the screen because it is the whole point of the visit. */
.verdict {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.verdict-mark {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--muted);
}
.verdict-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.verdict-ok .verdict-mark { background: var(--ok); }
.verdict-bad { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.verdict-bad .verdict-mark { background: var(--err); }
.verdict-line { margin: 0; font-size: 14px; font-weight: 600; color: var(--fg); line-height: 1.4; }
.verdict-next { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; max-width: 78ch; }

/* A two-column key/value row inside a table, for the evidence list. */
.kv-label {
  width: 1%;
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 18px;
}

/* ────────────────────── provider setup guide ─────────────────────── */

/* The handshake at the provider, in order. A numbered list with the "where" as a label
 * above the "what": an operator reads it with the provider's own dashboard open in another
 * tab, so the destination has to be findable at a glance and the action has to be the
 * longest thing in the row. */
.guide { margin: 0; padding: 4px 18px 18px; list-style: none; counter-reset: guide; display: flex; flex-direction: column; gap: 2px; }
.guide-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
  counter-increment: guide;
}
.guide-step:first-child { border-top: 0; }
.guide-step::before {
  content: counter(guide);
  grid-row: span 2;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}
.guide-where { font-size: 12px; font-weight: 600; color: var(--fg); line-height: 1.4; }
.guide-action { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.guide-action code { font-size: 11px; }
.guide-note {
  margin: 0;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}
.guide-note strong {
  display: inline-block;
  margin-right: 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

/* Per-provider help blocks are all in the HTML and CSS shows the one whose radio is
 * checked. The rule is generated per descriptor, so a new provider needs no stylesheet
 * change; without `:has()` every block shows, which is ugly and still correct. */
[data-provider-field] { display: flex; flex-direction: column; }
@supports selector(:has(*)) {
  [data-provider-field] { display: none; }
}
.field-help.flush { margin: 0; }
.link-row { margin: 10px 0 0; }
.btn-icon { width: 13px; height: 13px; flex: none; color: currentColor; }
.btn-icon + .long, .btn-icon + span { margin-left: 0; }

/* ────────────────────────────── responsive ───────────────────────────── */

/* Three breakpoints: the setup page loses its aside, the shell loses its sidebar, the
 * forms and the tables go single-column. Between them the layout is fluid. */

@media (max-width: 1100px) {
  .setup { grid-template-columns: minmax(0, 1fr); }
  .setup-aside { position: static; }
}

@media (max-width: 780px) {
  .graph-wide { display: none; }
  .graph-tall { display: block; }
  .canvas { padding: 10px 10px 12px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    overflow-x: auto;
  }
  .brand { padding: 0; }
  .side-actions { flex-direction: row; padding: 0; margin-left: auto; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-item { padding: 7px 9px; }
  .side-foot { display: none; }
  main { padding: 18px 14px 40px; gap: 16px; }
  footer { padding: 14px 14px 28px; }
  .card-head, .disclosure summary { padding-inline: 14px; }
  .hint, .empty { padding-inline: 14px; }
  .canvas { padding: 14px; }
  .providers, .choice, .fields { grid-template-columns: minmax(0, 1fr); }
  /* The sidebar becomes a bar. The four destinations keep their labels — they are the
   * primary navigation and an unlabelled icon is a guess — while the two create actions
   * become icons, because their labels are the longest thing on the row and their meaning is
   * carried by the `aria-label` and the screen they lead to. */
  .side-actions .btn .long { display: none; }
  .side-actions .btn { width: 32px; height: 32px; padding: 0; }
  .mode { align-self: center; padding: 3px 8px 3px 7px; font-size: 11px; }
  td:first-child, th:first-child { padding-left: 12px; }
  td:last-child, th:last-child { padding-right: 12px; }
  td .copy-row code { max-width: none; }

  /* Tables stop being tables. Each row becomes a labelled card, and the labels come
   * from the `data-label` on the cell rather than a duplicated header — one DOM, one
   * accessibility tree, two layouts. */
  .table-wrap { overflow: visible; }
  .table-wrap.scroll { overflow-x: auto; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  table { border-collapse: separate; }
  tbody tr { margin: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); overflow: hidden; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover, tr.has-error:hover td { background: var(--panel-2); }
  td, td.num {
    display: flex;
    align-items: baseline;
    gap: 12px;
    justify-content: space-between;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-soft);
    white-space: normal;
  }
  td::before {
    content: attr(data-label);
    flex: none;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--faint);
    padding-top: 1px;
  }
  td:not([data-label]) { justify-content: flex-end; }
  td:not([data-label])::before { content: none; }
  td.actions { display: block; padding: 10px 12px; }
  td.actions::before { content: none; }
  .action-row { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .action-row > *, .rotate, .rotate summary { flex: 1 1 auto; }
  .rotate[open] { flex-basis: 100%; }
  .rotate summary { text-align: center; }
  .rotate-form { width: 100%; }
  .rotate-form input { flex: 1 1 8rem; width: auto; }
  .action-row { justify-content: flex-start; }
  td .copy-row { min-width: 0; }
  td code { white-space: normal; word-break: break-all; }
  td.mono.trunc { max-width: none; }
  .trunc { max-width: 100%; }

  .matrix, .matrix thead, .matrix tbody, .matrix tr, .matrix th, .matrix td { display: revert; }
  .matrix thead { display: revert; }
  .matrix { display: table; }
  .matrix tbody tr { display: table-row; margin: 0; border: 0; border-radius: 0; background: transparent; }
  .matrix th, .matrix td { display: table-cell; white-space: nowrap; }
  .matrix td::before, .matrix th::before { content: none; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n + 2) { border-bottom: 1px solid var(--line-soft); }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 20px; }
  .page-head h1 { font-size: 18px; }
  .secret-row { flex-wrap: wrap; }
  .secret-row .input { flex-basis: 100%; }
}

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