/* ForestGuard console — the whole visual system, in one sheet.
 *
 * There is no other stylesheet and there is no inline style: the CSP forbids
 * both, and tools/build.mjs fails the build on either. Geometry that must be
 * computed (a tree row's indent) is assigned as a CSSOM number from the module
 * that knows the depth; everything else is a class in this file. */

@font-face {
  font-family: 'FGMonoASCII';
  src: url('/fonts/fg-mono-ascii.woff2') format('woff2');
  font-display: block;
  font-weight: 400;
  font-style: normal;
}

:root {
  --bg: #0d1117;
  --panel: #12171f;
  --panel-2: #161c26;
  --line: #262d38;
  --line-2: #30394a;
  --fg: #d3dae3;
  --dim: #8b949e;
  --faint: #6b7480;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --stale: #7d8590;
  --green-bg: #12261a;
  --yellow-bg: #2a2113;
  --red-bg: #2d1618;
  --stale-bg: #1c2029;
  --row: 24px;
  --mono: ui-monospace, 'FGMonoASCII', 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* ------------------------------------------------------------- motion --- */
/*
 * The whole panel's vocabulary of movement, in one place. Two rules govern it:
 *
 *   1. Nothing transitions `all`. Every transition below names the properties
 *      it animates, so a future declaration cannot silently join the list and
 *      start animating layout on hover.
 *   2. Entry animations are triggered by INSERTION, not by a class. A screen
 *      swap here is `replaceChildren`, and a freshly inserted element with an
 *      `animation` runs it — which is why route changes animate without a
 *      single line of choreography in the router.
 *
 * Durations live at 120–180ms: long enough to be read as motion, short enough
 * that an operator chasing a red leaf never waits for the console. Everything
 * here collapses under the `prefers-reduced-motion` block at the foot of the
 * sheet, which zeroes duration AND delay for animations and transitions alike.
 */

@keyframes fg-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@keyframes fg-fade {
  from {
    opacity: 0;
  }
}
@keyframes fg-fade-out {
  to {
    opacity: 0;
  }
}
@keyframes fg-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
@keyframes fg-modal-out {
  to {
    opacity: 0;
    transform: translateY(4px) scale(0.99);
  }
}
@keyframes fg-from-right {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}
@keyframes fg-from-left {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
}
/* List-item choreography for reconciled lists (src/ui/reconcile.ts): an item
 * that ARRIVES in an already-populated list fades in; one that LEAVES fades
 * out and is removed on animationend; one that MOVES slides via a FLIP
 * transform the reconciler applies inline. First paints do not animate — a
 * screen appearing is not fifty arrivals. */
@keyframes fg-item-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
}
@keyframes fg-item-out {
  to {
    opacity: 0;
  }
}
.fg-item-enter {
  animation: fg-item-in 150ms ease-out;
}
.fg-item-leave {
  animation: fg-item-out 150ms ease-out forwards;
  pointer-events: none;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.45 var(--sans);
  -webkit-tap-highlight-color: rgba(88, 166, 255, 0.24);
  touch-action: manipulation;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 40;
  padding: 4px 10px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--fg);
  text-decoration: none;
  transition: top 120ms ease;
}
.skip:focus {
  top: 6px;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
.lnk {
  transition: color 140ms ease-out;
}

/* -------------------------------------------------------------- icons --- */
/*
 * ONE pack: Lucide (ISC), vendored as individual SVGs under /icons/ui/. No
 * CDN, no icon font, no third-party script — `img-src 'self'` (which is what
 * governs a mask URL) would refuse anything else anyway.
 *
 * The mechanism is a MASK, not an <img>: the span is painted with
 * `background-color: currentColor` and the SVG only decides which pixels
 * survive. That is what lets one file serve a dimmed twisty, a red chevron on
 * a failing row and a green brand mark, and it is why every icon inherits
 * hover/selected/disabled state for free.
 *
 * Every icon is decorative (aria-hidden in the DOM). Nothing here is ever the
 * accessible name.
 */

.ico {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: none;
  background-color: currentColor;
  -webkit-mask-image: var(--ico);
  mask-image: var(--ico);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  vertical-align: -2px;
}
.ico-sm {
  width: 12px;
  height: 12px;
}
.ico-lg {
  width: 16px;
  height: 16px;
}

.ico-activity {
  --ico: url('/icons/ui/activity.svg');
}
.ico-arrow-right {
  --ico: url('/icons/ui/arrow-right.svg');
}
.ico-arrow-up-right {
  --ico: url('/icons/ui/arrow-up-right.svg');
}
.ico-ban {
  --ico: url('/icons/ui/ban.svg');
}
.ico-check {
  --ico: url('/icons/ui/check.svg');
}
.ico-chevron-down {
  --ico: url('/icons/ui/chevron-down.svg');
}
.ico-chevron-left {
  --ico: url('/icons/ui/chevron-left.svg');
}
.ico-chevron-right {
  --ico: url('/icons/ui/chevron-right.svg');
}
.ico-chevrons-down-up {
  --ico: url('/icons/ui/chevrons-down-up.svg');
}
.ico-chevrons-up-down {
  --ico: url('/icons/ui/chevrons-up-down.svg');
}
.ico-circle-help {
  --ico: url('/icons/ui/circle-help.svg');
}
.ico-circle-small {
  --ico: url('/icons/ui/circle-small.svg');
}
.ico-circle-x {
  --ico: url('/icons/ui/circle-x.svg');
}
.ico-clock {
  --ico: url('/icons/ui/clock.svg');
}
.ico-code {
  --ico: url('/icons/ui/code.svg');
}
.ico-copy {
  --ico: url('/icons/ui/copy.svg');
}
.ico-file-text {
  --ico: url('/icons/ui/file-text.svg');
}
.ico-flag {
  --ico: url('/icons/ui/flag.svg');
}
.ico-pause {
  --ico: url('/icons/ui/pause.svg');
}
.ico-pencil {
  --ico: url('/icons/ui/pencil.svg');
}
.ico-search {
  --ico: url('/icons/ui/search.svg');
}
.ico-shield {
  --ico: url('/icons/ui/shield.svg');
}
.ico-sparkle {
  --ico: url('/icons/ui/sparkle.svg');
}
.ico-terminal {
  --ico: url('/icons/ui/terminal.svg');
}
.ico-triangle-alert {
  --ico: url('/icons/ui/triangle-alert.svg');
}
.ico-x {
  --ico: url('/icons/ui/x.svg');
}

/* ------------------------------------------------------------- header --- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  min-height: 40px;
  padding: 0 10px;
  padding-top: env(safe-area-inset-top);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
/* The brand mark is the same shield the PWA icon is generated from — one
 * symbol, one file, drawn at 16px in a 40px header row. */
.mark {
  width: 16px;
  height: 16px;
  color: var(--green);
}
.wordmark {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.root-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--fg);
  padding: 2px 4px;
  border-radius: 4px;
}
.root-line {
  transition: background-color 140ms ease-out;
}
.root-line:hover {
  text-decoration: none;
  background: var(--panel-2);
}
.root-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34ch;
}
.root-counts {
  font-size: 12px;
  white-space: nowrap;
}
.count-sep {
  color: var(--faint);
}

