/* The console's one stylesheet (P13), for the shell at /app and every view in it.
 * Colours live only in the tokens below, for light and dark; nothing else names a colour, and
 * no view sets an inline style. Fonts are the system stacks: the console's policy loads no
 * fonts from elsewhere, so Inter and JetBrains Mono are used only where they are installed.
 * Layout: a 208px sidebar (instance switcher, nav from console_manifest) and a fluid main
 * column of dense tables; under 760px the sidebar becomes a bar above the main column.
 * The page is laid out edge to edge (viewport-fit=cover): every edge that meets the screen is
 * padded by at least its safe-area inset, so nothing sits under the status bar, the notch or
 * the home indicator on an iPhone. --safe-* are 0 everywhere else. */
:root {
  --bg: #FFFFFF; --sunk: #F6F5F7; --surface: #FFFFFF; --raised: #FAF9FB; --hover: #F3F1F5;
  --line: #E4E2E8; --line-strong: #CFCCD6;
  --ink: #1D1B21; --ink-2: #47434F; --muted: #6E6A76;
  --accent: #B03A6A; --accent-ink: #FFFFFF; --accent-soft: #FBEAF1; --accent-line: #E9B7CC;
  --ok: #1F7A4D; --ok-soft: #E4F3EB; --warn: #8F5600; --warn-soft: #FCF0DA;
  --bad: #B42318; --bad-soft: #FCEBE9; --info: #2C5E9E; --info-soft: #E7EEF8;
  --scrim: rgba(20, 18, 24, .42); --shadow: 0 8px 28px rgba(20, 18, 24, .16);
  --mark-ground: #F9E5EE; --mark-edge: #EEB9CF; --dot: #D5D1DB;
  --font-ui: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 18px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-1: 3px; --r-2: 6px;
  --row: 32px; --ctl: 26px; --side: 208px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141418; --sunk: #101013; --surface: #18181D; --raised: #1D1D23; --hover: #212128;
    --line: #2A2A31; --line-strong: #3B3B44;
    --ink: #ECEAE6; --ink-2: #C3C0C8; --muted: #98949F;
    --accent: #E07FA8; --accent-ink: #1A0F14; --accent-soft: #2B1821; --accent-line: #6A3550;
    --ok: #6CCB93; --ok-soft: #13261B; --warn: #E8B04A; --warn-soft: #2A2112;
    --bad: #F08A7A; --bad-soft: #2E1815; --info: #8DB6F0; --info-soft: #15202F;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 10px 32px rgba(0, 0, 0, .5);
    --mark-ground: #3D2935; --mark-edge: #844F67; --dot: #34333D;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141418; --sunk: #101013; --surface: #18181D; --raised: #1D1D23; --hover: #212128;
  --line: #2A2A31; --line-strong: #3B3B44;
  --ink: #ECEAE6; --ink-2: #C3C0C8; --muted: #98949F;
  --accent: #E07FA8; --accent-ink: #1A0F14; --accent-soft: #2B1821; --accent-line: #6A3550;
  --ok: #6CCB93; --ok-soft: #13261B; --warn: #E8B04A; --warn-soft: #2A2112;
  --bad: #F08A7A; --bad-soft: #2E1815; --info: #8DB6F0; --info-soft: #15202F;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 10px 32px rgba(0, 0, 0, .5);
  --mark-ground: #3D2935; --mark-edge: #844F67; --dot: #34333D;
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs-md)/1.45 var(--font-ui); -webkit-font-smoothing: antialiased; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r-1); }
code, .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-size: var(--fs-xl); letter-spacing: -.01em; }
h1:focus { outline: none; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
ul, ol { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.bad-text { color: var(--bad); }
.label { font-size: var(--fs-xs); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:not(:focus) { position: absolute; clip-path: inset(50%); }
.skip:focus { position: fixed; z-index: 60; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-1); }
svg.icon { width: 15px; height: 15px; flex: none; }

/* Button: default, primary (one per view), danger, ghost; 26px, or 22px in rows */
.btn { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-1);
  background: var(--surface); color: var(--ink); font: 500 var(--fs-sm)/1 var(--font-ui); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg.icon { width: 13px; height: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-danger.btn-primary { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-sm { height: 22px; padding: 0 8px; font-size: var(--fs-xs); }

/* Segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-1); overflow: hidden; }
.seg button { height: 24px; padding: 0 10px; border: 0; border-right: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font: 500 var(--fs-sm) var(--font-ui); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* Field and inputs */
.input { height: var(--ctl); padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); font: var(--fs-md) var(--font-ui); min-width: 0; }
textarea.input { height: auto; padding: 6px 8px; font: var(--fs-sm)/1.5 var(--font-mono); resize: vertical; width: 100%; }
.input.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input[type="search"] { width: 220px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
.field small { color: var(--muted); font-size: var(--fs-xs); }
kbd { font: 500 10px/1 var(--font-mono); padding: 2px 4px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-1); color: var(--muted); background: var(--surface); }

/* Pill: a dot and a word */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 18px; padding: 0 6px; border-radius: var(--r-1); font: 500 var(--fs-xs)/1 var(--font-ui);
  background: var(--raised); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; justify-self: start; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.plain::before { display: none; }
.tag { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-radius: var(--r-1); font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }
.tag + .tag { margin-left: 4px; }

/* App frame */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: var(--sp-3); overflow-y: auto;
  padding: max(var(--sp-3), var(--safe-t)) var(--sp-2) max(var(--sp-3), var(--safe-b)) max(var(--sp-2), var(--safe-l));
  background: var(--sunk); border-right: 1px solid var(--line); }

/* Instance switcher */
.switcher { position: relative; }
.sw-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.sw-btn:hover { background: var(--hover); }
.sw-btn > svg.icon { width: 12px; height: 12px; color: var(--muted); transform: rotate(90deg); }
.sw-text { flex: 1; min-width: 0; display: grid; }
.sw-text strong, .sw-text span { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-text small { color: var(--muted); font: var(--fs-xs) var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ini { width: 20px; height: 20px; border-radius: var(--r-1); background: var(--raised); border: 1px solid var(--line-strong); display: grid; place-items: center; font: 600 10px var(--font-ui); color: var(--ink-2); flex: none; }
.ini.home { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.sw-pop { position: absolute; z-index: 25; top: calc(100% + 4px); left: 0; width: max(100%, 280px); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-2); box-shadow: var(--shadow); padding: 4px; display: grid; gap: 1px; }
.sw-pop .label { padding: 6px 8px 2px; }
.sw-pop a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--r-1); color: var(--ink); text-decoration: none; }
.sw-pop a:hover, .sw-pop a:focus-visible { background: var(--hover); outline-offset: -2px; }
.sw-pop a[aria-current="true"] { background: var(--accent-soft); }
.sw-pop hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }

/* Nav, built from console_manifest */
.nav { display: grid; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: var(--r-1); color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: auto; min-width: 18px; height: 16px; padding: 0 5px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: 600 10px/16px var(--font-ui); text-align: center; }
.nav kbd { margin-left: auto; opacity: 0; }
.nav a:hover kbd, .nav a:focus-visible kbd { opacity: 1; }
.nav .count + kbd { margin-left: 4px; }

/* Account: one row (avatar, name) that opens a menu above it with the theme, the shortcuts and
 * sign out */
.side-foot { margin-top: auto; position: relative; padding-top: 8px; border-top: 1px solid var(--line); }
.acct-btn { width: 100%; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink); font: 500 var(--fs-md) var(--font-ui); text-align: left; cursor: pointer; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--hover); }
.acct-btn .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn > svg.icon { width: 12px; height: 12px; color: var(--muted); }
.acct-pop { position: absolute; z-index: 25; left: 0; right: 0; bottom: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-2); box-shadow: var(--shadow); padding: 4px; display: grid; gap: 1px; font-size: var(--fs-sm); }
.acct-pop .mi { display: flex; align-items: center; gap: 8px; width: 100%; height: 28px; padding: 0 8px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink); font: 400 var(--fs-sm) var(--font-ui); text-align: left; cursor: pointer; }
.acct-pop .mi:hover, .acct-pop .mi:focus-visible { background: var(--hover); outline-offset: -2px; }
.acct-pop .mi svg.icon { width: 14px; height: 14px; color: var(--muted); }
.acct-pop .mi kbd { margin-left: auto; }
.acct-pop hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
.acct-pop .theme { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 8px; color: var(--ink-2); }
.acct-pop .theme > span { flex: 1; }
.acct-pop .who-head, .acct-pop .who-sep { display: none; }
.acct-pop .who-head { padding: 6px 8px 4px; font-weight: 600; font-size: var(--fs-md); }
.seg button[role="radio"] { display: grid; place-items: center; width: 26px; height: 22px; padding: 0; color: var(--muted); }
.seg button[role="radio"] svg.icon { width: 13px; height: 13px; }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--raised); border: 1px solid var(--line-strong); display: grid; place-items: center; font: 600 10px var(--font-ui); color: var(--ink-2); flex: none; }

