/* Styles of the web client. Only tokens of design/tokens.css, as design/ui-rules.md asks.
   The shell follows the approved chat layout, design/prototypes/web-slim-* (part H). */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--sa-color-surface-default);
  color: var(--sa-color-text-default);
  font-family: var(--sa-font-family-sans);
  font-size: var(--sa-font-size-md);
  line-height: var(--sa-font-line-height-body);
}
button, input, textarea { font: inherit; color: inherit; }
svg {
  width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
h1 { font-size: var(--sa-font-size-xl); line-height: var(--sa-font-line-height-heading); margin: 0; }
h2 { font-size: var(--sa-font-size-lg); line-height: var(--sa-font-line-height-heading); margin: 0; }
p { margin: 0; }
.muted { color: var(--sa-color-text-muted); }
form { margin: 0; }
a:focus-visible, button:focus-visible, .button:focus-visible, main:focus-visible {
  outline: 2px solid var(--sa-color-focus); outline-offset: 2px;
}
button, .button {
  min-height: var(--sa-size-target-min); padding: 0 var(--sa-space-4);
  border-radius: var(--sa-radius-md); border: 1px solid transparent;
  font-weight: var(--sa-font-weight-medium); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.primary { background: var(--sa-color-primary); color: var(--sa-color-text-on-primary); }
.app {
  font-size: var(--sa-font-size-lg); font-weight: var(--sa-font-weight-bold);
  color: var(--sa-color-text-default); text-decoration: none;
  display: inline-flex; align-items: center; min-height: var(--sa-size-target-min);
}
.head-zone { display: inline-flex; align-items: center; gap: var(--sa-space-2); color: var(--sa-color-text-muted); font-size: var(--sa-font-size-sm); }
.zone {
  display: inline-flex; align-items: center; gap: var(--sa-space-2);
  padding: var(--sa-space-1) var(--sa-space-3);
  border-radius: var(--sa-radius-full);
  border: 1px solid var(--sa-color-border-subtle);
  color: var(--sa-color-text-default);
  font-size: var(--sa-font-size-sm); font-weight: var(--sa-font-weight-medium);
}
.zone::before { content: ""; width: 8px; height: 8px; border-radius: var(--sa-radius-full); }
.zone-green::before { background: var(--sa-color-success); }
.zone-yellow::before { background: var(--sa-color-warning); }
.zone-red::before { background: var(--sa-color-danger); }
/* The unknown zone of the head (D-118): the muted text and a ring in place of the colored dot. */
.zone.zone-unknown { color: var(--sa-color-text-muted); }
.zone.zone-unknown::before { border: 1px solid var(--sa-color-text-muted); }
.state { display: grid; gap: var(--sa-space-2); padding: var(--sa-space-4); border-radius: var(--sa-radius-md); }
.state.empty { color: var(--sa-color-text-muted); background: var(--sa-color-surface-raised); }
.state.error { border: 1px solid var(--sa-color-danger); background: var(--sa-color-surface-raised); }
/* Item 23, PR F5 (F5-02): a neutral box for a hint or a step where nothing failed, for example a
   sign-in. It has the subtle border and the inset surface, so it shows on a raised card and does
   not look like a field, which has the border of a control. */
.state.note { border: 1px solid var(--sa-color-border-subtle); background: var(--sa-color-surface-default); }
/* Item 23, PR F7: a box for a warning that is no error, for example a runner that replaces another
   one. It has the border of the warning color and the surface of `state note`; its text starts
   with a visible prefix such as "Note:" or "Warning:", so color is not the only signal. Since
   PR F9 its left border is as wide as the space token `--sa-space-1`, so it differs from the
   even border of `state error` by its shape too (F9-03). */
.state.warn {
  border: 1px solid var(--sa-color-warning); border-left-width: var(--sa-space-1);
  background: var(--sa-color-surface-default);
}
.state p { max-width: 80ch; }

/* A centered page without the sidebar: the login and an error before the viewer is known. */
.plain .head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sa-space-3); padding: var(--sa-space-2) var(--sa-space-6);
}
.plain main { max-width: 32rem; margin: var(--sa-space-8) auto 0; padding: 0 var(--sa-space-4); }
.card {
  display: grid; gap: var(--sa-space-4);
  background: var(--sa-color-surface-raised);
  border-radius: var(--sa-radius-lg);
  padding: var(--sa-space-6);
}

