/*
 * FoundryAS console — one design system for every console page (PROMPT-209).
 *
 * A control room for governed law, not a SaaS dashboard: calm surfaces, one quiet accent, type that reads like a
 * record. Presentation only. Nothing here hides, reorders or rewords what the Principal reads before an act; state is
 * always TEXT first and colour second (a badge carries its word and a border, so the page survives greyscale, a
 * colour-vision difference and a bad projector). MACHINE OFF is styled as a fact, never as an error, because OFF is
 * the correct state rather than a fault. No green on an approval: an approval is a phase, not a success.
 *
 * Every page links this one file (the CSP is style-src 'self', no inline style). Light and dark follow the device.
 *
 *   tokens      colour (dark, then light), type scale, spacing, radius
 *   base        body, headings, links, code, tables, focus
 *   frame       the brand strip and the page column of every standalone page
 *   controls    labels, inputs, selects, buttons
 *   shell       the Mandate console (header, side nav, cards, panels)
 *   badges      chips, priority, flags, states
 *   views       tree, priority buckets, convergence, detail
 *   act flow    the sections of an act page, the summary, the digest, perform, the result
 *   door        the front door and "not here"
 *   phones      PROMPT-205's phone layout, kept (everything under max-width 900px)
 *   console map PROMPT-223: the top bar on every console page, Home's "Needs you" and tiles, the front door's link
 */

/* ---- tokens ---------------------------------------------------------------------------------------------------- */

:root {
  color-scheme: dark light;

  /* surfaces: graphite, layered by a few percent of light */
  --bg: #0e1113;
  --panel: #151a1d;
  --panel-2: #1b2125;
  --panel-3: #222a2f;
  --line: #2a3238;
  --line-strong: #3a444b;

  /* ink */
  --ink: #e7eaec;
  --ink-dim: #a6afb6;
  --ink-faint: #737e87;

  /* one accent (a cool steel blue) and the meanings */
  --accent: #8ab4d8;
  --accent-ink: #0e1113;
  --accent-soft: rgba(138, 180, 216, 0.12);
  --ok: #6fb48f;
  --boundary: #d4ad5f;           /* withheld, approval, a boundary: amber */
  --boundary-soft: rgba(212, 173, 95, 0.10);
  --fault: #e2806f;
  --fault-soft: rgba(226, 128, 111, 0.10);
  --root: #b9a6e6;
  --off: #d99a57;                 /* MACHINE OFF: a fact, warm, not red */

  /* aliases older rules used (PROMPT-205 follow-up 2: --fg and --dim were never defined) */
  --fg: var(--ink);
  --dim: var(--ink-dim);

  /* type */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Georgia, ui-serif, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --t-xs: 11px;
  --t-sm: 12.5px;
  --t-base: 14.5px;
  --t-md: 16px;
  --t-lg: 19px;
  --t-xl: 24px;
  --t-2xl: 32px;

  /* space, radius, elevation */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r1: 4px; --r2: 8px; --r3: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 1px 2px rgba(0, 0, 0, 0.35);
  --column: 920px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f4f0;               /* paper */
    --panel: #ffffff;
    --panel-2: #f1efea;
    --panel-3: #e9e6df;
    --line: #dedad1;
    --line-strong: #c9c4b8;

    --ink: #1a1e22;
    --ink-dim: #4c5560;
    --ink-faint: #78818a;

    --accent: #2c5d88;
    --accent-ink: #ffffff;
    --accent-soft: rgba(44, 93, 136, 0.08);
    --ok: #2d7650;
    --boundary: #8a6417;
    --boundary-soft: rgba(138, 100, 23, 0.08);
    --fault: #a6402f;
    --fault-soft: rgba(166, 64, 47, 0.07);
    --root: #5e4a9e;
    --off: #9a5614;

    --shadow: 0 1px 2px rgba(28, 26, 20, 0.06);
  }
}

/* ---- base ------------------------------------------------------------------------------------------------------ */

* { box-sizing: border-box; }

/* The hidden attribute always wins: a rule below that sets display (a button, a chip) must never reveal what a page hid. */
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--t-base)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink); text-wrap: balance; }
h1 { font: 500 var(--t-xl)/1.2 var(--serif); letter-spacing: -0.01em; }
h2 { font: 500 var(--t-lg)/1.3 var(--serif); letter-spacing: -0.005em; }
h3 { font: 600 var(--t-md)/1.35 var(--sans); }
h4 { font: 600 var(--t-xs)/1.4 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

code, kbd, samp { font: 0.92em var(--mono); }
pre {
  margin: var(--s3) 0;
  padding: var(--s3) var(--s4);
  max-width: 100%;
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  font: 12px/1.6 var(--mono);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th {
  text-align: left; font: 600 var(--t-xs)/1.4 var(--sans); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line-strong);
}
td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: var(--panel-2); }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }

