/* The console. The same colours, type and marks as the infrastructure page
   (web/infra/infra.css): colour says state and never says anything a word
   or a shape next to it does not say too. No font or image comes from
   elsewhere. The path at the top is the page's one loud thing: where one
   is in the tree, each step a way back up. */

:root {
  color-scheme: light dark;
  --bg: #eef1f4;
  --surface: #ffffff;
  --sunk: #e3e8ed;
  --ink: #16202b;
  --muted: #566473;
  --line: #cfd7df;
  --ok: #1a7448;
  --warn: #8a5000;
  --bad: #b3261e;
  --bad-wash: #fbeceb;
  --warn-wash: #fbf2e1;
  --asleep: #5d6b7a;
  --link: #0b5cad;
  --term-bg: #16202b;
  --term-ink: #e3e8ee;
  --term-muted: #97a5b3;
  --term-err: #f2a59c;
  --sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #19212a;
    --sunk: #26313d;
    --ink: #e3e8ee;
    --muted: #97a5b3;
    --line: #313d4a;
    --ok: #58c08a;
    --warn: #e0a445;
    --bad: #f27d72;
    --bad-wash: #33201f;
    --warn-wash: #30281a;
    --asleep: #8d9aa8;
    --link: #7db7f0;
    --term-bg: #0b0f14;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 20px 64px;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.top, .crumbs, .notice, main, .token { max-width: 1240px; margin-inline: auto; }

h1, h2, h3, p, ul, ol, dl, dd, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13.5px; font-weight: 650; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }
strong { font-weight: 650; }

.quiet, .none { color: var(--muted); }
.none { padding: 6px 0; }
.id { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.sep { color: var(--muted); padding: 0 1px; }
.bad-text { color: var(--bad); font-weight: 550; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 2; }

/* The top: whose console this is, and the ways out of it. */
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; padding: 14px 0 0; }
.brand { color: var(--muted); font-weight: 650; text-decoration: none; letter-spacing: 0.01em; }
.brand:hover { color: var(--ink); }
.who { margin-left: auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.needs-token .who > :not(#who), .needs-token .crumbs, .needs-token main { display: none; }

/* The path: every level of the tree down to this page. */
.crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 9px; padding: 14px 0 12px; font-size: 22px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; border-bottom: 1px solid var(--line); min-height: 56px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--link); text-decoration: underline; }
.crumbs .sep { font-weight: 300; }
.crumbs [aria-current] { overflow-wrap: anywhere; }

main { padding-top: 18px; display: grid; gap: 14px; }
main[aria-busy] { opacity: 0.6; }
main > h1 { font-size: 17px; }
/* The page's name is the path's last step, said once for the eye and once for a heading. */
main > h1:first-child:not(.shown), .head h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-height: 30px; }
.kind { color: var(--muted); }
.chip + .kind::before, .kind + .kind::before { content: ""; display: inline-block; width: 1px; height: 11px; background: var(--line); margin-right: 16px; }
.facts { max-width: 100ch; overflow-wrap: anywhere; }
.lede, .help { color: var(--muted); max-width: 84ch; }
.help { font-size: 12.5px; }