/* The shell: the sidebar and the main area with the top bar. */
.shell { display: flex; }
.side {
  width: 260px; flex: none; height: 100vh; display: flex; flex-direction: column;
  background: var(--sa-color-surface-raised); padding: var(--sa-space-3); gap: var(--sa-space-2);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sa-space-2); }
.side .app { font-size: var(--sa-font-size-md); }
.ghost {
  display: flex; align-items: center; gap: var(--sa-space-2); min-height: var(--sa-size-target-min);
  padding: 0 var(--sa-space-3); border-radius: var(--sa-radius-md);
  color: var(--sa-color-text-default); text-decoration: none;
}
.ghost:hover, .chat-name:hover { background: var(--sa-color-surface-overlay); }
.side .state { margin: var(--sa-space-2) 0; font-size: var(--sa-font-size-sm); }
.side-note { padding: var(--sa-space-2) var(--sa-space-3); font-size: var(--sa-font-size-sm); }
.chats { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.chat { display: flex; align-items: center; gap: var(--sa-space-2); }
.chat-name {
  flex: 1; min-width: 0; display: block; line-height: var(--sa-size-target-min);
  padding: 0 var(--sa-space-3); border-radius: var(--sa-radius-md);
  color: var(--sa-color-text-default); text-decoration: none;
  font-size: var(--sa-font-size-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-name[aria-current="page"], .ghost[aria-current="page"] { background: var(--sa-color-surface-overlay); font-weight: var(--sa-font-weight-medium); }
.chat .zone { padding: 0 var(--sa-space-2); font-weight: var(--sa-font-weight-regular); }
.main { flex: 1; min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.shell .head {
  display: flex; align-items: center; gap: var(--sa-space-2);
  padding: var(--sa-space-2) var(--sa-space-4); min-height: 56px;
}
.icon-btn {
  display: grid; place-items: center; width: var(--sa-size-target-min); height: var(--sa-size-target-min);
  padding: 0; border: 0; background: transparent; border-radius: var(--sa-radius-md); color: inherit;
}
.icon-btn:hover { background: var(--sa-color-surface-overlay); }
.menu, .close { display: none; }
.head .model { font-size: var(--sa-font-size-lg); font-weight: var(--sa-font-weight-medium); padding: 0 var(--sa-space-2); }
.spacer { flex: 1; }
.main > main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main > main.page { overflow: auto; padding: var(--sa-space-6) var(--sa-space-4); }
.page > section { max-width: 768px; width: 100%; margin: 0 auto; display: grid; gap: var(--sa-space-4); }
.page .state.error { justify-items: start; }

/* The view of one chat: one centered column of lines. */
.scroll { flex: 1; overflow: auto; }
.thread {
  max-width: 768px; margin: 0 auto; padding: var(--sa-space-6) var(--sa-space-4);
  display: flex; flex-direction: column; gap: var(--sa-space-6);
}
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sa-space-6); }
.event .text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 80ch; }
.event .who { font-size: var(--sa-font-size-sm); font-weight: var(--sa-font-weight-medium); }
.event.message {
  align-self: flex-end; max-width: 80%; background: var(--sa-color-surface-raised);
  padding: var(--sa-space-3) var(--sa-space-4); border-radius: calc(var(--sa-radius-lg) * 2);
}
.event.message .who {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.event.answer { display: grid; grid-template-columns: 28px 1fr; column-gap: var(--sa-space-3); }
.event.answer::before {
  content: ""; grid-row: span 2; width: 28px; height: 28px;
  border-radius: var(--sa-radius-full); background: var(--sa-color-primary);
}
.event.note, .event.failed {
  display: flex; flex-wrap: wrap; gap: var(--sa-space-2); align-items: baseline;
  font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted);
  padding-left: var(--sa-space-3); border-left: 2px solid var(--sa-color-border-control);
}
.event.failed { color: var(--sa-color-danger); border-left-color: var(--sa-color-danger); }

/* The composer and the start page. */
.dock { padding: 0 var(--sa-space-4) var(--sa-space-3); display: grid; gap: var(--sa-space-2); }
.dock > * { max-width: 768px; width: 100%; margin: 0 auto; }
.composer {
  display: flex; align-items: flex-end; gap: var(--sa-space-2);
  padding: var(--sa-space-2); border: 1px solid var(--sa-color-border-subtle);
  border-radius: calc(var(--sa-radius-lg) * 2); background: var(--sa-color-surface-default);
}
.composer:focus-within { border-color: var(--sa-color-border-control); outline: 2px solid var(--sa-color-focus); outline-offset: 2px; }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent;
  padding: var(--sa-space-2) var(--sa-space-3); min-height: 40px; max-height: 200px;
  field-sizing: content;
}
.composer textarea::placeholder { color: var(--sa-color-text-muted); opacity: 1; }
.send {
  display: grid; place-items: center; width: var(--sa-size-target-min); height: var(--sa-size-target-min);
  padding: 0; border: 0; border-radius: var(--sa-radius-full);
  background: var(--sa-color-primary); color: var(--sa-color-text-on-primary);
}
.hint { text-align: center; font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted); }
.start { justify-content: center; padding: var(--sa-space-4); }
.start h1 { text-align: center; font-weight: var(--sa-font-weight-medium); margin: 0 0 var(--sa-space-6); }
.start .dock { padding: 0; }