.loading { padding: var(--s6); color: var(--ink-faint); }
.muted { color: var(--ink-dim); font-size: var(--t-sm); line-height: 1.6; }
.error { margin: var(--s3) 0 0; color: var(--fault); font-size: var(--t-sm); }

/* ---- frame: every standalone page (an act page, health, cells) ------------------------------------------------- */

/* The page column, and above it the brand strip. Drawn by CSS so the pages' own markup is unchanged. */
main.app {
  display: block;
  max-width: var(--column);
  margin: 0 auto;
  padding: var(--s5) var(--s5) var(--s7);
}
main.app::before {
  content: "FoundryAS";
  display: block;
  margin: 0 0 var(--s5);
  padding: 0 0 var(--s3) 22px;
  border-bottom: 1px solid var(--line);
  font: 600 var(--t-sm)/16px var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%) 0 1px / 12px 12px no-repeat,
              linear-gradient(var(--line-strong), var(--line-strong)) 4px 5px / 12px 12px no-repeat;
}
main.app > h1 { margin: 0 0 var(--s2); font-size: var(--t-2xl); }
main.app > h1 + p, main.app > p.lede { margin-top: 0; }
main.app > p { max-width: 70ch; color: var(--ink-dim); }

/* the console shell is a full-width grid, not a column */
#app.app { max-width: none; padding: 0; }
#app.app::before { content: none; }

/* ---- controls -------------------------------------------------------------------------------------------------- */

label { display: block; margin: 0 0 var(--s4); font-size: var(--t-sm); color: var(--ink-dim); }
label span { display: block; margin-bottom: 6px; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; }

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r2);
  font: var(--t-base) var(--sans);
}
select { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: auto; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
legend { padding: 0 6px; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--r2);
  font: 600 var(--t-sm)/1.2 var(--sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 120ms ease, background-color 120ms ease;
}
button:hover:not([disabled]) { filter: brightness(1.08); }
button[disabled] { background: var(--panel-2); color: var(--ink-faint); border-color: var(--line); cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--line-strong); }
button.ghost:hover:not([disabled]) { color: var(--ink); filter: none; background: var(--panel-2); }

.secret {
  margin: var(--s3) 0;
  padding: var(--s3);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  font: 12px/1.7 var(--mono);
  word-break: break-all;
  color: var(--ink);
}

/* ---- auth surfaces --------------------------------------------------------------------------------------------- */

.gate {
  max-width: 440px;
  margin: 12vh auto var(--s6);
  padding: var(--s6);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--shadow);
}
.gate::before {
  content: "FoundryAS";
  display: block;
  margin: 0 0 var(--s5);
  padding-left: 22px;
  font: 600 var(--t-sm)/16px var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%) 0 1px / 12px 12px no-repeat,
              linear-gradient(var(--line-strong), var(--line-strong)) 4px 5px / 12px 12px no-repeat;
}
.gate h1 { margin: 0 0 6px; font-size: var(--t-xl); }
.gate .sub { margin: 0 0 var(--s5); color: var(--ink-dim); font-size: var(--t-sm); }
.gate > button { width: 100%; margin-top: var(--s2); }
.gate .first-factor { display: inline-block; margin-top: var(--s4); font-size: var(--t-sm); }

/* ---- the console shell ----------------------------------------------------------------------------------------- */

.shell { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

header.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s5);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--line);
}
header.top button { min-height: 32px; padding: 6px 12px; background: transparent; color: var(--ink-dim); border-color: var(--line-strong); }
header.top button:hover:not([disabled]) { color: var(--ink); background: var(--panel-2); filter: none; }

.brand { position: relative; padding-left: 22px; font: 600 var(--t-md)/1.2 var(--sans); letter-spacing: -0.01em; }
.brand::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 16px; height: 16px;
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%) 0 0 / 12px 12px no-repeat,
              linear-gradient(var(--line-strong), var(--line-strong)) 4px 4px / 12px 12px no-repeat;
}
.brand small { display: block; margin-top: 1px; font-weight: 400; font-size: var(--t-xs); letter-spacing: 0.02em; color: var(--ink-faint); }
.spacer { flex: 1; }

.body { display: grid; grid-template-columns: 232px minmax(0, 1fr); }