/* Main column */
.main { min-width: 0; padding: max(var(--sp-4), var(--safe-t)) max(var(--sp-5), var(--safe-r)) calc(var(--sp-6) + var(--safe-b)) var(--sp-5); display: grid; align-content: start; gap: var(--sp-4); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.crumbs { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 2px; }
.subtabs { display: flex; gap: var(--sp-4); border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtabs a { padding: 6px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; text-decoration: none; }
.subtabs a:hover { color: var(--ink); }
.subtabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.view { display: grid; gap: var(--sp-4); min-width: 0; }
.section { display: grid; gap: var(--sp-2); min-width: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-3); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: 8px 12px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--r-2); }
.strip.neutral { border-color: var(--line); background: var(--raised); }
.strip.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.notice { border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--r-1); background: var(--surface); padding: 10px 12px; display: grid; gap: 8px; max-width: 720px; }
.panel { border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); padding: var(--sp-3) var(--sp-4); display: grid; gap: var(--sp-3); min-width: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); align-items: start; }

/* DataTable */
.tbl-wrap { border: 1px solid var(--line); border-radius: var(--r-2); overflow-x: auto; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.tbl th { height: 28px; padding: 0 10px; text-align: left; font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--raised); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td { height: var(--row); padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tr.group td { background: var(--raised); font-size: var(--fs-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); height: 26px; }
.tbl tr.child td:first-child { padding-left: 28px; position: relative; }
.tbl tr.child td:first-child::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 50%; width: 8px; border-left: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.tbl tr.expandable { cursor: pointer; }
.tbl tr.detail td, .tbl tr.detail:hover td { background: var(--raised); padding: 12px 14px 14px 34px; }
.tbl .acts { text-align: right; white-space: nowrap; width: 1%; }
.tbl .acts .btn + .btn { margin-left: 4px; }
.tbl .chev { width: 22px; padding-right: 0; color: var(--muted); }
.tbl .chev svg.icon { width: 12px; height: 12px; transition: transform .12s; }
.tbl tr[aria-expanded="true"] .chev svg.icon { transform: rotate(90deg); }
.tbl td.wide { min-width: 12em; overflow-wrap: normal; }
.tbl .sub { display: block; color: var(--muted); font-size: var(--fs-sm); }
.tbl .sub.mono { font-size: var(--fs-xs); white-space: nowrap; }
.tbl tr.empty td, .tbl tr.err td { height: 64px; text-align: center; color: var(--muted); }
.tbl tr.err td { color: var(--bad); }
.tbl tr.err .btn { margin-left: 8px; }
.skel { display: block; height: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--line) 0%, var(--hover) 50%, var(--line) 100%); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
.skel.w1 { width: 42%; } .skel.w2 { width: 66%; } .skel.w3 { width: 54%; } .skel.w4 { width: 80%; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .tbl .chev svg.icon { transition: none; } }

/* Bar and meter: inline bars in table cells (spend against budget, outcome mixes, shares) */
svg.bar { display: block; width: 72px; height: 6px; flex: none; border-radius: 3px; background: var(--line); overflow: hidden; }
svg.bar .fill { fill: var(--accent); }
svg.bar .fill.ok { fill: var(--ok); }
svg.bar .fill.warn { fill: var(--warn); }
svg.bar .fill.bad, svg.bar .fill.hot { fill: var(--bad); }
svg.bar .fill.info { fill: var(--info); }
svg.bar .fill.muted { fill: var(--line-strong); }
.bar-none { display: block; width: 72px; height: 6px; flex: none; border-radius: 3px; border: 1px dashed var(--line-strong); }
.meter { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.meter .num { text-align: left; }
.tbl .sub svg.bar { margin-top: 4px; }

/* Jobs › Runs: an expanded run's columns, stage timings and runner-check timeline */
.tbl td.nowrap { white-space: nowrap; }
.jobrun { display: flex; flex-wrap: wrap; gap: 24px; }
.jobcol { flex: 1 1 240px; display: grid; gap: 8px; align-content: start; }
.jobcol.wide { flex: 1 1 320px; gap: 6px; }
.jobcol.narrow { flex: 0 1 220px; gap: 6px; justify-items: start; }
.stage { display: grid; grid-template-columns: 110px 72px 1fr; gap: 10px; align-items: center; color: var(--ink-2); }
.stage.slowest > span:first-child { color: var(--ink); font-weight: 500; }
.stage .muted { font-size: var(--fs-sm); }
.timeline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.timeline .tag { font-family: var(--font-mono); }

/* Figures: a row of headline numbers above a table */
.figs { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); }
.fig { display: grid; gap: 2px; min-width: 0; }
.fig strong { font-size: var(--fs-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.fig small { color: var(--muted); font-size: var(--fs-xs); }

/* Facts, code, diffs */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: var(--fs-sm); padding-top: 1px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.code { margin: 0; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-1); font: var(--fs-sm)/1.5 var(--font-mono); overflow-x: auto; color: var(--ink-2); white-space: pre-wrap; }
.diff { display: grid; gap: 2px; font: var(--fs-sm)/1.6 var(--font-mono); }
.diff .del { color: var(--bad); }
.diff .add { color: var(--ok); }
.diff .note { color: var(--muted); }
ol.steps { padding-left: 18px; display: grid; gap: 2px; }
.changes { border: 1px solid var(--line); border-radius: var(--r-1); background: var(--raised); padding: 8px 10px; display: grid; gap: 6px; }

/* Dialogs, ShowOnce, toast, help */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); display: grid; place-items: center;
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l)); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-2); box-shadow: var(--shadow); display: grid; }
.modal > header { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal > header h2 { flex: 1; }
.modal-body { padding: 14px 16px; display: grid; gap: 12px; min-width: 0; }
.modal > footer { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal .status { margin-right: auto; font-size: var(--fs-sm); color: var(--muted); }
.modal .status.error { color: var(--bad); }
.copyfield { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--raised); }
.copyfield code { flex: 1; min-width: 0; padding: 6px 8px; overflow-wrap: anywhere; user-select: all; }
.copyfield .btn { border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; height: auto; }
.toast { position: fixed; z-index: 50; bottom: calc(16px + var(--safe-b)); right: calc(16px + var(--safe-r)); max-width: min(420px, calc(100vw - 32px)); padding: 8px 12px;
  border: 1px solid var(--line-strong); border-left: 3px solid var(--ok); border-radius: var(--r-1); background: var(--surface); box-shadow: var(--shadow); font-size: var(--fs-sm); }
.toast.info { border-left-color: var(--info); }
.toast.bad { border-left-color: var(--bad); }
.help-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; align-items: center; }