/* States: a mark whose shape goes with the word. */
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 550; }
.chip .mark { width: 9px; height: 9px; flex: none; background: currentColor; border-radius: 50%; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.warn .mark { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chip.bad { color: var(--bad); }
.chip.bad .mark { border-radius: 1px; }
.chip.asleep { color: var(--asleep); }
.chip.asleep .mark { background: none; border: 2px solid currentColor; }
.chip.busy { color: var(--link); }
.chip.busy .mark { border-radius: 0; transform: rotate(45deg) scale(0.85); }
.chip.quiet { color: var(--muted); font-weight: 400; }
.chip.quiet .mark { height: 2px; border-radius: 0; }

/* Buttons: plain by default, one filled per place, red where something is lost. */
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; padding: 4px 11px; background: var(--surface); border: 1px solid var(--muted); border-radius: 4px; font-weight: 550; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.danger { background: var(--bad); color: var(--surface); border-color: var(--bad); }
/* What the reader may not do is there, greyed out: its reason shows when pointed at and is said when pressed. */
[aria-disabled="true"], button.denied:hover { opacity: 0.5; cursor: not-allowed; border-color: var(--muted); }
a[aria-disabled="true"] { text-decoration-style: dotted; }
button.plain { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 2px; font-weight: 400; }
.actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: baseline; }

input[type="text"], input[type="search"], input[type="password"], select, textarea { padding: 5px 8px; background: var(--bg); border: 1px solid var(--muted); border-radius: 4px; max-width: 100%; }
textarea { width: 100%; font: 12.5px/1.5 var(--mono); resize: vertical; }
[aria-invalid="true"] { border-color: var(--bad); outline: 1px solid var(--bad); }

/* Asking for the token. */
.token { display: none; margin-top: 8vh; max-width: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 22px 24px 24px; }
.needs-token .token { display: block; }
.token p { color: var(--muted); margin: 8px 0 16px; max-width: 60ch; }
.token label { display: block; font-weight: 600; margin-bottom: 6px; }
.token-row { display: flex; flex-wrap: wrap; gap: 8px; }
.token input { flex: 1 1 220px; font: 14px var(--mono); padding: 8px 10px; }
.token button { padding: 8px 14px; }
.token .signin { margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; }
.token .signin a { padding: 8px 14px; border: 1px solid var(--muted); border-radius: 4px; font-weight: 600; text-decoration: none; color: inherit; }
.token .signin a:hover, .token .signin a:focus-visible { border-color: currentColor; }

/* What was just done, or could not be. */
.notice { margin-top: 14px; padding: 9px 14px; background: var(--surface); border: 1px solid var(--ok); border-left-width: 4px; border-radius: 4px; overflow-wrap: anywhere; }
.notice.warn { border-color: var(--warn); background: var(--warn-wash); }
.notice.bad { border-color: var(--bad); background: var(--bad-wash); font-weight: 550; }
.note { padding: 7px 10px; border-radius: 4px; background: var(--sunk); overflow-wrap: anywhere; max-width: 100ch; }
.note.bad { background: var(--bad-wash); color: var(--bad); font-weight: 550; }
.note.warn { background: var(--warn-wash); color: var(--warn); border-left: 4px solid var(--warn); }
/* How far an operation is. */
.progress { margin-top: 4px; min-width: 22ch; max-width: 60ch; white-space: normal; }
.progress progress { display: block; width: 100%; height: 6px; accent-color: var(--link); }
.working { color: var(--link); font-weight: 550; margin-top: 10px; }

/* A part of a page. */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px 12px; min-width: 0; display: grid; gap: 8px; }
.panel > header, .panel header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.panel h3 { margin-top: 8px; }
.group + .group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.group h3 { margin: 0 0 2px; font-size: 14px; }

