/* carvel — The page's rules. Every colour, face and size is a token in tokens.css. */

/* THE BRIDGE. tokens.css, loaded before this sheet, holds the whole palette,
   the faces and the type scale; the rules below and the extension panels
   still read the older names, so this one block points each of them at its
   token. It is the only place an old name survives: a line goes when its
   last reader goes. The data-skin layer further down re-points the few names
   that follow its own ink. Values a rule or a script computes (--ap-sail-t,
   --code-shown, --fill, --hold-age, --i, --lamp-age, --tm-ground,
   --topbar-h) stay as they are: they are read with a fallback and set on the
   element that animates. */
:root {
  /* The ground, the surfaces and the ink. */
  --system-black: var(--bg);
  --sea: var(--bg);
  --enamel-black: var(--bg);
  --deck: var(--bg-rail);
  --deck-2: var(--surface-1);
  --parch: var(--surface-1);
  --deck-3: var(--surface-3);
  --parch-2: var(--surface-3);
  --paper-white: var(--text);
  --bone: var(--text);
  --bone-1: var(--text);
  --parch-ink: var(--text);
  --code-str: var(--code-string);
  --bone-2: var(--text-2);
  --prose-dim: var(--text-2);
  --parch-ink-2: var(--text-2);
  --map-ink: var(--text-2);
  --map-ink-2: var(--text-2);
  --bone-3: var(--text-3);
  --prose-faint: var(--text-3);
  --prose-thought: var(--text-3);
  --diff-hunk: var(--text-3);

  /* The hairlines. */
  --glow-line: var(--line);
  --rope: var(--line);
  --parch-line: var(--line);
  --glow-dim: var(--line-strong);
  --glow: var(--line-strong);

  /* Selection, attention and the four signals. --attn needs no line: it is
     the token's own name. */
  --gold: var(--accent);
  --gold-ink: var(--accent);
  --signal-green: var(--accent);
  --link: var(--accent);
  --focus: var(--accent);
  --gold-edge: var(--accent-line);
  --on-gold: var(--text-on-solid);
  --on-gold-parch: var(--text-on-solid);
  --signal-amber: var(--attn);
  --attn-ink: var(--attn);
  --lamp-amber-wash: var(--attn-soft);
  --run: var(--ok);
  --diff-add: var(--ok-soft);
  --hazard-red: var(--bad);
  --danger: var(--bad);
  --danger-ink: var(--bad);
  --danger-fill: var(--bad);
  --danger-deck: var(--bad);
  --danger-raised: var(--bad);
  --signal-red: var(--bad);
  --hazard-wash: var(--bad-soft);
  --diff-del: var(--bad-soft);

  /* The veils and the washes, mixed from the ground and the ink. */
  --dim-veil: color-mix(in srgb, var(--bg) 62%, transparent);
  --shade: rgb(0 0 0 / .5);
  --ink-wash: color-mix(in srgb, var(--text) 14%, transparent);
  --ink-04: color-mix(in srgb, var(--text) 4%, transparent);
  --ink-08: color-mix(in srgb, var(--text) 8%, transparent);
  --ink-12: color-mix(in srgb, var(--text) 12%, transparent);
  --ink-20: color-mix(in srgb, var(--text) 20%, transparent);
  --ink-55: color-mix(in srgb, var(--text) 55%, transparent);

  /* The faces and the type scale. --font-mono is the token's own name. */
  --font-sans: var(--font-read);
  --font-label: var(--font-ui);
  --font-display: var(--font-ui);
  --fs-9: var(--text-xs);
  --fs-10: var(--text-xs);
  --fs-11: var(--text-sm);
  --fs-12: var(--text-sm);
  --fs-13: var(--text-md);
  --fs-14: var(--text-md);
  --fs-15: var(--text-lg);
  --fs-16: var(--text-lg);
  --fs-18: var(--text-xl);
  --fs-20: var(--text-xl);
  --fs-22: var(--text-2xl);
  --fs-display: var(--text-2xl);
  --track: normal;
  --caps: none;
  --radius: var(--r-md);
  --radius-sm: var(--r-sm);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--system-black);
  color: var(--paper-white);
  font-family: var(--font-sans);
  font-size: var(--fs-14, 0.875rem);
  line-height: 1.55; /* light on black wants a touch more leading */
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

a { color: var(--signal-green); text-underline-offset: 2px; }

kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  color: var(--glow-dim);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--glow-line) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glow-line); }
::-webkit-scrollbar-thumb:hover { background: var(--glow-dim); }
::-webkit-scrollbar-corner { background: transparent; }

#topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 2.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--glow-line);
}

#wordmark {
  font-family: var(--font-label);
  font-size: var(--fs-14, 0.875rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  color: var(--signal-green);
  text-transform: lowercase;
}

.wordmark-flag { display: none; }

#connection {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
#connection[data-state="live"] { color: var(--signal-green); }
#connection[data-state="reconnecting"] { color: var(--signal-amber); }

#relaunch-msg { color: var(--signal-amber); letter-spacing: var(--track, 0.1em); padding-right: 0.5rem; white-space: nowrap; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#relaunch-line { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; }
#relaunch-line[hidden] { display: none; }
#relaunch-line .btn { padding: 0.25rem 0.625rem; flex: none; }
#relaunch-btn { white-space: nowrap; }

/* The settings button takes the quiet corner of the bar. A Warden hold's
   lamp and the reports pill ride beside the wordmark, the in-page twins of
   the ◆ and ● in the tab title. */
#settings-button { margin-left: auto; }
#rigging-button { margin-left: auto; }
#topbar > #rigging-button:not([hidden]) + #settings-button { margin-left: -0.5rem; }
#wordmark-lamp { margin-left: -0.5rem; }

#topbar-ext {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto; flex: none;
  min-width: 0;
}
#topbar-ext:not([hidden]) + #rigging-button,
#topbar-ext:not([hidden]) + #rigging-button[hidden] + #settings-button { margin-left: 0; }

/* The reports pill: the reports waiting in every project; a click opens the
   one that waited longest. A thumb gets the full 44px. */
.topbar-reports { flex: none; }
@media (max-width: 700px), (pointer: coarse) {
  #reports-pill { height: 2.75rem; }
}

/* On a phone every item rides in one overflow menu behind MORE, so the bar
   never wraps or overflows; each row keeps its 44px target and its name in
   its title and aria-label. */
#topbar-more { display: none; }
#topbar-menu {
  position: absolute;
  top: calc(100% + 2px);
  right: 0.5rem;
  z-index: 60;
  min-width: 11.5rem;
  padding: 0.5rem;
  background: var(--enamel-black);
  border: 1px solid var(--glow-line);
  border-radius: var(--radius, 0.25rem);
}
#topbar-menu[hidden] { display: none; }
#topbar-menu-list { display: flex; flex-direction: column; gap: 0.25rem; }
#topbar-menu .topbar-btn { width: 100%; min-height: 2.75rem; justify-content: flex-start; margin: 0; }
@media (max-width: 700px) {
  #topbar { gap: 0.5rem; padding: 0 0.5rem; flex-wrap: nowrap; }
  #topbar > #topbar-ext,
  #topbar > #rigging-button,
  #topbar > #settings-button { display: none; }
  #topbar-more { display: inline-flex; height: 2.75rem; min-width: 2.75rem; padding: 0 0.625rem; justify-content: center; margin-left: auto; }
  #connection { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem;
  background: var(--enamel-black);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
  white-space: nowrap;
}
.panel-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glow-line);
}

/* Every panel's frame is header + title + Close ✕ on one shape, and every
   panel's tab row is one row. The family reads the existing theme variables
   only, so every theme, including new ones, styles it. */
.panel-frame {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 0.25rem 0 1rem;
  border-bottom: 1px solid var(--glow-line);
}
.panel-frame .panel-title { flex: 1; min-width: 0; margin: 0; }
.panel-frame-close { min-height: 2.75rem; }
.panel-tabs { display: flex; background: var(--enamel-black); border-bottom: 1px solid var(--glow-line); }
.panel-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.08em);
  font-variant-numeric: tabular-nums;
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
  white-space: nowrap;
  cursor: pointer;
}
.panel-tab:hover { color: var(--signal-green); }
.panel-tab[aria-selected="true"] { color: var(--signal-green); font-weight: 700; border-bottom-color: var(--signal-green); }
.panel-tab:focus-visible { outline-offset: -2px; }

.corner {
  position: absolute;
  width: 8px;
  height: 8px;
  pointer-events: none;
}
.corner.tl { top: 0; left: 0; border-top: 1px solid var(--signal-green); border-left: 1px solid var(--signal-green); }
.corner.tr { top: 0; right: 0; border-top: 1px solid var(--signal-green); border-right: 1px solid var(--signal-green); }
.corner.bl { bottom: 0; left: 0; border-bottom: 1px solid var(--signal-green); border-left: 1px solid var(--signal-green); }
.corner.br { bottom: 0; right: 0; border-bottom: 1px solid var(--signal-green); border-right: 1px solid var(--signal-green); }

/* A standing action's two labels: the whole words by default, one short word
   on the narrow rail (701-900px, under RESPONSIVE). */
.btn-label-short { display: none; }

#project-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 1rem;
}

.project {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--glow-dim);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}
.project::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--glow-line);
}
.project[aria-current="true"]::before { background: var(--signal-green); }
/* The row's lamp speaks for the chats inside: pulsing while any runs, steady
   amber while a report waits, the same code as the fleet lamps. */
.project[data-activity="running"]::before {
  background: var(--signal-green);
  box-shadow: 0 0 6px var(--signal-green);
  animation: mark-pulse 1.2s ease-in-out infinite;
}
.project[data-activity="report"]::before { background: var(--signal-amber); }
.project-running {
  flex: none;
  font-size: var(--fs-9, 0.5625rem);
  color: var(--signal-green);
  border: 1px solid var(--glow-line);
  padding: 0 0.3rem;
  line-height: 1.4;
}
.project[aria-current="true"] .project-running { margin-left: auto; }
.project[aria-current="true"] .project-running + .project-edit { margin-left: 0; }
.project:not([aria-current="true"]) .project-running { margin-left: auto; }
@media (prefers-reduced-motion: reduce) {
  .project[data-activity="running"]::before { animation: none; }
}
.project:hover { color: var(--signal-green); }
.project[aria-current="true"] {
  color: var(--signal-green);
  border-color: var(--glow-line);
  background: var(--ink-08);
}

#rail-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ink-20);
}
#rail-actions:empty { display: none; }
/* The rail is a fixed 19.5 rem above 1100 px, so the foot buttons hold one
   line each instead of wrapping a label onto two. */
@media (min-width: 1101px) {
  #rail-actions .btn { white-space: nowrap; }
}

#start-helmsman-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
}
#start-helmsman-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
}
#helmsman-model, #helmsman-effort, #add-project-model, #add-project-effort {
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  min-width: 0;
}
#helmsman-model, #helmsman-effort { flex: 1 1 100%; }

#add-project-row { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.75rem; max-width: 100%; }
.add-project-line { display: flex; gap: 0.5rem; min-width: 0; align-items: center; }
.add-project-models { flex-wrap: wrap; }
#add-project-model { flex: 1 1 8.5rem; max-width: 100%; }
#add-project-effort { flex: 0 1 6.25rem; max-width: 100%; }
#add-project-input { flex: 1; min-width: 0; font-family: var(--font-label); font-size: var(--fs-12, 0.75rem); }
.add-project-prompt-line { flex-direction: column; align-items: stretch; }
#add-project-prompt { width: 100%; box-sizing: border-box; min-width: 0; resize: vertical; font-family: var(--font-label); font-size: var(--fs-12, 0.75rem); }
#add-project-confirm { align-self: flex-end; }

#error-log {
  margin-top: 0.75rem;
  border-top: 1px solid var(--glow-line);
}
#error-log:empty { border-top: none; margin-top: 0; }
.error-log-head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.375rem 0;
  background: none;
  border: 0;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  text-align: left;
  color: var(--hazard-red);
  cursor: pointer;
}
.error-log-head::after { content: " \25BE"; }
.error-log-head[aria-expanded="true"]::after { content: " \25B4"; }
.error-log-list {
  margin: 0;
  padding: 0 0 0.25rem;
  max-height: 7rem;
  overflow: auto;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
}
.error-log-list[hidden] { display: none; }
.error-log-list li {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.125rem 0;
  white-space: nowrap;
}
.error-log-list .error-source { flex: none; text-transform: var(--caps, uppercase); color: var(--bone-3, var(--glow-dim)); }
.error-log-list .error-message { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--prose-dim); }

#readout-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glow-line);
}

#readout-identity {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

#chat-name {
  font-family: var(--font-label);
  font-size: var(--fs-16, 1rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.04em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}

/* The status word is read in one look, so idle is full ink at label size;
   running adds weight, the lamp beside it carries the rest. */
#chat-status {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--signal-green);
  text-transform: var(--caps, uppercase);
}
#chat-status[data-state="running"] { font-weight: 700; }
#chat-status[data-state="dead"], #chat-status[data-state="error"] { color: var(--hazard-red); }
#chat-status[data-state="report"] { color: var(--signal-amber); }

/* The run timer inside the pill: a clock and MM:SS. Tabular figures and a
   narrower track than the label's keep the width still as the seconds
   change, so the identity row never shifts. */
#chat-status .run-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
}
#chat-status .run-timer .i { width: 0.875em; height: 0.875em; }
#chat-status .run-timer .run-elapsed {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* The buttons share the identity row, right-aligned, and wrap under the
   name when the column is narrow. */
#readout-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

/* The status row under the name: MODEL and EFFORT, then the meter. It
   wraps only when the column is too narrow for one line. */
#readout-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  min-width: 0;
}
#readout-status > #readout-meter { padding-top: 0; }
/* On a wide screen the row keeps to one line at 1280 px: the model's value
   names itself (the select keeps its label for a screen reader), and the
   context reads as a number, amber past the threshold, as on the phone. */
@media (min-width: 701px) {
  #readout-status #meter-bar { display: none; }
  #readout-status select { padding-block: 0.25rem; }
  #readout-status + #chat-role + #readout-git { padding-top: 0; }
}
#meter-context.above-threshold { color: var(--signal-amber); }

#readout-model {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 1rem;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}

#chat-role {
  overflow: hidden;
  font-size: var(--fs-13, 0.8125rem);
  line-height: 1.5;
  color: var(--prose-dim);
  white-space: nowrap;
  text-overflow: ellipsis;
}
#chat-role:empty { display: none; }
/* A wide screen keeps the sentence as the name's tooltip; a screen reader
   still reads the line. The phone shows it when the header opens. */
@media (min-width: 701px) {
  #chat-role {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

#readout-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#readout-actions .btn { white-space: nowrap; }
#restart-confirm {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#new-chat-choice {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#new-chat-choice[hidden] { display: none; }
#new-chat-choice .btn { white-space: nowrap; }
.new-chat-question,
#new-chat-note {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--paper-white);
}
#new-chat-note { flex-basis: 100%; margin: 0; text-align: right; color: var(--glow-dim); }
#new-chat-note:empty { display: none; }
.restart-question {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--paper-white);
}

/* The one red rule crosses the column; the words stay white. */