/* The usage view. */
.figures, .limits {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--sa-space-3); margin: 0;
}
.figure {
  display: grid; gap: var(--sa-space-1);
  padding: var(--sa-space-3) var(--sa-space-4);
  border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-raised);
}
.figure dt { font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted); }
.figure dd {
  margin: 0; font-size: var(--sa-font-size-lg); font-weight: var(--sa-font-weight-medium);
  font-variant-numeric: tabular-nums;
}
.budget { display: grid; gap: var(--sa-space-3); }
.usage p.muted { max-width: 80ch; }

/* The catalog view for admins (part E). The state of a model is a text badge; its border
   only adds to the text. */
.catalog > p.muted { max-width: 80ch; }
.page .state.denied { justify-items: start; border: 1px solid var(--sa-color-border-control); background: var(--sa-color-surface-raised); }
.provider {
  display: grid; gap: var(--sa-space-3); min-width: 0;
  padding: var(--sa-space-4); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-raised);
}
.provider-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-3); }
.provider-head h2 { overflow-wrap: anywhere; min-width: 0; }
.provider h3 { font-size: var(--sa-font-size-md); line-height: var(--sa-font-line-height-heading); margin: 0; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--sa-space-2) var(--sa-space-4); margin: 0;
}
.fact { display: grid; gap: var(--sa-space-1); min-width: 0; }
.fact dt { font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted); }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.models { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-2); }
.models > .model {
  display: grid; gap: var(--sa-space-2); min-width: 0;
  padding: var(--sa-space-3); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-default);
}
.model-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); }
.model-id {
  flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere;
  font-family: var(--sa-font-family-mono); font-size: var(--sa-font-size-sm);
}
.badge {
  display: inline-flex; align-items: center; padding: var(--sa-space-1) var(--sa-space-3);
  border-radius: var(--sa-radius-full); border: 1px solid var(--sa-color-border-subtle);
  font-size: var(--sa-font-size-sm); font-weight: var(--sa-font-weight-medium);
}
.state-released { border-color: var(--sa-color-success); }
.state-discovered { border-style: dashed; border-color: var(--sa-color-border-control); }
.state-deprecated { border-color: var(--sa-color-warning); }
.state-removed { border-color: var(--sa-color-danger); }
.zone-unknown { font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted); }
.prices {
  list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-1);
  font-size: var(--sa-font-size-sm); font-variant-numeric: tabular-nums;
}
.price { overflow-wrap: anywhere; }
.price .note { color: var(--sa-color-text-muted); }
.model > .muted { margin: 0; font-size: var(--sa-font-size-sm); }

