/**
 * @license
 * Copyright 2026 Steven Roussey <sroussey@gmail.com>
 * SPDX-License-Identifier: Apache-2.0
 */

/* The console's token system: the chrome follows the viewer's light/dark
   setting, and the run screen keeps one identity in both — it is a terminal,
   not a card. */
/* ---------- tokens: light is the base, dark redefines only values ---------- */
:root {
  --ground: #f4f6f8;
  --panel: #ffffff;
  --sunk: #eceff4;
  --raise: #ffffff;
  --line: #dde2e9;
  --line-2: #e8ecf2;
  --ink: #151a22;
  --ink-2: #47515f;
  --ink-3: #727d8c;
  --accent: #0d8b84;
  --accent-2: #0a6f6a;
  --accent-soft: rgba(13, 139, 132, 0.1);
  --ok: #2c8b58;
  --run: #a2740b;
  --fail: #c33c39;
  /* The alert bar's own pair. `--fail` is tuned to be read AS text on the page
     background, so it is the wrong background to put text ON — in the dark
     theme it is light enough that white would fall under 3:1. Stated per theme
     instead, each pair checked for contrast. */
  --alert-bg: #c33c39;
  --alert-ink: #ffffff;
  --idle: #8b95a3;
  --shadow: 0 1px 2px rgba(16, 22, 30, 0.05), 0 8px 24px -16px rgba(16, 22, 30, 0.28);
  --screen: #0f1620;
  --screen-line: #222c39;

  /* the screen keeps one identity in both themes — it is a terminal, not a card */
  --scr-fg: #d7dfea;
  --scr-dim: #828f9f;
  --scr-faint: #5b6776;
  --scr-ok: #5cc98d;
  --scr-run: #e3b14c;
  --scr-fail: #f4746f;
  --scr-idle: #5f6c7c;
  --scr-accent: #4bd4c7;
  --scr-violet: #9a8cf5;
  --scr-cyan: #63c2e8;

  --r: 7px;
  --r-sm: 5px;
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-20: 20px;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c1015;
    --panel: #141922;
    --sunk: #10151d;
    --raise: #1a212b;
    --line: #242d39;
    --line-2: #1b222d;
    --ink: #e5eaf1;
    --ink-2: #a4afbe;
    --ink-3: #7a8695;
    --accent: #2fc0b4;
    --accent-2: #5ad8cd;
    --accent-soft: rgba(47, 192, 180, 0.13);
    --idle: #6d7a89;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -18px rgba(0, 0, 0, 0.7);
    --screen: #131b25;
    --screen-line: #26313f;
  }
}
:root[data-theme="dark"] {
  --ground: #0c1015;
  --panel: #141922;
  --sunk: #10151d;
  --raise: #1a212b;
  --line: #242d39;
  --line-2: #1b222d;
  --ink: #e5eaf1;
  --ink-2: #a4afbe;
  --ink-3: #7a8695;
  --accent: #2fc0b4;
  --accent-2: #5ad8cd;
  --accent-soft: rgba(47, 192, 180, 0.13);
  --ok: #4cbb7f;
  --run: #d9a63a;
  --fail: #ef6b66;
  --alert-bg: #7c2320;
  --alert-ink: #ffe7e5;
  --idle: #6d7a89;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -18px rgba(0, 0, 0, 0.7);
  --screen: #131b25;
  --screen-line: #26313f;
}

* {
  box-sizing: border-box;
}
html {
  background: var(--ground);
}
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-13);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- shell ---------- */
/*
 * The page: an optional alert bar, then the layout.
 *
 * A column flex rather than the layout owning the viewport itself, so the bar
 * PUSHES the layout down instead of covering the top of it. The viewport
 * height and the floor live here now; `.app` takes what is left.
 */
.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 560px;
}

/*
 * The CLI has stopped answering — the one condition that disables every
 * control on the page, so it is announced above all of them rather than inside
 * a column that scrolls. Full bleed and red: this is not a field-level error.
 */