#readout-hazard {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.25rem 0;
  padding: 0.5rem 0 0.375rem;
  border-top: 1px solid var(--hazard-red);
}
.hazard-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}
.hazard-flag {
  flex: none;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--hazard-red);
  text-transform: var(--caps, uppercase);
}
.hazard-text {
  min-width: 0;
  font-family: var(--font-label);
  font-size: var(--fs-13, 0.8125rem);
  color: var(--paper-white);
  overflow-wrap: anywhere;
}
.hazard-full summary {
  width: fit-content;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  cursor: pointer;
  text-transform: var(--caps, uppercase);
}
.hazard-full summary:hover { color: var(--signal-green); }
.hazard-full pre {
  margin-top: 0.25rem;
  max-height: 10rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.5;
  color: var(--prose-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hazard-recovery {
  font-size: var(--fs-13, 0.8125rem);
  line-height: 1.5;
  color: var(--prose-dim);
}

/* The phone's status row: below 700px the meter, git line, role and past chats
   fold behind it; lamp, name, status and STOP stay. A phone on its side (under 500px
   tall) folds them too, or the log has no room. */

/* No caps here: the summary carries the branch name, which is data. */
#readout-summary { display: none; }
@media (max-width: 700px), (max-height: 500px) {
  #readout-summary {
    display: block;
    min-height: 2.75rem;
    padding: 0 1.5rem 0 0.5rem;
    overflow: hidden;
    position: relative;
    background: transparent;
    border: 1px solid var(--glow-line);
    font-family: var(--font-label);
    font-size: var(--fs-10, 0.625rem);
    letter-spacing: var(--track, 0.1em);
    color: var(--glow-dim);
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  /* The caret is pinned outside the elided text, so the row always shows
     that it opens, however long the branch name runs. */
  #readout-summary::after {
    content: "▾";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
  }
  #readout-header.is-open #readout-summary::after { content: "▴"; }
  #readout-summary:hover { border-color: var(--signal-green); color: var(--signal-green); }
  #readout-summary.above-threshold { border-color: var(--signal-amber); color: var(--signal-amber); }
  /* The model and the effort stay in the phone's head: the picks are what the
     desk's head offers, and a phone changes a chat's model as the desk does.
     The meter, the git line and the role still fold behind the summary. */
  #readout-header:not(.is-open) > :is(#chat-role, #readout-more-drawer, #readout-ext),
  #readout-header > #readout-status > :is(#readout-meter, #readout-branch),
  #readout-header:not(.is-open) + #past-chats:not(.is-viewing-past) { display: none; }
  #readout-controls, #readout-actions, #new-chat-choice { justify-content: flex-start; }
  #new-chat-note { text-align: left; }
  #readout-controls .btn, #readout-actions .btn { min-height: 2.75rem; padding: 0 0.5rem; }
  #readout-branch { display: none; }
}

/* Wherever the summary row does not fold the header, it keeps to two rows:
   the identity with its actions, then the status row (model, effort, the
   meter, the branch at its head, the PR). MORE opens the actions row and,
   under it, the git line with the path, the links, the extension rows and
   the past chats. The needs-you zone never folds: a Warden hold stays. */
#readout-branch[hidden] { display: none; }
@media (min-width: 701px) and (min-height: 501px) {
  #readout-identity { flex-wrap: nowrap; min-width: 0; }
  #readout-identity > * { flex: none; }
  /* A long name gives way first, with an ellipsis; its title keeps the role.
     The row never wraps: the actions that do not fit move into the MORE row
     (fitReadoutIdentity), and when even that leaves no room the name gives
     way the rest of the way (is-crowded). */
  #readout-identity > #chat-name {
    flex: 0 1 auto;
    min-width: 4rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  #readout-identity > #readout-controls { flex: 1 0 auto; flex-wrap: nowrap; }
  #readout-identity.is-crowded > #chat-name { min-width: 0; }
  #readout-controls .btn { white-space: nowrap; }

  #readout-status { flex-wrap: nowrap; white-space: nowrap; }
  #readout-model { flex: 0 1 auto; flex-wrap: nowrap; }
  #readout-model .ctl { flex: none; }
  #readout-model .ctl > span:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  /* The header's model pick is the order form's searchable pick: one line
     here, cut with the whole spec in its title. */
  #readout-model .model-ctl { flex: 0 4 auto; min-width: 6rem; }
  .header-model > button {
    max-width: 13rem;
    padding-block: 0.125rem;
    font-family: var(--font-mono);
    font-size: var(--fs-11, 0.6875rem);
    line-height: 1.2;
  }
  #readout-meter { flex: none; flex-wrap: nowrap; padding-top: 0; }
  #readout-branch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: var(--fs-10, 0.625rem);
    letter-spacing: var(--track, 0.1em);
    color: var(--glow-dim);
  }
  #readout-branch .git-where { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #readout-branch > :not(.git-where) { flex: none; }

  #readout-git :is(.git-where, .git-links-toggle, .git-open-pr) { display: none; }
  #readout-more-drawer:has(> #readout-actions[hidden]) { display: none; }
  #readout-more-drawer:has(> #readout-actions[hidden]) ~ #readout-ext { display: none; }
  #readout-header:has(#readout-actions[hidden]) + #past-chats:not(.is-viewing-past) { display: none; }
  #readout-header:has(#readout-actions[hidden]) + #past-chats.is-viewing-past .past-chats-shelf { display: none; }
  #readout-more-drawer:has(> #readout-actions[hidden]) ~ #readout-ext:has(.wd-section:not(:empty)) { display: flex; }
  #readout-more-drawer:has(> #readout-actions[hidden]) ~ #readout-ext:has(.wd-section:not(:empty)) > :not(.wd-section) { display: none; }
}
/* A narrow readout (1280 px with the desk beside it) keeps the status row on
   one line: a known context and cost read as their numbers (the words stay
   for a screen reader), a cost not known leaves the row, and the counts take
   the small step. */
@media (min-width: 1101px) and (max-width: 1391px) and (min-height: 501px),
  (min-width: 901px) and (max-width: 1007px) and (min-height: 501px),
  (min-width: 701px) and (max-width: 791px) and (min-height: 501px) {
  #readout-meter > :not(.is-unknown) > .meter-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #meter-cost.is-unknown { display: none; }
  html[data-skin="jolly"] #readout-header :is(#readout-meter, #readout-branch, .pr-chip) { font-size: 0.75rem; }
}
.pr-chip {
  padding: 0 0.375rem;
  border: 1px solid var(--glow-line);
  font-family: var(--font-label);
  color: var(--glow-dim);
  text-decoration: none;
  text-transform: var(--caps, uppercase);
}
.pr-chip:hover { border-color: var(--signal-green); color: var(--signal-green); }

#readout-meter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  padding-top: 0.25rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}

#meter-context { white-space: nowrap; }
#meter-cache { white-space: nowrap; }
#meter-cost { white-space: nowrap; }

#meter-bar {
  display: inline-block;
  width: 6rem;
  height: 2px;
  background: var(--glow-line);
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
}
#meter-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: var(--signal-green);
  transform: scaleX(var(--fill, 0));
  transform-origin: left;
  transition: transform 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  #meter-bar-fill { transition: none; }
}
#meter-bar-fill.above-threshold { background: var(--signal-amber); }

#readout-git {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
#readout-git[hidden] { display: none; }
/* One row on a wide screen: the path gives way first, then the branch, with
   an ellipsis (their titles keep the full text); the controls never do.
   The phone's opened header wraps the line instead. */
@media (min-width: 701px) {
  #readout-git { flex-wrap: nowrap; min-width: 0; white-space: nowrap; }
  #readout-git > * { flex: none; }
  #readout-git > .git-dir-chip { flex: 0 3 auto; min-width: 2.5rem; }
  #readout-git > .git-branch, #readout-git > .git-gh-unavail { flex: 0 1 auto; min-width: 0; }
  .git-dir-text, #readout-git > .git-branch, #readout-git > .git-gh-unavail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
  }
}
.git-links-toggle {
  min-height: 1.5rem;
  padding: 0 0.375rem;
  background: transparent;
  border: 1px solid var(--glow-line);
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  cursor: pointer;
  text-transform: var(--caps, uppercase);
}
.git-links-toggle:hover, .git-links-toggle[aria-expanded="true"] { border-color: var(--signal-green); color: var(--signal-green); }
#readout-git-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.125rem 0 0 1.625rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
}
#readout-git-links[hidden] { display: none; }
.git-label { white-space: nowrap;
  text-transform: var(--caps, uppercase);
}
.git-branch, .git-link { min-width: 0; overflow-wrap: anywhere; }
.git-dir-chip { max-width: 100%; min-height: 1.5rem; }
.git-head { white-space: nowrap; }
.git-dirty { color: var(--signal-amber); }
.git-not-repo { white-space: nowrap; }
.git-dash { white-space: nowrap; opacity: 0.5; }
.git-gh-unavail { white-space: nowrap; font-style: italic; opacity: 0.6; }
.git-link { color: var(--glow-dim); text-decoration: underline; text-underline-offset: 2px; }
.git-link:hover { color: var(--signal-green); }
.git-dir-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
  padding: 0 0.375rem;
  cursor: pointer;
  overflow-wrap: anywhere;
  text-align: left;
}
.git-dir-chip:hover { border-color: var(--signal-green); }
.git-refresh {
  background: none;
  border: none;
  color: var(--glow-dim);
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  min-height: 1.5rem;
  min-width: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: var(--caps, uppercase);
}
.git-refresh:hover { color: var(--signal-green); }
.git-refresh:disabled { opacity: 0.4; cursor: default; }

/* Chip controls under a thumb: the hit area grows to 44 px with an invisible
   halo, so the line height and the chip's drawn frame stay as they are. */
.file-chip, .git-dir-chip, .git-refresh, .git-links-toggle, .node-overlap-line { position: relative; }
@media (pointer: coarse) {
  .file-chip::after, .git-dir-chip::after, .git-refresh::after, .git-links-toggle::after, .node-overlap-line::after {
    content: "";
    position: absolute;
    inset: -0.625rem -0.125rem;
    min-width: 2.75rem;
  }
  .btn { min-height: 2.75rem; }
}

#effort-select, .effort-select { max-width: 6rem; }
/* A model with no effort levels shows a disabled dash: it must read as
   inactive, not as an unlabeled choice. */
#effort-select:disabled, .effort-select:disabled { opacity: 0.55; }
#helmsman-effort { flex: 1 1 100%; }
/* The phone's head carries the chat's model and its effort, side by side and
   full width, each a thumb's height: the desk shows the same two picks, and
   this row is where the phone reaches them. The model's long spec stays on
   one line, cut, with the whole spec in its title and in the list. */
@media (max-width: 700px) {
  #readout-status { flex-wrap: wrap; gap: 0.25rem 0.5rem; width: 100%; }
  #readout-model { flex: 1 1 100%; flex-wrap: nowrap; gap: 0.5rem; min-width: 0; }
  #readout-model .ctl { flex: 1 1 50%; min-width: 0; }
  #readout-model .ctl > span:first-child { flex: none; }
  /* The slot a pick is drawn in is the flex item, and a long spec's min-content
     width is the whole spec: without this the model runs over the effort's
     label instead of ending in an ellipsis. */
  #readout-model .header-pick { display: flex; flex: 1 1 auto; min-width: 0; }
  /* The effort word is short and must stay whole; the model gives way and
     keeps its whole spec in the title and in the list. */
  #readout-model #effort-ctl { flex: 0 1 auto; }
  #readout-model .order-picker { flex: 1 1 auto; min-width: 0; max-width: none; }
  #readout-model .order-picker > button {
    width: 100%;
    min-height: 2.75rem;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #readout-model .header-effort > button { max-width: none; }
}

/* The chat's model and effort, and the line that says what a pick does: the
   desk reads it in the pick's title, a thumb has no hover. A refusal is drawn
   at every width, where the choice was made. */
#model-note {
  flex: 1 1 100%;
  margin: 0;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  line-height: 1.35;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  overflow-wrap: anywhere;
}
#model-note[hidden] { display: none; }
#model-note[data-kind="refusal"] { color: var(--hazard-red); }
@media (min-width: 701px) {
  #model-note[data-kind="wait"] { display: none; }
}

#past-chats {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  padding: 0.375rem 0;
}
#past-chats:empty { display: none; }
#past-chats .past-chat {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  background: transparent;
  border: 1px solid var(--glow-line);
  color: var(--glow-dim);
  padding: 0.125rem 0.375rem;
  cursor: pointer;
}
#past-chats .past-chat:hover, #past-chats .past-chat[aria-current="true"] { color: var(--signal-green); }

#messages-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  /* The jump bar and any overflow of the transcript stay inside the
     transcript's band: with a Warden hold on show and a short viewport,
     nothing draws over the hold, and the bar never rises onto it. */
  overflow: hidden;
}

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* The page holds the reader's place itself (holdReadout); the browser's
     own anchoring would pick another node and fight it. */
  overflow-anchor: none;
  padding: 1rem 0.5rem 1rem 0;
}

/* LATEST shows while the reader has scrolled up and new text lands below;
   START OF REPLY while the foot is in view and the latest reply's head is
   above it. The bar rests at the transcript's foot and never rises above
   the transcript's band. */
#jump-bar {
  position: absolute;
  right: 1rem;
  top: max(0px, calc(100% - 3rem));
  display: flex;
  gap: 0.5rem;
  pointer-events: none;
}
#jump-bar .btn { pointer-events: auto; background: var(--enamel-black); }
/* A short viewport gives the band little room: the jump buttons slim down
   to sit inside it whole, never over the hold or the verb legend. */
@media (max-height: 640px) and (min-width: 701px) {
  #jump-bar { top: max(0px, calc(100% - 2rem)); }
  #jump-bar .btn { min-height: 1.25rem; padding: 0.125rem 0.5rem; font-size: 0.75rem; }
}

/* The transcript is a wire. One hairline runs down its left; every turn taps
   it with a square lamp: filled green for the Quartermaster, amber for a
   forwarded report, hollow for the model, red when the call failed. The
   Quartermaster's own segments are lit solid; the live turn's segment
   carries current, the same dash the schematic's wires run. Its class is its
   own: `.rail` is the navigation rail, which a phone hides. */
.turn-rail {
  position: relative;
  padding-left: 1.25rem;
}
.turn-rail::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 1.5rem;
  left: 4px;
  width: 1px;
  background: var(--glow-line);
}
.turn-rail:empty::before { display: none; }

.turn { position: relative; margin-bottom: 1.5rem; }
.turn::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(-1.25rem + 4px);
  width: 1px;
}
.turn.user::before { background: var(--signal-green); }
.turn.user.report::before { background: var(--signal-amber); }
.turn.assistant.live-current::before {
  background-image: linear-gradient(var(--signal-green) 62%, transparent 62%);
  background-size: 1px 16px;
  animation: current-down 0.6s linear infinite;
}
@keyframes current-down {
  to { background-position: 0 16px; }
}

.turn-head {
  position: relative;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.375rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
}
.turn-head::before {
  content: "";
  position: absolute;
  top: 2px;
  left: calc(-1.25rem + 0.5px);
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  background: var(--enamel-black);
  border: 1px solid var(--glow-dim);
}
.turn.user .turn-head::before { background: var(--signal-green); border-color: var(--signal-green); }
.turn.user.report .turn-head::before { background: var(--signal-amber); border-color: var(--signal-amber); }
.turn.is-error .turn-head::before { background: var(--hazard-red); border-color: var(--hazard-red); }
.turn.live-current .turn-head::before {
  background: var(--signal-green);
  border-color: var(--signal-green);
  animation: mark-pulse 1.2s ease-in-out infinite;
}
.turn.user .turn-head::before { left: calc(-1.25rem - 0.875rem + 0.5px); }
.turn-head .who { font-size: var(--fs-12, 0.75rem); font-weight: 700; color: var(--signal-green); }
.turn-head .flag { color: var(--paper-white);
  text-transform: var(--caps, uppercase);
}
.turn-head .flag.is-error { color: var(--hazard-red); }
.turn-head .flag.is-live { color: var(--signal-green); }

/* The Quartermaster's words sit in a tinted block off the rail; a forwarded
   crew report is tinted amber: it came through the desk, not the keyboard. */
