/* shell.css: the main shell (board I1) and the pages that sit in it, Settings
   (board I23), Commands and the conductor's. Mock-ups only: nothing is served and nothing is
   wired; a tap shows another page, or an agent's terminal in place of its
   conversation, through a hidden radio and no script runs.

   NO VALUE IS WRITTEN HERE. Every colour, size, space, radius, font and
   motion is a token from tokens.css, and check-tokens.go fails this file on a
   digit, a colour, a font name or a quote in any declaration. What is left to
   a rule is a keyword: flex, none, solid, center. */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: var(--size-full); }

/* The body is the screen: no stage around it, no frame, edge to edge. The only
   space kept at a side is what a phone's own notch asks for, and that is none
   when it is held upright. */
body {
  margin: var(--sp-0);
  padding-block: var(--sp-0);
  padding-left: env(safe-area-inset-left, var(--sp-0));
  padding-right: env(safe-area-inset-right, var(--sp-0));
  background: var(--chrome);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
}

button, label, input, textarea, kbd { font: inherit; color: inherit; }
b { font-weight: var(--w-heavy); }
.mono, kbd { font-family: var(--font-mono); }

/* What is showing is held by radios and one tick box, each inside the label
   that sets it. Nothing of them is drawn, and the keyboard still reaches them. */
.state {
  appearance: none;
  position: absolute;
  width: var(--sp-0);
  height: var(--sp-0);
  margin: var(--sp-0);
  outline: none;
}
label:has(.state:focus-visible) {
  outline: var(--border-strong) solid var(--rule);
  outline-offset: var(--focus-inset);
}

/* The screen, as tall as what the phone is showing. The header and the bottom
   bar are its first and last rows and are sticky; only the page between them
   scrolls. */
.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--size-full);
  height: var(--size-screen);
  background: var(--pane);
  color: var(--text);
}

.ic {
  flex: none;
  width: var(--size-icon);
  height: var(--size-icon);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--stroke-icon);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic.solid { fill: currentColor; stroke: none; }