.alertbar {
  flex: 0 0 auto;
  background: var(--alert-bg);
  color: var(--alert-ink);
  padding: 9px 16px;
  font-size: var(--fs-13);
  line-height: 1.45;
  /* Above the rails' own backgrounds when a resize handle sits near the seam. */
  position: relative;
  z-index: 5;
}
.alertbar strong {
  font-weight: 600;
}

.app {
  /* Both rail widths are drag state, written back as inline custom properties
     on this element. The values here are the fallback for a first paint that
     happens before the script sets them. */
  --rail-l: 266px;
  --rail-r: 248px;
  display: grid;
  grid-template-columns: var(--rail-l) minmax(0, 1fr) var(--rail-r);
  grid-template-areas: "rail main status";
  /* Whatever the bar leaves. `min-height: 0` so the grid's own children can
     scroll instead of stretching this past the bottom of the window. */
  flex: 1 1 auto;
  min-height: 0;
  /* Containing block for the two resize handles, which sit on the seams rather
     than inside the rails (the status rail scrolls; a child of it would ride
     the scroll instead of holding the edge). */
  position: relative;
}

/* ---------- resize handles ---------- */
.resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  z-index: 5;
  cursor: col-resize;
  /* Without this a touch drag scrolls the page instead of moving the seam. */
  touch-action: none;
}
.resizer-l {
  left: calc(var(--rail-l) - 4px);
}
.resizer-r {
  right: calc(var(--rail-r) - 4px);
}
/* The seam itself is the rail's existing 1px border; this paints over it on
   hover and while dragging so the target is visible without adding a gutter
   that would be there all the time. */
.resizer::after {
  content: "";
  position: absolute;
  inset: 0 3px;
  background: transparent;
  transition: background 0.12s ease;
}
.resizer:hover::after,
.resizer:focus-visible::after,
.resizer[data-dragging="true"]::after {
  background: var(--accent);
}
.resizer:focus-visible {
  outline: none;
}
/* While a seam is being dragged the cursor must not flicker to a text caret
   over the panes it passes. */
.app:has(.resizer[data-dragging="true"]) {
  cursor: col-resize;
  user-select: none;
}
.rail {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Commands on the left, status on the right: the tree gets the full height it
   needs, and the runs/fetch/database lines stop pushing it up. */
.rail-l {
  grid-area: rail;
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 1;
}
.rail-r {
  grid-area: status;
  border-left: 1px solid var(--line);
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
.rail-r .railsec:first-child {
  border-top: 0;
}
.main {
  grid-area: main;
  display: grid;
  /* An implicit `auto` column sizes to min-content. WebKit then lets the
     form's max-width (and Safari's intrinsic <input> minimum) blow the
     middle track out over the status rail. Pin one shrinking column. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  /* Clip rather than scroll: a vertical scrollport here would steal
     position:sticky from .body. Isolation keeps a sticky cmdbar from
     compositing over the status rail. */
  overflow-x: clip;
  isolation: isolate;
}
.main > * {
  min-width: 0;
}

/* ---------- rail ---------- */
.brand {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  gap: 9px;
  align-items: center;
}
.mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  flex: none;
}
:root[data-theme="dark"] .mark,
:root:not([data-theme="light"]) .mark {
  color: #08121a;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .mark {
    color: #fff;
  }
}
.brand-t {
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-s {
  font-family: var(--mono);
  font-size: var(--fs-11);
  color: var(--ink-3);
}
.searchbox {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
}
.searchbox input {
  width: 100%;
  background: var(--sunk);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: var(--fs-12);
  color: var(--ink);
}
.searchbox input::placeholder {
  color: var(--ink-3);
}
.searchbox input:focus {
  background: var(--panel);
  border-color: var(--accent);
  outline: none;
}
.tree {
  overflow: auto;
  flex: 1;
  padding: 8px 8px 14px;
  min-height: 0;
}
.grp {
  margin-top: 10px;
}
.grp:first-child {
  margin-top: 2px;
}
.grp-h {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: var(--fs-11);
  color: var(--ink-3);
}
.grp-h .ext {
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: 0;
  font-size: 9px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 14px;
}
.cmd {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-2);
}
.cmd:hover {
  background: var(--sunk);
  color: var(--ink);
}
.cmd[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--ink);
}
.cmd[aria-current="true"] .cmd-n {
  color: var(--accent-2);
  font-weight: 600;
}
/* The name is the whole row in the rail: it never wraps or truncates, and the
   badges take the space after it. `.cmd-d` is the second column the same row
   shape gets in a picker's result list, where the detail beside a label is the
   point — it takes what is left and ellipsizes. */