.turn.user {
  padding: 0.5rem 0.875rem;
  background: var(--ink-04);
}
.turn.user .turn-body { color: var(--prose-dim); }
.turn.user.report { background: var(--lamp-amber-wash); }
.turn.user.report .turn-head .who { color: var(--signal-amber); }
.turn.user.hail { background: transparent; box-shadow: inset 0 0 0 1px var(--glow-line); }
.turn.user.hail::before { background: none; border-left: 1px dashed var(--signal-green); }
.turn.user.hail .turn-head::before { background: var(--enamel-black); }
.turn.user.handoff { background: transparent; box-shadow: inset 0 0 0 1px var(--signal-amber); }
.turn.user.handoff .turn-head .who { color: var(--signal-amber); }

.turn-body .shell-out {
  max-width: 72ch;
  max-height: 24rem;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--prose-dim);
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.shell-cmd { color: var(--signal-green); font-weight: 700; }
.shell-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.375rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
}
.shell-state.is-running { color: var(--signal-green); }
.shell-state.is-error { color: var(--hazard-red); }
.shell-note { text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.turn-head .flag.shell-private { padding: 0 0.25rem; border: 1px solid currentColor; color: var(--signal-amber); }
#composer-hint.is-run { font-family: var(--font-mono); }

/* The Helmsman's turns are the reading surface: the body fills the column
   and the type earns the wider measure. YOU and crew turns stay one step
   down and dimmed; the instrument never dresses the prose. */
.turn.assistant.helm-prose .turn-body {
  font-size: var(--fs-15, 0.9375rem);
  line-height: 1.65;
}
.turn-body .prose + .prose { margin-top: 1rem; }

.turn-body p { margin: 0 0 1rem; }
.turn-body p:last-child { margin-bottom: 0; }
.turn-body h1, .turn-body h2, .turn-body h3,
.turn-body h4, .turn-body h5, .turn-body h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.3;
  margin: 1.75rem 0 0.75rem;
}
.turn-body h1:first-child, .turn-body h2:first-child,
.turn-body h3:first-child { margin-top: 0; }
.turn-body ul, .turn-body ol { margin: 0 0 1rem 1.5rem; }
.turn-body li { margin-bottom: 0.375rem; }
.turn-body li::marker { color: var(--glow-dim); }
.turn-body blockquote {
  margin: 0 0 1rem;
  padding: 0.125rem 0 0.125rem 0.875rem;
  border-left: 1px solid var(--signal-green);
}
.turn-body blockquote p { margin: 0 0 0.5rem; }
.turn-body blockquote p:last-child { margin-bottom: 0; }
.turn-body table {
  border-collapse: collapse;
  margin: 0 0 1rem;
}
.turn-body th, .turn-body td {
  border: 1px solid var(--glow-line);
  padding: 0.375rem 0.625rem;
  text-align: left;
  vertical-align: top;
}
.turn-body th {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}
/* Inline code sits inside the line box: a line that holds it is no taller
   than its neighbours. */
.turn-body code {
  font-family: var(--font-mono);
  font-size: var(--fs-13, 0.8125rem);
  line-height: 1;
  background: var(--ink-08);
  padding: 0 0.25rem;
}
.turn-body pre {
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  padding: 0.875rem 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
}
.turn-body pre code { background: none; padding: 0; font-size: var(--fs-12, 0.75rem); line-height: 1.45; }
.turn-body pre.is-folded > code {
  display: block;
  max-height: calc(var(--code-shown, 20) * 1lh);
  overflow-y: clip;
  -webkit-mask-image: linear-gradient(to bottom, var(--sea) calc(100% - 1.5lh), transparent);
  mask-image: linear-gradient(to bottom, var(--sea) calc(100% - 1.5lh), transparent);
}
.turn-body pre:has(+ .code-more),
.turn-body .code-box:has(+ .code-more) { margin-bottom: 0.25rem; }
.turn-body .code-more { margin: 0 0 1rem; }
/* A block's Copy chip and its scrolling text are different boxes: the chip heads
   the block's frame and the pre scrolls inside it, so the chip hides no line and
   stays put while the block scrolls. A fine pointer reveals it on hover or
   focus; a coarse pointer has no hover and always shows it. */
.turn-body .code-box {
  position: relative;
  margin: 0 0 1rem;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
}
.turn-body .code-box > pre {
  margin: 0;
  padding: 0.125rem 1rem 0.875rem;
  background: none;
  border: 0;
}
/* The frame keeps the pre's own measure: its 72ch cap is read in the block's
   font, so the frame carries that font too (the chip sets its own type). */
.turn-body .code-box:has(> .shell-out) {
  margin: 0; /* the shell footer follows the block at its old distance */
  max-width: 72ch;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
}
.turn-body .code-box > .shell-out { padding: 0.125rem 0.5rem 0.5rem; }
.tool-body .code-box {
  margin: 0; /* the Output label and the next line keep their old distance */
  max-width: 72ch;
  font-family: monospace; /* the pre's own font, from the element default */
  font-size: var(--fs-11, 0.6875rem);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
}
.tool-body .code-box > pre { padding: 0.125rem 0.5rem 0.5rem; background: none; border: 0; }
.code-head { display: flex; justify-content: flex-end; padding: 0.375rem 0.375rem 0; }
.code-copy {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.4375rem;
  border: 1px solid var(--rope);
  border-radius: 4px;
  background: var(--deck-2);
  color: var(--bone-2);
  cursor: pointer;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  user-select: none;
  opacity: 0;
}
.turn-body .code-box:hover .code-copy,
.turn-body .code-box:focus-within .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: var(--deck-3); border-color: var(--bone-3); color: var(--bone); }
@media (hover: none) {
  .turn-body .code-box .code-copy { opacity: 1; }
}
.code-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.turn-body .table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 1rem; }
.turn-body .table-wrap > table { margin: 0; }
.turn-body :is(td, th) .file-chip { max-width: none; } /* the wrapper scrolls instead */
.turn-note :is(h1, h2, h3, h4, h5, h6) { font-size: inherit; margin: 0.75rem 0 0.25rem; }

/* carvel's speed-highlight theme: the token inks tokens.css names, over the
   chat's code blocks and the work pane's file alike. A file reads as structure
   (keywords, types), values (strings, numbers) and notes (comments) rather
   than as one weight of grey; amber and red never appear in code. */
.shj-syn-cmnt { color: var(--code-comment); }
.shj-syn-str, .shj-syn-num, .shj-syn-bool, .shj-syn-esc, .shj-syn-insert { color: var(--code-string); }
.shj-syn-kwd, .shj-syn-section { color: var(--code-keyword); font-weight: 700; }
.shj-syn-oper, .shj-syn-deleted { color: var(--code-punct); }
.shj-syn-type, .shj-syn-class, .shj-syn-var, .shj-syn-func { color: var(--code-type); }
.shj-syn-err { color: var(--code-keyword); font-weight: 700; }

.tool-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0.625rem 0;
  padding-left: 0.625rem;
  border-left: 1px solid var(--glow-line);
}
.tool-line { font-family: var(--font-mono); font-size: var(--fs-11, 0.6875rem); }
.tool-line summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  color: var(--glow-dim);
  padding: 0.125rem 0;
}
.tool-line summary::-webkit-details-marker { display: none; }
.tool-line summary::before { content: "▸"; color: var(--signal-green); flex: none; }
.tool-line[open] summary::before { content: "▾"; }
.tool-tag {
  flex: none;
  border: 1px solid var(--glow-line);
  padding: 0 0.25rem;
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.12em);
}
.tool-name { flex: none; color: var(--signal-green); text-transform: var(--caps, uppercase); letter-spacing: var(--track, 0.06em); }
.tool-arg {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--prose-dim);
}
/* On a phone the argument wraps instead of eliding: the full path is the
   point of the line, and touch has no hover to read a title. */
@media (max-width: 700px) {
  .tool-arg { white-space: normal; overflow-wrap: anywhere; }
}
.tool-state { flex: none; font-size: var(--fs-9, 0.5625rem); letter-spacing: var(--track, 0.12em);
  text-transform: var(--caps, uppercase);
}
.tool-line.is-running .tool-state { color: var(--signal-green); }
.tool-line.is-error .tool-name, .tool-line.is-error .tool-state { color: var(--hazard-red); }
.tool-body { padding: 0.25rem 0 0.375rem 1rem; }
.tool-label {
  display: block;
  margin: 0.25rem 0 0.125rem;
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.12em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.tool-body pre {
  max-width: 72ch;
  max-height: 24rem;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--prose-dim);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thinking { margin: 0 0 0.75rem; font-family: var(--font-label); font-size: var(--fs-11, 0.6875rem); }
.thinking summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  color: var(--glow-dim);
  padding: 0.125rem 0;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "▸"; flex: none; }
.thinking[open] summary::before { content: "▾"; }
.thinking-tag { flex: none; letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
}
.thinking-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  color: var(--prose-faint);
}
.thinking-text {
  max-width: 72ch;
  max-height: 18rem;
  margin-top: 0.375rem;
  padding: 0.25rem 0 0.25rem 0.75rem;
  overflow: auto;
  border-left: 1px solid var(--glow-line);
  font-family: var(--font-sans);
  font-size: var(--fs-13, 0.8125rem);
  line-height: 1.5;
  color: var(--prose-thought);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn-body.is-folded {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, var(--sea) calc(100% - 1.5em), transparent);
  mask-image: linear-gradient(to bottom, var(--sea) calc(100% - 1.5em), transparent);
}
.entry-more, .code-more {
  display: block;
  margin-top: 0.375rem;
  padding: 0.125rem 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}
.entry-more:hover, .code-more:hover { text-decoration: underline; }
@media (max-width: 700px), (pointer: coarse) {
  #messages .turn-work > summary, #messages :is(.entry-more, .code-more) { min-height: 2.75rem; align-items: center; }
  #messages .code-copy { min-height: 2.75rem; padding: 0 0.625rem; }
}

/* What the model is doing right now, and for how long. The lamp pulses:
   current on the wire, the one motion the schematic allows. */
.live-status {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.75rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--signal-green);
  text-transform: var(--caps, uppercase);
}
.live-total { margin-left: auto; color: var(--glow-dim); }

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

@media (prefers-reduced-motion: reduce) {
  .turn.live-current .turn-head::before { animation: none; }
  .turn.assistant.live-current::before { animation: none; background: var(--signal-green); }
}

.report-row { margin-top: 0.75rem; }

/* The Helm's own stop of a chat: amber, as it is the Helm's act, not a
   failure. */
.ended-by-helm {
  margin-top: 0.75rem;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  color: var(--signal-amber);
}

#verb-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.02em);
  color: var(--glow-dim);
}
.verb-legend-text { flex: 1; min-width: 0; }
.verb-legend-gloss { white-space: nowrap; }
.verb-legend-verb { text-transform: var(--caps, uppercase); }
#verb-legend .btn { flex: none; align-self: flex-end; padding: 0.25rem 0.5rem; }

/* The report and its button leave the readout the instant the POST does.
   Visibility keeps the column from jumping while the state event follows. */
.report-departed { visibility: hidden; }
@keyframes mark-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.75); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  max-width: 44ch;
  padding: 2rem 0;
  color: var(--prose-dim);
}
.empty-state .empty-title {
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}

#composer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--glow-line);
}
#composer-row { display: flex; align-items: flex-end; gap: 0.5rem; }

/* A wide screen keeps the verb legend on one row: the words at the left,
   the actions at the right. */
@media (min-width: 1101px) {
  #verb-legend .btn { align-self: center; }
}
#composer-input {
  flex: 1;
  resize: none;
  overflow-y: hidden;
  font-size: var(--fs-14, 0.875rem);
  line-height: 1.5;
}
#send-button { flex: none; }
#composer textarea:disabled { color: var(--glow-dim); }
#composer-hint {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.08em);
  color: var(--glow-dim);
}
#composer-refusal {
  margin: 0.25rem 0 0;
  padding: 0.25rem 0 0 0.5rem;
  border-left: 2px solid var(--hazard-red);
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--hazard-red);
  overflow-wrap: anywhere;
}

.thumb-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.thumb {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid var(--glow-line);
  background: var(--system-black);
  padding: 0.25rem;
}

.thumb-view {
  background: none;
  border: none;
  padding: 0;
  cursor: zoom-in;
  line-height: 0;
}
.thumb-view:hover { border: none; }
.thumb img {
  display: block;
  height: 3.5rem;
  width: auto;
  max-width: 9rem;
  object-fit: cover;
}

.thumb-meta { display: flex; align-items: center; gap: 0.375rem; }
.thumb-label {
  flex: 1;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
}
.thumb-remove {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  background: transparent;
  border: 1px solid var(--glow-line);
  color: var(--glow-dim);
  padding: 0 0.375rem;
  cursor: pointer;
}
.thumb-remove:hover { color: var(--signal-green); border-color: var(--signal-green); }

.turn .thumb-strip { margin-top: 0.5rem; }

#image-viewer {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100vh - 6rem);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#image-viewer-head { display: flex; align-items: center; gap: 0.5rem; }
#image-viewer-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}
#image-viewer img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 12rem);
  object-fit: contain;
  background: var(--system-black);
}

.thumb.inline {
  display: inline-flex;
  vertical-align: middle;
  margin: 0.125rem 0.25rem;
}
.thumb.inline img { height: 2.5rem; }
.thumb.inline .thumb-label { font-size: var(--fs-9, 0.5625rem); }

.file-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  /* Short enough to sit inside the line box: a line that holds a chip is
     no taller than its neighbours. inline-block (not inline-flex) keeps
     Selection.toString() on one line without inserting newlines. */
  line-height: 1.2;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
  padding: 0.0625rem 0.5rem;
  margin: 0 0.125rem;
  vertical-align: -0.22em;
  cursor: pointer;
  white-space: nowrap;
  /* A long chip shrinks inside its line instead of clipping: the path
     ellipsises and the full path rides on the chip's title. */
  max-width: calc(100% - 0.25rem); /* the side margins stay inside the line */
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip:hover { border-color: var(--signal-green); }
.file-chip-glyph { color: var(--signal-green); margin-right: 0.375rem; user-select: none; -webkit-user-select: none; }
/* Pseudo-element content sits outside the DOM text tree, so dragging across a
   chip copies only the path and never copies {}, <>, # or other glyphs. */
.file-chip-glyph::before { content: attr(data-glyph); }
.file-chip-path { white-space: nowrap; }
.file-chip-line { color: var(--glow-dim); margin-left: 0.25rem; }
.file-chip.is-copied { border-color: var(--signal-green); }
.file-chip.is-missing { border-color: var(--hazard-red); }
.file-chip.is-missing .file-chip-glyph,
.file-chip.is-missing .file-chip-path { color: var(--hazard-red); }
.md-file-ref {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  padding: 0.0625rem 0.375rem;
  border: 1px solid var(--glow-line);
  background: var(--system-black);
  color: var(--paper-white);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.md-file-ref-lines { color: var(--glow-dim); }

.path-images {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}
.path-image {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 1px solid var(--glow-line);
  background: var(--system-black);
  line-height: 0;
  cursor: zoom-in;
}
.path-image:hover, .path-image:focus-visible { border-color: var(--signal-green); }
.path-image img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
}

.skill-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.375rem;
  font-family: var(--font-label);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
}
.skill-chip-glyph { color: var(--signal-green); }
.skill-chip-name {
  font-size: var(--fs-12, 0.75rem);
  letter-spacing: var(--track, 0.05em);
}
.skill-chip-remove {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  background: transparent;
  border: 1px solid var(--glow-line);
  color: var(--glow-dim);
  padding: 0 0.375rem;
  cursor: pointer;
}
.skill-chip-remove:hover { color: var(--signal-green); border-color: var(--signal-green); }

/* A collapsed <skill> block in a YOU turn: non-removable, sitting on the
   text line where the block was. */
.turn-body .skill-chip {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 0.125rem;
  padding: 0 0.375rem;
}