/* More: a folded secondary list under a table */
details.more { border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); }
details.more > summary { padding: 7px 10px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
details.more[open] > summary { border-bottom: 1px solid var(--line); }
details.more > .section { padding: 8px; }
.tbl ul.plain { list-style: none; padding: 0; display: grid; gap: 2px; }
.tbl tr.detail .tbl-wrap { background: var(--surface); }
.who-cell { display: inline-flex; align-items: center; gap: 8px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); }
.stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* A diagram the platform drew (an SVG in an img), scrolled sideways when narrow */
.figure { border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); padding: var(--sp-2); overflow-x: auto; }
.figure img { display: block; width: 100%; min-width: 760px; height: auto; }
/* Platform › Architecture: the map drawn light and dark; the one matching the theme shows. */
.arch-map picture { display: block; }
.arch-map .arch-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .arch-map .arch-light { display: none; }
  :root:not([data-theme="light"]) .arch-map .arch-dark { display: block; }
}
:root[data-theme="dark"] .arch-map .arch-light { display: none; }
:root[data-theme="dark"] .arch-map .arch-dark { display: block; }
@media (max-width: 640px) { .arch-map img { min-width: 0; } }

/* Sign in and full-page states */
.signin { min-height: 100vh; display: grid; place-items: center; background-color: var(--sunk);
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.5px); background-size: 16px 16px; background-position: 8px 8px;
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l)); }
.signin .box { width: min(340px, 100%); border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-2); padding: 20px; display: grid; gap: 12px; }
.signin .lockup { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs-lg); }
/* The pigeon.dev mark: its artwork (served by the Worker at /app/mark/head.webp) on its ground. */
.mark { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--mark-edge); flex: none; background: url("mark/head.webp") center / cover no-repeat border-box, var(--mark-ground); }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: max(8px, var(--safe-t)) max(16px, var(--safe-r)) 8px max(16px, var(--safe-l)); border-right: 0; border-bottom: 1px solid var(--line); }
  .switcher { order: 2; flex: 1 1 200px; }
  /* The account is an avatar on the bar's right; its menu opens downward and names the person. */
  .side-foot { order: 3; margin: 0; border: 0; padding: 0; }
  .acct-btn { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .acct-btn .name, .acct-btn > svg.icon { display: none; }
  .acct-btn .avatar { width: 24px; height: 24px; }
  .acct-pop { left: auto; right: 0; bottom: auto; top: calc(100% + 4px); width: 220px; }
  .acct-pop .who-head { display: grid; }
  .acct-pop .who-sep { display: block; }
  .nav { order: 4; display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .nav a { flex: none; }
  .nav kbd { display: none; }
  .main { padding-top: var(--sp-4); padding-left: max(16px, var(--safe-l)); padding-right: max(16px, var(--safe-r)); }
  .input[type="search"] { width: 100%; }
  /* Narrow: a table keeps its words whole and scrolls inside its frame instead. */
  .tbl td { overflow-wrap: normal; }
  .tbl td.mono { white-space: nowrap; }
  .tbl td:not(.acts) { min-width: 88px; }
  .tbl td.wide { min-width: 220px; }
}

/* Email › Mailboxes: mailboxes, the message list, the message. */
.mail { display: grid; grid-template-columns: minmax(160px, 200px) minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--sp-4); align-items: start; }
.mail .boxes { display: flex; flex-direction: column; gap: var(--sp-1); }
.mail .boxes .btn { justify-content: space-between; }
.mail-frame { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); }
@media (max-width: 1100px) { .mail { grid-template-columns: minmax(0, 1fr); } .mail .boxes { flex-direction: row; flex-wrap: wrap; } }