/* The panel (item 21). The stage of a ticket is a text badge; its border only adds to the
   text. A ticket is one row that wraps on a narrow screen. */
.panel > p.muted { max-width: 80ch; }
/* Item 21, part B, PR 5: the line of a viewer who is not an admin, why no origin shows (D-102).
   Muted text on the raised surface, so it reads as a note and not as an error. */
.panel > p.note {
  max-width: 80ch; margin: 0; padding: var(--sa-space-2) var(--sa-space-3);
  border-radius: var(--sa-radius-md); background: var(--sa-color-surface-raised);
  color: var(--sa-color-text-muted); font-size: var(--sa-font-size-sm);
}
/* Item 21, part E, PR 2: the line of the status that the script fills after a live change, after
   the section of the panel (D-144). Empty, it takes no place but stays in the tree of the
   screen reader. */
p.live { margin: 0; color: var(--sa-color-text-muted); font-size: var(--sa-font-size-sm); }
p.live:empty {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.part { display: grid; gap: var(--sa-space-3); min-width: 0; }
.group { display: grid; gap: var(--sa-space-2); min-width: 0; }
.panel h2, .panel h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); }
.panel h3 { font-size: var(--sa-font-size-md); line-height: var(--sa-font-line-height-heading); margin: 0; }
.count {
  padding: 0 var(--sa-space-2); border-radius: var(--sa-radius-full);
  background: var(--sa-color-surface-raised); color: var(--sa-color-text-muted);
  font-size: var(--sa-font-size-sm); font-weight: var(--sa-font-weight-medium);
  font-variant-numeric: tabular-nums;
}
.tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-2); }
.ticket {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); min-width: 0;
  padding: var(--sa-space-3); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-raised);
}
.ticket-id {
  flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere;
  font-family: var(--sa-font-family-mono); font-size: var(--sa-font-size-sm);
}
.limit { font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted); }
.stage-waiting-for-answer, .stage-waiting-for-review, .stage-input-not-delivered { border-color: var(--sa-color-warning); }
.stage-blocked-or-failed { border-color: var(--sa-color-danger); }
.badge.coding { border-style: dashed; border-color: var(--sa-color-border-control); }

@media (max-width: 767px) {
  .side { display: none; }
  .side-open .side {
    display: flex; position: fixed; inset: 0 auto 0 0; z-index: 10;
    width: min(320px, 85vw); border-right: 1px solid var(--sa-color-border-subtle);
  }
  .menu, .side-open .close { display: grid; }
  .shell .head { padding: var(--sa-space-2); }
  .event.message { max-width: 90%; }
  .event.answer { grid-template-columns: 1fr; }
  .event.answer::before { display: none; }
  .figures, .limits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plain main { margin-top: var(--sa-space-4); }
  .login button { width: 100%; }
  .ticket-id { flex-basis: 100%; }
  /* On a narrow screen the origin comes before the limit and the action Stop, so a person
     reads what a ticket is about before the action. The order in the HTML stays. */
  .ticket .limit, .ticket .stop { order: 2; }
  /* The labels of the origin are one column, so that each value starts at the same place. */
  dl.origin { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sa-space-1) var(--sa-space-2); }
  .origin > div { display: contents; }
}
@media (prefers-reduced-motion: no-preference) {
  .ghost, .chat-name, .icon-btn, .button, button {
    transition: background-color var(--sa-motion-duration-fast) var(--sa-motion-easing-standard);
  }
}
/* Findings of ui-reviewer on part H: the icon of a failed answer, the model in one line,
   "Your usage" at the bottom of the sidebar, and a light empty state in the chat. */