#file-viewer {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(60rem, calc(100vw - 4rem));
  max-height: calc(100vh - 6rem);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#file-viewer-head { display: flex; align-items: center; gap: 0.75rem; }
#file-viewer-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.04em);
  color: var(--signal-green);
}
#file-viewer-size {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
#file-viewer-body {
  min-height: 0;
  overflow: auto;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
}
/* Line numbers live in a dim gutter: a CSS counter per line, the target
   line's number lit to full ink so the :line target reads at a glance. */
#file-viewer-body pre {
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.6;
  counter-reset: file-line;
}
.file-line { display: block; min-height: 1.6em; counter-increment: file-line; }
.file-line::before {
  content: counter(file-line);
  display: inline-block;
  width: 3.5em;
  margin-right: 1em;
  text-align: right;
  color: var(--code-punct);
  user-select: none;
}
.file-line.is-target { background: var(--ink-wash); }
.file-line.is-target::before { color: var(--signal-green); font-weight: 700; }
#file-viewer-body img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 14rem);
  object-fit: contain;
}
/* An image takes its own shape: the frame shrinks to the image, up to the
   text width and the height cap, and never below the head's buttons. The
   head does not widen the frame; its title ellipsizes. Centred by inset and
   auto margins: with left: 50% the fit would stop at half the viewport. */
#image-viewer,
#file-viewer.is-image {
  inset: 0;
  margin: auto;
  transform: none;
  width: fit-content;
  height: fit-content;
  max-width: min(60rem, calc(100vw - 4rem));
  min-width: min(20rem, calc(100vw - 4rem));
}
#image-viewer-head,
#file-viewer.is-image #file-viewer-head { contain: inline-size; }
#image-viewer img,
#file-viewer-body img { margin-inline: auto; }
#file-viewer-note {
  padding: 1rem;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--prose-dim);
}

.release-all-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.release-all-row select:not(.effort-select) {
  max-width: 14rem;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
}
.release-all-none {
  flex-basis: 100%;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--glow-dim);
}

.field { margin-bottom: 0.5rem; }
.field-label {
  display: block;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
  margin-bottom: 0.25rem;
}
.field input, .field select { width: 100%; }
.field .field-readonly {
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  color: var(--prose-dim);
  padding: 0.375rem 0;
}

.order-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.order-node-vessel {
  font-size: var(--fs-11, 0.6875rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--paper-white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-node-voyage {
  flex: 1 1 auto;
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--glow-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-node-state {
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.order-node-chain {
  color: var(--signal-green);
  white-space: nowrap;
  border: 1px solid var(--glow-line);
  padding: 0 0.25rem;
}
.order-older {
  position: relative;
  padding-left: 0.75rem;
  background: var(--enamel-black);
  font-family: var(--font-label);
}
.order-older-toggle {
  padding: 0.125rem 0;
  border: 0;
  background: none;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--glow-dim);
  cursor: pointer;
}
.order-older-toggle:hover,
.order-older-toggle[aria-expanded="true"] { color: var(--signal-green); }
.order-older-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--glow-line);
}
.order-older-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.order-older-line .order-node-vessel { flex-shrink: 0; }
.order-older-line .order-node-voyage { min-width: 0; }
.order-older-line .btn { padding: 0.125rem 0.375rem; flex-shrink: 0; }
.order-older-id { margin-left: auto; }
.order-older-age { flex-shrink: 0; font-size: var(--fs-10, 0.625rem); color: var(--glow-dim); white-space: nowrap; }
.order-older-all { align-self: flex-start; margin-top: 0.25rem; }

#overlay-dim {
  position: fixed;
  inset: 0;
  background: var(--dim-veil);
  z-index: 40;
}

.overlay {
  position: fixed;
  z-index: 50;
  background: var(--enamel-black);
  border: 1px solid var(--signal-green);
}

/* The settings body is a size container, so the theme grid and each project block lay out by
   the room they get. The PERMISSION answer reads in the dim ink; the amber stays for lamps. */

#settings-overlay {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(68rem, calc(100vw - 3rem));
  height: min(54rem, calc(100dvh - 3rem));
  display: grid;
  grid-template-columns: 12.5rem minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "head head" "nav body";
  overflow: hidden;
  animation: settings-open 140ms ease-out;
}
/* The dialog is a state change, so it may arrive; nothing else on the page
   moves when it does. */
@keyframes settings-open { from { opacity: 0; transform: translate(-50%, -49%); } }
#settings-head { grid-area: head; }
#settings-nav {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  border-right: 1px solid var(--glow-line);
  overflow-y: auto;
}
#settings-nav button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  background: none;
  border: 1px solid transparent;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.1em);
  text-align: left;
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
}
.settings-nav-icon { flex: none; display: flex; width: 1rem; height: 1rem; }
.settings-nav-icon svg { width: 1rem; height: 1rem; }
#settings-nav button:hover { color: var(--signal-green); background: var(--ink-04); }
#settings-nav button[aria-current="true"] { color: var(--signal-green); border-color: var(--glow-line); background: var(--ink-08); }
#settings-body {
  grid-area: body;
  position: relative;
  container: settings / inline-size;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
/* A panel is one sheet: a ruled heading, one line of what it is for, then its
   own rows. The rail's current panel and an unsaved field both read without a
   second colour: a line, a fill and one word. */
.settings-sec {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.875rem 1rem 1rem;
  border: 1px solid var(--glow-line);
  background: var(--ink-04);
  scroll-margin-top: 1rem;
}
.settings-sec:has([data-unsaved]) { border-color: color-mix(in srgb, var(--attn) 55%, var(--glow-line)); }
.settings-section {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--glow-line);
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--paper-white);
  text-transform: var(--caps, uppercase);
}
.settings-unsaved {
  display: none;
  margin-left: auto;
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 400;
  color: var(--attn);
}
.settings-sec:has([data-unsaved]) .settings-unsaved { display: inline; }
.settings-purpose {
  margin: 0;
  max-width: 68ch;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.5;
  color: var(--glow-dim);
}
/* The block that holds a changed field: an amber edge, the colour the page
   keeps for what waits for the owner. Drawn on the box, so it moves nothing. */
[data-unsaved] { box-shadow: inset 2px 0 0 var(--attn); }
.settings-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; }
.settings-row { display: flex; align-items: center; gap: 0.5rem; }
.settings-label {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--prose-dim);
  text-transform: var(--caps, uppercase);
}
#settings-permission {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
#settings-sound { min-width: 6rem; }
#settings-theme { display: flex; flex-direction: column; gap: 0.375rem; }
.settings-check input { accent-color: var(--signal-green); }
.settings-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--prose-dim);
  cursor: pointer;
  text-transform: var(--caps, uppercase);
}
.theme-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem 0.5rem 0.375rem;
  border: 1px solid var(--glow-line);
}
.theme-row:hover { border-color: var(--glow-dim); }
.theme-row:has(input:checked) { border-color: var(--signal-green); background: var(--ink-08); }
.theme-row > input { margin: 0; }
#settings-access { display: flex; flex-direction: column; gap: 0.5rem; }
.access-word {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--paper-white);
  text-transform: var(--caps, uppercase);
}
.access-source, .access-fixed {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.access-source { margin-left: auto; text-align: right; }
.access-count { font-family: var(--font-label); font-size: var(--fs-11, 0.6875rem); color: var(--paper-white); }
.access-note, .access-error {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.5;
  color: var(--prose-dim);
}
.access-error { color: var(--hazard-red); overflow-wrap: anywhere; }
.access-error[hidden] { display: none; }
.access-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.access-token {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem;
  border: 1px solid var(--glow-line);
}
.access-token-row { display: flex; align-items: stretch; gap: 0.5rem; }
.access-token-value {
  flex: 1;
  min-width: 0;
  padding: 0.375rem 0.5rem;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.5;
  color: var(--paper-white);
  overflow-wrap: anywhere;
  user-select: all;
}
.access-hosts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.access-host { display: flex; align-items: center; gap: 0.5rem; min-height: 2rem; }
.access-host-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--paper-white);
  overflow-wrap: anywhere;
}
.access-allow { display: flex; gap: 0.5rem; }
.access-allow input { flex: 1; min-width: 0; }
#settings-projects { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-empty { font-family: var(--font-sans); font-size: var(--fs-12, 0.75rem); color: var(--prose-dim); }
.settings-project { border: 1px solid var(--glow-line); }
.settings-project > summary {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  align-items: baseline;
  min-height: 2.25rem;
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  list-style: none;
}
.settings-project > summary::-webkit-details-marker { display: none; }
.settings-project > summary::before { content: "▸"; color: var(--signal-green); grid-row: 1; }
.settings-project[open] > summary::before { content: "▾"; }
.settings-project > summary:hover .settings-project-name { color: var(--signal-green); }
.settings-project > summary:focus-visible { outline: 1px solid var(--signal-green); outline-offset: -1px; }
.settings-project-name {
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  color: var(--paper-white);
  overflow-wrap: anywhere;
}
.settings-project-path {
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-dim);
  overflow-wrap: anywhere;
}
.settings-project[open] .settings-project-path { display: none; }
.settings-project-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 0.75rem;
}
.settings-project-people, .settings-project-ext { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-project-people:empty, .settings-project-ext:empty { display: none; }
.settings-project-body textarea { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); }
.settings-project-body .helmsman-lines > .btn { align-self: flex-start; }
.settings-project-people { gap: 1rem; }
.settings-project-people .crew-line-meta { flex: 1; }
.settings-project-people .crew-confirm { flex-basis: 100%; }
.project-settings-link { align-self: flex-start; }
.settings-project-hail, .settings-project-doors, .settings-project-gather { display: flex; flex-direction: column; gap: 0.25rem; } .settings-project-gather .settings-gather-number { width: 7rem; }
.settings-project-hail-hint, .settings-project-doors-hint, .settings-project-gather-hint { margin: 0; max-width: 60ch; font-size: var(--fs-12, 0.75rem); line-height: 1.4; color: var(--glow-dim); }
.settings-review-model { display: flex; flex-direction: column; gap: 0.375rem; }
.settings-review-model .settings-review-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.settings-review-model .settings-review-input { flex: 1 1 14rem; max-width: 26rem; min-height: 2rem; font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); }
.settings-review-model .settings-review-now { margin: 0; max-width: 60ch; font-size: var(--fs-12, 0.75rem); line-height: 1.4; color: var(--glow-dim); }
.settings-review-model .settings-review-now b { color: var(--bone-1, inherit); font-weight: 700; }
.settings-review-model .settings-review-error { margin: 0; max-width: 60ch; font-size: var(--fs-12, 0.75rem); line-height: 1.4; color: var(--danger); }
.settings-review-model .settings-review-error:empty { display: none; }
@media (max-width: 700px) { .settings-review-model .settings-review-input { flex-basis: 100%; max-width: none; } }
/* A wide body sets the summary on one line, and the open block in two
   columns: the worktree links on the left; extension rows, helmsmen and
   crew on the right. */
@container settings (min-width: 40rem) {
  .settings-project > summary { grid-template-columns: auto auto minmax(0, 1fr); grid-template-rows: auto; column-gap: 0.75rem; }
  .settings-project-path { grid-column: 3; }
  .settings-project-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 1rem 2rem;
  }
  .settings-project-body > .project-path-line { grid-column: 1 / -1; }
  .settings-project-body > :nth-child(2) { grid-column: 1; grid-row: 2 / span 2; }
  .settings-project-hail, .settings-project-doors, .settings-project-gather, .settings-review-model, .settings-project-export, .settings-project-ext, .settings-project-people { grid-column: 2; } .settings-project-gather .settings-check { gap: 0.5rem; }
}
#settings-access { max-width: 44rem; }
#settings-storage { display: flex; flex-direction: column; gap: 0.75rem; max-width: 52rem; }
.storage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.storage-status { flex: 1 1 20rem; margin: 0; font-family: var(--font-sans); font-size: var(--fs-12, 0.75rem); color: var(--paper-white); }
.storage-hint { margin: 0; max-width: 64ch; font-size: var(--fs-12, 0.75rem); line-height: 1.4; color: var(--glow-dim); }
.storage-projects { display: flex; flex-direction: column; gap: 1rem; }
.storage-project { display: flex; flex-direction: column; gap: 0.25rem; }
.storage-project-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
.storage-project-name { font-family: var(--font-label); font-size: var(--fs-12, 0.75rem); font-weight: 700; color: var(--paper-white); }
.storage-project-size { font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); color: var(--prose-dim); }
.storage-rows { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.storage-row { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 0; border-top: 1px solid var(--glow-line); }
.storage-row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
.storage-crew { font-family: var(--font-label); font-size: var(--fs-12, 0.75rem); font-weight: 700; color: var(--paper-white); }
.storage-state { font-family: var(--font-label); font-size: var(--fs-12, 0.75rem); color: var(--prose-dim); }
.storage-state.is-running { color: var(--signal-green); }
.storage-size { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); font-weight: 700; color: var(--paper-white); }
.storage-ignored { font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); color: var(--prose-dim); }
.storage-top { margin: 0; font-family: var(--font-mono); font-size: var(--fs-12, 0.75rem); color: var(--prose-dim); overflow-wrap: anywhere; }
.storage-dir { display: inline-block; max-width: 100%; }
.storage-blocker { font-size: var(--fs-12, 0.75rem); color: var(--glow-dim); overflow-wrap: anywhere; }
.storage-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.storage-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem; border: 1px solid var(--glow-line); }
.storage-confirm p { flex-basis: 100%; margin: 0; font-size: var(--fs-12, 0.75rem); line-height: 1.5; color: var(--paper-white); }

@media (prefers-reduced-motion: reduce) {
  #settings-nav button, .ap-saved, .ap-check { transition: none; }
  #settings-overlay:not([hidden]) { animation: none; }
  .ap-model-group-body.is-opening { animation: none; }
}

@media (max-width: 700px) {
  /* The phone gives Settings the whole screen: the head, the rail as a row
     of tabs, then the body. 44px targets, and 16px text so a phone does not
     zoom on focus. */
  #settings-overlay {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "head" "nav" "body";
  }
  #settings-head { padding-top: max(0.75rem, env(safe-area-inset-top)); }
  #settings-nav {
    flex-direction: row;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--glow-line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  #settings-nav button { flex: none; min-height: 44px; }
  #settings-body { padding: 1rem 1rem max(1.5rem, env(safe-area-inset-bottom)); }
  #settings-access .btn, #settings-projects .btn, #settings-storage .btn, #settings-close, #settings-notify, .project-settings-link { min-height: 44px; }
  .storage-actions .btn, .storage-confirm .btn { flex: 1 1 auto; }
  #settings-test { min-width: 44px; min-height: 44px; }
  #settings-sound { min-height: 44px; font-size: var(--fs-16, 1rem); }
  #settings-hidden-only { width: 1.25rem; height: 1.25rem; }
  .settings-fields > .settings-check { min-height: 44px; }
  .theme-row { min-height: 44px; }
  .access-allow input, .settings-gather-number { min-height: 44px; font-size: var(--fs-16, 1rem); }
  .settings-project > summary { min-height: 44px; align-content: center; }
  .settings-project-body textarea { font-size: var(--fs-16, 1rem); }
  .settings-project-hail .settings-check, .settings-project-doors .settings-check, .settings-project-gather .settings-check { min-height: 44px; }
  .settings-project-hail input, .settings-project-doors input { width: 1.25rem; height: 1.25rem; }
}

#picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.25rem);
  z-index: 30;
  background: var(--enamel-black);
  border: 1px solid var(--signal-green);
  padding: 0.5rem;
}
#picker-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
#picker-title {
  flex: 1;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