nav.side { padding: var(--s4) var(--s3); border-right: 1px solid var(--line); background: var(--panel); }
nav.side h2 {
  margin: var(--s4) 10px 6px;
  font: 600 10.5px/1.4 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
nav.side h2:first-child { margin-top: 4px; }
nav.side a, nav.side span.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: var(--t-sm);
}
nav.side a em, nav.side span.nav em { font-style: normal; }
nav.side a:hover { background: var(--panel-2); color: var(--ink); }
nav.side a.current { background: var(--accent-soft); color: var(--ink); border-left-color: var(--accent); border-radius: 0 6px 6px 0; }
nav.side span.nav { color: var(--ink-faint); cursor: not-allowed; }
nav.side .tag { font: 9.5px var(--mono); letter-spacing: 0.05em; color: var(--ink-faint); }

main { padding: var(--s5) var(--s6) var(--s7); min-width: 0; }
main h1 { margin: 0 0 4px; font-size: var(--t-2xl); }
main .lede { margin: 0 0 var(--s5); color: var(--ink-dim); font-size: var(--t-base); max-width: 72ch; }

.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card {
  padding: var(--s4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card .k {
  font: 600 10.5px/1.4 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.card .v { margin-top: 8px; font: 500 19px/1.3 var(--mono); letter-spacing: -0.01em; overflow-wrap: break-word; min-width: 0; }
.card .v.off { color: var(--off); }
.card .n { margin-top: 8px; font-size: var(--t-sm); line-height: 1.5; color: var(--ink-dim); }

.panel {
  margin-top: var(--s4);
  padding: var(--s4) var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 var(--s3); font-size: var(--t-md); }
.panel p { margin: 0 0 var(--s2); color: var(--ink-dim); font-size: var(--t-base); }
.panel .src { font: 11.5px var(--mono); color: var(--ink-faint); }

.notimpl {
  display: inline-block;
  padding: 2px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r1);
  font: 10.5px var(--mono);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

@media (max-width: 720px) {
  .body { grid-template-columns: 1fr; }
  nav.side { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---- badges: text first, colour second ------------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font: 11px/1.4 var(--mono);
  color: var(--ink-dim);
  white-space: nowrap;
}
.chip.aal2 { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.chip.off { color: var(--off); border-color: color-mix(in srgb, var(--off) 55%, transparent); }
.chip.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.chip.off::before, .chip.on::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* A priority label is text before it is colour (CC: 'a priority label is text before it is colour'). */
.prio { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 7px;
  border-radius: 3px; border: 1px solid currentColor; }
.p-high { color: var(--fault); }
.p-medium { color: var(--boundary); }
.p-low { color: var(--accent); }
.p-undeclared { color: var(--ink-faint); border-style: dashed; }

/* The elevation flag states a NEGATIVE: authorization is not established. It is deliberately not a success colour, a
   tick, a shield or anything else that could read as approval. */
.flag { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; color: var(--boundary);
  border: 1px dashed currentColor; border-radius: 3px; padding: 2px 6px; }
.warnbox { border: 1px dashed color-mix(in srgb, var(--boundary) 60%, transparent); border-radius: var(--r2); padding: var(--s3); margin-top: var(--s2); background: var(--boundary-soft); }
.warnbox p { margin: 6px 0 0; font-size: var(--t-sm); line-height: 1.55; color: var(--ink-dim); }

.rootbadge { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; color: var(--root);
  border: 1px solid color-mix(in srgb, var(--root) 55%, transparent); border-radius: 3px; padding: 2px 6px; }
.notcanon { font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-faint);
  border: 1px dashed var(--line-strong); border-radius: 3px; padding: 2px 6px; }
.life { font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-dim); }
.conv { font-size: 11px; color: var(--accent); }
.mid { font: 12.5px var(--mono); }

/* An empty registry and a refused one must never look alike. `settled` is a fact; `refused` is a fault. Neither is
   a spinner. Withheld is neither settled nor broken: amber, bordered on the leading edge, so it reads as a boundary. */
.state { border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4) var(--s5); margin: var(--s3) 0; background: var(--panel); }
.state h3 { margin: 0 0 var(--s2); font-size: var(--t-md); }
.state p { margin: 4px 0; color: var(--ink-dim); font-size: var(--t-base); line-height: 1.55; }
.state.settled h3 { color: var(--ink); }
.state.refused { border-color: color-mix(in srgb, var(--fault) 55%, transparent); background: var(--fault-soft); border-left-width: 3px; }
.state.refused h3 { color: var(--fault); }
.state.withheld { border-color: color-mix(in srgb, var(--boundary) 55%, transparent); background: var(--boundary-soft); border-left-width: 3px; }
.state.withheld h3 { color: var(--boundary); }

/* ---- views: tree, priority, convergence, detail --------------------------------------------------------------- */

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.tree { display: flex; flex-direction: column; gap: 2px; padding: var(--s2); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r3); }
.node { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 8px 12px; border: 1px solid transparent; border-radius: var(--r2); cursor: pointer; font-size: var(--t-sm); }
.node:hover { background: var(--panel-2); }
.node:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.node.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
/* Indentation carries depth, and a left rule makes the level readable without counting pixels. */
.node.d1 { margin-left: 22px; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r2) var(--r2) 0; }
.node.d2 { margin-left: 44px; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r2) var(--r2) 0; }
.node.d3 { margin-left: 66px; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r2) var(--r2) 0; }
.node.d4 { margin-left: 88px; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r2) var(--r2) 0; }
.node.d5 { margin-left: 110px; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r2) var(--r2) 0; }