/* a switch's chosen side, wherever one is drawn */
.on,
:root:has(#page-agent:checked) .seg-agent,
:root:has(#mode-light:checked) .mode-light,
:root:has(#mode-dark:checked) .mode-dark,
:root:has(#mode-system:checked) .mode-system,
:root:has(#view-agent-conv:checked) .view-agent-conv,
:root:has(#view-agent-term:checked) .view-agent-term,
:root:has(#view-conductor-conv:checked) .view-conductor-conv,
:root:has(#view-conductor-term:checked) .view-conductor-term {
  background: var(--selected);
  color: var(--text);
  font-weight: var(--w-strong);
}

/* ---------- the frame: the header (board I1) ---------- */

.top {
  flex: none;
  position: sticky;
  top: var(--sp-0);
  box-sizing: content-box;
  height: var(--size-bar);
  display: flex;
  align-items: center;
  gap: var(--sp-7);
  padding: env(safe-area-inset-top, var(--sp-0)) var(--sp-7) var(--sp-0);
  background: var(--chrome);
  border-bottom: var(--border) solid var(--line);
}

.ib {
  flex: none;
  width: var(--size-icon-button);
  height: var(--size-icon-button);
  display: grid;
  place-items: center;
  padding: var(--sp-0);
  border: none;
  border-radius: var(--radius-control);
  background: none;
  color: var(--dim);
  cursor: pointer;
}

.seg {
  flex: none;
  display: inline-flex;
  overflow: hidden;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-control);
}
.seg > * {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control);
  padding: var(--sp-3) var(--sp-8);
  border: none;
  background: none;
  color: var(--dim);
  font-size: var(--t-control);
  cursor: pointer;
}

.spacer { flex: var(--grow); }

/* ---------- the frame: the body, one page at a time ---------- */

.page {
  display: none;
  flex: var(--grow);
  flex-direction: column;
  min-height: var(--sp-0);
}
:root:has(#page-agent:checked) .page-agent,
:root:has(#page-conductor:checked) .page-conductor,
:root:has(#page-settings:checked) .page-settings,
:root:has(#page-commands:checked) .page-commands { display: flex; }

/* ---------- the frame: the bottom tab bar ---------- */

.bar {
  flex: none;
  position: sticky;
  bottom: var(--sp-0);
  box-sizing: content-box;
  height: var(--size-bar);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, var(--sp-0));
  background: var(--chrome);
  border-top: var(--border) solid var(--line);
}

/* five tabs, each a fifth of the bar: an icon over a label */
.tab {
  flex: var(--grow);
  min-width: var(--size-touch);
  min-height: var(--size-touch);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-0) var(--sp-3);
  border: none;
  border-top: var(--border-strong) solid var(--clear);
  background: none;
  color: var(--dim);
  font-size: var(--t-control);
  cursor: pointer;
}

/* a placeholder: it has no purpose yet and goes nowhere */
.tab:disabled { cursor: default; }

/* the one that leaves: a link drawn as a tab, which opens the tracking site in a new tab */
a.tab { text-decoration: none; }

/* the three that open a page */
:root:has(#page-conductor:checked) .tab-conductor,
:root:has(#page-commands:checked) .tab-commands,
:root:has(#page-settings:checked) .tab-settings {
  border-top-color: var(--rule);
  color: var(--text);
}

/* ---------- the main shell's own page: one agent (board I1) ---------- */

.ahead {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-height: var(--size-agent);
  padding: var(--sp-5) var(--sp-7) var(--sp-5) var(--sp-11);
  background: var(--focus);
  border-bottom: var(--border) solid var(--line);
}
.ahead .g { color: var(--rule); font-size: var(--t-mark); }
.ahead .nm { color: var(--text); font-size: var(--t-name); font-weight: var(--w-heavy); }
.ahead .task {
  flex: var(--grow);
  min-width: var(--sp-0);
  overflow: hidden;
  color: var(--dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* An agent's state is its mark alone, in a ring: no word beside it, which
   leaves the row to the task. The word is kept in the markup, drawn a pixel
   square and cut off, for a reader that does not see the mark. */
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size-icon);
  height: var(--size-icon);
  border: var(--border) solid currentColor;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.chip.waiting { color: var(--you); }
.chip.done { color: var(--rule); }
.ahead .chip .g { color: inherit; font-size: var(--t-glyph); }
.chip .word {
  position: absolute;
  width: var(--sp-1);
  height: var(--sp-1);
  overflow: hidden;
}

.conv {
  flex: var(--grow);
  min-height: var(--sp-0);
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: var(--sp-10);
  padding: var(--sp-12) var(--sp-13);
}

.turn-sep {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  color: var(--dim);
  font-size: var(--t-note);
}
.turn-sep .hair { flex: var(--grow); border-top: var(--border) solid var(--line); }

.msg .by { margin-bottom: var(--sp-3); color: var(--dim); font-size: var(--t-note); }
.msg .by b { color: var(--text); }
.msg .body { line-height: var(--lh-body); }

.ask {
  display: grid;
  gap: var(--sp-7);
  padding: var(--sp-8) var(--sp-9);
  border: var(--border) solid var(--you);
  border-radius: var(--radius-card);
}
.ask .q { font-size: var(--t-ask); }
.ask .q b { color: var(--you); }
.ask .how { color: var(--dim); font-size: var(--t-note); }

.comp {
  flex: none;
  padding: var(--sp-8) var(--sp-10);
  background: var(--pane);
  border-top: var(--border) solid var(--line);
}

.box {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-5);
  padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-9);
  border: var(--border) solid var(--edge);
  border-radius: var(--radius-box);
  background: var(--focus);
}
.box:focus-within { border-color: var(--rule); }
.box .ta {
  box-sizing: content-box;
  flex: var(--grow);
  min-width: var(--sp-0);
  height: var(--size-input);
  padding: var(--sp-6) var(--sp-0);
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: var(--t-input);
  line-height: var(--lh-input);
  resize: none;
}
.box .ta::placeholder { color: var(--dim); }

.send {
  flex: none;
  width: var(--size-button);
  height: var(--size-button);
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-send);
  background: var(--you);
  color: var(--pane);
  cursor: pointer;
}
.send .ic { stroke-width: var(--stroke-send); }

/* ---------- conversation or terminal: every agent's page ---------- */

/* At the right of an agent's row is a switch of two, the main shell's agent's
   and the conductor's alike: it takes no row of its own, and the task beside
   it gives way. Its two words are Chat, the conversation, and CLI, the
   terminal. The page opens on the conversation; a tap on CLI checks a radio
   and the rules below put the conversation away and show the terminal: its
   lines as they are, in the fixed-width face, scrolling inside itself either
   way. */
.ahead .mini { flex: none; }
:root:has(#view-agent-term:checked) .page-agent .conv,
:root:has(#view-agent-conv:checked) .page-agent .term,
:root:has(#view-conductor-term:checked) .page-conductor .conv,
:root:has(#view-conductor-conv:checked) .page-conductor .term { display: none; }

.term {
  flex: var(--grow);
  min-height: var(--sp-0);
  margin: var(--sp-0);
  overflow: auto;
  padding: var(--sp-12) var(--sp-13);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--t-note);
  line-height: var(--lh-note);
  white-space: pre;
}

/* ---------- the more menu (board I1's tap state), a full modal ---------- */

/* It covers the page between the two bars and leaves both in view. It opens
   from the more button: it grows out of that button's centre, which is where
   the tap landed, and the origin is measured from the modal's own corner. */
.modal {
  display: none;
  position: absolute;
  inset: calc(var(--size-bar) + var(--border) + env(safe-area-inset-top, var(--sp-0))) var(--sp-0) calc(var(--size-bar) + var(--border) + env(safe-area-inset-bottom, var(--sp-0)));
  overflow-y: auto;
  align-content: start;
  gap: var(--sp-7);
  padding: var(--sp-8) var(--sp-11) var(--sp-12);
  background: var(--chrome);
  transform-origin: var(--more-x) var(--more-y);
  animation: more-open var(--motion-open) var(--ease-open);
}
:root:has(#more:checked) .modal { display: grid; }
@keyframes more-open {
  from { transform: scale(var(--scale-closed)); opacity: var(--opacity-closed); }
}
@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
}
.mhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-9);
}
.mhead h2 {
  margin: var(--sp-0);
  color: var(--text);
  font-size: var(--t-name);
  font-weight: var(--w-heavy);
}
.modal h3 {
  margin: var(--sp-0) var(--sp-0) var(--sp-3);
  color: var(--dim);
  font-size: var(--t-ask);
  font-weight: var(--w-strong);
}
/* the heading names the agent whose page is showing: the conductor on its own
   page, the main shell's agent on every other */
.modal .for-conductor,
:root:has(#page-conductor:checked) .modal .for-agent { display: none; }
:root:has(#page-conductor:checked) .modal .for-conductor { display: inline; }
.act {
  display: flex;
  align-items: center;
  gap: var(--sp-9);
  min-height: var(--size-touch);
  padding: var(--sp-0) var(--sp-10);
  border: var(--border) solid var(--line);
  border-radius: var(--radius-card);
  background: none;
  color: var(--text);
  font-size: var(--t-body);
  text-align: left;
  cursor: pointer;
}
.act .what { flex: var(--grow); min-width: var(--sp-0); color: var(--dim); font-size: var(--t-note); }
.act .key { color: var(--key); font-family: var(--font-mono); font-size: var(--t-note); }
.act .n {
  padding: var(--sp-0) var(--sp-4);
  border: var(--border) solid var(--you);
  border-radius: var(--radius-pill);
  color: var(--you);
  font-size: var(--t-count);
  font-weight: var(--w-heavy);
  line-height: var(--lh-count);
}
.close {
  height: var(--size-touch);
  display: flex;
  align-items: center;
  gap: var(--sp-7);
  padding: var(--sp-0) var(--sp-10);
  border: var(--border) solid var(--line);
  border-radius: var(--radius-card);
  color: var(--text);
  font-size: var(--t-body);
  cursor: pointer;
}

/* ---------- Settings (board I23) and the list Commands shares ---------- */

.scroll {
  flex: var(--grow);
  min-height: var(--sp-0);
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: var(--sp-10);
  padding: var(--sp-9) var(--sp-11) var(--sp-11);
  scrollbar-width: thin;
}

.sec h3 {
  margin: var(--sp-0) var(--sp-0) var(--sp-7);
  color: var(--dim);
  font-size: var(--t-note);
  font-weight: var(--w-strong);
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.sw {
  display: grid;
  grid-template-columns: var(--cols-palette);
  gap: var(--sp-7);
  margin-bottom: var(--sp-7);
}
.swatch {
  display: grid;
  gap: var(--sp-5);
  min-height: var(--size-touch);
  padding: var(--sp-4);
  border: var(--border-strong) solid var(--clear);
  border-radius: var(--radius-card);
  cursor: pointer;
}
.swatch .strip {
  display: grid;
  grid-template-columns: var(--cols-palette);
  overflow: hidden;
  height: var(--size-swatch);
  border: var(--border) solid var(--edge);
  border-radius: var(--radius-swatch);
}
.swatch .name { color: var(--text); font-family: var(--font-mono); font-size: var(--t-note); }

/* a swatch shows its own palette whatever the page is wearing, in the mode chosen */
.swatch-tui { border-color: var(--ring-tui); }
.swatch-tui .strip { background: var(--tui-pane); }
.swatch-tui .c-you { background: var(--tui-you); }
.swatch-tui .c-agent { background: var(--tui-agent); }
.swatch-tui .c-rule { background: var(--tui-rule); }
.swatch-tui .c-text { background: var(--tui-text); }

.swatch-paper { border-color: var(--ring-paper); }
.swatch-paper .strip { background: var(--paper-pane); }
.swatch-paper .c-you { background: var(--paper-you); }
.swatch-paper .c-agent { background: var(--paper-agent); }
.swatch-paper .c-rule { background: var(--paper-rule); }
.swatch-paper .c-text { background: var(--paper-text); }

.swatch-signal { border-color: var(--ring-signal); }
.swatch-signal .strip { background: var(--signal-pane); }
.swatch-signal .c-you { background: var(--signal-you); }
.swatch-signal .c-agent { background: var(--signal-agent); }
.swatch-signal .c-rule { background: var(--signal-rule); }
.swatch-signal .c-text { background: var(--signal-text); }

.swatch-plain { border-color: var(--ring-plain); }
.swatch-plain .strip { background: var(--plain-paper); }
.swatch-plain .c-you,
.swatch-plain .c-agent,
.swatch-plain .c-rule,
.swatch-plain .c-text { background: var(--plain-ink); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-8);
  min-height: var(--size-row);
  border-bottom: var(--border) solid var(--line);
  font-size: var(--t-row);
}
.row:last-child { border-bottom: none; }
.row .v {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  color: var(--dim);
  font-size: var(--t-control);
}
.palette-name::before { content: var(--palette-name); }

.mini {
  display: inline-flex;
  overflow: hidden;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-control);
}
.mini > * {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control);
  padding: var(--sp-0) var(--sp-8);
  border: none;
  background: none;
  color: var(--dim);
  font-size: var(--t-note);
  cursor: pointer;
}

.where { color: var(--dim); font-size: var(--t-note); line-height: var(--lh-note); }

.forget {
  min-height: var(--size-button);
  padding: var(--sp-0) var(--sp-9);
  border: var(--border) solid var(--key);
  border-radius: var(--radius-control);
  background: none;
  color: var(--key);
  font-size: var(--t-control);
  cursor: pointer;
}

/* ---------- Commands: today's list, drawn in the shell's parts ---------- */

.find {
  flex: none;
  display: grid;
  gap: var(--sp-7);
  padding: var(--sp-8) var(--sp-10);
  border-bottom: var(--border) solid var(--line);
}
.find .box { align-items: center; }
.find .ic { color: var(--dim); }
.find .q {
  flex: var(--grow);
  min-width: var(--sp-0);
  padding: var(--sp-6) var(--sp-0);
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: var(--t-input);
  line-height: var(--lh-input);
}
.find .q::placeholder { color: var(--dim); }
.find .ctx { color: var(--dim); font-size: var(--t-note); }
.find .ctx b { color: var(--text); }

.it {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-9);
  min-height: var(--size-touch);
  padding: var(--sp-5) var(--sp-0);
  border-bottom: var(--border) solid var(--line);
  font-size: var(--t-row);
}
.it:last-child { border-bottom: none; }
.it kbd { flex: none; color: var(--key); font-size: var(--t-note); white-space: nowrap; }

.foot {
  flex: none;
  display: flex;
  gap: var(--sp-11);
  padding: var(--sp-7) var(--sp-11);
  border-top: var(--border) solid var(--line);
  color: var(--dim);
  font-size: var(--t-note);
}
.foot kbd { color: var(--key); }