#picker-list {
  list-style: none;
  max-height: 18rem;
  overflow: auto;
  margin-top: 0.25rem;
}
#picker-list li {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.375rem 0.5rem;
  cursor: pointer;
}
#picker-list li[aria-selected="true"] { background: var(--ink-12); }
#picker-list .picker-group {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  cursor: default;
  padding: 0.375rem 0.5rem 0.125rem;
}
#picker-list .command-name {
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  color: var(--signal-green);
}
#picker-list .command-doc {
  font-size: var(--fs-12, 0.75rem);
  color: var(--prose-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#picker-list .empty { color: var(--prose-dim); cursor: default; }

/* The process block is one line now, so a narrow window keeps it; only the
   wide lists go. */
@media (max-width: 899px) {
  .node-drop, .node-overlap { display: none; }
}

/* viewport-fit=cover lets the page run under a notch; the content keeps
   clear of it. Zero everywhere else. */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

/* Under a thumb, on a phone or a tablet: 44px targets, and 16px fields so
   the page does not zoom on focus. A mouse keeps the denser desk. */
@media (max-width: 700px), (pointer: coarse) {
  :is(#rail, #readout-header, #github-overlay) :is(input, select, textarea) { font-size: var(--fs-16, 1rem); min-height: 2.75rem; }
  :is(#topbar, #rail, #readout-controls, #readout-actions, #new-chat-choice, #messages, #composer, #verb-legend) .btn,
  .project, .thumb-view, #messages .tool-line > summary { min-height: 2.75rem; }
  .project-edit, #verb-legend .btn, .thumb-view { min-width: 2.75rem; }
}

.order-after {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
  margin: -0.375rem 0 0.25rem;
  overflow-wrap: anywhere;
}
.order-blocker {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.04em);
  color: var(--ink-55);
  padding-left: 0.75rem;
  margin-bottom: 0.125rem;
  overflow-wrap: anywhere;
}
.order-after + .order-blocker { margin-top: 0.125rem; }
.order-draft-pr { white-space: nowrap; }
.order-blocker.order-error { color: var(--hazard-red); }
.order-blocker:last-of-type { margin-bottom: 0.625rem; }
.order-mark-reported {
  min-height: 1.5rem;
  padding: 0.125rem 0.5rem;
  font-size: var(--fs-10, 0.625rem);
  white-space: nowrap;
}
.order-running-hint {
  margin: 0 0 0.625rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--signal-amber);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.4;
  color: var(--prose-dim);
  overflow-wrap: anywhere;
}
.order-running-hint code { font-family: var(--font-mono); color: var(--signal-amber); }

.order-badge {
  margin-left: 0.5rem;
  border: 1px solid var(--glow-line);
  padding: 0 0.25rem;
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}

.node-host {
  flex-basis: 100%;
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 400;
  letter-spacing: var(--track, 0.04em);
  color: var(--glow-dim);
  text-align: center;
}
/* Why the cull keeps the crew: one short dim line; a long branch name
   wraps once rather than lose the words after it. */
.node-blocker, .node-outside {
  flex-basis: 100%;
  max-width: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 400;
  letter-spacing: var(--track, 0.04em);
  text-transform: none;
  color: var(--glow-dim);
  text-align: center;
}

.node-drop {
  align-self: center;
  margin-top: -0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: var(--fs-10, 0.625rem);
}

/* The processes a crew left: one line while folded, whatever they are; the
   trees open under it, one row each. */
.node-processes {
  align-self: stretch;
  margin-top: -0.25rem;
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
}
.node-proc-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
  min-width: 0;
}
.node-proc-fold {
  flex: 1 1 12rem;
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  min-width: 0;
  color: var(--bone-3, var(--glow-dim));
  text-align: left;
}
.node-proc-fold:hover .node-proc-head { color: var(--text); }
.node-proc-caret {
  flex: none;
  width: 0.75rem;
  color: var(--glow-dim);
}
.node-proc-caret::before { content: "▸"; }
.node-proc-fold[aria-expanded="true"] .node-proc-caret::before { content: "▾"; }
.node-proc-head {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.node-proc-trees {
  margin: 0.25rem 0 0;
  padding: 0 0 0 1.125rem;
  list-style: none;
  color: var(--bone-3, var(--glow-dim));
}
.node-proc-tree {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  min-width: 0;
}
.node-proc-tree-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
}
.node-proc-tree-kids, .node-proc-tree-age, .node-proc-tree-mem {
  flex: none;
  color: var(--glow-dim);
}
.node-proc-buttons {
  display: flex;
  flex-wrap: nowrap;
  flex: none;
  align-items: center;
  gap: 0.375rem;
}
.node-proc-ask { flex: 1 1 auto; min-width: 0; }
/* A phone keeps the line one line long: the buttons stay beside a headline
   that cuts with an ellipsis, and the full words are in the label. */
@media (max-width: 700px) {
  .node-proc-line { flex-wrap: nowrap; }
  .node-proc-fold { flex: 1 1 auto; }
}

.node-overlap {
  align-self: stretch;
  margin-top: -0.25rem;
  text-align: center;
}
.node-overlap-line {
  max-width: 100%;
  padding: 0.25rem 0.5rem;
  background: none;
  border: 0;
  font: inherit;
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.04em);
  color: var(--signal-amber);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.node-overlap-line::after { content: " \25BE"; }
.node-overlap-line[aria-expanded="true"]::after { content: " \25B4"; }
.node-overlap-line:hover { text-decoration: underline; }
.node-overlap.conflict .node-overlap-line { font-weight: 700; }
.node-overlap-files {
  margin: 0 0 0.25rem;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-10, 0.625rem);
  color: var(--bone-3, var(--glow-dim));
  overflow-wrap: anywhere;
}

.project-edit {
  margin-left: auto;
  flex: none;
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  padding: 0 0.25rem;
}

.project-editor {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  border: 1px solid var(--glow-line);
  background: var(--ink-04);
  padding: 0.5rem;
}
.project-editor input { min-width: 0; }
.project-path-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.project-path-line .id-tag { margin-left: auto; }
.project-path {
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-dim);
  word-break: break-all;
}
.project-editor-actions {
  display: flex;
  gap: 0.5rem;
}

.helmsman-lines { display: flex; flex-direction: column; gap: 0.25rem; }
.helmsman-lines:empty { display: none; }
.helmsman-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.helmsman-line-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.04em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crew-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--ink-12);
}
.crew-line-name {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.04em);
  text-transform: var(--caps, uppercase);
  color: var(--paper-white);
}
.crew-line-meta {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.04em);
  color: var(--glow-dim);
}


#picker-args {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.5rem;
}
.picker-command-name {
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
  margin: 0;
}
.picker-arg {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: var(--fs-11, 0.6875rem);
  color: var(--glow-dim);
}
.picker-arg input {
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
  border: none;
  border-bottom: 1px solid var(--glow-line);
  padding: 0.375rem 0.25rem;
  min-width: 0;
}
#picker-args .btn { align-self: flex-start; }

#add-project-choose { flex: none; }

/* Every object the API names by id shows it, dim, in space its row already
   has: never wrapped, clicked to copy, flashed once in ink. */

.id-tag {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 400;
  letter-spacing: var(--track, 0.04em);
  text-transform: none;
  white-space: nowrap;
  /* Ink, not a hairline: --glow-dim is the control edge's colour and read
     3.1:1 as text in light mode. */
  color: var(--text-3);
  cursor: copy;
  transition: color 0.12s;
}
.id-tag.copied { color: var(--signal-green); }
#readout-identity #chat-id {
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  border: 1px solid var(--glow-line);
  padding: 0.125rem 0.375rem;
}

/* The GITHUB panel: the list on the left, the selected item on the right,
   two columns at 1280 and one at 900. Full height like the middle column;
   the overlay is the panel, the shell gains no fourth column. */

#github-overlay {
  top: 3.5rem;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#github-repo {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
#github-columns {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) 1fr;
  gap: 0.75rem;
}
#github-list-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-right: 1px solid var(--glow-line);
  padding-right: 0.75rem;
}
#github-list-head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
#github-tabs {
  flex: 1;
  display: flex;
  gap: 0;
}

#github-new-issue-form {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem;
  border: 1px solid var(--glow-line);
  background: var(--system-black);
}
#github-new-issue-form input, #github-new-issue-form textarea {
  font-family: var(--font-sans);
  font-size: var(--fs-13, 0.8125rem);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
  padding: 0.3rem 0.5rem;
  resize: vertical;
}
#github-new-issue-form input { font-family: var(--font-label); }
#github-new-issue-form input:focus, #github-new-issue-form textarea:focus { border-color: var(--signal-green); outline: none; }
.github-form-row { display: flex; gap: 0.375rem; }

#github-list {
  list-style: none;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}
.github-row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--ink-08);
  padding: 0.5rem 0.5rem 0.5rem 0.375rem;
  cursor: pointer;
}
.github-row:hover { background: var(--ink-04); }
.github-row.is-selected {
  background: var(--ink-08);
  border-left-color: var(--signal-green);
}
/* The README is the list's first entry, not an issue: no number, and it is
   the row that is selected whenever nothing else is. */
.github-row.is-readme .github-row-title { font-weight: 700; }
.github-row-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.github-row-num {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--signal-green);
  flex: none;
}
.github-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--paper-white);
}
.github-row-draft {
  flex: none;
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  border: 1px solid var(--glow-line);
  padding: 0 0.25rem;
  text-transform: var(--caps, uppercase);
}
.github-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}
.github-row-meta {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--prose-faint);
}
.github-label {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--glow-dim);
  border: 1px solid var(--glow-line);
  padding: 0 0.3125rem;
  line-height: 1.5;
}

/* The view column reads like a document: one 52rem track, prose held to
   about 72 characters inside it, blocks separated by a generous 1.5rem and
   grouped tight within. */
#github-view {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.25rem 0.75rem 1rem 0.25rem;
}
#github-view > * { width: 100%; max-width: 52rem; }
.github-view-head {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glow-line);
}
.github-view-titleline { display: flex; align-items: baseline; gap: 0.625rem; }
.github-view-num {
  font-family: var(--font-label);
  font-size: var(--fs-16, 1rem);
  font-variant-numeric: tabular-nums;
  color: var(--signal-green);
  flex: none;
}
.github-view-title {
  font-family: var(--font-sans);
  font-size: var(--fs-22, 1.375rem);
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: anywhere;
  color: var(--paper-white);
}
.github-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.08em);
  color: var(--glow-dim);
}
.github-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--signal-green);
  color: var(--signal-green);
  font-weight: 700;
  letter-spacing: var(--track, 0.12em);
}
.github-state::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
}
/* Merged is the closed circuit: the one filled mark. Draft is current not yet
   applied; closed is a dead wire, not a failure, so it takes no red. */
.github-state.is-merged { background: var(--signal-green); color: var(--system-black); }
.github-state.is-draft { border-color: var(--glow-line); color: var(--glow-dim); }
.github-state.is-draft::before { background: transparent; border: 1px solid currentColor; }
.github-state.is-closed { border-color: var(--glow-line); color: var(--prose-dim); }
.github-state.is-closed::before { background: transparent; border: 1px solid currentColor; }
.github-meta-author { color: var(--paper-white); text-transform: var(--caps, uppercase); font-weight: 700; }
.github-meta-refs { display: inline-flex; align-items: center; gap: 0.375rem; min-width: 0; }
.github-ref {
  padding: 0.0625rem 0.375rem;
  background: var(--ink-08);
  color: var(--paper-white);
  letter-spacing: var(--track, 0.02em);
  overflow-wrap: anywhere;
}
.github-meta-arrow { color: var(--glow-dim); }
.github-meta-time { color: var(--prose-dim); font-variant-numeric: tabular-nums; }
.github-readme-link { color: var(--signal-green); }
.github-readme-link:hover { text-decoration: underline; }
.github-review-word {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.github-review-word.is-approved { color: var(--signal-green); }
.github-review-word.is-changes-requested { color: var(--signal-amber); }
.github-view-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.github-section {
  margin: 0 0 0.375rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.github-section::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 0.3rem;
  background: var(--glow-line);
}
.github-block { display: flex; flex-direction: column; gap: 0.3rem; }
.github-empty-note {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--prose-faint);
}

.github-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
}
.github-check-name { color: var(--paper-white); }
.github-check-state {
  margin-left: auto;
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
.github-check-state.is-pass { color: var(--signal-green); }
.github-check-state.is-pending { color: var(--signal-amber); }
.github-check-state.is-fail { color: var(--hazard-red); }
.github-file {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
}
.github-file-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--paper-white);
}
.github-file-add, .github-file-del {
  flex: none;
  min-width: 3.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.github-file-add { color: var(--signal-green); font-weight: 700; }
.github-file-del { color: var(--prose-dim); }

/* Prose in the body face at a reading measure; mono only for code, keys,
   and table heads. Every colour is a theme token. */

/* Media (images, tables, code) may use the 48rem track; running text holds
   to 37em, about 72 characters of this face. */
.gh-md {
  max-width: 48rem;
  font-family: var(--font-sans);
  font-size: var(--fs-14, 0.875rem);
  line-height: 1.65;
  color: var(--paper-white);
  overflow-wrap: break-word;
}
.github-body { font-size: var(--fs-15, 0.9375rem); }
.gh-md.is-plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.gh-md p, .gh-md li, .gh-md h1, .gh-md h2, .gh-md h3, .gh-md h4, .gh-md h5,
.gh-md h6, .gh-md blockquote, .gh-md summary { max-width: 37em; }
.gh-md summary { max-width: none; }
.gh-md p:empty { display: none; }
/* An image GitHub leaves outside a paragraph still keeps the paragraph gap. */
.gh-md > img.gh-img, .gh-md > a:has(> img.gh-img) { display: block; width: fit-content; margin-bottom: 0.875rem; }
.gh-md > :first-child { margin-top: 0; }
.gh-md > :last-child { margin-bottom: 0; }
.gh-md p, .gh-md ul, .gh-md ol, .gh-md blockquote, .gh-md pre,
.gh-md table, .gh-md details { margin: 0 0 0.875rem; }
.gh-md h1, .gh-md h2, .gh-md h3, .gh-md h4, .gh-md h5, .gh-md h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.3;
  margin: 1.5rem 0 0.5rem;
  text-wrap: balance;
}
.gh-md h1 { font-size: var(--fs-20, 1.25rem); }
.gh-md h2 { font-size: var(--fs-18, 1.125rem); }
.gh-md h3 { font-size: var(--fs-16, 1rem); }
.gh-md h4, .gh-md h5, .gh-md h6 { font-size: var(--fs-15, 0.9375rem); }
.gh-md h1, .gh-md h2 { padding-bottom: 0.25rem; border-bottom: 1px solid var(--glow-line); }
.gh-md ul, .gh-md ol { padding-left: 1.5rem; }
.gh-md ul { list-style-type: square; } /* lamps are squares, never circles */
.gh-md li + li, .gh-md li > ul, .gh-md li > ol { margin-top: 0.25rem; }
.gh-md li > ul, .gh-md li > ol { margin-bottom: 0; }
.gh-md li::marker { color: var(--glow-dim); }
.gh-md li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.375rem; }
.gh-md input[type="checkbox"] {
  appearance: none;
  width: 0.625rem;
  height: 0.625rem;
  margin: 0 0.625rem 0 0;
  vertical-align: 0.0625rem;
  border: 1px solid var(--glow-dim);
  background: transparent;
}
.gh-md input[type="checkbox"]:checked { background: var(--signal-green); border-color: var(--signal-green); }
.gh-md blockquote {
  padding: 0 0 0 0.875rem;
  border-left: 1px solid var(--signal-green);
  color: var(--prose-dim);
}
.gh-md a { color: var(--signal-green); overflow-wrap: anywhere; }
.gh-md code, .gh-md kbd { font-family: var(--font-mono); font-size: 0.8125em; }
.gh-md code { padding: 0.0625rem 0.3125rem; background: var(--ink-08); }
.gh-md kbd {
  padding: 0 0.3125rem;
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
}
.gh-md pre {
  max-width: 100%;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  background: var(--system-black);
  border: 1px solid var(--glow-line);
}
.gh-md pre code {
  padding: 0;
  background: none;
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.5;
  white-space: pre;
}
.gh-md table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.gh-md th, .gh-md td {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--glow-line);
  text-align: left;
  vertical-align: top;
}
.gh-md th {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
  background: var(--ink-04);
}
.gh-md [data-align="center"] { text-align: center; }
.gh-md [data-align="right"] { text-align: right; }
.gh-md hr { height: 1px; margin: 1.25rem 0; border: 0; background: var(--glow-line); }
.gh-md sup, .gh-md sub { font-size: 0.75em; line-height: 0; }
.gh-md del { color: var(--prose-dim); }