.cmd-n {
  font-family: var(--mono);
  font-size: var(--fs-12);
  flex: none;
  white-space: nowrap;
}
.cmd-d {
  font-size: var(--fs-11);
  color: var(--ink-3);
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmd .badges {
  flex: none;
  margin-left: auto;
}
/* The `all` marker and the cost badges are two groups on one row, and two auto
   margins split the free space between them — which staggers the marker down
   the rail. Only the first takes the space; the rest close up behind it, so
   every chip on every row lands in one right-hand cluster. */
.cmd .badges ~ .badges {
  margin-left: 0;
}
.grp-h {
  background: none;
  border: 0;
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.grp-h:hover {
  color: var(--ink-2);
}
/* A group heading is selectable too — it opens the group's own page — so it
   says when it is the thing on screen, in the accent the rows use. */
.grp-h[aria-current="true"] {
  color: var(--accent-2);
}
.caret {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-3);
  width: 9px;
  flex: none;
  display: inline-block;
}
/* A sub-group row is set exactly like the leaves around it — the caret is
   what says it opens; a heavier face would outrank the group heading above. */
.cmd.sub .cmd-n {
  color: inherit;
  font-weight: 400;
}
/* One box per subtree: the rule runs from under the parent's caret past its
   last child, so where a subtree ends is drawn, not inferred from indent. */
.kids {
  margin-left: 10px;
  padding-left: 3px;
  border-left: 1px solid var(--line);
}
.kids .kids {
  margin-left: 12px;
  margin-top: 1px;
  margin-bottom: 4px;
}
.kids .cmd {
  padding-left: 6px;
}
.cmd.sub[aria-expanded="true"] .caret {
  color: var(--ink-2);
}
.railsec {
  border-top: 1px solid var(--line-2);
  padding: 10px 12px 12px;
}
.railsec h4 {
  margin: 0 0 7px;
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: var(--fs-11);
  color: var(--ink-3);
  font-weight: 600;
}
.runitem {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-align: left;
}
.runitem:hover {
  background: var(--sunk);
}
.runitem .lbl {
  font-family: var(--mono);
  font-size: var(--fs-11);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.runitem .t {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--idle);
}
.dot.ok {
  background: var(--ok);
}
.dot.run {
  background: var(--run);
}
.dot.fail {
  background: var(--fail);
}
.dot.warn {
  background: var(--run);
}
.dot.run {
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.meter {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}
.meter .bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--sunk);
  overflow: hidden;
}
.meter .bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 62%;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
}
.crumb {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
  font-size: var(--fs-13);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.crumb b {
  font-weight: 600;
}
.crumb .sep {
  color: var(--ink-3);
}
.crumb .dim {
  color: var(--ink-3);
}
.spacer {
  flex: 1;
}
.ctl {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tgl {
  display: inline-flex;
  background: var(--sunk);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.tgl button {
  background: none;
  border: 0;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: var(--fs-11);
  color: var(--ink-3);
  cursor: pointer;
  font-family: var(--cond);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tgl button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  cursor: pointer;
  font-size: var(--fs-12);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover {
  border-color: var(--ink-3);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #052120;
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.btn.danger {
  color: var(--fail);
  border-color: var(--line);
}
.btn.danger:hover {
  border-color: var(--fail);
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Sized to sit inside a table cell without growing the row. */
.btn.sm {
  padding: 2px 8px;
  font-size: var(--fs-11);
  white-space: nowrap;
}

/* Several actions on one row stay on one line, and wrap only when narrow. */
.rowacts {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  color: var(--ink-3);
}
.btn.primary .kbd {
  border-color: rgba(0, 0, 0, 0.28);
  color: #052120;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 12px 8px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: var(--fs-12);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: -1px;
}
.tab:hover {
  color: var(--ink);
}
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.tab .pill {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--sunk);
  border-radius: 9px;
  padding: 1px 6px;
  color: var(--ink-3);
}
.tab[aria-selected="true"] .pill {
  background: var(--accent-soft);
  color: var(--accent-2);
}

/* ---------- body ---------- */
.body {
  overflow: auto;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  /* Flex centering, not margin:auto. WebKit resolves auto side margins on a
     max-width block inside a grid item against the outer grid (the whole
     app), which shifts .wrap over the status rail and leaves the main
     column empty on the left. */
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wrap {
  width: 100%;
  max-width: 1040px;
  min-width: 0;
  flex-shrink: 0;
}
.lede {
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0 0 16px;
}
h2.sec {
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--fs-11);
  color: var(--ink-3);
  font-weight: 600;
  margin: 22px 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2.sec::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-2);
}
h2.sec:first-child {
  margin-top: 0;
}
/* The command description leads the options pane; the first section under it
   does not need the full inter-section gap on top of the lede's own. */
.lede + h2.sec {
  margin-top: 0;
}

/* A group's page lists its commands with the descriptions the rail has no room
   for: the pane has the width, so a line wraps here instead of ellipsizing —
   which is the whole reason the rail gave it up. The names take a common
   minimum so the second column starts in one place. */
.grouplist {
  padding: 4px;
}
.grouplist .cmd-n {
  min-width: 14ch;
}
.grouplist .cmd-d {
  white-space: normal;
  overflow: visible;
}

/* ---------- form ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.field {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  min-width: 0;
  max-width: 100%;
}
.field:last-child {
  border-bottom: 0;
}
.field.req .fl b::after {
  content: "*";
  color: var(--fail);
  margin-left: 3px;
  font-weight: 400;
}
.fl b {
  font-family: var(--mono);
  font-size: var(--fs-12);
  font-weight: 500;
  display: block;
}
.fl span {
  display: block;
  font-size: var(--fs-11);
  color: var(--ink-3);
  margin-top: 2px;
}
.fl .type {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}
.fc {
  min-width: 0;
}
.fc input[type="text"],
.fc input[type="number"],
.fc select,
.fc textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--sunk);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: var(--fs-12);
}
.fc textarea {
  font-family: var(--mono);
  resize: vertical;
  min-height: 62px;
  line-height: 1.55;
}
.fc input:focus,
.fc select:focus,
.fc textarea:focus {
  outline: none;
  background: var(--panel);
  border-color: var(--accent);
}
/*
 * A text field and its expand button.
 *
 * The button sits inside the field's top-right corner rather than beside it, so
 * the control keeps the full column width — a form two rails in from the left
 * has none to give away — and stays in the same place when the input becomes a
 * text box.
 */
.fexp {
  position: relative;
  min-width: 0;
}
.fexp input[type="text"],
.fexp textarea {
  padding-right: 28px;
}
.fexpb {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  font-size: var(--fs-12);
  line-height: 1;
  cursor: pointer;
}
.fexpb:hover:not(:disabled) {
  background: var(--sunk);
  color: var(--ink);
}
.fexpb:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
/* Still legible, because its title explains why it cannot be pressed. */
.fexpb:disabled {
  opacity: 0.45;
  cursor: default;
}

.fc .hint {
  font-size: var(--fs-11);
  color: var(--ink-3);
  margin-top: 5px;
}
.swi {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: var(--fs-12);
  color: var(--ink-2);
}
.swi input {
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--sunk);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.swi input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-3);
  transition:
    transform 0.15s,
    background 0.15s;
}
.swi input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.swi input:checked::after {
  transform: translateX(14px);
  background: #fff;
}
details.adv {
  margin-top: 12px;
}
details.adv > summary {
  cursor: pointer;
  font-size: var(--fs-12);
  color: var(--ink-3);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 2px;
}
details.adv > summary::-webkit-details-marker {
  display: none;
}
details.adv > summary::before {
  content: "▸";
  font-family: var(--mono);
  transition: transform 0.15s;
  display: inline-block;
}
details.adv[open] > summary::before {
  transform: rotate(90deg);
}
details.adv > summary:hover {
  color: var(--ink);
}

/* widget: model picker */
.wpick {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--sunk);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 5px 9px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.wpick:hover {
  border-color: var(--line);
}
.wpick .prov {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  color: #fff;
  background: #c96442;
  flex: none;
}
.wpick .nm {
  font-family: var(--mono);
  font-size: var(--fs-12);
}
.wpick .cost {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
/* widget: entity lookup (extension-contributed) */
.wlookup {
  display: flex;
  gap: 7px;
}
.wlookup input {
  flex: 1;
}
.chipres {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 2px 9px 2px 7px;
  font-size: var(--fs-11);
}
.chipres b {
  font-family: var(--mono);
  font-weight: 500;
}

/* command bar (CLI preview) */
.cmdbar {
  position: sticky;
  bottom: -18px;
  margin-top: 16px;
  width: 100%;
  max-width: 100%;
  background: var(--screen);
  border: 1px solid var(--screen-line);
  border-radius: var(--r);
  padding: 10px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}
.cmdbar code {
  font-family: var(--mono);
  font-size: var(--fs-12);
  color: var(--scr-fg);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}
.cmdbar code .fl {
  color: var(--scr-accent);
}
.cmdbar code .vl {
  color: var(--scr-cyan);
}
.cmdbar code .pr {
  color: var(--scr-faint);
}
.cmdbar .acts {
  display: flex;
  gap: 7px;
  flex: none;
}
.cmdbar .ghost {
  background: transparent;
  border: 1px solid var(--screen-line);
  color: var(--scr-dim);
  border-radius: var(--r-sm);
  padding: 4px 9px;
  font-size: var(--fs-11);
  cursor: pointer;
}
.cmdbar .ghost:hover {
  color: var(--scr-fg);
  border-color: var(--scr-dim);
}

/* ---------- screen (run console) ---------- */
.screen {
  background: var(--screen);
  border: 1px solid var(--screen-line);
  border-radius: var(--r);
  color: var(--scr-fg);
  font-family: var(--mono);
  font-size: var(--fs-12);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.scr-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--screen-line);
  background: rgba(255, 255, 255, 0.02);
}
.scr-head .cli {
  color: var(--scr-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.scr-head .cli b {
  color: var(--scr-fg);
  font-weight: 500;
}
.scr-head .el {
  color: var(--scr-faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.scr-body {
  padding: 10px 12px 12px;
  overflow: auto;
  max-height: min(58vh, 620px);
}
.gline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 8px;
  color: var(--scr-dim);
  border-bottom: 1px dashed var(--screen-line);
  margin-bottom: 8px;
}
.gline .lb {
  color: var(--scr-fg);
}
.gline .pct {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 1.5px 0;
  position: relative;
}
.row .gl {
  width: 12px;
  flex: none;
  text-align: center;
}
.row .lab {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.row .msg {
  color: var(--scr-dim);
}
.row .bar {
  flex: none;
  color: var(--scr-faint);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.row .pct {
  flex: none;
  width: 38px;
  text-align: right;
  color: var(--scr-dim);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.row.d1 {
  padding-left: 20px;
}
.row.d2 {
  padding-left: 40px;
}
.row.d3 {
  padding-left: 60px;
}
.usage.d1 {
  padding-left: 42px;
}
.usage.d2 {
  padding-left: 62px;
}
.bubble.d1 {
  margin-left: 42px;
}
.err.d1 {
  margin-left: 42px;
}
.row.sel {
  background: rgba(75, 212, 199, 0.07);
  border-radius: 4px;
}
.row:hover {
  background: rgba(255, 255, 255, 0.035);
  border-radius: 4px;
  cursor: pointer;
}
.st-COMPLETED .gl {
  color: var(--scr-ok);
}
.st-COMPLETED .lab {
  color: var(--scr-dim);
}
.st-PROCESSING .gl {
  color: var(--scr-run);
}
.st-PROCESSING .lab {
  color: var(--scr-fg);
}
.st-PENDING .gl {
  color: var(--scr-idle);
}
.st-PENDING .lab {
  color: var(--scr-idle);
}
.st-FAILED .gl,
.st-FAILED .lab {
  color: var(--scr-fail);
}
.st-ABORTED .gl,
.st-ABORTED .lab {
  color: var(--scr-idle);
}
.usage {
  padding-left: 22px;
  color: var(--scr-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.usage .up {
  color: var(--scr-cyan);
}
.usage .dn {
  color: var(--scr-violet);
}
.guide {
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--screen-line);
}
.bubble {
  margin: 5px 0 7px 22px;
  border: 1px solid var(--screen-line);
  border-left: 2px solid var(--scr-violet);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 7px 10px;
  max-width: 78ch;
  background: rgba(154, 140, 245, 0.05);
}
.bubble .turn {
  margin-bottom: 5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.bubble .turn:last-child {
  margin-bottom: 0;
}
.bubble .r {
  font-weight: 600;
}
.bubble .r.user {
  color: var(--scr-cyan);
}
.bubble .r.assistant {
  color: var(--scr-violet);
}
.bubble .txt {
  color: var(--scr-fg);
}
.bubble .caret {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--scr-violet);
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* map iterations — two renderings of the same slot data */
.maphost {
  margin: 3px 0 6px 20px;
}
.mapgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 6px 0 2px;
  max-width: 720px;
}
.cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  cursor: pointer;
}
.cell.done {
  background: var(--scr-ok);
  opacity: 0.85;
}
.cell.run {
  background: var(--scr-run);
  animation: pulse 1.1s ease-in-out infinite;
}
.cell.fail {
  background: var(--scr-fail);
}
.cell.sel {
  border-color: var(--scr-fg);
}
.cell:hover {
  border-color: var(--scr-fg);
}
.maplegend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--scr-faint);
  font-size: 11px;
  padding-top: 4px;
  font-variant-numeric: tabular-nums;
}
.maplegend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: 0;
}
.mapmore {
  color: var(--scr-faint);
  font-size: 11px;
  padding-left: 20px;
}
.seg {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
  flex: none;
}
.seg button {
  background: none;
  border: 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--scr-faint);
  font-family: var(--mono);
}
.seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--scr-fg);
}
/* Controls on the screen's own header belong to the screen, not to the page. */
.scr-head .ghost {
  background: transparent;
  border: 1px solid var(--screen-line);
  color: var(--scr-dim);
  border-radius: var(--r-sm);
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--mono);
  flex: none;
}
.scr-head .ghost:hover {
  color: var(--scr-fail);
  border-color: var(--scr-fail);
}
/* A command that builds no task graph: its printed output is the run, so it is
   rendered on the screen rather than under it. */
.scr-out {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--fs-12);
  line-height: 1.6;
  color: var(--scr-fg);
  white-space: pre;
  overflow-x: auto;
  padding: 2px 0;
}
.scr-foot {
  border-top: 1px solid var(--screen-line);
  padding: 8px 12px;
  display: flex;
  gap: 16px;
  color: var(--scr-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.scr-foot b {
  color: var(--scr-fg);
  font-weight: 500;
}
.err {
  margin: 6px 0 8px 22px;
  border-left: 2px solid var(--scr-fail);
  padding: 6px 10px;
  background: rgba(244, 116, 111, 0.07);
  color: var(--scr-fail);
  max-width: 80ch;
  white-space: pre-wrap;
  line-height: 1.6;
}
.err .act {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.err .act button {
  background: transparent;
  border: 1px solid var(--scr-fail);
  color: var(--scr-fail);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--mono);
}

/* inspector drawer */
.inspect {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .inspect {
    grid-template-columns: minmax(0, 1fr);
  }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.panel h5 {
  margin: 0;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: var(--fs-11);
  color: var(--ink-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel .pb {
  padding: 11px 12px;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: var(--fs-11);
}
.kv dt {
  color: var(--ink-3);
}
.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
pre.json {
  margin: 0;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: var(--fs-12);
  line-height: 1.6;
  overflow: auto;
  max-height: 340px;
  color: var(--ink-2);
}
pre.json .k {
  color: var(--ink-3);
}
pre.json .s {
  color: var(--ink);
}
pre.json .n {
  color: var(--accent-2);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-12);
}
.tbl th {
  text-align: left;
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: var(--fs-11);
  color: var(--ink-3);
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-2);
  font-weight: 600;
}
.tbl td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-variant-numeric: tabular-nums;
}
.tbl tr:last-child td {
  border-bottom: 0;
}
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--ink-3);
}
.badge.ok {
  color: var(--ok);
  border-color: var(--ok);
}
.badge.fail {
  color: var(--fail);
  border-color: var(--fail);
}
.badge.ext {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- status bar ---------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--mono);
  font-size: var(--fs-11);
  color: var(--ink-3);
}
.statusbar .live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
}
.statusbar b {
  color: var(--ink-2);
  font-weight: 500;
}