.event.failed::before {
  content: "!"; flex: none; align-self: center; display: inline-grid; place-items: center;
  width: 16px; height: 16px; border: 1.8px solid currentColor; border-radius: var(--sa-radius-full);
  font-size: var(--sa-font-size-sm); font-weight: var(--sa-font-weight-bold); line-height: 1;
}
.head .model { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.side > .chats + a.ghost, .side > .state + a.ghost, .side > .side-note + a.ghost { margin-top: auto; }
.thread .state.empty { background: none; padding: 0; }
/* Part C: the zone and model choice in the top bar, as details menus with one form or link
   per option, so that it works with no script (D-72). */
.pick { position: relative; min-width: 0; }
.pick > summary {
  display: inline-flex; align-items: center; gap: var(--sa-space-1); max-width: 100%;
  min-height: var(--sa-size-target-min); padding: 0 var(--sa-space-2);
  border-radius: var(--sa-radius-md); cursor: pointer; list-style: none;
}
.pick > summary::-webkit-details-marker { display: none; }
.pick > summary:hover, .pick[open] > summary { background: var(--sa-color-surface-raised); }
.pick > summary:focus-visible { outline: 2px solid var(--sa-color-focus); outline-offset: 2px; }
.pick > summary svg {
  flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2;
  color: var(--sa-color-text-muted);
}
.pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-zone { white-space: nowrap; }
.pick-list {
  position: absolute; top: calc(100% + var(--sa-space-1)); left: 0; z-index: 5;
  display: grid; gap: var(--sa-space-1); padding: var(--sa-space-2);
  width: max-content; min-width: 16rem; max-width: min(24rem, calc(100vw - 2 * var(--sa-space-4)));
  background: var(--sa-color-surface-default); border: 1px solid var(--sa-color-border-subtle);
  border-radius: var(--sa-radius-lg); font-size: var(--sa-font-size-md);
  font-weight: var(--sa-font-weight-regular); white-space: normal;
}
.zone-pick .pick-list { left: auto; right: 0; }
.pick-title, .pick-list .empty {
  margin: 0; padding: var(--sa-space-1) var(--sa-space-2); max-width: 80ch;
  font-size: var(--sa-font-size-sm); color: var(--sa-color-text-muted);
}
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-1); }
/* A row is a button in a chat and a link on the start page, so the row itself sets the target
   size, the radius and no underline, the values that `button` has (D-80). */