.spacer {
  flex: 1;
  min-width: 0;
}

.worst {
  flex: none;
}
/* A quiet estate keeps the button's space (visibility, not display): the
 * header must not reflow when the first red row appears. */
.worst.idle {
  visibility: hidden;
}

.live {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--dim);
  font-size: 12px;
}
/* The live indicator is Lucide's `activity` — a pulse line, which is what the
 * thing actually means — tinted by state. `color`, not `background`: the mask
 * paints itself with currentColor. */
.live-dot {
  width: 14px;
  height: 14px;
  color: var(--stale);
}
.live-streaming {
  color: var(--green);
  animation: beat 2.4s ease-in-out infinite;
}
.live-degraded {
  color: var(--yellow);
  animation: beat 2.4s ease-in-out infinite;
}
.live-down {
  color: var(--red);
}
@keyframes beat {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.tabs {
  display: flex;
  gap: 2px;
  flex: none;
}
.tab {
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--dim);
  font-size: 12px;
  border: 1px solid transparent;
  transition:
    color 140ms ease-out,
    background-color 140ms ease-out,
    border-color 140ms ease-out;
}
.tab:active {
  transform: translateY(1px);
}
.tab:hover {
  color: var(--fg);
  background: var(--panel-2);
  text-decoration: none;
}
.tab.on {
  color: var(--fg);
  background: var(--panel-2);
  border-color: var(--line-2);
}

/* ------------------------------------------------------------ content --- */

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.pane {
  min-height: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
}

.pane-tree {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane-tree[hidden] {
  display: none;
}

.pane-detail {
  flex: 1;
  min-width: 0;
  padding: 0 0 24px;
}
/* A route change is `detailPane.replaceChildren(...)`. The children are new
 * nodes, so this animation runs on every screen swap — the router does not
 * have to know that the console animates. The tree pane deliberately has no
 * such rule: it re-renders on every keystroke in the filter box, and a fade
 * per keystroke is noise, not feedback. */
.pane-detail > * {
  animation: fg-enter 160ms ease-out;
}
/* …except when the SAME screen swapped its own children (a data refresh, a
 * range click): `markScreen` sets this class so only navigation animates.
 * Replaying the route-change entrance on every refresh was the "UI blinks"
 * report, verbatim. */
.pane-detail.detail-quiet > * {
  animation: none;
}

/* --------------------------------------------------------- tree pane ---- */

.tree-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.filter-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.filter-input,
.text-input,
.say-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--fg);
  padding: 3px 8px;
  font: 13px/1.45 var(--sans);
}
.filter-input::placeholder,
.text-input::placeholder,
.say-input::placeholder {
  color: var(--faint);
}
.filter-input:focus-visible,
.text-input:focus-visible,
.say-input:focus-visible {
  border-color: var(--accent);
}

.tree-list {
  flex: 1;
  min-height: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: 4px 0 8px;
  content-visibility: auto;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--row);
  padding-right: 8px;
  color: var(--fg);
  border-left: 2px solid transparent;
  white-space: nowrap;
  transition:
    background-color 120ms ease-out,
    border-left-color 120ms ease-out;
}
.tree-row:hover {
  background: #171d27;
  text-decoration: none;
}
.tree-row.sel {
  background: #1c2432;
  border-left-color: var(--accent);
}

.twisty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: var(--row);
  flex: none;
  color: var(--faint);
  cursor: pointer;
}
.tree-row:hover .twisty,
.tree-row.sel .twisty {
  color: var(--dim);
}
.twisty {
  transition: color 120ms ease-out;
}
/* The chevron PERSISTS across tree updates (the pane is reconciled, not
 * rebuilt), so its quarter-turn is a plain transition with a real
 * before-state — only the row the operator toggled has a class change, so
 * only that chevron turns. */
.twisty-ico {
  transition: transform 150ms ease-out;
}
.twisty-ico.open {
  transform: rotate(90deg);
}

.tree-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-id {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 11.5px;
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-pills {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex: none;
}

.tree-fold {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--row);
  padding-right: 8px;
}
.tree-fold-note {
  color: var(--faint);
  font-size: 11px;
}

.tree-empty,
.muted-note {
  color: var(--dim);
  padding: 8px 12px;
  font-size: 12px;
}