.tabs { display: flex; gap: 4px 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tabs a { flex: none; padding: 6px 0 8px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--ink); }
.count { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* Tables. */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: baseline; padding: 6px 14px 6px 0; border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { padding-right: 0; }
thead th { font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
tbody th { font-weight: 600; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
td { overflow-wrap: break-word; }
td .id { overflow-wrap: anywhere; }
.does { font-weight: 600; }
.names { display: inline-flex; flex-wrap: wrap; gap: 2px 14px; }
.env-link { text-decoration: none; display: inline-flex; gap: 6px; align-items: baseline; }
.env-link:hover { text-decoration: underline; }

/* Forms: a query in a row, a method's parameters in a column. */
.query { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 14px; }
.query label { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); }
.query label.check { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; color: var(--ink); font-size: 14px; }
.query input[type="search"] { min-width: min(100%, 320px); }
.fields { display: grid; gap: 12px; max-width: 640px; }
.field { display: grid; gap: 3px; }
.field label { font-weight: 600; font-family: var(--mono); font-size: 13px; }
.field label .quiet { font-family: var(--sans); font-weight: 400; }
.field input, .field select { width: 100%; max-width: 420px; }
.my { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; margin-top: 10px; }
.my::before { content: "In a terminal: "; font-family: var(--sans); }
.answer { display: grid; gap: 8px; }
.pairs { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.pairs dt { color: var(--muted); }
.pairs dd { overflow-wrap: anywhere; }

dialog { width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow: auto; padding: 18px 20px 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--muted); border-radius: 8px; }
dialog::backdrop { background: rgb(10 16 22 / 0.5); }
dialog h2 { font-size: 17px; margin-bottom: 8px; }
dialog > * + * { margin-top: 10px; }
.secret { font: 13px/1.5 var(--mono); padding: 10px 12px; background: var(--sunk); border-radius: 4px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; }

/* What machines wrote: logs, a file, a terminal. */
.log, .file, .term-out { font: 12.5px/1.5 var(--mono); }
.log { max-height: 62vh; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; background: var(--bg); }
.log { display: grid; grid-template-columns: max-content max-content 1fr; gap: 0 12px; align-content: start; }
.log li { display: contents; }
.log time, .log .from { color: var(--muted); white-space: nowrap; }
.said-line { white-space: pre-wrap; overflow-wrap: anywhere; }
pre.file { max-height: 68vh; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; background: var(--bg); white-space: pre; tab-size: 4; min-height: 3em; }
.path { font-family: var(--mono); font-size: 13.5px; overflow-wrap: anywhere; }
.paths li { padding: 1px 0; }

.term { background: var(--term-bg); color: var(--term-ink); border-radius: 6px; padding: 10px 12px; display: grid; gap: 6px; }
.term-out { height: min(56vh, 520px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-out .typed { color: var(--term-muted); }
.term-out .errors { color: var(--term-err); }
.term-out .note { color: var(--term-muted); font-style: italic; background: none; padding: 0; }
.term-in { display: flex; gap: 8px; align-items: baseline; border-top: 1px solid rgb(255 255 255 / 0.14); padding-top: 8px; font: 12.5px/1.5 var(--mono); }
.term-cwd, .term-prompt { color: var(--term-muted); white-space: nowrap; }
.term-in .term-line { flex: 1; min-width: 0; background: none; border: 0; padding: 2px 0; color: var(--term-ink); font: inherit; border-radius: 0; }
.term-in .term-line:focus-visible { outline: 0; box-shadow: 0 1px 0 var(--term-muted); }
.term-in .term-line::placeholder { color: var(--term-muted); opacity: 0.7; }

/* A narrow window: a table's row becomes a short list of its own. */
@media (max-width: 680px) {
  body { padding: 0 12px 48px; }
  .crumbs { font-size: 18px; min-height: 0; }
  .who { margin-left: 0; }
  .actions { margin-left: 0; flex-basis: 100%; }
  table, tbody, tr, td, tbody th { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  tbody th, td, th.num, td.num { border: 0; padding: 1px 0; text-align: left; white-space: normal; }
  td:empty { display: none; }
  td::before { content: attr(data-label) ": "; color: var(--muted); }
  td[data-label=""]::before { content: none; }
  .log { display: block; }
  .log li { display: block; padding: 3px 0; }
  .log time { margin-right: 8px; }
  .said-line { display: block; }
  .pairs { grid-template-columns: 1fr; }
  .pairs dd { margin-bottom: 6px; }
}

@media print {
  body { background: #fff; }
  .tabs, .who, .actions, .skip { display: none; }
}

/* The full terminal (xterm.js): the box gives it its size. */
.term-full { display: block; height: min(64vh, 620px); padding: 8px 4px 8px 10px; overflow: hidden; }
.term-full .xterm { height: 100%; }