/* ---------- annotation mode ---------- */
.app.annotate [data-slot] {
  outline: 1.5px dashed var(--accent);
  outline-offset: -1px;
  position: relative;
}
.app.annotate [data-slot]::after {
  content: attr(data-slot);
  position: absolute;
  top: 0;
  right: 0;
  z-index: 9;
  background: var(--accent);
  color: #04201e;
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 0 0 0 4px;
  pointer-events: none;
  letter-spacing: 0.02em;
}
:root[data-theme="dark"] .app.annotate [data-slot]::after {
  color: #04201e;
}

.notes {
  max-width: 70ch;
}
.notes h3 {
  font-size: var(--fs-16);
  margin: 26px 0 6px;
  letter-spacing: -0.01em;
}
.notes h3:first-child {
  margin-top: 0;
}
.notes p {
  color: var(--ink-2);
  margin: 0 0 10px;
}
.notes code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--sunk);
  padding: 1px 5px;
  border-radius: 4px;
}
.notes ul {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--ink-2);
}
.notes li {
  margin-bottom: 5px;
}
.q {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 12px;
  margin: 0 0 14px;
  color: var(--ink-2);
}
.q b {
  color: var(--ink);
}

.back {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0 6px 0 -4px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.back:hover {
  border-color: var(--ink-3);
}

/* ---------- contributed UI: badges, status lines, panels ---------- */
/* Every colour below is a token, so a downstream package's badge and a
   built-in one are the same colour in both themes and neither can hard-code
   one that only works in the theme its author had open. */
.badges {
  display: inline-flex;
  gap: 3px;
  flex: none;
  margin-left: auto;
}
.cb {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.cb-ai {
  color: var(--accent-2);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}
.cb-network {
  color: var(--ink-2);
}
.cb-slow {
  color: var(--run);
  border-color: color-mix(in srgb, var(--run) 40%, transparent);
}
.cb-writes {
  color: var(--ink-2);
}
.cb-destructive {
  color: var(--fail);
  border-color: color-mix(in srgb, var(--fail) 45%, transparent);
  background: color-mix(in srgb, var(--fail) 10%, transparent);
  font-weight: 700;
}
/* Membership in an `all`, not a cost: outlined rather than filled, so it reads
   beside the cost badges without competing with them. `partial` is the one an
   operator has to look twice at — an `all` that leaves siblings out. */
.cb-all {
  color: var(--ink-2);
  border-color: var(--line-2);
  white-space: nowrap;
}
.cb-all.partial {
  color: var(--run);
  border-color: color-mix(in srgb, var(--run) 40%, transparent);
}

/* The order behind that marker, spelled out where the Run button is. */
.plan {
  margin-bottom: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--sunk);
  font-size: var(--fs-12);
  color: var(--ink-2);
}
/* Not the uppercase rail heading: it names commands, and a command spelled in
   capitals is not the command anyone types. */
.plan h3 {
  margin: 0;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--ink-2);
}
.plan ol {
  margin: 6px 0 0;
  padding-left: 20px;
}
.plan li {
  margin: 1px 0;
}
.plan code {
  font-family: var(--mono);
  font-size: var(--fs-11);
  color: var(--ink);
}
.plan .when {
  margin-left: 6px;
  color: var(--ink-3);
  font-size: var(--fs-11);
}
.plan .skipped {
  margin: 6px 0 0;
  color: var(--ink-3);
}
.plan .skipped code {
  color: var(--ink-2);
}