.option {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: var(--sa-space-3); min-height: var(--sa-size-target-min); padding: 0 var(--sa-space-2);
  border-radius: var(--sa-radius-md); background: transparent; text-decoration: none;
  color: var(--sa-color-text-default); font-weight: var(--sa-font-weight-regular);
}
.option:hover { background: var(--sa-color-surface-raised); }
.option-name { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.option[aria-current="true"] { background: var(--sa-color-surface-raised); font-weight: var(--sa-font-weight-medium); }
.option[aria-current="true"] .option-name::before { content: "✓ " / ""; }
/* Finding of ui-reviewer on part C: on a phone the open list spans the top bar, so the page
   never scrolls sideways, and the model has room to show in full. */
@media (max-width: 767px) {
  .shell .head { position: relative; }
  .pick { position: static; }
  .pick-list, .zone-pick .pick-list {
    left: var(--sa-space-2); right: var(--sa-space-2);
    width: auto; min-width: 0; max-width: none;
  }
  .head .model { font-size: var(--sa-font-size-md); }
}
/* Part G, PR 4: the sign-out at the bottom of the sidebar, a button that looks like the links
   above it (D-110). */
.sign-out { margin: 0; }
.sign-out .ghost {
  border: 0;
  width: 100%; justify-content: flex-start; padding: 0 var(--sa-space-3);
  background: none; font-weight: var(--sa-font-weight-regular);
}
.sign-out .ghost:hover { background: var(--sa-color-surface-overlay); }
/* Item 21, part B: the stop of a ticket. The buttons `secondary` and `danger` have the look of
   design/preview/index.html. The action Stop is the last thing of a ticket row, and the form
   of the step is one row of the button and the link that wraps on a narrow screen. */
.secondary { background: transparent; color: var(--sa-color-text-default); border-color: var(--sa-color-border-control); }
.danger { background: transparent; color: var(--sa-color-danger); border-color: var(--sa-color-danger); }
.secondary:hover, .danger:hover { background: var(--sa-color-surface-raised); }
/* Item 21, part B, PR 6 (D-120): the button Stop ticket of the step is off until a key in the
   field turns it on. An off button has the muted text and the border of a control, no hover
   and no pointer, so it looks off in both themes. */
/* Item 21, part C, PR 4 (D-146): the button Allow call of the step has the same off look,
   because a filled primary button looks on even when it is disabled. */
.danger:disabled, .danger:disabled:hover, .primary:disabled, .primary:disabled:hover {
  background: transparent; color: var(--sa-color-text-muted);
  border-color: var(--sa-color-border-control); cursor: not-allowed;
}
/* A ticket row has the raised surface already, so the action of a row shows its hover with the
   overlay surface. */
.ticket .stop:hover { background: var(--sa-color-surface-overlay); }
/* The border of the action of a row uses the muted text color, so that it has a contrast of at
   least 3:1 on the raised surface of the row, in both themes (item 21, part B, PR 3). */
.ticket .stop { margin-left: auto; border-color: var(--sa-color-text-muted); }
.panel.stop, .panel.allow { display: grid; gap: var(--sa-space-4); min-width: 0; }
.effect, .check, .panel.stop noscript p, .panel.allow noscript p, .chat-delete noscript p { max-width: 80ch; margin: 0; }
.stop-form, .allow-form, .delete-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-3); }
/* Item 21, part B, PR 4: the field where the person types the code of the step before the
   stop (D-89, D-93). The label takes a full line of the form. On a wide screen the field, 20
   characters wide, shares the next row with the button and the link; on a narrow screen the
   field takes a full line (D-96). The field holds a code, so it uses the mono font, as the
   code in the label. */
.stop-form .confirm, .allow-form .confirm, .delete-form .confirm { flex: 0 0 100%; }
label.confirm { font-weight: var(--sa-font-weight-medium); }
input.confirm {
  min-height: var(--sa-size-target-min); padding: 0 var(--sa-space-3);
  border: 1px solid var(--sa-color-border-control); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-default); font-family: var(--sa-font-family-mono);
  max-width: 20ch;
}
/* D-96: the field is 20 characters wide on a wide screen and full width on a narrow one. */
@media (max-width: 767px) {
  input.confirm { max-width: none; }
}
input.confirm:focus-visible { outline: 2px solid var(--sa-color-focus); outline-offset: 2px; }
/* Item 21, part B, PR 4: the code of the step that the person types (D-93). It cannot be
   selected, so it cannot be dragged into the field, and it uses the mono font with space
   between its characters, so that each one reads apart. It is larger than the text (D-96). */
.stop-code {
  font-family: var(--sa-font-family-mono); font-size: var(--sa-font-size-lg);
  letter-spacing: var(--sa-space-1);
  -webkit-user-select: none; user-select: none;
}
/* Item 21, part B, PR 3: the origin of a ticket. It is a line of its own, under the first line
   of the row on a wide screen: the action Stop stays the last element of the row in the HTML,
   and `order` puts the origin after it in the layout. A value is content from outside, so it
   looks like data, as the ticket ID: mono font, and it breaks at any character. */
