/*
 * One accent (cobalt) carries both "act here" and "waiting on you": the primary
 * button and a Parked Session are the same call to the Operator. Green, amber and
 * red are states, never decoration.
 *
 * Radii: controls 6px, panels 10px, pills and badges round. Nothing else.
 * Fonts: the system's. The CSP names no font-src, so a web font would not load.
 */
:root {
  --bg: #f3f4f6;
  --panel: #fcfcfd;
  --sunken: #eceef2;
  --text: #15171c;
  --muted: #5d6470;
  --line: #e0e3e8;
  --line-strong: #c9ced6;
  --accent: #2a54c8;
  --accent-ink: #f7f9ff;
  --accent-soft: rgb(42 84 200 / .09);
  --ok: #1b7a3e;
  --warn: #975c00;
  --error: #b42318;
  --shadow: 0 1px 2px rgb(21 30 50 / .05), 0 4px 16px rgb(21 30 50 / .05);

  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --topbar: 56px;

  color-scheme: light dark;
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --panel: #15181e;
    --sunken: #1b1f26;
    --text: #e6e8ed;
    --muted: #979eab;
    --line: #242830;
    --line-strong: #343a45;
    --accent: #8fa9ff;
    --accent-ink: #0e1014;
    --accent-soft: rgb(143 169 255 / .12);
    --ok: #5cc98a;
    --warn: #e0b04f;
    --error: #ff7b72;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1 { margin: 0; }
h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; letter-spacing: -.005em; margin: 36px 0 12px; }
p { margin: 0; }
code, pre { font: 12.5px/1.5 var(--mono); }
code { background: var(--sunken); border-radius: 6px; padding: 2px 6px; }
pre { background: var(--sunken); padding: 10px 12px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; }
pre.plain { background: none; padding: 0; font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

button, select, input, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px;
  font-weight: 500; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease);
}
button:hover:not(:disabled) { background: var(--sunken); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--error); }
button.danger:hover:not(:disabled) { border-color: var(--error); background: var(--panel); }
button.ghost { border-color: transparent; background: none; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--sunken); }
select:disabled { opacity: .6; cursor: not-allowed; }

input[type=text], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px;
  transition: border-color .15s, box-shadow .15s;
}
/* The halo has to be seen from across the desk, not just by the one who clicked. */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin: 0; }