.cnote {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--sunk);
  color: var(--ink-2);
  font-size: var(--fs-12);
  min-width: 0;
  max-width: 100%;
}
.cnote > span {
  min-width: 0;
}
.cnote .badges {
  margin-left: 0;
}
.cnote.danger {
  border-color: color-mix(in srgb, var(--fail) 45%, transparent);
  background: color-mix(in srgb, var(--fail) 8%, transparent);
  color: var(--ink);
}

.sline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
}
.sl-l {
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}
.sl-v {
  font-family: var(--mono);
  margin-left: auto;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sline.t-ok .sl-v {
  color: var(--ok);
}
.sline.t-warn .sl-v {
  color: var(--run);
}
.sline.t-fail .sl-v {
  color: var(--fail);
}
.sline.t-idle .sl-v {
  color: var(--ink-3);
}

/* A wide result table scrolls inside its panel; the page never scrolls sideways. */
.tblwrap {
  overflow-x: auto;
  max-width: 100%;
}
.tbl tr.t-warn td {
  background: color-mix(in srgb, var(--run) 9%, transparent);
}
.tbl tr.t-fail td {
  background: color-mix(in srgb, var(--fail) 9%, transparent);
}
.tbl tr.t-ok td {
  background: color-mix(in srgb, var(--ok) 8%, transparent);
}
.pnote {
  padding: 7px 10px;
  color: var(--ink-3);
  font-size: var(--fs-11);
  border-top: 1px solid var(--line-2);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line-2);
}
.stat {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--panel);
}
.stat-l {
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 10px;
  color: var(--ink-3);
}
.stat-v {
  font-family: var(--mono);
  font-size: var(--fs-16);
  font-variant-numeric: tabular-nums;
}
.stat-d {
  font-size: var(--fs-11);
  color: var(--ink-3);
}
.stat.t-ok .stat-v {
  color: var(--ok);
}
.stat.t-warn .stat-v {
  color: var(--run);
}
.stat.t-fail .stat-v {
  color: var(--fail);
}
.stat.t-idle .stat-v {
  color: var(--ink-3);
}