.origin { order: 1; flex: 0 0 100%; min-width: 0; margin: 0; font-size: var(--sa-font-size-sm); }
dl.origin { display: flex; flex-wrap: wrap; gap: var(--sa-space-1) var(--sa-space-4); }
.origin > div { display: flex; align-items: baseline; gap: var(--sa-space-2); min-width: 0; }
.origin dt { flex: none; color: var(--sa-color-text-muted); }
.origin dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-family: var(--sa-font-family-mono); }
.origin.unknown { color: var(--sa-color-text-muted); }
/* Item 21, part C, PR 1: the action Answer comes before the action Stop and has its look. The
   form of the step has the label, the field and the hint on lines of their own. */
.ticket .answer { margin-left: auto; border-color: var(--sa-color-text-muted); }
.ticket .answer + .stop { margin-left: 0; }
.ticket .answer:hover { background: var(--sa-color-surface-overlay); }
@media (max-width: 767px) { .ticket .answer { order: 2; } }
.panel.answer { display: grid; gap: var(--sa-space-4); min-width: 0; }
.answer-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-3); max-width: 80ch; }
.answer-form label, .answer-form textarea, .answer-form .answer-hint { flex: 0 0 100%; }
.answer-form label { font-weight: var(--sa-font-weight-medium); }
.answer-form textarea {
  min-width: 0; padding: var(--sa-space-2) var(--sa-space-3); resize: vertical;
  border: 1px solid var(--sa-color-border-control); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-default);
}
.answer-form textarea:focus-visible { outline: 2px solid var(--sa-color-focus); outline-offset: 2px; }
.answer-hint { margin: calc(var(--sa-space-2) * -1) 0 0; font-size: var(--sa-font-size-sm); }
/* Item 21, part C, PR 3: a question of the approval tool is a row like a ticket row. The input
   comes from a model, so it is data: a mono block that wraps at any character, with no
   horizontal scroll on a narrow screen. The form with Deny is the last line. */
.approvals { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-2); }
.approval {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); min-width: 0;
  padding: var(--sa-space-3); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-raised);
}
/* The tool does not grow, so the badge of the level and the ticket ID sit right after it. */
.approval-tool {
  flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere;
  font-family: var(--sa-font-family-mono); font-weight: var(--sa-font-weight-medium);
}
.approval .ticket-id { flex: 0 1 auto; }
.approval .level-ask { border-color: var(--sa-color-warning); }
.approval .level-never { border-color: var(--sa-color-danger); }
.approval .approval-label, .approval .approval-input, .approval .effect, .approval-form { flex: 0 0 100%; min-width: 0; margin: 0; }
.approval .approval-label { color: var(--sa-color-text-muted); font-size: var(--sa-font-size-sm); }
.approval-input {
  padding: var(--sa-space-2) var(--sa-space-3); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-default); border: 1px solid var(--sa-color-border-subtle);
  font-family: var(--sa-font-family-mono); font-size: var(--sa-font-size-sm);
  white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden;
}
.approval .effect { font-size: var(--sa-font-size-sm); }
.approval-form { display: flex; flex-wrap: wrap; gap: var(--sa-space-2); }
.approval-form .button { border-color: var(--sa-color-text-muted); }
.approval-form .button:hover { background: var(--sa-color-surface-overlay); }
@media (max-width: 767px) { .approval-tool { flex-basis: 100%; } }
/* Item 21, part C, PR 4: the link Allow to the step with a code comes before the form Deny, on
   the same line, with the look of the action of a row. The step reuses the field and the code
   of the step of the stop. */
.approval .allow { border-color: var(--sa-color-text-muted); }
.approval .allow:hover { background: var(--sa-color-surface-overlay); }
.approval .allow + .approval-form { flex: 0 1 auto; }
/* Item 21, part D, PR 3: the runners of a person after the open tickets, each a row like a
   ticket row. The device comes from outside, so it is data in mono that wraps at any
   character. The state is a badge with text, and each slot is a line with no link. */