.detail { border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4) var(--s5); background: var(--panel);
  position: sticky; top: 72px; box-shadow: var(--shadow); }
.detail.empty { border-style: dashed; background: transparent; box-shadow: none; color: var(--ink-faint); }
.detail h3 { margin: 0 0 var(--s3); font: 600 13px var(--mono); overflow-wrap: anywhere; }
.detail h4 { margin: var(--s4) 0 6px; }
.pair { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 5px 0; font-size: var(--t-sm);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.pair:last-child { border-bottom: 0; }
.pair .k { color: var(--ink-faint); }
.pair .v { word-break: break-word; }

.buckets { display: flex; flex-direction: column; gap: var(--s3); }
.bucket { border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s3) var(--s4); background: var(--panel); }
/* UNDECLARED is set apart from the three canonical buckets so a reader does not file it as a fourth priority. */
.bucket.b-undeclared { border-style: dashed; background: transparent; }
.bhead { display: flex; gap: 10px; align-items: center; }
.bhead .count { font: 500 20px var(--mono); }
.prow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 7px 2px; border-top: 1px solid var(--line); font-size: var(--t-sm); }

.targets { display: flex; flex-direction: column; gap: var(--s3); }
.target { border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s3) var(--s4); background: var(--panel); }
.target h3 { margin: 0; font: 600 13px var(--mono); }
.target .count { font-size: 11px; color: var(--ink-dim); }

.order { margin-top: var(--s3); font-style: italic; }

/* The Principal control surface (PROMPT-041). No green: an approval is a phase, not a success. */
.ceremony { display: flex; flex-direction: column; gap: 10px; margin: var(--s3) 0; max-width: 720px; }
.ceremony label { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: var(--t-sm); }
.ceremony input { margin-top: 2px; }
.bytes { white-space: pre-wrap; word-break: break-word; font: 12px/1.6 var(--mono);
  max-height: 420px; overflow: auto; padding: var(--s3) var(--s4); border-radius: var(--r2);
  border: 1px solid var(--line); background: var(--panel-2); }
/* Amber, like the withheld state and unlike a confirmation: this is a boundary, not a success. */
.panel.approval { border-color: color-mix(in srgb, var(--boundary) 55%, transparent); background: var(--boundary-soft); border-left-width: 3px; }
.fingerprint { font: 12px/1.6 var(--mono); word-break: break-all; color: var(--boundary); margin: 0 0 var(--s2); }
button.reserved { border-color: var(--boundary); }
button.reserved[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- the act flow: every act page has the same four parts ----------------------------------------------------- */
/*   1. the state line (#status)  2. choose and fill (section)  3. the summary of exactly what happens (#summary-section)
 *   4. the result (#result). The summary is the boundary: amber edge, the digest in its own box, then the one button. */

main.app > section {
  margin: var(--s4) 0;
  padding: var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--shadow);
}
main.app > section > h2:first-child { margin: 0 0 var(--s4); }
main.app > section > p { color: var(--ink-dim); max-width: 75ch; }
main.app > section > label { max-width: 560px; }
main.app > section ol, main.app > section ul { padding-left: 22px; }
main.app > section li { margin: 4px 0; }
main.app > ol, main.app > ul { padding: var(--s3) var(--s4) var(--s3) 40px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r3); }
main.app > ol:empty, main.app > ul:empty { display: none; }
main.app > ol li { margin: 3px 0; color: var(--ink-dim); }

/* 1. the state line */
main.app > #status {
  display: flex; align-items: flex-start; gap: 10px;
  margin: var(--s3) 0 var(--s4);
  padding: 10px var(--s4);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  color: var(--ink-dim);
  font-size: var(--t-sm);
  max-width: none;
}
main.app > #status::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--ink-faint); }
main.app > #status:empty { display: none; }