.tline {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
}
.tline li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 5px 0 5px 12px;
  border-left: 2px solid var(--line);
  position: relative;
}
.tline li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--idle);
}
.tline li.t-ok::before {
  background: var(--ok);
}
.tline li.t-warn::before {
  background: var(--run);
}
.tline li.t-fail::before {
  background: var(--fail);
}
.tline li.t-info::before {
  background: var(--accent);
}
.tl-d {
  font-family: var(--mono);
  font-size: var(--fs-11);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.tl-l {
  font-size: var(--fs-13);
}
.tl-x {
  grid-column: 2;
  font-size: var(--fs-11);
  color: var(--ink-3);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ground) 72%, transparent);
  padding: 20px;
}
.modal-b {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.modal-b h3 {
  margin: 0 0 8px;
  font-size: var(--fs-16);
}
.modal-b p {
  margin: 0 0 12px;
  color: var(--ink-2);
}
.modal-c {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-12);
  background: var(--sunk);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  white-space: pre;
  margin-bottom: 14px;
}
.modal-b .acts {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
@media (max-width: 1080px) {
  .app {
    grid-template-columns: var(--rail-l) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "rail main"
      "status main";
  }
  .rail-r {
    border-left: 0;
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
    max-height: 40dvh;
  }
  /* Status stacks under the commands here, so its width is no longer its own
     to drag — it shares the rail column. */
  .resizer-r {
    display: none;
  }
}
@media (max-width: 820px) {
  /* One column, one pane at a time: there is no seam to drag. */
  .resizer {
    display: none;
  }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "rail"
      "status";
  }
  .app[data-pane="list"] .main {
    display: none;
  }
  .app[data-pane="detail"] .rail {
    display: none;
  }
  .back {
    display: inline-flex;
  }
  .rail {
    border-right: 0;
  }
  .app[data-pane="detail"] {
    grid-template-areas: "main";
  }
  .field {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}