/* Capability options (views/options.js): the drawer, its four sections and the diff bar. */
.opt { color: var(--ink-2); font-size: var(--fs-sm); }
.field > .seg { justify-self: start; }
.opt-stack { display: grid; gap: var(--sp-2); min-width: 0; }
.opt-saved { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.opt-multi { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); }
.opt-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; }
.drawer-scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); }
.drawer { position: fixed; z-index: 31; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding-right: var(--safe-r); }
.drawer-head { padding: max(14px, var(--safe-t)) 20px 0; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.drawer-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.drawer-title h2 { font-family: var(--font-mono); font-size: var(--fs-lg); }
.drawer-title h2:focus { outline: none; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-sm); color: var(--muted); }
.drawer-meta b { font-weight: 500; color: var(--ink-2); }
.drawer-tabs { gap: var(--sp-4); }
.drawer-tabs button { padding: 6px 0; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 500 var(--fs-md) var(--font-ui); white-space: nowrap; cursor: pointer; }
.drawer-tabs button:hover { color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; display: grid; align-content: start; gap: 0; }
.drawer-body > [role="status"] { padding-top: 12px; }
.sect { display: grid; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--line); min-width: 0; scroll-margin-top: 4px; }
.sect:last-child { border-bottom: 0; }
.sect-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sect-head h3 { font-size: var(--fs-md); }
.sect-head .hint, .hint { font-size: var(--fs-xs); color: var(--muted); }
.sect-empty { color: var(--muted); font-size: var(--fs-sm); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--raised); min-width: 0; }
.item[hidden] { display: none; }
.item.item-top { align-items: flex-start; }
.item.rows-item { display: grid; gap: 10px; align-items: start; }
.item-main { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
.item-main strong { font-weight: 500; overflow-wrap: anywhere; }
.item-main small { color: var(--muted); font-size: var(--fs-xs); }
.item-main .facts { margin-top: 6px; font-size: var(--fs-sm); }
.item-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.coll-item { display: grid; gap: 6px; }
.coll-creds { display: grid; gap: 6px; padding-left: 16px; border-left: 2px solid var(--line); margin-left: 10px; }
.check-answer:empty { display: none; }
.check-answer { margin-top: 4px; }
.danger { border: 1px solid var(--bad); border-radius: var(--r-2); padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--bad-soft); }
.danger .muted { color: var(--ink-2); }
.diffbar { border-top: 1px solid var(--line-strong); background: var(--raised); padding: 10px 20px calc(10px + var(--safe-b)); display: grid; gap: 8px; }
.diffbar[hidden] { display: none; }
.diffbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.diffbar .diff { max-height: 120px; overflow: auto; }
.kbdnote { font-size: var(--fs-xs); color: var(--muted); }
.input.changed, .seg.changed, select.input.changed { border-color: var(--accent-line); background: var(--accent-soft); }
@media (max-width: 640px) {
  .drawer-head { padding-left: 16px; padding-right: 16px; }
  .drawer-body { padding-left: 16px; padding-right: 16px; }
  .diffbar { padding-left: 16px; padding-right: 16px; }
  .coll-creds { padding-left: 10px; margin-left: 4px; }
  .diffbar-row > .hint { display: none; }
}