.tree-meta {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 6px 10px;
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------- status dots -- */

.st {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stale);
  flex: none;
  /* The header's dot is one node whose CLASS changes when the estate turns;
   * animating the colour is what makes a green→red flip register as an event
   * rather than as a repaint the operator was not looking at. */
  transition: background-color 160ms ease-out;
}
.dot-red {
  background: var(--red);
}
.dot-yellow {
  background: var(--yellow);
}
.dot-green {
  background: var(--green);
}
.dot-stale {
  background: var(--stale);
}
.dot-unknown {
  background: var(--faint);
}
.st-word {
  color: var(--dim);
  font-size: 12px;
}

/* -------------------------------------------------------------- chips --- */

.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--stale-bg);
  color: var(--dim);
  white-space: nowrap;
  flex: none;
}
.sev-crit,
.c-red {
  background: var(--red-bg);
  color: var(--red);
}
.sev-warn,
.c-yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.sev-info,
.c-dim {
  background: var(--stale-bg);
  color: var(--dim);
}
.c-green {
  background: var(--green-bg);
  color: var(--green);
}
.c-stale {
  background: var(--stale-bg);
  color: var(--stale);
}
.c-open {
  background: #1d2a3a;
  color: var(--accent);
  text-transform: lowercase;
}
.c-role {
  background: #1a2130;
  color: #a9b6c8;
  text-transform: none;
}
.chip.struck {
  text-decoration: line-through;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* ------------------------------------------------------------ buttons --- */

.btn {
  font: 12px/1.45 var(--sans);
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 140ms ease-out,
    border-color 140ms ease-out,
    background-color 140ms ease-out,
    transform 90ms ease-out;
}
/* Press feedback: 1px of travel, on transform only, so a held button reads as
 * held on a touch screen where there is no hover to tell the operator the tap
 * landed. */
.btn:not(:disabled):active {
  transform: translateY(1px);
}
.btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}
/* A button that carries an icon lays out as a row, so the 14px mark and the
 * label share one baseline instead of the icon riding the text's descender. */
.btn:has(> .ico) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn > .ico {
  vertical-align: baseline;
}
.icon-btn {
  padding: 4px;
  line-height: 0;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  color: var(--fg);
  border-color: var(--accent);
  background: #16283d;
}
.btn.primary:hover {
  background: #1b3454;
}
.btn.destructive {
  color: var(--red);
  border-color: #5c2226;
  background: var(--red-bg);
}
.btn.destructive:hover {
  border-color: var(--red);
  color: #ff8078;
}
.btn.rowchip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 6px;
}
a.btn {
  text-decoration: none;
}
a.btn:hover {
  text-decoration: none;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  overflow: hidden;
}
.seg .btn {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line-2);
  font-family: var(--mono);
  padding: 1px 9px;
}
.seg .btn:last-child {
  border-right: 0;
}
.seg .btn.on {
  background: #1b3a63;
  color: #dce6f2;
}

/* ------------------------------------------------------- detail pane ---- */

.detail-head {
  padding: 12px 18px 6px;
  max-width: 1240px;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--dim);
  font-size: 11.5px;
  flex-wrap: wrap;
}
.crumb {
  color: var(--dim);
  transition: color 140ms ease-out;
}
.crumb:hover {
  color: var(--accent);
}
.crumb-sep {
  color: var(--faint);
}
.back-btn {
  margin-right: 6px;
}

.detail-title {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
  text-wrap: balance;
}