.runners, .slots { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-2); }
.runner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); min-width: 0;
  padding: var(--sa-space-3); border-radius: var(--sa-radius-md);
  background: var(--sa-color-surface-raised);
}
.runner-device {
  flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere;
  font-family: var(--sa-font-family-mono); font-weight: var(--sa-font-weight-medium);
}
.runner-online { border-color: var(--sa-color-success); }
/* Offline has a solid muted border and muted text of its own, so it never looks like the
   dashed badge of the kind of work (`badge coding`). */
.runner-offline {
  border-color: var(--sa-color-text-muted); color: var(--sa-color-text-muted);
  background: var(--sa-color-surface-default);
}
.slots { flex: 0 0 100%; min-width: 0; gap: var(--sa-space-1); }
.slot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-2); min-width: 0;
  font-size: var(--sa-font-size-sm);
}
.slot-label { font-weight: var(--sa-font-weight-medium); }
.slot-free, .slot-offline { color: var(--sa-color-text-muted); }
.slot .ticket-id { flex: 0 1 auto; }

/* Item 21, part D, PR 4: the health of the system after the part "needs a person". Only a part
   that is not ready, or a state that cannot be read, takes room: one error line each. */
.health-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sa-space-2); }
/* Item 72, PR 3b-A: the action Delete chat at the top of the main area of a chat, on the right
   edge of the column of the lines, because the top bar gets no new control (X-02). The step of
   the delete reuses the page of a step: the question, then the button and the link in one row
   that wraps on a narrow screen. */
.chat-actions {
  display: flex; justify-content: flex-end;
  max-width: 768px; width: 100%; margin: 0 auto; padding: var(--sa-space-2) var(--sa-space-4) 0;
}

/* Item 23, part F, PR F5: the approval page of a runner (`.device`) and the admin page of the
   runners (`.runner-admin`). Each rule stays inside these pages (F5-02). */
/* The two answers of the check stand side by side on the desktop, Approve first. */
.device-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sa-space-3); }
/* A bad code: the field has the border of an error, next to the alert above it. */
.device input.confirm[aria-invalid="true"] { border-color: var(--sa-color-danger); }
/* The causes of a refused code stand as a short list inside the box (plan-f7). */
.device .state ul { margin: 0; padding-left: var(--sa-space-6); }
/* A line and space between the cards of two persons and before the form by Person ID. */
.runner-admin-person { display: grid; gap: var(--sa-space-3); min-width: 0; }
.runner-admin-person + .runner-admin-person, .runner-admin .runner-admin-by-id {
  margin-top: var(--sa-space-2); padding-top: var(--sa-space-6);
  border-top: 1px solid var(--sa-color-border-subtle);
}
/* The link back of the empty state and the button that reads the list again stand apart from
   the form by Person ID. */
.runner-admin .runner-admin-by-id + p, .runner-admin-again { margin-top: var(--sa-space-6); }
/* The field Person ID holds a GUID of 36 characters with its padding. */
.runner-admin input.confirm { max-width: 42ch; }
/* The three facts of a runner share one row on the desktop: the short count of the workers
   takes its own width, and the two times share the rest in the small size, so that each time
   keeps one line in the narrow card. */
.runner-admin .model .facts { grid-template-columns: auto 1fr 1fr; }
.runner-admin .model .fact dd { font-size: var(--sa-font-size-sm); }
@media (max-width: 767px) {
  .device-actions { flex-direction: column; align-items: stretch; }
  .device-actions button { width: 100%; }
  /* The form of a revoke stacks its button and Cancel at full width, as the actions of the
     approval page do (plan-f10). */
  .runner-admin-confirm .stop-form, .runner-admin-refused .stop-form {
    flex-direction: column; align-items: stretch;
  }
  .runner-admin-confirm .stop-form button, .runner-admin-confirm .stop-form .button,
  .runner-admin-refused .stop-form button, .runner-admin-refused .stop-form .button { width: 100%; }
  .runner-admin input.confirm { max-width: none; }
  .runner-admin .model .facts { grid-template-columns: 1fr; }
}