.gh-md details { border: 1px solid var(--glow-line); }
.gh-md summary {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}
.gh-md summary::-webkit-details-marker { display: none; }
.gh-md summary::before {
  content: "▸";
  flex: none;
  font-family: var(--font-label);
  color: var(--signal-green);
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.gh-md summary:hover { background: var(--ink-04); }
.gh-md details[open] > summary { margin-bottom: 0.625rem; border-bottom: 1px solid var(--glow-line); }
.gh-md details[open] > summary::before { transform: rotate(90deg); }
.gh-md details > :not(summary) { margin-left: 0.75rem; margin-right: 0.75rem; }
.gh-md details[open] { padding-bottom: 0.125rem; }
.gh-md details[open] > :not(summary) { animation: gh-draw-in 220ms cubic-bezier(0.16, 1, 0.3, 1) both; }

.gh-md img.gh-img {
  max-width: 100%;
  max-height: 480px;
  height: auto;
  object-fit: contain;
  vertical-align: top;
  border: 1px solid var(--glow-line);
  background: var(--system-black);
  cursor: zoom-in;
  opacity: 0;
  transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.gh-md img.gh-img.is-loaded { opacity: 1; }
.gh-md img.gh-img:hover { border-color: var(--signal-green); }
.gh-img-broken {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--glow-line);
  font-family: var(--font-sans);
  font-size: var(--fs-13, 0.8125rem);
  color: var(--prose-dim);
}
.gh-img-broken::before {
  content: "IMAGE";
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}

/* Each event is a node on the wire: an outlined square for a comment, a
   filled one for a review verdict. */

.github-timeline {
  position: relative;
  list-style: none;
  padding: 0.25rem 0 0 1.5rem;
}
.github-timeline::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 1px;
  background: var(--glow-line);
  transform-origin: top;
}
.github-event { position: relative; padding-bottom: 1.5rem; }
.github-event:last-child { padding-bottom: 0.25rem; }
.github-event::before {
  content: "";
  position: absolute;
  left: calc(-1.5rem + 0.25rem - 4px);
  top: 0.3125rem;
  width: 9px;
  height: 9px;
  background: var(--enamel-black);
  border: 1px solid var(--signal-green);
}
.github-event.is-review::before { background: var(--signal-green); }
.github-event.is-file::before { border-color: var(--glow-dim); }
.github-event-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.625rem;
  max-width: 48rem;
  font-family: var(--font-label);
}
.github-event-author {
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.08em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}
.github-event-kind {
  font-size: var(--fs-9, 0.5625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  text-transform: var(--caps, uppercase);
}
.github-event-time {
  margin-left: auto;
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.05em);
  font-variant-numeric: tabular-nums;
  color: var(--prose-dim);
}
.github-event-body { margin-top: 0.5rem; }
.github-event.is-verdict { padding-bottom: 1rem; }
.github-file-ref { margin-top: 0.5rem; max-width: 48rem; display: flex; flex-direction: column; }
.github-file-ref-path {
  align-self: flex-start;
  padding: 0.125rem 0.5rem;
  background: var(--ink-08);
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--paper-white);
  overflow-wrap: anywhere;
}
.github-file-ref-hunk {
  margin: 0;
  padding: 0.375rem 0.625rem;
  border-top: none;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.6;
}

/* Opening a view: the head and body arrive, then the rail draws down like
   current on a wire and each node lights as it passes. Re-renders stay
   still; reduced motion shows everything at once. */
@keyframes gh-draw-in {
  from { opacity: 0; transform: translateY(0.25rem); }
  to { opacity: 1; transform: none; }
}
@keyframes gh-rail {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
#github-view.is-opening > * { animation: gh-draw-in 240ms cubic-bezier(0.16, 1, 0.3, 1) both; }
#github-view.is-opening > :nth-child(2) { animation-delay: 40ms; }
#github-view.is-opening > :nth-child(n + 3) { animation-delay: 80ms; }
#github-view.is-opening .github-timeline::before { animation: gh-rail 520ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both; }
#github-view.is-opening .github-event {
  animation: gh-draw-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(140ms + var(--i, 0) * 45ms);
}
@media (prefers-reduced-motion: reduce) {
  #github-overlay *, #github-overlay *::before {
    animation: none !important;
    transition: none !important;
  }
}

.github-diff-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.github-diff-wrap .btn { align-self: flex-start; }
.diff-view {
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  overflow: auto;
  max-height: 24rem;
}
.diff-view pre {
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.6;
}
.diff-line { display: block; white-space: pre; }
.diff-line.add { background: var(--diff-add); }
.diff-line.del { background: var(--diff-del); color: var(--prose-faint); }
.diff-line.hunk { color: var(--diff-hunk); font-weight: 700; }
.diff-line.meta { color: var(--code-comment); }
/* In the GITHUB panel and the Logbook an added line carries an ink edge and wash, a deleted
   line a dim edge and dimmed text: told apart by edge, wash, and the +/- glyph,
   never by a second hue. */
:is(#github-overlay, #ext-sheet[data-panel="logbook"]) .diff-line { padding-left: 0.5rem; border-left: 1px solid transparent; }
:is(#github-overlay, #ext-sheet[data-panel="logbook"]) .diff-line.add { background: var(--ink-12); border-left-color: var(--signal-green); color: var(--paper-white); }
:is(#github-overlay, #ext-sheet[data-panel="logbook"]) .diff-line.del { background: var(--ink-04); border-left-color: var(--glow-line); color: var(--prose-dim); }

.github-composer {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  border-top: 1px solid var(--glow-line);
  padding-top: 0.5rem;
}
.github-composer textarea {
  font-family: var(--font-sans);
  font-size: var(--fs-13, 0.8125rem);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--paper-white);
  padding: 0.4rem 0.5rem;
  resize: vertical;
}
.github-composer textarea:focus { border-color: var(--signal-green); outline: none; }
.github-composer .btn { align-self: flex-start; }

.github-merge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--glow-line);
  padding-top: 0.5rem;
}

.github-merge-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
}
.github-merge-delete-label {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
.github-merge-confirm {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.github-merge-question {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.05em);
  color: var(--paper-white);
}

#open-pr-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}
.open-pr-label {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.1em);
  color: var(--signal-green);
  text-transform: var(--caps, uppercase);
}
#open-pr-row input, #open-pr-row textarea {
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  background: var(--system-black);
  border: 1px solid var(--glow-line);
  color: var(--signal-green);
  padding: 0.2rem 0.4rem;
}
#open-pr-row input:focus, #open-pr-row textarea:focus { border-color: var(--signal-green); outline: none; }
#open-pr-head, #open-pr-base { width: 9rem; }
#open-pr-title { flex: 1; min-width: 12rem; }
#open-pr-body { flex: 1 1 100%; resize: vertical; color: var(--paper-white); font-family: var(--font-sans); font-size: var(--fs-13, 0.8125rem); }

@media (max-width: 1100px) {
  #github-columns { grid-template-columns: 1fr; }
  /* A grid item's minimum width is its content's, so one long line in a
     README would push the column, and the panel, past the screen. */
  #github-columns > * { min-width: 0; }
  #github-overlay.has-item #github-list-pane { display: none; }
  #github-list-pane { border-right: none; padding-right: 0; }
}

#readout-ext {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  padding-top: 0.25rem;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  overflow-wrap: anywhere;
}
#readout-ext[hidden] { display: none; }

/* A chat whose readout carries a pinned area (the Warden's holds and, under
   them, the newest notice): the header may give height back to the
   transcript, scrolling its own rows, so the message box and the phone's tab
   bar keep their room. The area's own size is bounded by
   the extension that draws it. */
#readout-header:has(.wd-section) {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* One sheet for every extension panel: at the right edge on a wide screen,
   from the bottom on a phone. It dims the page as the other overlays do. */

#ext-sheet {
  top: 0;
  right: 0;
  bottom: 0;
  /* A panel can open from an order card's issue chip; Esc closes the sheet
     first, so it is drawn above the overlays. */
  z-index: 51;
  width: min(26rem, 100vw);
  display: flex;
  flex-direction: column;
  border-width: 0 0 0 1px;
}
#ext-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 1rem 1rem;
}
@media (max-width: 700px) {
  #ext-sheet {
    top: auto;
    left: 0;
    width: auto;
    max-height: 85dvh;
    border-width: 1px 0 0;
  }
  #ext-sheet-body { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

#readout-panels { display: flex; align-items: center; gap: 0.25rem; }
#readout-panels:empty { display: none; }
.panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 2rem;
  min-height: 1.75rem;
  padding: 0 0.375rem;
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--font-label);
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: var(--track, 0.1em);
  font-variant-numeric: tabular-nums;
  color: var(--glow-dim);
  cursor: pointer;
}
.panel-badge:hover { border-color: var(--glow-line); color: var(--signal-green); }
@media (max-width: 700px) {
  /* A 44px target that does not make the name row taller. */
  .panel-badge { min-width: 2.75rem; min-height: 2.75rem; margin-block: -0.625rem; justify-content: center; }
}

/* The extension manager: a numbered overlay, one row per extension. The row
   reads like a list row of a code host; its switch is a tab. Error text is
   prose, never red: the lamp carries the state. */

#rigging-overlay {
  top: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(44rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 4.25rem);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#rigging-note {
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
  overflow-wrap: anywhere;
}
#rigging-note:empty { display: none; }
#rigging-list { list-style: none; min-height: 0; overflow-y: auto; }
.rigging-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.625rem 0.5rem 0.625rem 0.375rem;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--ink-08);
}
.rigging-row[data-status="loaded"] { border-left-color: var(--signal-green); }
.rigging-row-top { display: flex; align-items: center; gap: 0.5rem; }
.rigging-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  font-weight: 700;
  letter-spacing: var(--track, 0.04em);
  text-transform: var(--caps, uppercase);
  color: var(--signal-green);
}
.rigging-meta, .rigging-status, .rigging-sub {
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--glow-dim);
}
.rigging-meta, .rigging-status { flex: none; white-space: nowrap; }
.rigging-status { margin-left: auto;
  text-transform: var(--caps, uppercase);
}
.rigging-status.status-loaded { color: var(--signal-green); }
.rigging-status.status-refused { color: var(--signal-amber); }
.rigging-status.status-error { color: var(--hazard-red); }
.rigging-switch { flex: none; width: 5.5rem; }
.rigging-switch button { padding: 0.25rem; }
.rigging-switch button:disabled { opacity: 0.55; cursor: default; }
.rigging-sub { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; padding-left: 1rem; }
.rigging-id, .rigging-package, .rigging-requires { overflow-wrap: anywhere; }
.rigging-id { text-transform: none; }
.rigging-package { text-transform: none; color: var(--prose-dim); }
.rigging-description, .rigging-error {
  padding-left: 1rem;
  font-family: var(--font-sans);
  font-size: var(--fs-13, 0.8125rem);
  line-height: 1.5;
  color: var(--prose-dim);
  overflow-wrap: anywhere;
}
.rigging-error {
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--paper-white);
  border-left: 1px solid var(--glow-line);
  margin-left: 1rem;
  padding-left: 0.5rem;
}
@media (max-width: 900px) {
  .rigging-row-top { flex-wrap: wrap; }
  .rigging-status { margin-left: 0; }
  .rigging-switch { margin-left: auto; }
}

/* The Jolly Roger world (DESIGN.md). The default look: a night sea, bone
   ink, and one colour per job. Everything below is scoped by data-skin, so a
   part it does not cover draws from the bridge above. Native CSS nesting:
   `&` is the themed <html>. */

html[data-skin="jolly"] {
  /* The Classic names that follow the world's own ink, re-pointed. The rest
     come from :root's alias and the theme's palette. */
  --signal-green: var(--bone-2);
  --ink-wash: color-mix(in srgb, var(--bone) 8%, transparent);
  --ink-04: color-mix(in srgb, var(--bone) 3%, transparent);
  --ink-08: color-mix(in srgb, var(--bone) 6%, transparent);
  --ink-12: color-mix(in srgb, var(--bone) 9%, transparent);
  --ink-20: color-mix(in srgb, var(--bone) 14%, transparent);
  --ink-55: color-mix(in srgb, var(--bone) 45%, transparent);
  --prose-faint: var(--bone-3);
  /* Crimson text on the deck and its tints: nudged toward the ink for 7:1. */
  --danger-deck: color-mix(in srgb, var(--danger) 85%, var(--bone));
  /* The raised deck is lighter than the deck, so crimson words on a rail
     node need a little more ink to hold the band. Rum on the raised deck is
     already over 7:1, so it needs no twin. */
  --danger-raised: color-mix(in srgb, var(--danger) 55%, var(--bone));
  --prose-thought: var(--bone-3);
  --lamp-amber-wash: color-mix(in srgb, var(--attn) 10%, transparent);

  & body { line-height: 1.5; }
  & a { color: var(--link); }
  & :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  & * { scrollbar-color: var(--rope) transparent; }
  & ::-webkit-scrollbar-thumb { background: var(--rope); border-radius: 4px; }
}