.detail-body {
  padding: 8px 18px 0;
  max-width: 1240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-body-flush {
  gap: 8px;
}

.sec-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 6px;
}
.sec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.sec-row .sec-label {
  margin-top: 0;
}
.row-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 6px;
  background: var(--panel);
}
.banner {
  animation: fg-enter 160ms ease-out;
}
.banner-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.banner-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.banner-next {
  color: var(--dim);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.banner-age {
  margin-left: auto;
  color: var(--dim);
  font-size: 11.5px;
  white-space: nowrap;
}
.b-red {
  background: var(--red-bg);
  border-color: #4a2226;
  border-left-color: var(--red);
}
.b-yellow {
  background: var(--yellow-bg);
  border-color: #453718;
  border-left-color: var(--yellow);
}
.b-green {
  background: var(--green-bg);
  border-color: #1e3d28;
  border-left-color: var(--green);
}
.b-stale,
.b-unknown {
  background: var(--stale-bg);
  border-left-color: var(--stale);
}

.loading {
  color: var(--dim);
  padding: 6px 2px;
  animation: fg-fade 140ms ease-out;
}

/* -------------------------------------------------------------- events -- */

.event-list {
  display: flex;
  flex-direction: column;
}
.event,
.inc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  min-height: 30px;
  color: var(--fg);
}
.event:last-child,
.inc-row:last-child {
  border-bottom: 0;
}
.event,
.inc-row {
  transition: background-color 120ms ease-out;
}
.inc-row:hover,
.event:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.event-kind {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}
.event-msg,
.inc-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.event-src {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.event-src .ico {
  color: var(--faint);
}
.event-src,
.inc-node {
  color: var(--dim);
  font-size: 11.5px;
  max-width: 26ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-age,
.inc-counts {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  flex: none;
}
.more-row {
  display: flex;
  gap: 8px;
  padding: 2px 0 8px;
}

/* -------------------------------------------------------------- sparks -- */

.spark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.spark {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px 6px;
  min-width: 0;
}
.spark-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.spark-name {
  color: var(--dim);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spark-value {
  margin-left: auto;
  font-size: 16px;
  color: var(--fg);
  white-space: nowrap;
}
.spark-figure {
  position: relative;
  height: 64px;
  margin: 6px 0 4px;
}
.spark-svg {
  display: block;
  width: 100%;
  height: 64px;
}
.spark-band {
  fill: #131a24;
}
.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.l-red {
  stroke: var(--red);
}
.l-yellow {
  stroke: var(--yellow);
}
.l-stale {
  stroke: var(--stale);
}
.spark-cursor {
  stroke: var(--line-2);
  stroke-width: 1;
  opacity: 0;
  transition: opacity 120ms ease-out;
}
.spark-hover .spark-cursor {
  opacity: 1;
}
.spark-readout {
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 11px;
  color: var(--dim);
  background: rgba(13, 17, 23, 0.85);
  padding: 0 4px;
  border-radius: 3px;
  pointer-events: none;
}
.spark-foot {
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spark-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  color: var(--faint);
  font-size: 11.5px;
}
.spark-failed {
  border-style: dashed;
}
.spark-grid > .muted-note,
.spark-grid > .panel {
  grid-column: 1 / -1;
  padding: 10px 12px;
}

.v-red {
  color: var(--red);
}
.v-yellow {
  color: var(--yellow);
}
.v-green {
  color: var(--green);
}
.v-stale,
.v-dim {
  color: var(--dim);
}

/* -------------------------------------------------------------- tables -- */

.table-wrap {
  overflow-x: auto;
}
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.grid-table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
.grid-table tbody tr:last-child td {
  border-bottom: 0;
}
.grid-table tbody tr {
  transition: background-color 120ms ease-out;
}
.grid-table tbody tr:hover {
  background: var(--panel-2);
}
.row-revoked td {
  color: var(--faint);
}
.row-current td {
  background: #151d29;
}
.evidence-row td {
  padding: 0 6px 4px;
  border-bottom: 1px solid var(--line);
}
.evidence-row .disc {
  border: 0;
  background: transparent;
}
.evidence-row .disc-sum {
  padding: 2px 6px;
  font-size: 11px;
  color: var(--faint);
}
.evidence-list {
  margin: 4px 0 6px;
  padding-left: 18px;
  color: var(--dim);
  font-size: 12px;
  white-space: normal;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.fact-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.fact-value {
  font-size: 12.5px;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 10px 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.stat-value {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.line {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.kill {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
}

/* ------------------------------------------------------- disclosures ---- */

.disc {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.disc-sum {
  cursor: pointer;
  padding: 6px 10px;
  color: var(--dim);
  font-size: 12px;
  list-style: none;
}
.disc-sum::-webkit-details-marker {
  display: none;
}
.disc-sum::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  vertical-align: -2px;
  background-color: currentColor;
  color: var(--faint);
  -webkit-mask: url('/icons/ui/chevron-right.svg') no-repeat center / contain;
  mask: url('/icons/ui/chevron-right.svg') no-repeat center / contain;
}
.disc[open] .disc-sum::before {
  -webkit-mask-image: url('/icons/ui/chevron-down.svg');
  mask-image: url('/icons/ui/chevron-down.svg');
}
.disc-sum {
  transition: color 140ms ease-out;
}
.disc-sum:hover {
  color: var(--fg);
}
/* `<details>` gives no transitionable box, but its body goes from unrendered
 * to rendered on open — which restarts an animation on it, the same trigger a
 * freshly inserted node uses. */
.disc[open] > .disc-body {
  animation: fg-enter 150ms ease-out;
}
.disc-sum::before {
  transition: color 140ms ease-out;
}
.disc-body {
  padding: 2px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prose {
  margin: 0;
  color: var(--fg);
  font-size: 12.5px;
  max-width: 78ch;
  text-wrap: pretty;
}
.dim-prose {
  color: var(--dim);
}

.copy {
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--bg);
}
.copy-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
.copy-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.copy-btn {
  margin-left: auto;
}
.copy-val {
  margin: 0;
  padding: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ------------------------------------------------------- session feed --- */

.feed {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  flex: 1;
  min-height: 320px;
  height: calc(100vh - 250px);
  overflow: auto;
  overscroll-behavior: contain;
  font-size: 12px;
  color: var(--fg);
}
.feed-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 1px 0;
  color: var(--dim);
}
.feed-line.red-line {
  color: var(--red);
}
.feed-line.yellow-line {
  color: var(--yellow);
}
.feed-line.dim-line {
  color: var(--faint);
}
.say-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ---------------------------------------------------------- overlays ---- */

.overlay-host:empty {
  display: none;
}
.scrim {
  animation: fg-fade 140ms ease-out;
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
  overscroll-behavior: contain;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 16px;
  max-height: calc(100% - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  animation: fg-modal-in 170ms ease-out;
}
/* Dismissal is the one motion that cannot be triggered by insertion, so it is
 * the one that costs JavaScript: `dismiss()` in ui/dom.ts sets this class and
 * takes the node out on animationend (with a timer as the backstop, because an
 * animation on a hidden tab never ends). */
.scrim.leaving {
  animation: fg-fade-out 140ms ease-out forwards;
  pointer-events: none;
}
.scrim.leaving > .modal {
  animation: fg-modal-out 140ms ease-out forwards;
}
.destructive-modal {
  border-color: #5c2226;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.modal-head .btn:last-child {
  margin-left: auto;
}
.modal-actions {
  display: flex;
  gap: 8px;
}
fg-exact-view {
  display: block;
  width: 100%;
  /* The engine's grid is a fixed 40 columns of a 1rem monospace face and its
   * host is `contain: strict`, so anything narrower than the grid CLIPS the
   * request instead of wrapping it. The floor keeps every cell drawn and lets
   * the scroll box carry the overflow on a phone. */
  min-width: 400px;
}
.exact-wrap {
  background: #fff;
  border-radius: 6px;
  padding: 6px;
  max-height: 46vh;
  overflow: auto;
  overscroll-behavior: contain;
}
.ceremony {
  width: 640px;
  max-width: 100%;
}
.ceremony-status {
  color: var(--dim);
  font-size: 12.5px;
  min-height: 18px;
  overflow-wrap: anywhere;
}
.ceremony-status.refused {
  color: var(--red);
}
.ceremony-status.done {
  color: var(--green);
}
.arm-note {
  color: var(--faint);
  font-size: 11.5px;
}

.signin {
  width: 400px;
  max-width: 100%;
  gap: 12px;
}
.signin-brand {
  display: flex;
  align-items: center;
  gap: 7px;
}
.signin-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.signin-live:empty {
  display: none;
}
.enroll-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.enroll-form .btn {
  align-self: flex-start;
}
.enroll-result:empty {
  display: none;
}
.enroll-ok {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ------------------------------------------------------------ mobile ---- */

.bottom-tabs {
  display: none;
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }
  .app-header {
    gap: 8px;
  }
  .tabs {
    display: none;
  }
  /* `.btn:has(> .ico)` sets `display: inline-flex`, and a media query adds no
   * specificity — so the hide rule has to out-specify it or the worst-leaf
   * button reappears on top of the counts. */
  .wordmark,
  .btn.worst {
    display: none;
  }
  /* 40px of header on a phone: the worst-state dot and the counts are the
   * payload, the estate's name is not — it is one tap away on the root row. */
  .root-title {
    display: none;
  }
  .live-word {
    display: none;
  }
  .root-line {
    flex: 1;
    min-width: 0;
  }
  /* The counts are the header's payload on a phone; they may ellipsis, but the
   * live dot must never be pushed off the edge. */
  .root-counts {
    min-width: 0;
  }
  .scrim {
    padding: 8px;
  }
  .modal {
    padding: 12px;
  }
  .pane-tree {
    width: 100%;
    min-width: 0;
    border-right: 0;
  }
  .content.estate-mode .pane-detail {
    display: none;
  }
  .content.estate-mode.show-detail .pane-tree {
    display: none;
  }
  .content.estate-mode.show-detail .pane-detail {
    display: block;
    /* The two panes are the same screen on a phone: one replaces the other,
     * and `display: none → block` restarts an animation exactly the way an
     * insertion does. So the slide needs no JS and no transition state. */
    animation: fg-from-right 170ms ease-out;
  }
  .content.estate-mode:not(.show-detail) .pane-tree {
    animation: fg-from-left 170ms ease-out;
  }
  .filter-input,
  .text-input,
  .say-input {
    font-size: 16px;
    padding: 8px;
  }
  /* Density, deliberately: 22px rows, half the old 44. A phone tree that
   * lists five nodes per screen is not a tree, it is a scroll bar with
   * opinions — the operator asked for the desktop IDE reading, and every
   * measure below is re-tuned for the shorter row rather than left at its
   * desk size and clipped. Touch targets that are NOT list rows (buttons,
   * tabs, inputs) keep their 44px minimum further down this block. */
  .tree-pane {
    --row: 22px;
  }
  .tree-list {
    padding: 2px 0 6px;
  }
  .tree-row {
    gap: 5px;
    font-size: 12.5px;
    line-height: 1;
  }
  .tree-row .dot {
    width: 7px;
    height: 7px;
  }
  .tree-row .ico-sm {
    width: 11px;
    height: 11px;
  }
  .twisty {
    width: 14px;
  }
  .tree-id {
    font-size: 11px;
  }
  .tree-pills .chip {
    font-size: 10px;
    padding: 0 4px;
  }
  .tree-fold-note {
    font-size: 10.5px;
  }
  .tree-fold .btn {
    min-height: 20px;
    padding: 0 6px;
    font-size: 11px;
  }
  .btn {
    min-height: 44px;
    padding: 6px 12px;
    font-size: 14px;
  }
  .seg .btn {
    min-height: 36px;
  }
  .detail-body,
  .detail-head {
    padding-left: 12px;
    padding-right: 12px;
  }
  .spark-grid {
    grid-template-columns: 1fr;
  }
  .content {
    padding-bottom: 0;
  }
  .bottom-tabs {
    display: flex;
    flex: none;
    border-top: 1px solid var(--line);
    background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-tab {
    flex: 1;
    text-align: center;
    padding: 12px 4px;
    min-height: 44px;
    color: var(--dim);
    font-size: 12px;
  }
  .bottom-tab {
    transition:
      color 140ms ease-out,
      background-color 140ms ease-out,
      box-shadow 140ms ease-out;
  }
  .bottom-tab:active {
    background: var(--panel-2);
  }
  .bottom-tab.on {
    color: var(--fg);
    background: var(--panel-2);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  .bottom-tab:hover {
    text-decoration: none;
  }
  /* The same density, applied to every other list on the phone: an event
   * row, an incident row and an admin table row all read at the tree's
   * pitch, so switching sections does not switch typographic worlds. */
  .event,
  .inc-row {
    flex-wrap: nowrap;
    min-height: 22px;
    padding: 2px 10px;
    gap: 6px;
    font-size: 12.5px;
    line-height: 1.25;
  }
  .event-kind,
  .event-src,
  .inc-node,
  .event-age,
  .inc-counts {
    font-size: 11px;
  }
  /* On a 390px row the TITLE is the payload — it is what tells the operator
   * which incident this is. The node path is one tap away on the incident
   * itself, so it yields the width rather than truncating the title to three
   * characters. */
  .inc-node {
    display: none;
  }
  .event-src {
    max-width: 12ch;
  }
  /* One exception to the single dense line, and it is the operator's own
   * rule: a row that carries an ACTION carries a 44px target, which no 22px
   * row can hold. Those rows — an escalation waiting to be signed, a question
   * waiting for an answer — wrap instead, and get their full title back with
   * them. Every other row in the list stays at the tree's pitch. */
  .event:has(.btn),
  .inc-row:has(.btn) {
    flex-wrap: wrap;
    row-gap: 4px;
    padding: 4px 10px;
  }
  .event:has(.btn) .event-msg,
  .inc-row:has(.btn) .inc-title {
    flex: 1 1 100%;
    white-space: normal;
    overflow: visible;
  }
  /* A role list stacks vertically inside a narrow cell, which turns a 24px row
   * into a 70px one. The table already carries its overflow sideways. */
  .grid-table .chip-row {
    flex-wrap: nowrap;
  }
  .event .chip,
  .inc-row .chip {
    font-size: 10px;
    padding: 0 4px;
  }
  .grid-table {
    font-size: 12px;
  }
  .grid-table td {
    padding: 2px 6px;
  }
  .grid-table th {
    padding: 4px 6px;
  }
  .grid-table .chip {
    font-size: 9.5px;
    padding: 0 3px;
  }
  .line {
    padding: 3px 12px;
  }
  .feed {
    height: calc(100vh - 300px);
    min-height: 240px;
  }
}

/* ------------------------------------------------- dsh session replica --- */
/*
 * The session view replicates dsh 0.1.0-rc.8's Chat rendering, measurement for
 * measurement (its shipped client.js is the reference; dark-theme tokens).
 * One centred 748px column, flat 16px gaps, no per-entry chrome; the 24px
 * disclosure row is the backbone; the IN/OUT card is the generic tool body.
 */

/* The session route owns the pane: the flow scrolls INSIDE the view and the
 * composer dock stays put, exactly as dsh docks its composer. */
.pane-detail:has(> .dsh-root) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}
.pane-detail:has(> .dsh-root) > .detail-head {
  flex: none;
}

.detail-body.dsh-root {
  padding: 0;
  max-width: none;
  gap: 0;
}

.dsh-root {
  --dsh-bg: #151517;
  --dsh-label-primary: #f9fafb;
  --dsh-label-primary-dimmed: #ebeef2;
  --dsh-label-secondary: #cfd3d6;
  --dsh-label-tertiary: #adb2b8;
  --dsh-label-caption: #81858c;
  --dsh-border-l1: #ffffff0f;
  --dsh-border-l2: #ffffff1f;
  --dsh-code-block: #1b1b1c;
  --dsh-hover: #ffffff14;
  --dsh-error: #f25a5a;
  --dsh-warn: #f59e0b;
  --dsh-warn-tertiary: #27241f;
  --dsh-success: #22c55e;
  --dsh-brand: #679efe;
  --dsh-brand-soft: #d3e2ff;
  --dsh-bubble: #2c2c2e;
  --dsh-card-bg: #2c2c2e;
  --dsh-content-width: 748px;
  --dsh-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --dsh-code: 'SF Mono', 'JetBrains Mono', 'Fira Code', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: auto;
  background: var(--dsh-bg);
  font-family: var(--dsh-sans);
}

.dsh-banners {
  flex: none;
}

.dsh-scroll {
  min-height: 0;
  flex: auto;
  overflow-y: auto;
  padding: 16px 32px;
}

.dsh-column {
  max-width: var(--dsh-content-width);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dsh-flow-item {
  min-width: 0;
}
.dsh-flow-item:empty {
  display: none;
}
.dsh-flow-item.chain-broken {
  border-left: 2px solid var(--dsh-error);
  padding-left: 10px;
}
.chain-note {
  color: var(--dsh-error);
  font-size: 11px;
  line-height: 16px;
}

.dsh-empty {
  padding: 24px;
}

/* --- the disclosure row: [16px icon]6px[Title 14/24]·[summary 14/24] ------ */

.dsh-disclosure {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}
.dsh-row {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  height: 24px;
  min-width: 0;
}
.dsh-row[data-expandable] {
  cursor: pointer;
}
.dsh-leading {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  color: var(--dsh-label-tertiary);
}
.dsh-icon-idle {
  opacity: 1;
  transition: opacity 0.1s ease;
}
.dsh-chevron-hover {
  position: absolute;
  inset: 0;
  margin: auto;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.dsh-row:hover .dsh-icon-idle,
.dsh-disclosure[data-open] .dsh-icon-idle {
  opacity: 0;
}
.dsh-row:hover .dsh-chevron-hover,
.dsh-disclosure[data-open] .dsh-chevron-hover {
  opacity: 1;
}
.dsh-title {
  flex: none;
  font-size: 14px;
  line-height: 24px;
  color: var(--dsh-label-secondary);
}
.dsh-sep {
  background: var(--dsh-label-caption);
  border-radius: 1px;
  flex: none;
  width: 2px;
  height: 2px;
  margin: 0 8px;
}
.dsh-summary {
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--dsh-label-tertiary);
  flex: auto;
  font-size: 14px;
  line-height: 24px;
  overflow: hidden;
}
.dsh-summary.dsh-error {
  color: var(--dsh-error);
}
/* cordis-style brand tint for the responder's own tools, kept for parity */
.dsh-disclosure[data-tool^='fg_'] .dsh-leading,
.dsh-disclosure[data-tool^='fg_'] .dsh-title {
  color: var(--dsh-brand);
}
/* running sweep: a 300px light band travels L→R every 2.6s */
.dsh-disclosure[data-state='running'] .dsh-row::after {
  content: '';
  background: linear-gradient(90deg, transparent 0%, #f9fafb1f 55%, transparent 100%);
  pointer-events: none;
  width: 300px;
  animation: 2.6s ease-out infinite dsh-tool-row-sweep;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
}
@keyframes dsh-tool-row-sweep {
  0% {
    left: -300px;
  }
  90%,
  to {
    left: 100%;
  }
}

/* dsh's StateDot: solid 60%-inset core over a 10%-opacity halo */
.dsh-state-dot {
  position: relative;
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
}
.dsh-state-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.1;
}
.dsh-state-dot::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: currentColor;
}
.dsh-state-dot[data-state='error'] {
  color: var(--dsh-error);
}
.dsh-state-dot[data-state='warning'] {
  color: var(--dsh-warn);
}
.dsh-state-dot[data-state='done'] {
  color: var(--dsh-success);
}

/* --- the IN/OUT card ------------------------------------------------------ */

.dsh-io-card {
  border: 1px solid var(--dsh-border-l1);
  background: var(--dsh-code-block);
  font-family: var(--dsh-code);
  font-size: 12px;
  line-height: 18px;
  border-radius: 12px;
  flex-direction: column;
  margin: 4px 0 4px 4px;
  display: flex;
}
.dsh-io-section {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: baseline;
  column-gap: 14px;
  max-height: 150px;
  padding: 12px 16px;
  overflow-y: auto;
}
.dsh-io-label {
  color: var(--dsh-label-caption);
  align-self: start;
  position: sticky;
  top: 0;
}
.dsh-io-divider {
  background: var(--dsh-border-l2);
  flex: none;
  height: 1px;
}
.dsh-io-text {
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
  color: var(--dsh-label-secondary);
}
.dsh-io-text[data-error] {
  color: var(--dsh-error);
}
.dsh-io-pending {
  color: var(--dsh-label-caption);
}

.dsh-gate-detail {
  border: 1px solid var(--dsh-border-l1);
  background: var(--dsh-code-block);
  border-radius: 12px;
  margin: 4px 0 4px 4px;
  padding: 12px 16px;
  color: var(--dsh-label-tertiary);
  font-size: 13px;
  line-height: 20px;
  max-height: 260px;
  overflow-y: auto;
}
.dsh-gate-line + .dsh-gate-line {
  margin-top: 4px;
}
.dsh-json {
  margin: 0;
  font-family: var(--dsh-code);
  font-size: 12px;
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--dsh-label-secondary);
}

/* --- prose and bubbles ---------------------------------------------------- */

.dsh-assistant {
  color: var(--dsh-label-primary);
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 16px;
  line-height: 28px;
}
.dsh-p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-dim {
  color: var(--dsh-label-tertiary);
}

.dsh-user-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.dsh-user-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: min(525px, 82%);
}
.dsh-bubble {
  background: var(--dsh-bubble);
  max-width: 100%;
  color: var(--dsh-label-primary);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 16px;
  line-height: 24px;
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-time {
  color: var(--dsh-label-tertiary);
  font-size: 12px;
  line-height: 20px;
  opacity: 0;
  transition: opacity 80ms;
}
.dsh-user-row:hover .dsh-time,
.dsh-user-row:focus-within .dsh-time {
  opacity: 1;
}

/* --- question & escalation cards (the approval-card grammar) ------------- */

.dsh-card {
  border: 1px solid var(--dsh-warn);
  border-radius: 20px;
  background: var(--dsh-card-bg);
  overflow: hidden;
}
.dsh-card.settled {
  border-color: var(--dsh-border-l2);
}
.dsh-card-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--dsh-warn-tertiary);
  color: var(--dsh-warn);
  padding: 10px 16px;
  font-size: 13px;
  line-height: 18px;
}
.dsh-card.settled .dsh-card-strip {
  background: var(--dsh-code-block);
  color: var(--dsh-label-tertiary);
}
.dsh-strip-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.dsh-card-headline {
  color: var(--dsh-label-primary);
  padding: 14px 16px 0;
  font-size: 15px;
  line-height: 24px;
  font-weight: 500;
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-card-line {
  color: var(--dsh-label-secondary);
  padding: 8px 16px 0;
  font-size: 13px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-provenance {
  color: var(--dsh-label-caption);
  padding: 4px 16px 0;
  font-size: 12px;
  line-height: 18px;
}
.dsh-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 0;
}
.dsh-option {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-radius: 12px;
  padding: 8px 12px 8px 8px;
  color: var(--dsh-label-secondary);
  font-size: 14px;
  line-height: 22px;
}
.dsh-option:hover {
  background: var(--dsh-hover);
}
.dsh-answer {
  color: var(--dsh-success);
  padding: 8px 16px 0;
  font-size: 14px;
  line-height: 22px;
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
}
.dsh-exact-wrap {
  margin: 12px 16px 0;
  border-radius: 12px;
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--dsh-border-l2);
}
.dsh-digest {
  color: var(--dsh-label-tertiary);
  padding: 8px 16px 0;
  font-size: 12px;
  line-height: 18px;
}
.dsh-refused {
  color: var(--dsh-error);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 20px;
}

/* --- tail status, stats, composer ---------------------------------------- */

.dsh-turn-status {
  height: 26px;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
  white-space: nowrap;
  background: linear-gradient(
    90deg,
    var(--dsh-brand) 0%,
    var(--dsh-brand) 40%,
    var(--dsh-brand-soft) 50%,
    var(--dsh-brand) 60%,
    var(--dsh-brand) 100%
  );
  color: transparent;
  -webkit-text-fill-color: transparent;
  background-position: 100% 0;
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  flex: none;
  align-self: flex-start;
  align-items: center;
  animation: 1.8s linear infinite dsh-turn-status-shimmer;
  display: inline-flex;
}
@keyframes dsh-turn-status-shimmer {
  to {
    background-position: 0 0;
  }
}

.dsh-stats {
  flex: none;
  max-width: var(--dsh-content-width);
  width: 100%;
  margin: 0 auto;
  padding: 4px 32px 0;
  font-size: 12px;
  line-height: 20px;
  color: var(--dsh-label-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dsh-dock {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(var(--dsh-content-width) + 32px);
  width: 100%;
  margin: 0 auto;
  padding: 6px 32px 10px;
}
.dsh-composer {
  flex: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--dsh-border-l2);
  background: var(--dsh-card-bg);
  border-radius: 20px;
  padding: 6px 6px 6px 16px;
  box-shadow: 0 4px 12px 0 #00000005, 0 2px 8px 0 #0000000a;
}
.dsh-say {
  flex: auto;
  min-width: 0;
  background: none;
  border: none;
  color: var(--dsh-label-primary);
  font-family: var(--dsh-sans);
  font-size: 14px;
  line-height: 22px;
}
.dsh-say:focus-visible {
  outline: none;
}
.dsh-say::placeholder {
  color: var(--dsh-label-caption);
}
.dsh-interrupts {
  flex: none;
  display: flex;
  gap: 8px;
}

.session-head-row {
  align-items: center;
}
.attempt-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.attempt-label {
  color: var(--dim);
}
.attempt-link {
  color: var(--dim);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.attempt-link.on {
  color: var(--fg);
  border-color: var(--line-2);
  background: var(--panel-2);
}
.stale-marker {
  margin-left: 8px;
}
.inc-record {
  flex: none;
}

/* --------------------------------------------------- motion & forced ---- */

/* Every animation and transition on this sheet is authored inside this
 * envelope: nothing above uses a delay this does not zero, nothing above
 * relies on an animation still being visible when its duration is 0.001ms
 * (every keyframe's `to` state is the resting state, so collapsing one lands
 * on exactly the layout the element would have had), and no `animation-name`
 * above depends on running more than once. An operator who has asked their OS
 * for stillness gets a console that changes state instantly. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .dot {
    forced-color-adjust: none;
  }
  /* A masked icon is a background, and forced-colors would repaint that
   * background as Canvas — i.e. erase every icon on the panel. Opting the
   * icons out leaves `currentColor`, which IS the forced colour of whatever
   * context they sit in (CanvasText in prose, ButtonText inside a button), so
   * they stay visible and stay correct. */
  .ico,
  .disc-sum::before {
    forced-color-adjust: none;
    background-color: currentColor;
  }
  .btn,
  .panel,
  .banner,
  .modal,
  .spark {
    border: 1px solid CanvasText;
  }
  .tree-row.sel {
    outline: 2px solid Highlight;
  }
}

/* --- the raw transcript surface (§14.1, 2026-08-29) ----------------------- */
/* transcript.item prose, the agent.delta streaming bubble, the task bubble,
 * the jump-to-newest affordance, and the spawn ("talk to infra") panel. */

.dsh-md {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.dsh-md-h {
  font-weight: 650;
  line-height: 24px;
}
.dsh-md-h[data-level='1'] {
  font-size: 20px;
}
.dsh-md-h[data-level='2'] {
  font-size: 18px;
}
.dsh-md-h[data-level='3'],
.dsh-md-h[data-level='4'],
.dsh-md-h[data-level='5'],
.dsh-md-h[data-level='6'] {
  font-size: 16px;
}
.dsh-md-code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--dsh-sep, var(--line));
  background: var(--dsh-code-block);
  font-family: var(--dsh-code);
  font-size: 12.5px;
  line-height: 19px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--dsh-label-secondary);
}
.dsh-md-code-inline {
  font-family: var(--dsh-code);
  font-size: 0.86em;
  background: var(--dsh-code-block);
  border-radius: 5px;
  padding: 1px 5px;
}
.dsh-md-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Link TEXT only — the destination is model-authored and is dropped. The
 * dotted underline says "this was a link"; there is nothing to click. */
.dsh-md-link {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.dsh-truncated {
  color: var(--yellow);
  font-size: 12px;
}

/* The in-progress agent.delta bubble: same prose grammar, marked live by the
 * trailing caret. Replaced by the sealed entry; never persisted. */
.dsh-stream-bubble {
  white-space: pre-wrap;
  word-break: break-word;
}
.dsh-stream-bubble::after {
  content: '▍';
  color: var(--accent);
  animation: 1s step-end infinite dsh-caret-blink;
}
@keyframes dsh-caret-blink {
  50% {
    opacity: 0;
  }
}

/* Reasoning rows read as an aside, not as an event. */
.dsh-reasoning {
  opacity: 0.62;
}
.dsh-reasoning[data-open] {
  opacity: 0.85;
}

/* The task that opened an operator-spawned session. */
.dsh-task .dsh-bubble {
  border: 1px solid var(--accent);
}

/* Unpinned from the tail: one quiet way back down. Anchored to the session
 * body, which becomes the containing block here. */
.detail-body.dsh-root {
  position: relative;
}
.dsh-jump {
  position: absolute;
  bottom: 96px;
  right: 24px;
  z-index: 3;
  box-shadow: 0 4px 14px rgb(0 0 0 / 40%);
}

/* --- the spawn panel (sessions screen) ------------------------------------ */

.sessions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.spawn-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.spawn-note {
  color: var(--dim);
  font-size: 12px;
  line-height: 18px;
}
.spawn-targets {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spawn-target {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.spawn-target:hover {
  background: var(--panel-2);
}
.spawn-target.spawn-refused {
  cursor: not-allowed;
  opacity: 0.55;
}
.spawn-subtree {
  font-family: var(--mono);
  font-size: 12.5px;
}
.spawn-reason {
  color: var(--dim);
  font-size: 12px;
}
.spawn-task {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--fg);
  font: 13px/1.5 var(--sans);
  padding: 8px 10px;
  resize: vertical;
  min-height: 60px;
}
.spawn-task:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.spawn-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.spawn-status {
  color: var(--dim);
  font-size: 12px;
}