.muted { color: var(--muted); }
.aside { color: var(--muted); font-size: 12.5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.error { color: var(--error); }
.error:empty { display: none; }
.spacer { flex: 1; }

.brand { font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 450; }
.brand-lg { font-size: 22px; letter-spacing: -.02em; }

/* ── Sign-in ────────────────────────────────────────────────────────────── */

.login { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login-box {
  width: min(400px, 100%); display: grid; gap: 12px; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.login-intro { color: var(--muted); margin-bottom: 8px; }
.login-intro code { display: block; margin-top: 8px; padding: 8px 10px; color: var(--text); overflow-x: auto; white-space: nowrap; }
.login-box .field { font-weight: 500; font-size: 13px; margin-bottom: -6px; }
.login-box #token { font-family: var(--mono); }
.login-box button.primary { min-height: 36px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); cursor: pointer; }
.language { display: flex; gap: 8px; align-items: center; justify-self: end; color: var(--muted); font-size: 13px; }
.language select, .topbar select { width: auto; min-height: 30px; padding: 2px 8px; }

/* ── Frame ──────────────────────────────────────────────────────────────── */

.app {
  display: grid; min-height: 100dvh;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: var(--topbar) 1fr auto;
  grid-template-areas: 'top top' 'side main' 'side feed';
}
.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 10;
  display: flex; gap: 12px; align-items: center; padding: 0 16px 0 20px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.version { color: var(--muted); font: 12px var(--mono); }
.sidebar {
  grid-area: side; align-self: start; position: sticky; top: var(--topbar);
  height: calc(100dvh - var(--topbar)); overflow-y: auto; padding: 4px 12px 24px; border-right: 1px solid var(--line);
}
.sidebar h2 { margin: 20px 8px 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.content { grid-area: main; min-width: 0; width: 100%; max-width: 1040px; padding: 0 32px 16px; }
.activity { grid-area: feed; min-width: 0; max-width: 1040px; padding: 0 32px 48px; }

/* Wide screens: the feed is a rail beside the work, not a page below it. */
@media (min-width: 1360px) {
  .app { grid-template-columns: 232px minmax(0, 1fr) 400px; grid-template-rows: var(--topbar) 1fr; grid-template-areas: 'top top top' 'side main feed'; }
  .content { padding-bottom: 48px; }
  .activity {
    position: sticky; top: var(--topbar); align-self: start;
    height: calc(100dvh - var(--topbar)); overflow-y: auto; overscroll-behavior: contain;
    padding: 0 20px 24px; border-left: 1px solid var(--line); background: var(--panel);
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .activity h2 { position: sticky; top: 0; z-index: 1; margin: 0 -20px 8px; padding: 22px 20px 10px; background: var(--panel); }
  .activity .feed li { background: none; }
}

/* ── Link status ────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12px; padding: 2px 10px 2px 8px; border-radius: 999px;
  color: var(--muted); background: var(--sunken);
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* The words lean toward the text colour so they clear 4.5:1 on their own tint, in both schemes. */
.pill.ok { color: color-mix(in srgb, var(--ok) 78%, var(--text)); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill.warn { color: color-mix(in srgb, var(--warn) 78%, var(--text)); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: 600 11.5px/1 var(--mono);
}
.count:empty { display: none; }
/* What cannot be answered — on an offline Node, or past its time — is a fact, not a call. */
.count.quiet { background: var(--sunken); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; margin: 36px 0 12px; }
.section-head h2 { margin: 0; }
.keys { color: var(--muted); font-size: 12px; }
.filter { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.filter select { width: auto; min-height: 30px; padding: 2px 8px; color: var(--text); }
.note { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.note.warn { color: var(--warn); }

/* ── Nodes ──────────────────────────────────────────────────────────────── */

.nodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nodes button {
  width: 100%; justify-content: flex-start; gap: 10px; min-height: 34px; padding: 0 8px;
  border-color: transparent; background: none; font-weight: 450; text-align: left;
}
.nodes button:hover:not(:disabled) { background: var(--sunken); }
.nodes button.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nodes .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px var(--muted); }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.none { margin: 4px 8px; color: var(--muted); font-size: 13px; }
.none code { display: block; width: fit-content; margin-top: 6px; color: var(--text); }

/* ── Waiting on you ─────────────────────────────────────────────────────── */

.waiting .section-head { margin-top: 28px; }
.waiting h2 { font-size: 17px; }

.empty {
  padding: 18px 20px; border: 1px dashed var(--line-strong); border-radius: 10px;
  color: var(--muted); text-align: center;
}

.cards { display: grid; gap: 12px; }
.card {
  position: relative; overflow: clip; padding: 16px 18px 16px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  transition: opacity .3s, box-shadow .3s;
}
.card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.card.reminded { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
/*
 * Lift means it needs you. Expired: it may no longer; answerable still, but grey and
 * flat, and no answer is the primary one. Stale: the Node is gone, so the request
 * and its buttons recede while the reason why stays at full strength.
 */
.card.stale::before, .card.expired::before, .card.done::before { background: var(--line-strong); }
.card.stale, .card.expired, .card.done { box-shadow: none; }
.card.stale > :not(.card-head, .result) { opacity: .5; }
/* Already faded with the rest of the card; fading again would put them at a quarter. */
.card.stale :disabled { opacity: 1; }
.card.stale .when { color: var(--muted); font-weight: 400; }
.card.expired .when { flex-basis: 100%; margin: 6px 0 0; font-size: 13px; color: var(--text); }
.card.done > :is(.actions, details.more, .scope) { display: none; }
.card > p { margin-top: 8px; }
.card:focus-visible { outline-offset: 3px; }
.card-head { display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; align-items: baseline; }
.card-head .headline { font-weight: 600; font-size: 15px; }
.card-head .meta { color: var(--muted); font: 12px var(--mono); }
.card .when { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card .when.urgent { color: var(--error); font-weight: 600; }
.card .scope { font-size: 12.5px; color: var(--muted); }
.card .scope code { font-size: 12px; padding: 1px 5px; color: var(--text); overflow-wrap: anywhere; }
.card .dismiss { margin: 6px 0 0 -12px; }
.card.done .result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions input { width: auto; flex: 1; min-width: 160px; }
/* Two Allows side by side must not be one slip apart. */
.actions.answer > :first-child { margin-right: 8px; }
details.more > .actions { margin-top: 10px; padding-top: 0; border-top: 0; }
details.more > .actions.cancel { align-items: baseline; }
details.more .cancel .aside { flex: 1; min-width: 200px; }
.result { margin-top: 10px; font-size: 13px; }
.result:empty { display: none; }
.result.ok { color: var(--ok); }
.result.warn { color: var(--warn); }
.result.error { color: var(--error); }
details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 10px; width: fit-content; }
details summary:hover { color: var(--text); }

fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0 0; padding: 10px 12px 12px; display: grid; gap: 4px; }
legend { font-weight: 600; padding: 0 6px; }
fieldset > p { margin-bottom: 4px; }
.option { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; cursor: pointer; }
.option:hover { background: var(--sunken); }
.option input { transform: translateY(2px); }
.option .desc { grid-column: 2; color: var(--muted); font-size: 12.5px; }
.other { margin-top: 6px; }

/* ── New task ───────────────────────────────────────────────────────────── */

.new-task {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.new-task label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.new-task label > :is(select, textarea) { font-size: 14px; font-weight: 400; }
.new-task .optional { color: var(--muted); font-weight: 400; }
.new-task .wide, .new-task .result, .new-task .aside { grid-column: 1 / -1; }
.new-task .result { margin-top: -4px; }
.new-task button { justify-self: start; min-width: 96px; }
.new-task .hint { margin-top: -6px; }
.new-task .hint.warn { color: var(--warn); }

/* ── Sessions ───────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.table-wrap:has(> table[hidden]) { display: none; }
.sessions { width: 100%; min-width: 640px; border-collapse: collapse; }
.sessions th, .sessions td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.sessions tbody tr:last-child td { border-bottom: 0; }
.sessions tbody tr { transition: background-color .15s; }
.sessions tbody tr:hover { background: var(--sunken); }
.sessions th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--sunken); white-space: nowrap; }
.sessions td:is(.session, .cwd, .active) { font: 12.5px var(--mono); font-variant-numeric: tabular-nums; }
.sessions td:is(.active, .origin) { color: var(--muted); white-space: nowrap; }
/* The Session takes what the other columns leave: its name, and under it what it last did. */
.sessions td.session { width: 100%; max-width: 0; }
.sessions td.session .label { display: block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
.sessions td.session .last {
  display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis;
  font: 12.5px/1.45 var(--sans); color: var(--muted);
}
.sessions td.session .last.error { color: var(--error); }
.sessions td.cwd { color: var(--muted); }
.sessions td.origin .runs-on { display: block; margin-top: 1px; font-size: 12px; }
.sessions td.cwd span { display: block; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; }
/* Stop and Kill stay in reach when the table is wider than the screen. */
.sessions td.row-actions, .sessions th:last-child { position: sticky; right: 0; }
.sessions td.row-actions { white-space: nowrap; text-align: right; background: var(--panel); transition: background-color .15s; }
.sessions tbody tr:hover td.row-actions { background: var(--sunken); }
.sessions td.row-actions button { margin-left: 6px; min-height: 28px; padding: 0 10px; font-size: 13px; }
.row-status { display: inline-block; max-width: 28ch; vertical-align: middle; white-space: normal; text-align: right; font-size: 12.5px; color: var(--muted); }
.row-status.ok { color: var(--ok); }
.row-status.error { color: var(--error); }
.sessions tr.confirming td { border-bottom: 0; }
.sessions tr.confirm-row td { white-space: normal; background: var(--sunken); }
.confirm-row .actions { margin-top: 10px; padding-top: 0; border-top: 0; }
/* One Node says the same name on every row. */
.sessions.one-node :is(th, td).node { display: none; }
.sessions td.state { white-space: nowrap; }
.sessions td.state::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: currentColor; vertical-align: middle; }
.state-parked { color: var(--accent); font-weight: 600; }
.state-working, .state-starting { color: var(--text); }
.state-settled { color: var(--ok); }
.state-exited { color: var(--muted); }
/* Cold: kept, and resumable, but nothing is running there. The row recedes and its lamp is out. */
.sessions tr.cold td, .sessions td.state-cold { color: var(--muted); }
.sessions td.state-cold::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }

/* ── One task ───────────────────────────────────────────────────────────── */

/* The way out sits on its own line above the title, where the eye starts, and looks like a button. */
.task-back { margin-top: 28px; }
.task-back::before { content: '←' / ''; font-size: 15px; line-height: 1; }
.task-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 14px 0 4px; }
.task-head h2 { margin: 0; font: 600 15px var(--mono); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-state { font-size: 13px; white-space: nowrap; }
.task-state::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: currentColor; vertical-align: middle; }
.task-state.state-cold { color: var(--muted); }
.task-state.state-cold::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.task-state:empty { display: none; }
.task-meta { margin-bottom: 14px; color: var(--muted); font: 12.5px var(--mono); overflow-wrap: anywhere; }
.task .note { margin: 0 0 12px; }

.transcript { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.transcript li.you, .transcript li.agent { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-width: 0; }
/* The Operator's words sit to the right and in the accent, as in any conversation. */
.transcript li.you { margin-left: max(10%, 48px); background: var(--accent-soft); border-color: transparent; }
.transcript li.agent { margin-right: max(10%, 48px); }
.transcript li.pending { opacity: .6; }
.transcript li.draft { border-style: dashed; }
.transcript .who { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.transcript .at { font: 11.5px var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; color: var(--muted); }
.transcript .text { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.55; }
.transcript li.event { display: flex; gap: 10px; align-items: baseline; padding: 0 14px; font-size: 12.5px; color: var(--muted); }
.transcript li.event.tone-ok { color: var(--ok); }
.transcript li.event.tone-warn { color: var(--warn); }
.transcript li.event.tone-error { color: var(--error); }
.transcript li.event.tone-attention { color: var(--accent); }

/* The box to write in stays at the foot of the screen while the conversation scrolls by. */
.composer {
  position: sticky; bottom: 0; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: end;
  margin: 16px 0 0; padding: 12px 0 16px; background: var(--bg);
}
.composer textarea { min-height: 64px; max-height: 40vh; }
.composer .result { grid-column: 1 / -1; margin-top: 0; }

/* ── Activity ───────────────────────────────────────────────────────────── */

.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li {
  position: relative; padding: 10px 0 10px 18px;
  border-bottom: 1px solid var(--line);
}
.feed li:last-child { border-bottom: 0; }
.feed li::before { content: ''; position: absolute; left: 2px; top: 17px; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.feed .line { display: flex; gap: 4px 10px; flex-wrap: wrap; align-items: baseline; }
.feed .at { color: var(--muted); font: 11.5px var(--mono); font-variant-numeric: tabular-nums; }
.feed .where { color: var(--muted); font: 11.5px var(--mono); }
.feed .title { flex-basis: 100%; font-weight: 500; }
.feed-empty { padding: 10px 0; font-size: 13px; }
.feed .body { white-space: pre-wrap; word-break: break-word; margin-top: 4px; max-height: 18em; overflow: auto; color: var(--muted); font-size: 13px; }
.feed li.tone-ok::before { background: var(--ok); }
.feed li.tone-warn::before { background: var(--warn); }
.feed li.tone-error::before { background: var(--error); }
.feed li.tone-attention::before { background: var(--accent); }
.feed li.tone-ok .title { color: var(--ok); }
.feed li.tone-warn .title { color: var(--warn); }
.feed li.tone-error .title { color: var(--error); }
.feed li.tone-attention .title { color: var(--accent); }
.feed li.draft::before { background: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.feed li.draft .title { color: var(--muted); font-style: italic; font-weight: 400; }
.feed li.draft .body { color: var(--text); }

/* ── Motion: only for things that just changed ──────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  /* A new ask arrives; a pill that is reconnecting says it is still trying. */
  .card { animation: arrive .45s var(--ease) both; }
  .feed li.draft::before, .pill.warn::before { animation: breathe 1.4s ease-in-out infinite; }
  .login-box { animation: arrive .5s var(--ease) both; }
}
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } }
@keyframes breathe { 50% { opacity: .35; } }

/* ── Narrow screens ─────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar) auto 1fr auto; grid-template-areas: 'top' 'side' 'main' 'feed'; }
  .topbar { padding: 0 12px; gap: 8px; }
  .version { display: none; }
  .sidebar { position: static; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar h2 { display: none; }
  /* A visible scrollbar says there are more Nodes than fit. */
  .nodes { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  .none { margin: 4px 0; }
  .content, .activity { padding-left: 16px; padding-right: 16px; }
  .new-task { grid-template-columns: 1fr; padding: 14px; }
  .transcript li.you { margin-left: 24px; }
  .transcript li.agent { margin-right: 0; }
  .card { padding: 14px 14px 14px 16px; }
  .card .when { margin-left: 0; }
  .login-box { padding: 22px; }

  /* Sessions stack: what it is and its state, where it runs, then Stop and Kill in reach. */
  .table-wrap { overflow: visible; }
  .sessions { min-width: 0; }
  .sessions thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .sessions, .sessions tbody { display: block; }
  .sessions tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .sessions tbody tr:last-child { border-bottom: 0; }
  .sessions tbody tr.confirming { border-bottom: 0; padding-bottom: 4px; }
  .sessions td, .sessions tbody tr:last-child td { display: block; padding: 0; border: 0; }
  .sessions td.session { order: 1; flex: 1 1 0; width: auto; min-width: 0; max-width: none; overflow: hidden; }
  .sessions td.state { order: 2; }
  .sessions td.cwd { order: 3; flex-basis: 100%; min-width: 0; }
  .sessions td.cwd span { max-width: none; }
  .sessions td.node { order: 4; color: var(--muted); font-size: 12.5px; }
  .sessions td.origin { order: 5; font-size: 12.5px; }
  .sessions td.active { order: 6; font-size: 12px; }
  .sessions td.row-actions { order: 7; flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; text-align: left; position: static; background: none; }
  .sessions tbody tr:hover td.row-actions { background: none; }
  .row-status { flex-basis: 100%; max-width: none; text-align: left; }
  .sessions td.row-actions:empty { display: none; }
  .sessions td.row-actions button { margin-left: 0; }
  .sessions tr.confirm-row td { flex-basis: 100%; background: none; }
  /* The dot sits in the middle of the gap, not against the word after it. */
  .sessions td:is(.origin, .active)::before { content: '·'; margin-right: 10px; }
  .sessions.one-node td.origin::before { content: none; }

  /* Three answers do not fit one row: the two Allows share it, Deny takes the next. */
  .actions.answer > * { flex: 1 1 auto; }
  details.more .actions input { flex-basis: 100%; }
}

/* ── Touch: 44px targets ────────────────────────────────────────────────── */

@media (pointer: coarse) {
  button, .nodes button, .sessions td.row-actions button, .login-box button.primary { min-height: 44px; min-width: 44px; }
  input[type=text], input[type=password], input:not([type]), select, textarea,
  .filter select, .language select, .topbar select { min-height: 44px; }
  .actions { gap: 10px; }
  .actions.answer > :first-child { margin-right: 12px; }
  details summary { padding: 10px 0; margin-top: 4px; }
  .option { padding: 10px 8px; }
}

/* ── Your Nodes, your account, the Admin's page ─────────────────────────── */

.view h2 { margin-top: 14px; }
.view > .aside { margin-bottom: 14px; }
.view .table-wrap, .admin .table-wrap { margin-top: 14px; }
.new-task label > input { font-size: 14px; font-weight: 400; }
.new-task input[autocomplete=off] { font-family: var(--mono); }
.password-form { max-width: 640px; }
.manage-open { width: 100%; margin-top: 10px; justify-content: flex-start; color: var(--accent); }
.account-name { font: 12.5px var(--mono); max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot.inline { display: inline-block; margin-right: 8px; vertical-align: 1px; }

/* Why a Session stopped, when it is worth a colour; and a Node gone quiet. */
.sessions td.state.tone-error { color: var(--error); }
.sessions td.state.tone-stale { opacity: .6; }
.note.chosen { display: flex; align-items: center; gap: 8px; margin-top: 0; color: var(--text); }
.note.chosen button { min-height: 26px; padding: 0 8px; font-size: 12.5px; }

/* Counts of Sessions by state: the same chip wherever they are counted. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chip {
  display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--sunken); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
}
.chip.attention { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 600; }
.chip.busy { color: var(--text); }
.chip.error { color: var(--error); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--error) 35%, transparent); }

/* A Repository across Nodes: one card, its Nodes' Projects listed under it. */
.groups { display: grid; gap: 12px; margin-top: 14px; }
.group {
  display: grid; gap: 10px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.group h3 { margin: 0; font-size: 15px; font-weight: 600; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 4px; }
.group-head .spacer { flex: 1; }
.group .repository { font: 12.5px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.group .repository.none { font-family: var(--sans); font-style: italic; }
.group.unfiled { box-shadow: none; background: transparent; border-style: dashed; }
.members { margin: 0; }
.members th, .members td { padding: 6px 10px; }
.members tr.stale td { color: var(--muted); }
.members td.branch { font: 12.5px var(--mono); }

/* A Node's host and room, from its report. */
.sessions td.node-name .label { font: 600 13px var(--mono); }
.sessions td :is(.node-name, .node-state, .host) .last, .sessions td:is(.node-name, .node-state, .host) .last { display: block; font-size: 12px; color: var(--muted); }
.sessions td.host .label { font-weight: 600; }
.sessions td.room { font-size: 12.5px; color: var(--muted); white-space: normal; min-width: 18ch; }
.room-line { display: block; }
.room-line + .room-line { margin-top: 2px; }
.room-meter { display: block; width: 100%; max-width: 18ch; height: 6px; margin: 2px 0 4px; }
.sessions td.agents { font: 12px var(--mono); }
.sessions td.agents .agent { display: block; }
.sessions td.agents .agent.missing { color: var(--muted); }
.sessions td.node-state { white-space: normal; min-width: 12ch; }
.sessions td.node-state .chips { margin-top: 6px; }

/* What is shown once: a token or a password, and what to do with it. *//* What is shown once: a token or a password, and what to do with it. */
.once {
  display: grid; gap: 8px; margin-top: 14px; padding: 18px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow);
}
.once-head { font-weight: 600; }
.once .actions { margin-top: 6px; }
.copyable { display: flex; gap: 8px; align-items: flex-start; }
.copyable pre { flex: 1; min-width: 0; margin: 0; }
.copy { flex: none; }

.users td.user-nodes { white-space: normal; }
.user-node { display: inline-flex; align-items: center; margin: 0 14px 2px 0; font: 12.5px var(--mono); }

.app.admin { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar) 1fr; grid-template-areas: 'top' 'main'; }
.admin .content { justify-self: center; padding-bottom: 48px; }
.admin h2 + .aside { margin-top: -4px; }
.admin .new-task { margin-top: 14px; }

@media (min-width: 1360px) {
  .app.admin { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'top' 'main'; }
}

@media (max-width: 760px) {
  .app.admin { grid-template-rows: var(--topbar) 1fr; grid-template-areas: 'top' 'main'; }
  .manage-open { width: auto; margin: 6px 0 0; }
  .copyable { flex-direction: column; }
  .sessions td.user-nodes { order: 3; flex-basis: 100%; }
}