html[data-skin="jolly"] {
  & body { font-size: 0.875rem; }
  & #topbar {
    height: 3.25rem;
    gap: 0.75rem;
    padding: 0 0.75rem 0 1.25rem;
    background: var(--deck);
    border-bottom: 1px solid color-mix(in srgb, var(--rope) 60%, transparent);
  }
  & #wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-ui);
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1;
    color: var(--bone);
  }
  & .wordmark-flag { display: block; width: 1.5rem; height: 1.5rem; color: var(--bone); }
  & .wordmark-hole { fill: var(--deck); }
  & #wordmark-lamp { margin-left: 0; }
  /* 7:1 on the deck: crimson words, and a selected GitHub row's meta. */
  & .github-check-state.is-fail, & .rigging-status.status-error { color: var(--danger-deck); }
  & .github-row.is-selected .github-row-meta { color: var(--bone-2); }
  & #rigging-button:not([hidden]) + #settings-button { margin-left: 0; }

  & .panel { padding: 1.25rem; background: var(--deck); }
  & #readout { background: var(--sea); }
  & .corner { display: none; }

  /* One confident title per panel, in the display face. The readout's title
     is the chat's own name, so its panel title steps aside for screen
     readers only. */
  & .panel-title {
    gap: 0;
    margin-bottom: 0.875rem;
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 400;
    line-height: 1.1;
    color: var(--bone);
  }
  & .panel-title::after, & .panel-index { display: none; }
  & #readout > .panel-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }


  & .overlay {
    background: var(--deck);
    border: 1px solid var(--rope);
    border-radius: 10px;
    box-shadow: 0 1.25rem 3rem var(--shade);
  }
  & #settings-head { padding: 1rem 1rem 1rem 1.5rem; border-bottom-color: color-mix(in srgb, var(--rope) 60%, transparent); }
  & #settings-nav { gap: 0.25rem; padding: 1rem 0.75rem; border-right: 0; background: color-mix(in srgb, var(--sea) 55%, var(--deck)); }
  & #settings-nav button {
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bone-2);
    transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
  }
  & #settings-nav button:hover { background: var(--deck-3); color: var(--bone); }
  & #settings-nav button[aria-current="true"] { background: var(--deck-2); border-color: var(--bone-3); color: var(--bone); font-weight: 700; }
  & #settings-body { padding: 1.5rem 2rem 2.5rem; gap: 2.75rem; }
  & .settings-sec { gap: 1rem; scroll-margin-top: 1.5rem; }
  & .settings-section { font-size: 1.25rem; font-weight: 700; line-height: 1.3; color: var(--bone); }
  & .settings-section::after { display: none; }
  & .theme-row {
    padding: 0.5rem 0.625rem 0.625rem 0.5rem;
    border-color: var(--rope);
    border-radius: 8px;
    background: var(--deck-2);
    transition: border-color 120ms ease-out;
  }
  & .theme-row:hover { border-color: var(--bone-3); background: var(--deck-2); }
  & .theme-row:has(input:checked) { border-color: var(--bone-2); box-shadow: inset 0 0 0 1px var(--bone-2); background: var(--deck-2); }
  & .theme-row:has(input:checked) > span:last-child { font-weight: 700; }
  & .settings-project { border-color: var(--rope); border-radius: 8px; background: var(--deck-2); }
  & .settings-project > summary { min-height: 3rem; padding: 0.625rem 1rem; }
  & .settings-project > summary::before { color: var(--gold-ink); }
  & .settings-project > summary:hover .settings-project-name { color: var(--gold-ink); }
  & .settings-project > summary:focus-visible { outline-color: var(--gold-ink); border-radius: 8px; }
  & .settings-project-name { font-family: var(--font-sans); font-size: 1rem; color: var(--bone); }
  & .settings-project-path { font-size: 0.8125rem; color: var(--bone-3); }
  & .settings-project-body { padding: 0.25rem 1rem 1.25rem; }
  & .settings-project-body textarea { background-color: var(--deck); min-height: 7.5rem; }
  & #settings-title, & #ext-sheet-title {
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 400;
    line-height: 1.1;
    color: var(--bone);
  }
  & .settings-check, & .settings-label { font-size: 0.875rem; color: var(--bone); }
  & .settings-project-hail-hint, & .settings-project-doors-hint { font-size: 0.8125rem; color: var(--bone-3); }
  & .storage-status { font-size: 0.875rem; color: var(--bone); }
  & .storage-hint { font-size: 0.8125rem; color: var(--bone-3); }
  & .storage-project { padding: 0.75rem 1rem; border: 1px solid var(--rope); border-radius: 8px; background: var(--deck-2); }
  & .storage-project-name { font-family: var(--font-sans); font-size: 1rem; color: var(--bone); }
  & .storage-project-size { font-size: 0.8125rem; color: var(--bone-3); }
  & .storage-row { padding: 0.625rem 0; border-top-color: var(--rope); }
  & .storage-crew { font-family: var(--font-sans); font-size: 0.875rem; font-weight: 600; color: var(--bone); }
  & .storage-state { font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; color: var(--bone-2); }
  & .storage-state.is-running { color: var(--run); }
  & .storage-size { font-size: 0.8125rem; color: var(--bone); }
  & .storage-ignored, & .storage-top { font-size: 0.8125rem; color: var(--bone-3); }
  & .storage-blocker { font-size: 0.8125rem; color: var(--bone-3); }
  & .storage-confirm { padding: 0.75rem; border-color: var(--rope); border-radius: 6px; background: var(--deck); }
  & .storage-confirm p { font-size: 0.875rem; color: var(--bone); }
}

@media (max-width: 700px) {
  html[data-skin="jolly"] {
    & #topbar { gap: 0.25rem; padding: 0 0.25rem 0 0.75rem; }
    & #wordmark { font-size: 1.25rem; }
    & #topbar .btn { min-height: 2.75rem; padding: 0 0.625rem; }
    & #topbar { height: auto; min-height: 3.25rem; }
  }
}
@media (max-width: 700px) {
  #settings-overlay, html[data-skin="jolly"] #settings-overlay {
    inset: 0;
    transform: none;
    width: auto;
    height: auto;
    border-radius: 0;
    border-width: 0;
  }
  html[data-skin="jolly"] {
    & #settings-head { padding: max(0.75rem, env(safe-area-inset-top)) 0.5rem 0.75rem 1rem; }
    & #settings-nav { padding: 0.375rem 0.75rem; }
    & #settings-nav button { min-height: 44px; }
    & #settings-body { padding: 1.25rem 1rem max(2rem, env(safe-area-inset-bottom)); gap: 2.25rem; }
    & .settings-project > summary { padding: 0.5rem 0.75rem; }
    & .settings-project-body { padding: 0.25rem 0.75rem 1rem; }
  }
}
@media (max-width: 700px), (pointer: coarse) {
  #settings-overlay select { min-height: 2.75rem; font-size: var(--fs-16, 1rem); }
  #github-overlay .btn { min-height: 2.75rem; }
  #github-overlay .github-check a { display: inline-flex; align-items: center; min-height: 2.75rem; min-width: 2.75rem; }
  .rigging-switch button { min-width: 2.75rem; }
}
/* A phone bar with extension chips keeps one row: the skull stands for the name. */
@media (max-width: 440px) {
  html[data-skin="jolly"] #topbar:has(#topbar-ext:not([hidden])) #wordmark { font-size: 0; gap: 0; }
}

/* A Warden hold's cutlasses: the panel masks its badge with this, so the one
   definition stays here, where the skin's ink lives. */
html[data-skin="jolly"] {
  --mark-swords: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22' fill='none' stroke='black' stroke-linecap='round'><path d='M4 3.5c3.5 3 7 7.2 11 12M18 3.5c-3.5 3-7 7.2-11 12' stroke-width='2'/><path d='M13 17.5l4-4M9 17.5l-4-4' stroke-width='2'/><path d='M16.2 16.7l2.3 2.3M5.8 16.7L3.5 19' stroke-width='2.6'/></svg>");

}

html[data-skin="jolly"] {
  & #project-list { gap: 0.125rem; margin-bottom: 1.25rem; }
  & .project {
    gap: 0.625rem;
    min-height: 2.25rem;
    padding: 0.375rem 0.625rem;
    border: 0;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bone-2);
  }
  & .project::before { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--rope); }
  & .project:hover { color: var(--bone); background: var(--deck-2); }
  & .project[aria-current="true"] { color: var(--bone); background: var(--deck-2); border-color: var(--bone-3); }
  & .project[aria-current="true"]::before { background: var(--gold); }
  & .project[data-activity="running"]::before { background: var(--run); box-shadow: none; animation: none; }
  & .project[data-activity="report"]::before { background: var(--attn); }
  & .project-running {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--run);
    border: 1px solid color-mix(in srgb, var(--run) 45%, transparent);
    border-radius: 999px;
    padding: 0 0.4375rem;
  }
  & .project-edit { padding: 0.25rem 0.5rem; font-size: 0.8125rem; }
  & .node-host {
    order: 4;
    margin-top: 0.125rem;
    padding-left: 1.875rem;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--bone-3);
  }
  & .node-blocker, & .node-outside {
    order: 4;
    margin-top: 0.125rem;
    padding-left: 1.875rem;
    text-align: left;
    font-size: 0.75rem;
    color: var(--bone-3);
  }
  /* 2.125rem is the card's padding, lamp and gap (2.625rem) less the line's
     own padding, so the words start under the crew name. */
  & .node-overlap { margin-top: -0.125rem; padding-left: 2.125rem; text-align: left; }
  & .node-overlap-line { font-size: 0.75rem; letter-spacing: 0; }
  & .node-overlap-files { padding-left: 0.5rem; font-size: 0.75rem; }

  & .node-processes {
    margin-top: 0;
    padding: 0.5rem 0.75rem 0.625rem;
    background: var(--deck);
    border: 1px solid var(--rope);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    font-size: 0.75rem;
  }
  & .node-process-list li { color: var(--bone-2); }
  & .node-proc-pid { color: var(--bone-3); }
  & .node-proc-command { color: var(--bone-2); }
  & .node-proc-rule { color: var(--bone-3); font-size: 0.75rem; }
  & .node-proc-ask { color: var(--bone); font-weight: 600; }
  & #rail-actions { gap: 0.5rem; padding-top: 1rem; border-top: 0; }
  /* Gold is the one primary action; the rail's standing actions stay quiet. */
  & #error-log .error-log-head { color: var(--danger-deck); }
  & #error-log .error-log-head:hover { color: var(--bone); }
}

/* The narrow rail keeps the marks and drops the words. The phone shows the
   whole rail as its Fleet view, so it keeps them. */
@media (min-width: 701px) and (max-width: 900px) {
  html[data-skin="jolly"] {
    & .node-host { margin: 0; }
    & .node-blocker, & .node-outside, & .node-drop, & .node-overlap, & .node-processes { display: none; }
    & .panel { padding: 0.75rem; }
    & #rail { padding-inline: 0.5rem; }
  }
}