/* 2. the first step's button reads as a question, not as the act */
#preview, button#preview { background: transparent; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
#preview:hover:not([disabled]) { background: var(--accent-soft); filter: none; }

/* 3. the summary: exactly what the act does, then its digest, then the one button that performs it */
#summary-section { border-left: 3px solid var(--boundary) !important; }
#summary-section > h2 { font-size: var(--t-xl); }
#summary h3 { margin: var(--s4) 0 6px; font: 600 var(--t-xs)/1.4 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
#summary > div:first-child h3, #summary > h3:first-child { margin-top: 0; }
#summary ul { margin: 0; padding-left: 20px; }
#summary li { margin: 4px 0; line-height: 1.55; }
#summary-section > p { color: var(--ink-dim); font-size: var(--t-sm); }
#summary-digest, #routine-fingerprint {
  display: block; margin-top: 6px; padding: 10px 12px;
  font: 13px/1.6 var(--mono); word-break: break-all;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r2); color: var(--ink);
}
#perform { margin-top: var(--s2); padding: 11px 20px; font-size: var(--t-base); }

/* 4. the result */
main.app > #result:not(:empty) {
  padding: var(--s3) var(--s4);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r2);
  font: 13px/1.6 var(--mono);
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* lists of records on an act page (your approvals, the order of acts) */
#approvals { list-style: none; padding: 0; margin: 0; }
#approvals li { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
#approvals li:first-child { border-top: 0; }
#approvals li button { background: transparent; color: var(--ink-dim); border-color: var(--line-strong); min-height: 32px; padding: 6px 12px; }
#approvals li button:hover:not([disabled]) { color: var(--ink); background: var(--panel-2); filter: none; }

/* ---- the front door, and "not here" --------------------------------------------------------------------------- */

body.door { min-height: 100vh; display: flex; flex-direction: column; }
.door-top, .door-main, .door-foot { width: 100%; max-width: 1080px; margin: 0 auto; padding-left: var(--s6); padding-right: var(--s6); }
.door-top { display: flex; align-items: center; gap: 10px; padding-top: var(--s5); padding-bottom: var(--s5); border-bottom: 1px solid var(--line); }
.mark {
  display: inline-block; width: 18px; height: 18px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%) 0 0 / 13px 13px no-repeat,
              linear-gradient(var(--line-strong), var(--line-strong)) 5px 5px / 13px 13px no-repeat;
}
.wordmark { font: 600 var(--t-md)/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; }
.door-main { flex: 1; padding-top: var(--s7); padding-bottom: var(--s7);
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); grid-template-areas: "hero signin" "hero picker" "points points";
  column-gap: var(--s7); align-items: start; }
.door-hero { grid-area: hero; max-width: 640px; }
.door-signin { grid-area: signin; margin-top: 30px; }
.door-points { grid-area: points; }
/* PROMPT-226: the tenant picker, under the address box */
.door-signin.door-picker-box { grid-area: picker; margin-top: var(--s5); }
.door-picker { margin: 0 0 var(--s4); padding: 0; list-style: none; }
.door-picker li a { display: flex; align-items: center; min-height: 44px; font: 500 var(--t-md) var(--mono); }
.eyebrow { margin: 0 0 var(--s4); font: 600 var(--t-xs)/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.door-hero h1 { margin: 0 0 var(--s5); font: 400 54px/1.06 var(--serif); letter-spacing: -0.02em; }
.door-lede { margin: 0; max-width: 62ch; font-size: 18px; line-height: 1.65; color: var(--ink-dim); }
.door-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); margin: var(--s7) 0; padding-top: var(--s5); border-top: 1px solid var(--line); }
.door-point h2 { margin: 0 0 var(--s2); font-size: var(--t-lg); }
.door-point p { margin: 0; color: var(--ink-dim); line-height: 1.65; }
.door-signin { max-width: 520px; padding: var(--s6); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r3); box-shadow: var(--shadow); }
.door-signin h2 { margin: 0 0 6px; font-size: var(--t-xl); }
.door-signin .muted { margin: 0 0 var(--s5); }
.door-form label { margin-bottom: 6px; }
.door-address { display: flex; align-items: stretch; margin-bottom: var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--bg); overflow: hidden; }
.door-address:focus-within { outline: 2px solid var(--accent); border-color: var(--accent); }
.door-address input { margin: 0; border: 0; border-radius: 0; background: transparent; text-align: right; font: 500 var(--t-md) var(--mono); }
.door-address input:focus { outline: 0; }
.door-suffix { display: flex; align-items: center; padding: 0 14px 0 2px; font: 500 var(--t-md) var(--mono); color: var(--ink-faint); white-space: nowrap; }
.door-form button { width: 100%; min-height: 44px; font-size: var(--t-base); }
.door-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); padding-top: var(--s4); padding-bottom: var(--s5); border-top: 1px solid var(--line); font-size: var(--t-sm); color: var(--ink-dim); }
.door-main.door-nothere { display: flex; flex-direction: column; justify-content: center; gap: var(--s3); max-width: 560px; }
.door-nothere h1 { margin: var(--s4) 0 0; font: 400 44px/1.1 var(--serif); }
.door-nothere .mark { width: 26px; height: 26px; background-size: 19px 19px, 19px 19px; background-position: 0 0, 7px 7px; }

@media (max-width: 900px) {
  .door-top, .door-main, .door-foot { padding-left: var(--s4); padding-right: var(--s4); }
  .door-main { padding-top: var(--s6); padding-bottom: var(--s6); display: block; }
  .door-signin { margin-top: var(--s6); }
  .door-hero h1 { font-size: 38px; }
  .door-lede { font-size: 17px; }
  .door-points { grid-template-columns: 1fr; gap: var(--s4); margin: var(--s6) 0; }
  .door-signin { padding: var(--s5); }
  .door-nothere h1 { font-size: 36px; }
}

/* ---- PROMPT-205: phones (375–430 px), kept --------------------------------------------------------------------
   Every rule sits under max-width 900px. Body type 16 px (and 16 px in every input and select, so iOS does not zoom
   on focus); tap targets at least 44 px; no horizontal page scroll: long words, digests and fingerprints wrap, wide
   tables and exact bytes scroll inside their own box. Nothing here hides, reorders or rewords what the Principal reads
   before an act. */
@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 16px; overflow-wrap: anywhere; }
  .app, main { min-width: 0; max-width: 100%; }
  main, main.app { padding: var(--s4) var(--s4) var(--s6); }
  main.app::before { margin-bottom: var(--s4); }
  main h1, main.app > h1 { font-size: 26px; }
  main h2, .obs h2 { font-size: 19px; }
  main h3 { font-size: 16px; }
  main p, main li, .panel p, .state p, .muted, .lede, main .lede { font-size: 16px; line-height: 1.55; }
  ol, ul { padding-left: 22px; }
  .loading { padding: 12px 0; }
  main.app > section { padding: var(--s4); }

  /* forms: one field per row, the control full width under its words */
  label, .ceremony label { font-size: 15px; color: var(--ink-dim); }
  label span { font-size: 13px; }
  input, select, textarea, .ceremony input {
    display: block; width: 100%; max-width: 100%; min-height: 44px; margin-top: 6px;
    padding: 10px 12px; font: 16px var(--sans);
    background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r2);
  }
  select { padding-right: 32px; }
  .door-address input { font: 500 16px var(--mono); min-height: 48px; }
  .door-suffix { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { display: inline-block; width: 24px; min-height: 24px; margin: 0 8px 0 0; vertical-align: middle; }
  .obs-filters select { max-width: 100%; font-size: 16px; }

  /* tap targets */
  button, .obs-btn { min-height: 44px; padding: 10px 16px; font-size: 16px; border-radius: var(--r2); touch-action: manipulation; }
  main section > button, form > button, .gate > button, .panel > button, .ceremony button { width: 100%; margin: 6px 0; }
  li > button { min-width: 44px; margin-top: 6px; }
  details summary { min-height: 44px; display: flex; align-items: center; font-size: 15px !important; }

  /* the act summary and its digest: readable without zooming */
  #summary-section { margin-top: 18px; }
  #summary h3 { margin: 14px 0 6px; font-size: 12.5px; }
  #summary ul { margin: 0; }
  #summary li { margin: 4px 0; }
  code, .mid, .fingerprint, .secret { overflow-wrap: anywhere; word-break: break-all; }
  #summary-digest, #routine-fingerprint, .fingerprint {
    display: block; margin-top: 6px; padding: 10px 12px; font: 15px/1.6 var(--mono);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r2); color: var(--ink);
  }

  /* exact bytes and wide tables scroll inside their own box, never the page */
  pre, .bytes { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 13px; }
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-collapse: collapse; font-size: 15px; }
  th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line);
    white-space: nowrap; overflow-wrap: normal; }
  td:last-child { white-space: normal; min-width: 260px; }

  /* the console shell: header wraps, the side nav becomes a row of large links */
  header.top { position: static; flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  header.top .spacer { flex-basis: 100%; height: 0; }
  header.top button { min-height: 40px; padding: 8px 12px; font-size: 15px; }
  .chip { font-size: 13px; padding: 4px 10px; }
  nav.side { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  nav.side h2 { flex-basis: 100%; margin: 6px 4px 0; font-size: 12px; }
  nav.side a, nav.side span.nav { min-height: 44px; align-items: center; gap: 8px; padding: 10px 12px; font-size: 15px;
    border: 1px solid var(--line); border-radius: var(--r2); }
  nav.side a.current { border-color: var(--accent); border-radius: var(--r2); }
  nav.side .tag { font-size: 11px; }
  .gate { margin: 16px; padding: 20px; max-width: none; }
  .gate h1 { font-size: 24px; }
  .gate .sub { font-size: 15px; }

  /* the Mandate tree and detail */
  .node { min-height: 44px; font-size: 15px; }
  .node.d1 { margin-left: 10px; } .node.d2 { margin-left: 20px; } .node.d3 { margin-left: 30px; }
  .node.d4 { margin-left: 40px; } .node.d5 { margin-left: 50px; }
  .detail { position: static; }
  .pair { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 6px 0; font-size: 15px; }
  .prow, .mid, .pair .v { font-size: 15px; }
  .card .k, .life, .prio, .flag, .rootbadge, .notcanon { font-size: 12px; }
  .card .n, .panel .src, .warnbox p { font-size: 14px; }
  .panel, .state { padding: 14px; }

  /* the observatory: bigger feed text and filters */
  .obs-feed > li, .obs-list > li, .obs-tile, .obs-stuck, .obs-tierlaw { font-size: 15px; }
  .obs-plain, .obs-meter-row, .obs-filters, .obs-live, .obs-crumbs, .obs-foot { font-size: 14px; }
}

/* ---- PROMPT-223: the console map — the top bar on every console page, Home's "Needs you" and its tiles ------------
   Drawn by /console-nav.js from the one route table (/console-routes.js). Presentation only: it hides, reorders or
   rewords nothing a page says before an act. Every tap target is at least 44 px; nothing here can widen the page. */
.cnav { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.cnav-row { display: flex; align-items: center; gap: var(--s3); max-width: 1180px; margin: 0 auto; padding: 6px var(--s4); min-width: 0; }
.cnav-home, .cnav-signin {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; flex: 0 0 auto;
  border: 1px solid var(--line-strong); border-radius: var(--r2); color: var(--ink); text-decoration: none;
  font: 600 var(--t-base)/1 var(--sans);
}
.cnav-home .cnav-mark {
  display: inline-block; width: 14px; height: 14px;
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%) 0 0 / 10px 10px no-repeat,
              linear-gradient(var(--line-strong), var(--line-strong)) 4px 4px / 10px 10px no-repeat;
}
.cnav-home[aria-current="page"] { border-color: var(--accent); }
.cnav-home:hover, .cnav-signin:hover { background: var(--panel-2); }
.cnav-signin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.cnav-here { flex: 1 1 auto; min-width: 0; font: 500 var(--t-md)/1.25 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.cnav-menu-button { flex: 0 0 auto; min-height: 44px; min-width: 76px; background: transparent; color: var(--ink); border-color: var(--line-strong); }
.cnav-menu-button[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.cnav-menu { max-width: 1180px; margin: 0 auto; padding: 0 var(--s4) var(--s4); max-height: calc(100vh - 64px); overflow-y: auto; }
.cnav-menu-note { margin: var(--s2) 0; color: var(--ink-faint); font-size: var(--t-sm); }
.cnav-menu ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s2); }
.cnav-item, .tile, .need {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 10px 14px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r2); color: var(--ink); text-decoration: none;
}
a.cnav-item:hover, a.tile:hover, .need:has(> a.need-main:hover) { border-color: var(--line-strong); background: var(--panel-3); }
.cnav-item[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.cnav-item-name, .tile-name, .need-title { font: 600 var(--t-base)/1.3 var(--sans); padding-right: 48px; overflow-wrap: anywhere; }
.cnav-item-line, .tile-line, .need-state { color: var(--ink-dim); font-size: var(--t-sm); line-height: 1.45; overflow-wrap: anywhere; }
.cnav-aal2 {
  position: absolute; top: 10px; right: 10px; padding: 1px 7px; border: 1px solid var(--boundary); border-radius: 999px;
  color: var(--boundary); font: 600 var(--t-xs)/1.5 var(--mono);
}
body.has-cnav main.app::before { display: none; }

.chome { max-width: 1180px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s4); }
.chome-h { margin: var(--s4) 0 var(--s3); font-size: var(--t-xl); }
.chome-h:first-child { margin-top: 0; }
.needs, .tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.needs { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tiles { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.need { padding: 0; border-left: 3px solid var(--line-strong); }
.need-main { display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 14px 16px 10px; color: var(--ink); text-decoration: none; border-radius: var(--r2); }
.need-lines a { display: inline-block; min-height: 32px; padding: 4px 0; }
.need-waiting { border-left-color: var(--boundary); background: var(--boundary-soft); }
.need-unread { background: transparent; border-style: dashed; }
.need-waiting .need-state { color: var(--ink); font-weight: 600; }
.need-lines { margin: 0 0 12px; padding: 0 16px 0 34px; color: var(--ink); font-size: var(--t-sm); }
.need-lines li { margin: 2px 0; overflow-wrap: anywhere; }
.need-go { margin-top: 4px; color: var(--accent); font-size: var(--t-sm); font-weight: 600; }
.tile { padding: 14px 16px; min-height: 96px; }
.tile-access { margin-top: auto; padding-top: 6px; color: var(--ink-faint); font: 600 var(--t-xs)/1.4 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; }
.tile-access.aal2 { color: var(--boundary); }

/* the front door's one link into the console */
.door-open { margin: var(--s5) 0 0; }
.door-open-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: var(--r2);
  font: 600 var(--t-md)/1 var(--sans); text-decoration: none;
}
.door-open-link:hover { filter: brightness(1.08); }
/* PROMPT-256: the header's way in, and the three steps under the hero's button */
.door-top-open {
  margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--accent); border-radius: var(--r2); color: var(--accent); font: 600 var(--t-base)/1 var(--sans);
  text-decoration: none;
}
.door-top-open:hover { background: var(--accent-soft); }
.door-steps { margin: var(--s4) 0 0; padding-left: 1.4em; color: var(--ink-dim); line-height: 1.6; }