html[data-skin="jolly"] {
  & #readout { padding: 1.25rem 1.5rem 1rem; }
  & #readout-header {
    gap: 0.5rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid color-mix(in srgb, var(--rope) 70%, transparent);
  }
  & #readout-identity { gap: 0.75rem; }
  & #chat-name {
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 400;
    line-height: 1.1;
    color: var(--bone);
  }
  & #readout-identity #chat-id { font-size: 0.75rem; color: var(--bone-3); }
  & #chat-status {
    padding: 0.125rem 0.625rem;
    border-radius: 999px;
    background: var(--deck-2);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--bone-2);
  }
  & #chat-status[data-state="running"] { background: color-mix(in srgb, var(--run) 10%, transparent); color: var(--run); }
  & #chat-status[data-state="report"] { background: color-mix(in srgb, var(--attn) 10%, transparent); color: var(--attn); }
  & #chat-status[data-state="dead"], & #chat-status[data-state="error"] { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
  & #readout-controls { gap: 0.375rem; }
  & #readout-controls .btn, & #readout-actions .btn { padding: 0.375rem 0.75rem; }

  & #readout-status { gap: 0.375rem 1.25rem; }
  & .ctl { font-size: 0.8125rem; color: var(--bone-3); }
  & #readout-status select, & .header-pick .order-picker > button { font-size: 0.8125rem; padding-block: 0.25rem; }
  & .header-model > button:focus-visible, & .header-effort > button:focus-visible { border-color: var(--gold); outline: 1px solid var(--gold); outline-offset: 0; }
  & #readout-meter { gap: 0.25rem 1rem; font-size: 0.8125rem; color: var(--bone-3); }
  & #meter-context.above-threshold { color: var(--attn); font-weight: 700; }
  & #meter-bar { height: 4px; border-radius: 2px; background: var(--deck-3); }
  & #meter-bar-fill { border-radius: 2px; background: var(--bone-3); }
  & #meter-bar-fill.above-threshold { background: var(--attn); }
  & #chat-role { font-size: 0.875rem; color: var(--bone-2); }
  & .restart-question { font-size: 0.875rem; color: var(--bone); }

  & #readout-git { gap: 0.5rem; font-size: 0.8125rem; color: var(--bone-3); }
  & .git-label { font-family: var(--font-sans); font-weight: 600; }
  & .git-dir-chip {
    min-height: 1.625rem;
    border: 0;
    border-radius: 4px;
    background: var(--deck-2);
    font-size: 0.8125rem;
    color: var(--bone-2);
  }
  & .git-dir-chip:hover { background: var(--deck-3); color: var(--bone); }
  & .git-links-toggle, & .git-refresh { border-radius: 4px; font-size: 0.8125rem; color: var(--bone-2); }
  & .git-links-toggle { min-height: 1.625rem; border-color: var(--rope); }
  & .git-links-toggle:hover, & .git-links-toggle[aria-expanded="true"] { border-color: var(--bone-3); color: var(--bone); }
  & #readout-git-links { font-size: 0.8125rem; }
  & .git-link { color: var(--link); }
  & .git-link:hover { color: var(--bone); }
  & .git-dirty { color: var(--attn); }
  & #readout-branch { gap: 0.625rem; font-size: 0.8125rem; color: var(--bone-3); }
  & .pr-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.625rem;
    padding: 0 0.4375rem;
    border: 1px solid color-mix(in srgb, var(--link) 28%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--link) 9%, transparent);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--link);
  }
  & .pr-chip:hover { border-color: var(--link); }
  @media (min-width: 701px) and (min-height: 501px) {
    & #readout-identity { gap: 0.625rem; }
    & #readout-controls .btn { padding-inline: 0.625rem; }
    & #readout-status { gap: 0 0.75rem; }
    & #readout-model { gap: 0 0.375rem; }
    & #readout-meter { gap: 0 0.75rem; }
  }

  & #readout-hazard {
    gap: 0.375rem;
    margin: 0.25rem 0 0;
    padding: 0.75rem 1rem;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--danger) 7%, var(--sea));
  }
  & .hazard-line { align-items: center; gap: 0.625rem; }
  & .hazard-flag { font-size: 0.875rem; font-weight: 700; color: var(--danger); }
  & .hazard-text { font-size: 0.875rem; color: var(--bone); }
  & .hazard-full summary { font-size: 0.8125rem; color: var(--bone-2); }
  & .hazard-full pre { font-size: 0.8125rem; color: var(--bone-2); }
  & .hazard-recovery { font-size: 0.875rem; color: var(--bone-2); }
  & #readout-ext { gap: 0.5rem 1rem; padding-top: 0.25rem; font-size: 0.8125rem; color: var(--bone-3); }

  & #messages { padding: 1.25rem 0.75rem 1rem 0; }
  & .turn-rail { padding-left: 1.5rem; }
  & .turn-rail::before { left: 5px; width: 1px; background: color-mix(in srgb, var(--rope) 80%, transparent); }
  & .turn { margin-bottom: 1.75rem; }
  & .turn::before { left: calc(-1.5rem + 5px); }
  & .turn.user::before { background: var(--bone-3); }
  & .turn.user.report::before { background: var(--attn); }
  & .turn.assistant.live-current::before { background: var(--run); background-image: none; animation: none; }
  & .turn-head { gap: 0.625rem; margin-bottom: 0.375rem; font-size: 0.8125rem; color: var(--bone-3); }
  & .turn-head::before {
    top: 0.25rem;
    left: calc(-1.5rem + 1px);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--bone-3);
    background: var(--sea);
  }
  & .turn.user .turn-head::before { left: calc(-1.5rem - 1rem + 1px); background: var(--bone-3); border-color: var(--bone-3); }
  & .turn.user.report .turn-head::before { background: var(--attn); border-color: var(--attn); }
  & .turn.is-error .turn-head::before { background: var(--danger); border-color: var(--danger); }
  & .turn.live-current .turn-head::before { background: var(--run); border-color: var(--run); animation: jr-breathe 2.4s ease-in-out infinite; }
  & .turn-head .who { font-size: 0.875rem; font-weight: 700; color: var(--bone); }
  & .turn-head .flag { font-weight: 700; color: var(--bone-2); }
  & .turn-head .flag.is-error { color: var(--danger); }
  & .turn-head .flag.is-live { color: var(--run); }

  & .turn.user { padding: 0.75rem 1rem; border-radius: 10px; background: var(--deck); }
  & .turn.user .turn-body { color: var(--bone-2); }
  & .turn.user.report { background: color-mix(in srgb, var(--attn) 9%, var(--sea)); }
  & .turn.user.report .turn-head .who { color: var(--attn); }
  & .turn.user.hail { background: transparent; box-shadow: inset 0 0 0 1px var(--rope); }
  & .turn.user.hail::before { background: none; border-left: 1px dashed var(--bone-3); }
  & .turn.user.hail .turn-head::before { background: var(--sea); }
  & .turn.user.handoff { background: transparent; box-shadow: inset 0 0 0 1px var(--attn); }
  & .turn.user.handoff .turn-head .who { color: var(--attn); }
  & .turn-body .code-box:has(> .shell-out) { border-radius: 8px; background: var(--deck-2); }
  & .turn-body .code-box > .shell-out { padding: 0.125rem 0.75rem 0.625rem; }
  & .turn-body .shell-out { font-size: 0.8125rem; color: var(--bone-2); }
  & .shell-cmd { color: var(--bone); }
  & .shell-foot { font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--bone-3); }
  & .shell-state.is-running { color: var(--run); }
  & .shell-state.is-error { color: var(--danger); }
  & .turn-head .flag.shell-private { padding: 0 0.5rem; border-radius: 999px; font-size: 0.75rem; color: var(--attn); }

  & .turn-body { max-width: 70ch; font-size: 1rem; line-height: 1.6; }
  & .turn.assistant.helm-prose .turn-body { font-size: 1rem; line-height: 1.6; }
  & .turn-body p { margin: 0 0 1rem; }
  & .turn-body :is(h1, h2, h3) { margin: 1.75rem 0 0.5rem; font-size: 1.25rem; line-height: 1.3; }
  & .turn-body :is(h4, h5, h6) { margin: 1.25rem 0 0.25rem; font-size: 1rem; line-height: 1.5; }
  & .turn-body :is(h1, h2, h3, h4, h5, h6):first-child { margin-top: 0; }
  & .turn-body :is(ul, ol) { margin: 0 0 1rem 1.5rem; }
  & .turn-body li { margin: 0 0 0.25rem; }
  & .turn-body li > :is(ul, ol) { margin: 0.25rem 0 0.5rem 1.25rem; }
  & .turn-body li::marker { color: var(--bone-3); }
  & .turn-body blockquote { margin: 0 0 1rem; padding: 0 0 0 1rem; border-left: 1px solid var(--bone-3); color: var(--bone-2); font-style: italic; }
  & .turn-body table { font-size: 0.875rem; line-height: 1.5; }
  & .turn-body th, & .turn-body td { border: 0; padding: 0.5rem 0.75rem; }
  & .turn-body th { font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; color: var(--bone-2); }
  & .turn-body tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--bone) 5%, transparent); }
  & .turn-body code { font-size: 0.875em; line-height: 1; background: color-mix(in srgb, var(--bone) 7%, transparent); border-radius: 4px; padding: 0.0625rem 0.3125rem; }
  & .turn-body pre { background: var(--deck); border: 0; border-radius: 10px; padding: 0.875rem 1.125rem; }
  & .turn-body .code-box { background: var(--deck); border: 0; border-radius: 10px; }
  & .turn-body .code-box > pre { padding: 0.125rem 1.125rem 0.875rem; background: none; border: 0; }
  & .turn-body pre code { font-size: 0.8125rem; line-height: 1.6; background: none; padding: 0; }
  & .shj-syn-kwd, & .shj-syn-section { font-weight: 700; }

  /* Paths are sky: the one cool accent, for everything that opens. */
  & .file-chip {
    margin: 0 0.0625rem;
    padding: 0.0625rem 0.375rem;
    border: 1px solid color-mix(in srgb, var(--link) 16%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--link) 9%, transparent);
    font-size: 0.8125rem;
    color: var(--link);
  }
  & .file-chip:hover { border-color: var(--link); background: color-mix(in srgb, var(--link) 16%, transparent); }
  & .file-chip-glyph { color: var(--link); opacity: 0.8; margin-right: 0.3125rem; user-select: none; -webkit-user-select: none; }
  & .file-chip-line { color: var(--bone-3); }
  & .file-chip.is-copied { border-color: var(--ok); }
  & .file-chip.is-missing { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: transparent; }
  & .file-chip.is-missing :is(.file-chip-glyph, .file-chip-path) { color: var(--danger); }
  & code.md-file-ref {
    border: 1px solid color-mix(in srgb, var(--link) 16%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--link) 9%, transparent);
    font-size: 0.8125rem;
    color: var(--link);
  }
  & .md-file-ref-lines { color: var(--bone-3); }
  & .path-image { border: 0; border-radius: 8px; overflow: hidden; background: var(--deck); }
  & .skill-chip { border-radius: 999px; border-color: var(--rope); background: var(--deck-2); color: var(--bone); }
  & .skill-chip-glyph { color: var(--link); }
  & .skill-chip-name { font-size: 0.8125rem; }

  & .tool-log { gap: 0.25rem; margin: 0.75rem 0; padding-left: 0.75rem; border-left: 1px solid var(--rope); }
  & .tool-line { font-size: 0.8125rem; }
  & .tool-line summary { gap: 0.5rem; color: var(--bone-3); }
  & .tool-line summary::before { color: var(--bone-3); }
  & .tool-tag { border: 0; padding: 0; font-family: var(--font-sans); font-size: 0.75rem; color: var(--bone-3); }
  & .tool-name { font-weight: 700; color: var(--bone); }
  & .tool-arg { color: var(--bone-2); }
  & .tool-state { font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; color: var(--bone-3); }
  & .tool-line.is-running .tool-state { color: var(--run); }
  & .tool-line.is-error :is(.tool-name, .tool-state) { color: var(--danger); }
  & .tool-label { font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; color: var(--bone-3); }
  & .tool-body .code-box { border: 0; border-radius: 8px; background: var(--deck); font-size: 0.8125rem; }
  & .turn-body .code-box:has(> .shell-out) { font-size: 0.8125rem; }
  & .tool-body pre { border: 0; font-size: 0.8125rem; color: var(--bone-2); }

  & .thinking { font-size: 0.8125rem; }
  & .thinking summary { color: var(--bone-3); }
  & .thinking-meta { font-size: 0.8125rem; font-style: italic; color: var(--bone-3); }
  & .thinking-text { border-left-color: var(--rope); font-size: 0.875rem; font-style: italic; color: var(--bone-3); }

  & .turn-work-summary { font-size: 0.8125rem; font-weight: 600; color: var(--bone-3); }
  & .turn-work-summary::before { color: var(--bone-3); }
  & .turn-work-summary:hover { color: var(--bone-2); }
  & .turn-work-summary > * + :not(.turn-work-errors)::before { color: var(--bone-3); font-weight: 400; }
  & .turn-work-count { color: var(--bone-2); }
  & .turn-work-errors { color: var(--danger); }
  & .turn-work-body { margin-top: 0.5rem; padding-left: 1rem; }
  & .turn-note { font-size: 0.875rem; line-height: 1.5; color: var(--bone-2); }
  & .turn-note.is-error { color: var(--danger); }
  & :is(.entry-more, .code-more) { font-size: 0.8125rem; font-weight: 600; color: var(--bone-2); }
  & .entry-more { margin-top: 0.5rem; }
  & :is(.entry-more, .code-more):hover { color: var(--bone); }

  & .live-status { gap: 0.625rem; margin-top: 0.875rem; font-size: 0.8125rem; font-weight: 600; color: var(--run); }
  & .live-total { color: var(--bone-3); font-weight: 400; }

  & #verb-legend { gap: 0.75rem; padding-top: 0.625rem; font-size: 0.8125rem; color: var(--bone-3); }
  & .verb-legend-verb { font-weight: 700; color: var(--bone-2); }
  & .report-row { display: flex; gap: 0.5rem; margin-top: 1rem; }
  & .empty-state { gap: 0.75rem; color: var(--bone-2); }
  & .empty-state .empty-title { font-family: var(--font-display); font-size: 1.625rem; font-weight: 400; color: var(--bone); }

  & #composer { gap: 0.5rem; padding-top: 0.5rem; border-top: 0; }
  & #composer-row { gap: 0.625rem; }
  & #composer-input {
    padding: 0.375rem 0.875rem;
    border-radius: 10px;
    background: var(--deck);
    border-color: var(--rope);
    font-size: 1rem;
  }
  & #composer-input:focus { border-color: var(--gold); }
  & #send-button { min-width: 5.5rem; }
  & #composer-hint { font-size: 0.75rem; color: var(--bone-3); }
  & #composer-refusal {
    padding: 0.375rem 0.75rem;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--danger) 7%, var(--sea));
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--danger);
  }
  & .thumb { border: 0; border-radius: 8px; background: var(--deck-2); }
  & .thumb-label { font-size: 0.75rem; color: var(--bone-3); }
}

@keyframes jr-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (max-width: 700px) {
  html[data-skin="jolly"] {
    & #readout { padding: 0.75rem 0.75rem 0.5rem; }
    & #chat-name { font-size: 1.25rem; }
    & .turn.user { padding: 0.625rem 0.75rem; }
    & #composer-input { font-size: 1rem; }
    & #send-button { min-width: 4.5rem; padding-inline: 0.75rem; }
    & #composer-input { padding-block: 0.5rem; }
  }
}

@media (max-width: 700px), (max-height: 500px) {
  html[data-skin="jolly"] {
    & #readout-summary {
      border-radius: var(--radius);
      border-color: var(--rope);
      background: var(--deck);
      font-size: 0.8125rem;
      color: var(--bone-2);
    }
    & #readout-summary:hover { border-color: var(--bone-3); color: var(--bone); }
    & #readout-summary.above-threshold { border-color: var(--attn); color: var(--attn); }
  }
}
@media (max-height: 500px) {
  html[data-skin="jolly"] {
    & #readout { padding-block: 0.5rem; }
    & #composer { padding-top: 0.5rem; }
  }
}

@media (max-width: 700px), (pointer: coarse) {
  html[data-skin="jolly"] :is(#readout-status select, .header-pick .order-picker > button) { font-size: 1rem; min-height: 2.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-skin="jolly"] .turn.live-current .turn-head::before { animation: none; }
}

/* Parchment ink on the night sea. The one bright surface is the open order
   card: a bounded slip of parchment. */
html[data-skin="jolly"] {
  & .release-all-row { gap: 0.5rem; padding: 0.75rem; border-radius: 10px; background: color-mix(in srgb, var(--sea) 55%, transparent); }
  & .release-all-none { font-size: 0.8125rem; color: var(--map-ink-2); }
  & .order-node-vessel { font-size: 0.875rem; font-weight: 700; color: var(--map-ink); }
  & .order-node-voyage { font-size: 0.8125rem; font-style: italic; color: var(--map-ink-2); }
  & .order-node-state { font-size: 0.75rem; font-weight: 700; color: var(--map-ink-2); }

  & .order-older { padding-left: 0.875rem; background: none; }
  & .order-older-toggle { padding: 0.25rem 0; font-size: 0.8125rem; font-weight: 600; color: var(--map-ink-2); }
  & .order-older-toggle:hover, & .order-older-toggle[aria-expanded="true"] { color: var(--map-ink); }
  & .order-older-list { gap: 0.375rem; padding-left: 0.625rem; border-left: 1px dashed color-mix(in srgb, var(--gold) 55%, transparent); }
  & .order-older-line { font-size: 0.8125rem; }
  & .order-older-line .btn { padding: 0.1875rem 0.5rem; font-size: 0.8125rem; color: var(--map-ink-2); }
  & .order-older-age { font-size: 0.75rem; color: var(--map-ink-2); }

  & .empty-state .empty-title::first-letter { text-transform: uppercase; }
}

/* Autopilot, Linear, Tunnel and Terminal write their labels in sentence
   case, and Classic sets them in capitals through --caps. An extension that
   still writes capitals is set in sentence case here, where the words allow
   it; the title is a block, so its first letter can take the capital. */
html[data-skin="jolly"] {
  --attn-ink: #6e3004;     /* rum, dark enough for parchment */
  --danger-ink: #7a1520;
  & #ext-sheet-title { display: block; overflow: hidden; text-overflow: ellipsis; }
  & #ext-sheet { border-radius: 10px 0 0 10px; border-width: 0; }
  & #ext-sheet-head { min-height: 3.25rem; padding: 0 0.5rem 0 1.25rem; border-bottom: 1px solid color-mix(in srgb, var(--rope) 70%, transparent); }
  & #ext-sheet-body { padding: 1rem 1.25rem 1.25rem; }
  & .panel-badge { border-radius: 999px; font-size: 0.8125rem; color: var(--bone-2); }
  & .panel-badge:hover { border-color: var(--rope); color: var(--bone); }
}
@media (max-width: 700px) {
  html[data-skin="jolly"] #ext-sheet { border-radius: 10px 10px 0 0; }
}

/* The flag of a running crew ripples; a new report draws its X once; a
   crew that died shows its skull once and settles; a released order draws
   its route once; the Autopilot compass turns while Autopilot runs (in its
   extension). Transform and opacity only. The running wire keeps still:
   the flag carries the motion, so the rail does not restyle every frame. */
html[data-skin="jolly"] {
  & #reports-pill.is-new { animation: jr-swell 360ms cubic-bezier(0.16, 1, 0.3, 1) 1; }
  /* an overlay or sheet opens: it slides 12px in from its edge and fades in,
     once, as it appears. The sheet comes from the right (from the bottom on
     a phone); the overlays under the top bar come down from it. */
  & #ext-sheet:not([hidden]) { animation: jr-in-left 160ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  & :is(#settings-overlay, #rigging-overlay, #github-overlay):not([hidden]) { animation: jr-in-down 160ms cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes jr-route {
  0% { opacity: 1; transform: scaleX(0); }
  70% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0.45; transform: scaleX(1); }
}
@keyframes jr-pin { from { opacity: 0; transform: translateY(-3px) scale(1.6); } }
@keyframes jr-swell { 40% { transform: scale(1.15); } }
/* The individual translate property composes with an overlay's own
   centring transform. */
@keyframes jr-in-left { from { opacity: 0; translate: 12px 0; } }
@keyframes jr-in-down { from { opacity: 0; translate: 0 -12px; } }
@media (max-width: 700px) {
  html[data-skin="jolly"] #ext-sheet:not([hidden]) { animation-name: jr-in-up; }
}

/* A short viewport leaves the transcript's band no room for the transcript's
   own breathing room: the padding shrinks, so the transcript's box keeps
   inside the band and draws over nothing. */
@media (max-height: 640px) {
  #messages, html[data-theme^="jolly-roger"] #messages { padding-block: 0.25rem; }
}
.turn .carvel-source{margin:0 0 .375rem;font-family:var(--font-label);font-size:var(--fs-10,.625rem);letter-spacing:var(--track,.1em);text-transform:var(--caps,uppercase);color:var(--signal-green)}

/* The seat bar: the Reckoner's own row under the header, its name and its
   state. */
#seat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
  padding: 0.35rem 0;
  border-top: 1px solid var(--glow-line);
}
#seat-bar[hidden] { display: none; }
#seat-bar-name {
  font-size: var(--fs-11, 0.6875rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal-green);
}
@media (max-width: 700px) {
  /* The phone's mount: the middle column's head is off its screen, so the
     switch takes the row of the readout's header. */
  #readout-controls #seat-switch { margin-right: auto; }
}

/* The nightly ask in the Inbox: its own kind of row (web/app-inbox.js), drawn
   as a moon beside a decision's circle, with the window's counts and the two
   picks over the two actions a decision row answers with. */
.inbox-mark.is-reckoning { border: 2px solid var(--attn); border-radius: 50%; }
.inbox-mark.is-reckoning::after { inset: 3px 3px 3px 6px; border-radius: 50%; background: var(--attn); }
.inbox-kind.is-reckoning { color: var(--attn); }
.inbox-reckoning-counts { margin: 0.25rem 0 0; padding-left: 1.125rem; font-size: 0.875rem; color: var(--bone-2); }
.inbox-reckoning-window { margin: 0.125rem 0 0; font-size: 0.75rem; color: var(--bone-3); }
.inbox-reckoning-picks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.5rem; }
.inbox-reckoning-picks .ctl { display: inline-flex; align-items: center; gap: 0.375rem; }