/* PROMPT-256: the console by clicks — the bar's direct links and their count, the breadcrumb, Home's systems */
.cnav-here { display: none; }
.cnav-links { flex: 1 1 auto; min-width: 0; }
.cnav-links ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
.cnav-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid transparent;
  border-radius: var(--r2); color: var(--ink); text-decoration: none; font: 500 var(--t-base)/1 var(--sans);
}
.cnav-link:hover { background: var(--panel-2); }
.cnav-link[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.cnav-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--boundary); color: var(--bg); font: 700 13px/1 var(--sans);
}
.cnav-count[hidden] { display: none; }
.cnav-item .cnav-count { position: absolute; top: 10px; right: 62px; }
.cnav-menu-button .cnav-count { margin-left: 6px; }
@media (min-width: 901px) { .cnav-menu-button .cnav-count { display: none; } }
.cnav-crumbs { max-width: 1180px; margin: 0 auto; padding: 0 var(--s4) 8px; }
.cnav-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; font-size: var(--t-sm); color: var(--ink-dim); }
.cnav-crumbs li { display: inline-flex; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.cnav-crumbs li + li::before { content: "\203A"; margin: 0 8px; color: var(--ink-faint); }
.cnav-crumbs a { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); }
.cnav-crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.systems { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.system {
  display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 16px 18px; border: 1px solid var(--accent);
  border-radius: var(--r2); background: var(--accent-soft); color: var(--ink); text-decoration: none;
}
.system:hover { filter: brightness(1.08); }
.system-name { font: 600 var(--t-lg)/1.2 var(--sans); }
.system-line { color: var(--ink-dim); font-size: var(--t-sm); line-height: 1.45; }
.system-go { margin-top: 6px; color: var(--accent); font-size: var(--t-sm); font-weight: 600; }

@media (max-width: 900px) {
  .cnav { position: static; }
  .cnav-row { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .cnav-here { order: 3; flex-basis: 100%; font-size: 18px; }
  .cnav-home { flex: 1 1 auto; justify-content: flex-start; font-size: 16px; }
  .cnav-menu-button { font-size: 16px; }
  .cnav-menu { padding: 0 12px 12px; max-height: none; }
  .cnav-menu ul, .needs, .tiles { grid-template-columns: minmax(0, 1fr); }
  .cnav-item-name, .tile-name, .need-title { font-size: 16px; }
  .cnav-item-line, .tile-line, .need-state, .need-lines { font-size: 15px; }
  .chome { padding: var(--s4) 12px; }
  .chome-h { font-size: 21px; }
  .tile { min-height: 0; }
  .door-open-link { display: flex; width: 100%; }
  /* PROMPT-256: on a phone the direct links live in the Menu (they are its first entries); the breadcrumb stays */
  .cnav-links { display: none; }
  .cnav-crumbs { padding: 0 12px 8px; }
  .cnav-crumbs ol { font-size: 15px; }
  .systems { grid-template-columns: minmax(0, 1fr); }
}
