/* The look of every page this backend renders: the pages a person meets around
   the app — signing in, signing out, a refusal, a token — and the operator
   console. One stylesheet so they are recognisably the same product.

   Served per domain: each site folder holds its own copy beside its own logo.
   The four copies are held identical, and checks/check_page_styling.py refuses
   one that differs, so a change is made in every copy at once. A domain that
   ever needs its own look would start at the accent below, and the check would
   have to be told so.

   Fonts come from the page: Nunito for text, Syne Mono for anything that is
   typed or copied — addresses, tokens, paths, versions.

   ONE DEFINITION PER MEANING. Every colour, size, corner, weight, speed and
   width this stylesheet uses is named once below, for the job it does rather
   than the amount it is, and every rule reads a name. A raw value in a rule is
   a defect: it cannot be changed in one place, and nothing can find its twins.

   What is deliberately left literal, and why:
     - Structure rather than decision: 0, auto, 100%, 1fr, 50%, none, inherit.
       These say "fill", "centre", "unset"; they carry no judgement to change.
     - The widths in media queries. Custom properties cannot be read there, so
       the three thresholds are written at their queries and nowhere else.
     - Drawings: the shape of the enlarged scan code's square, which is its
       own geometry rather than a decision about the page. */

:root {
    /* - - - Colour: what a thing is, not what shade it happens to be - - - */
    --accent: #2563c9;
    --accent-soft: #eaf0fb;
    --accent-edge: #c5d8f5;
    --on-accent: #ffffff;

    --ink: #1b2430;
    --ink-quiet: #64748b;
    --page: #f7f6f3;
    --card: #ffffff;
    --edge: #e2e0da;

    --warn: #b45309;
    --warn-soft: #fdf3e6;
    --warn-edge: #f1d4a6;
    --stop: #b42318;
    --stop-soft: #fdecea;
    --stop-edge: #f0c8c4;

    /* A scan code is read by a camera, which wants it dark on white whatever
       the page around it is doing. */
    --scan-ground: #ffffff;
    --lift-over-page: 0 12px 48px rgba(0, 0, 0, 0.35);

    /* - - - Type - - - */
    --type-page-title: 26px;
    --type-panel-title: 22px;
    --type-brand: 19px;
    --type-section-title: 16px;
    --type-body: 15px;
    --type-control: 14px;
    --type-subsection-title: 14px;
    --type-note: 13px;
    --type-aside: 12px;
    --type-label: 11px;

    --weight-strong: 700;
    --weight-brand: 800;

    --line-body: 1.5;
    --line-title: 1.2;
    --line-note: 1.35;

    --tracking-title: -0.01em;
    --tracking-badge: 0.06em;
    --tracking-column-label: 0.08em;
    --tracking-label: 0.1em;
    --tracking-brand-mark: 0.16em;

    /* - - - Room - - - */
    --gap: 20px;
    --gap-tight: 10px;
    --gap-inline: 6px;
    --gap-brand: 12px;
    --gap-choices: 4px;
    --gap-tick: 7px;
    --gap-pairs-row: 4px;
    --gap-fact-lines: 2px;

    --room-page-top: 48px;
    --room-page-side: 24px;
    --room-control-y: 7px;
    --room-control-x: 14px;
    --room-field-y: 7px;
    --room-field-x: 10px;
    --room-cell: 10px;
    --room-cell-side: 12px;
    --room-heading-under: 8px;
    --room-fact-y: 9px;
    --room-fact-x: 14px;
    --room-chip-x: 8px;
    --room-badge-y: 3px;
    --room-badge-x: 12px;
    --room-choice-y: 9px;
    --room-choice-x: 12px;
    --room-token: 12px;
    --room-scan-frame: 8px;
    --room-scan-frame-large: 16px;
    --room-title-over: 16px;
    --room-blurb-over: 2px;

    /* - - - Edges, corners and marks - - - */
    --line-hair: 1px;
    --mark-chosen: 3px;
    --focus-ring: 2px;
    --corner-card: 10px;
    --corner-control: 8px;
    --corner-chip: 4px;
    --corner-badge: 99px;
    --corner-logo: 7px;
    --corner-page-mark: 11px;

    /* - - - Sizes - - - */
    --header-height: 64px;
    --measure: 620px;
    --size-logo: 34px;
    --size-page-mark: 52px;
    --width-section-list: 232px;
    --width-number-field: 96px;
    --width-pairs-term: 140px;
    /* An editor's fields stand side by side down to this width each. */
    --width-field-least: 220px;
    /* The list keeps this share of the width beside an open editor, and never
       less than the least. */
    --share-list-pane: 42%;
    --width-list-pane-least: 340px;
    --width-tick-column: 40px;
    --height-growing-box-least: 64px;
    --height-growing-box-most: 520px;
    /* How many lines a row's title shows before it is cut short. */
    --lines-row-title: 2;
    --width-role-choice: 150px;
    --width-scan-code: 168px;
    --width-scan-code-large: min(80vw, 80vh);
    --width-arguments-column: 200px;
    --width-request-column: 240px;
    --width-answer-column: 240px;
    --height-code-box: 160px;
    --height-code-box-most: 420px;

    /* The endpoint list's columns: a route must never wrap, a role needs room
       for the longest single one, and the description gives up the rest. */
    --column-route: 23%;
    --column-methods: 6%;
    --column-description: 40%;
    --column-roles: 13%;
    --column-payload: 18%;

    /* The accounts list's columns, kept to exactly these shares rather than
       guessed from what is in them: an address gets the most, since it is the
       longest thing in a row; a date and a time hold one line; and the calls
       column holds the largest allowance anyone can be given, six figures. What
       is left over goes to the address, so the roles keep their chips side by
       side until the width genuinely runs out. */
    --column-address: 29%;
    --column-account-roles: 16%;
    --column-end-date: 16%;
    --column-duration: 9%;
    --column-calls: 9%;
    --column-seen: 21%;

    /* The item lists' columns, named for what a column holds rather than which
       list it is in — a name, a short state, a date, a count — so every list of
       items sizes them alike. The title takes whatever they leave. */
    --column-name: 18%;
    --column-state: 9em;
    --column-when: 7em;
    --column-count: 6em;

    /* - - - Depth, dimming and pace - - - */
    --layer-pinned: 10;
    /* One step above the pinned column headings: the chosen row rides over
       them while its editor is in view, since they describe cells that are out
       of sight anyway. */
    --layer-pinned-chosen: 11;
    --layer-over-page: 9999;
    --dim-unavailable: 0.5;
    --pace-grow: 0.25s;
    --easing: ease;

    /* A control held down gives a little and dims, and comes back when it is
       let go: both together, since a give alone is invisible on a small
       control and a dim alone reads as nothing happening on a wide one. */
    --press-give: 0.98;
    --press-dim: 0.7;
    --pace-press: 0.15s;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #6aa6ff;
        --accent-soft: #17283f;
        --accent-edge: #2c4b74;
        --on-accent: #06121f;

        --ink: #e8ecf2;
        --ink-quiet: #94a1b2;
        --page: #10151c;
        --card: #171e27;
        --edge: #26303c;

        --warn: #f3b95f;
        --warn-soft: #2a2114;
        --warn-edge: #5a4523;
        --stop: #ff8a80;
        --stop-soft: #2b1b1b;
        --stop-edge: #5a2b2b;
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--page);
    color: var(--ink);
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: var(--type-body);
    line-height: var(--line-body);
}

/* Every page is at least as tall as the window, with its content taking
   whatever the header and footer leave, so the footer sits on the bottom edge
   on a short page rather than partway up it. */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;  /* waiver: the window itself, which every page is at least as tall as */
}

main {
    flex: 1 1 auto;
}

.mono, code, pre {
    font-family: 'Syne Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

a {
    color: var(--accent);
}

/* - - - Header and footer - - - */

/* The header belongs to the window rather than to the page under it: it stays
   where it is on every surface, so the site's name and the way out are never
   scrolled away. One rule, no page-by-page exceptions. */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    height: var(--header-height);
    padding: 0 var(--gap);
    background: var(--card);
    border-bottom: var(--line-hair) solid var(--edge);
    position: sticky;
    top: 0;
    z-index: var(--layer-pinned);
}

/* A working surface — the console — fills the window and never scrolls as a
   whole: what scrolls is whatever inside it holds a list. A page somebody reads
   once scrolls normally, under the same held-in-place header. */
body.working-surface {
    display: flex;
    flex-direction: column;
    height: 100vh;  /* waiver: the window itself, which the surface is sized to fill */
    overflow: hidden;
}

/* Nothing on a working surface is prose to be taken away, so dragging across it
   selects nothing: a drag that begins on a row is a drag on the row, and a
   double click opens it rather than picking out a word. What a person does need
   to copy stays selectable below. */
body.working-surface {
    /* Safari honours only the prefixed spelling of this one, and ignoring that
       leaves the whole surface selectable there while it reads as fixed
       everywhere else. */
    -webkit-user-select: none;
    user-select: none;
}

/* Anything typed into, and the boxes that hold code either way: the request
   somebody composes and the answer they take away from it. */
body.working-surface input,
body.working-surface textarea,
body.working-surface .code-box {
    -webkit-user-select: text;
    user-select: text;
}

body.working-surface header {
    flex: 0 0 auto;
}

body.working-surface main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--gap-brand);
}

/* The link around the logo is a line of text unless it is told otherwise, and a
   line of text keeps room under it for the tails of letters, which would push
   the logo above everything else in the header. */
.header-logo a {
    display: flex;
}

.header-logo img {
    height: var(--size-logo);
    width: auto;
    border-radius: var(--corner-logo);
}

.header-title {
    font-size: var(--type-brand);
    font-weight: var(--weight-brand);
    letter-spacing: var(--tracking-title);
}

.header-centered-title {
    color: var(--ink-quiet);
    font-size: var(--type-label);
    text-transform: uppercase;
    letter-spacing: var(--tracking-brand-mark);
}

.header-side {
    display: flex;
    align-items: center;
    gap: var(--gap-tight);
    color: var(--ink-quiet);
    font-size: var(--type-note);
}

/* The footer belongs to the window in the same way the header does: it holds
   the bottom edge and does not scroll away under a long page. No line divides
   it from the content above, since it carries the page's own background and
   reads as part of it rather than as a band of its own. */
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: var(--gap-tight) var(--gap);
    background: var(--page);
    color: var(--ink-quiet);
    font-size: var(--type-aside);
    position: sticky;
    bottom: 0;
    z-index: var(--layer-pinned);
}

footer p, footer a {
    margin: 0;
}

/* - - - Standalone pages (login, logout, token, refusals) - - - */

main {
    display: block;
}

.content {
    max-width: var(--measure);
    margin: 0 auto;
    padding: var(--room-page-top) var(--room-page-side);
}

.content.centred {
    text-align: center;
}

.page-mark {
    height: var(--size-page-mark);
    width: auto;
    border-radius: var(--corner-page-mark);
}

h1 {
    font-size: var(--type-page-title);
    line-height: var(--line-title);
    letter-spacing: var(--tracking-title);
    margin: var(--room-title-over) 0 var(--room-heading-under);
}

h2 {
    font-size: var(--type-section-title);
    margin: 0 0 var(--gap-tight);
}

h3 {
    font-size: var(--type-subsection-title);
    margin: 0 0 var(--gap-inline);
}

.lede {
    color: var(--ink-quiet);
    margin: 0;
}

.quiet {
    color: var(--ink-quiet);
    font-size: var(--type-note);
}

.badge {
    display: inline-block;
    padding: var(--room-badge-y) var(--room-badge-x);
    border-radius: var(--corner-badge);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--type-aside);
    letter-spacing: var(--tracking-badge);
    text-transform: uppercase;
}

.badge.stop {
    background: var(--stop-soft);
    color: var(--stop);
}

.badge.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

/* - - - Controls - - - */

.button, button, input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-inline);
    padding: var(--room-control-y) var(--room-control-x);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-control);
    background: var(--card);
    color: inherit;
    font: inherit;
    font-size: var(--type-control);
    text-decoration: none;
    cursor: pointer;
}

.button:hover, button:hover {
    border-color: var(--accent);
}

.button.primary, button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: var(--weight-strong);
}

.button.danger, button.danger {
    color: var(--stop);
    border-color: var(--stop-edge);
}

button:disabled {
    opacity: var(--dim-unavailable);
    cursor: default;
}

/* Anything told to step aside does, whatever display its kind is given
   elsewhere: one rule for every hidden thing, rather than one per kind of
   thing that sets a display of its own. */
[hidden] {
    display: none !important;
}

/* Every control a person presses gives slightly and dims while it is held: one
   answer everywhere, so a press is acknowledged even on a phone, where no hover
   says a thing can be pressed. A row only dims, since a row that gave would
   shift the cells around it. The scan code is left out: pressing it enlarges
   it, which is its own answer. */
.button, button, input[type="submit"], summary, .access-token {
    transition: transform var(--pace-press) var(--easing), opacity var(--pace-press) var(--easing);
}

.button:active, button:active:not(:disabled), input[type="submit"]:active, summary:active, .access-token:active {
    transform: scale(var(--press-give));
    opacity: var(--press-dim);
}

tr.choosable:active td {
    opacity: var(--press-dim);
}

/* A control whose action is waiting on the backend: dimmed, with the pointer
   saying so, until the answer arrives. */
[aria-busy="true"] {
    opacity: var(--dim-unavailable);
    cursor: progress;
}

input, select, textarea {
    padding: var(--room-field-y) var(--room-field-x);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-control);
    background: var(--card);
    color: inherit;
    font: inherit;
    font-size: var(--type-control);
}

input:focus, select:focus, textarea:focus {
    outline: var(--focus-ring) solid var(--accent-soft);
    border-color: var(--accent);
}

input[type="number"] {
    width: var(--width-number-field);
}

label {
    font-size: var(--type-control);
}

.row {
    display: flex;
    align-items: center;
    gap: var(--gap-tight);
    flex-wrap: wrap;
}

.row.centred {
    justify-content: center;
}

.row.spread {
    justify-content: space-between;
}

.stack > * + * {
    margin-top: var(--gap-tight);
}

/* Named spacing for things that follow something else on a standalone page,
   rather than a one-off measurement written at each site. */
.spaced {
    margin-top: var(--gap);
}

.spaced-tight {
    margin-top: var(--gap-inline);
}

.plain {
    text-align: left;
}

hr {
    border: 0;
    border-top: var(--line-hair) solid var(--edge);
    margin: var(--gap) 0;
}

/* - - - Cards, facts and tables - - - */

.card {
    background: var(--card);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-card);
    padding: var(--gap);
    margin-top: var(--gap);
}

.card.tight {
    padding: var(--gap-tight);
}

.facts {
    margin-top: var(--gap);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-card);
    background: var(--card);
    text-align: left;
    overflow: hidden;
}

.facts .fact {
    display: flex;
    justify-content: space-between;
    gap: var(--gap);
    padding: var(--room-fact-y) var(--room-fact-x);
    border-top: var(--line-hair) solid var(--edge);
    font-size: var(--type-note);
}

.facts .fact:first-child {
    border-top: 0;
}

.facts .label {
    color: var(--ink-quiet);
    flex: 0 0 auto;
}

.facts .value {
    text-align: right;
    word-break: break-word;
}

.pairs {
    display: grid;
    grid-template-columns: minmax(var(--width-pairs-term), max-content) 1fr;
    gap: var(--gap-pairs-row) var(--gap);
    font-size: var(--type-control);
    margin: 0;
}

.pairs dt {
    color: var(--ink-quiet);
}

.pairs dd {
    margin: 0;
    word-break: break-word;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--type-control);
}

th {
    text-align: left;
    color: var(--ink-quiet);
    font-size: var(--type-label);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    font-weight: var(--weight-strong);
    padding: 0 var(--room-cell) var(--room-heading-under);
}

td {
    padding: var(--room-cell);
    border-top: var(--line-hair) solid var(--edge);
    vertical-align: top;
}

tr.choosable {
    cursor: pointer;
}

tr.choosable:hover td {
    background: var(--page);
}

tr.chosen td {
    background: var(--accent-soft);
    /* The chosen row is a pinned header while its editor is in view: it holds
       at the top of the scroll and the next row pushes it off, so what the
       editor edits stays named on screen. Sticky sits on the cells rather than
       the row because a stuck <tr> is still unreliable across engines. */
    position: sticky;
    top: 0;
    z-index: var(--layer-pinned-chosen);
}

tr.chosen td:first-child {
    box-shadow: inset var(--mark-chosen) 0 0 var(--accent);
}

/* What a listed thing is called — an account's address, an endpoint's route.
   Named for what it is rather than for which cell it sits in, so the chosen
   one reads as chosen wherever a list puts it. */
tr.chosen .item-name {
    font-weight: var(--weight-strong);
}

/* The panel for the chosen row, in a row of its own directly beneath it:
   free-standing, inset at the sides, with a small gap above separating it from
   the row it belongs to and a slightly larger one below before the next. */
tr.editor-holder td {
    padding: var(--gap-tight) var(--gap) var(--gap);
    border-top: 0;
    background: transparent;
}

.card.editor {
    margin-top: 0;
}

/* A chip is one label: broken across two lines it reads as two. */
.pill {
    display: inline-block;
    padding: 0 var(--room-chip-x);
    margin: var(--line-hair) var(--gap-choices) var(--line-hair) 0;
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-chip);
    font-size: var(--type-aside);
    color: var(--ink-quiet);
    white-space: nowrap;
}


details summary {
    cursor: pointer;
    color: var(--ink-quiet);
    font-size: var(--type-note);
}

details[open] summary {
    margin-bottom: var(--gap-tight);
}

/* - - - Tokens and scan codes - - - */

.access-token {
    display: block;
    width: 100%;
    word-break: break-all;
    background: var(--accent-soft);
    border: var(--line-hair) solid var(--accent-edge);
    border-radius: var(--corner-control);
    padding: var(--room-token);
    margin-top: var(--gap);
    color: inherit;
    font-size: var(--type-aside);
    text-align: left;
    cursor: copy;
}

.access-token:hover {
    border-color: var(--accent);
}

/* The code is small enough to sit in the page and too small to scan from across
   a desk, so hovering it grows it over everything else, centred, on white —
   which is what a phone camera needs. */
div.qrcode {
    width: var(--width-scan-code);
    margin: var(--gap) auto 0;
    padding: var(--room-scan-frame);
    background: var(--scan-ground);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-control);
    transition: width var(--pace-grow) var(--easing),
                height var(--pace-grow) var(--easing),
                padding var(--pace-grow) var(--easing);
}

/* Enlarged by hovering with a mouse, and by tapping where there is no hover to
   have: the page adds the class on a tap, and removes it on the next one. */
div.qrcode:hover, div.qrcode.enlarged {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Sized by width alone, with the square coming from the ratio: giving both
       dimensions the same expression let a browser answer them differently and
       stretch the code. The ratio is the code's own geometry, not a decision
       about the page. */
    width: var(--width-scan-code-large);
    height: auto;
    aspect-ratio: 1 / 1;
    padding: var(--room-scan-frame-large);
    z-index: var(--layer-over-page);
    box-shadow: var(--lift-over-page);
}

@media (hover: none) {
    div.qrcode:hover:not(.enlarged) {
        position: static;
        width: var(--width-scan-code);
        height: auto;
        padding: var(--room-scan-frame);
        transform: none;
        box-shadow: none;
    }
}

svg.qrcode {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    display: block;
}

/* - - - Lines saying what happened, and the tones they carry - - - */

/* What went wrong, what an action did, and what wants a look: one shape, in
   the tone of what it says. */
.trouble, .error-info, .result, .notice {
    display: block;
    padding: var(--gap-tight) var(--room-cell-side);
    border: var(--line-hair) solid;
    border-radius: var(--corner-control);
    font-size: var(--type-note);
    text-align: left;
}

.trouble:empty, .error-info:empty, .result:empty, .notice:empty {
    display: none;
}

.notice p {
    margin: 0;
}

/* Three tones, each a ground, an edge and an ink read together: the accent for
   what is chosen or done, warn for what wants a look, stop for what went
   wrong. Every chip and line that carries one reads it from here. The admin
   role is marked in the accent wherever it is listed, so it is never just
   another word in a row of words; so is a field a person set. */
.pill.role-admin, .pill.field-mark, .result {
    color: var(--accent);
    border-color: var(--accent-edge);
    background: var(--accent-soft);
}

.pill.warn, .notice {
    color: var(--warn);
    border-color: var(--warn-edge);
    background: var(--warn-soft);
}

.pill.stop, .trouble, .error-info {
    color: var(--stop);
    border-color: var(--stop-edge);
    background: var(--stop-soft);
}

.inactive {
    opacity: var(--dim-unavailable);
}

/* - - - The operator console - - - */

.console-shell {
    display: flex;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}

.console-sections {
    flex: 0 0 var(--width-section-list);
    padding: var(--gap);
    border-right: var(--line-hair) solid var(--edge);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.section-choices {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--gap-choices);
    overflow-y: auto;
    /* A wheel that reaches the end of the choices stops there rather than
       passing the rest of its travel to whatever is behind it. */
    overscroll-behavior: contain;
}

/* Under the choices and part of the same column: no line divides them, and it
   holds its place while the choices scroll. */
.console-footing {
    flex: 0 0 auto;
    padding-top: var(--gap);
}

.console-footing p {
    margin: 0;
}

/* A choice of where to go — a section, a part of one, a task or a version of
   it — in one look, so what is chosen reads the same wherever it sits. */
.section-choice, .part-choice, .version-choice {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--room-choice-y) var(--room-choice-x);
    border: var(--line-hair) solid transparent;
    border-radius: var(--corner-control);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.section-choice:hover, .part-choice:hover, .version-choice:hover {
    background: var(--card);
    border-color: var(--edge);
}

.section-choice[aria-current="true"], .part-choice[aria-current="true"], .version-choice[aria-current="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-edge);
}

.section-choice[aria-current="true"] .section-label,
.version-choice[aria-current="true"] .section-label,
.part-choice[aria-current="true"] {
    color: var(--accent);
}

/* The parts sit across their section's heading, each taking only the room its
   name needs. */
.part-choices {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-choices);
}

.part-choice {
    width: auto;
    white-space: nowrap;
    font-weight: var(--weight-strong);
}

.version-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--gap-choices);
}

.section-label {
    display: block;
    font-weight: var(--weight-strong);
}

.section-blurb {
    display: block;
    color: var(--ink-quiet);
    font-size: var(--type-aside);
    line-height: var(--line-note);
    margin-top: var(--room-blurb-over);
}

/* The panel itself does not scroll: its section's heading and controls stay
   put, and the list beneath them takes the scrolling. */
.console-panel {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--gap);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* A section, and a part inside one, fill what the panel leaves below the lines
   above them. */
.console-panel .section, .console-panel .part {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.console-panel > .trouble, .console-panel > .result {
    flex: 0 0 auto;
    margin-bottom: var(--gap-tight);
}

/* A section whose content is a stack of cards rather than one list scrolls the
   stack; a section whose content is a list scrolls inside the list's own card. */
.section-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.list-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.list-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    /* A wheel that reaches the end of the rows stops there rather than passing
       the rest of its travel to anything behind it. */
    overscroll-behavior: contain;
}

/* The column headings belong to the card, not to the rows: they stay while the
   rows move under them. */
.list-scroll thead th {
    position: sticky;
    top: 0;
    z-index: var(--layer-pinned);
    background: var(--card);
}

/* The same room on every side of the panel's contents: the heading sits at the
   panel's own inset, and the card below it is one gap away, like everything
   else. */
.console-panel h1 {
    margin: 0;
    font-size: var(--type-panel-title);
}

/* A section's name, the note saying what is shown, and the controls that act on
   it. While there is room the three share a line, with the note pushed across to
   sit beside the controls it describes. */
.section-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--gap-tight);
    margin-bottom: var(--gap);
}

.section-note {
    margin: 0 0 0 auto;
}

/* The heading already leaves a gap under itself; the first card below it must
   not add a second one, whether it sits in the section or in the stack that
   scrolls inside it. */
.console-panel .section > .card,
.console-panel .section-scroll > .card:first-child {
    margin-top: 0;
}

.roles-choice {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--width-role-choice), 1fr));
    gap: var(--gap-inline) var(--room-cell-side);
}

.roles-choice label {
    display: flex;
    align-items: center;
    gap: var(--gap-tick);
}

/* Present for a screen reader and for anyone reading the markup, absent from
   the page: a column whose contents say what they are without a heading. */
.unseen {
    position: absolute;
    width: var(--line-hair);
    height: var(--line-hair);
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* The endpoint list's columns, held to set widths so a long description cannot
   crush the roles or wrap a payload name. */
.endpoint-list {
    table-layout: fixed;
}

.endpoint-list th.column-route {
    width: var(--column-route);
}

/* A route broken across lines stops reading as an address. */
.endpoint-list td.column-route {
    white-space: nowrap;
}

.endpoint-list th.column-methods {
    width: var(--column-methods);
}

.endpoint-list th.column-description {
    width: var(--column-description);
}

.endpoint-list th.column-roles {
    width: var(--column-roles);
}

.endpoint-list th.column-payload {
    width: var(--column-payload);
}

/* The columns keep the shares they are given rather than being sized by what
   happens to be in them: one long address in one row cannot then squeeze the
   dates in every other row onto two lines. Anything too long for its share
   wraps inside it. */
.account-list {
    table-layout: fixed;
}

/* Values that mean nothing broken in half: a figure, a date, a state. An
   address is not among them — it wraps rather than overflow its column, and on
   a phone, where a row becomes a block, it has the whole width to wrap in. */
.account-list td.column-end-date,
.account-list td.column-calls,
.account-list td.column-seen {
    white-space: nowrap;
}

.account-list th.column-address {
    width: var(--column-address);
}

.account-list th.column-roles {
    width: var(--column-account-roles);
}

.account-list th.column-end-date {
    width: var(--column-end-date);
}

.account-list th.column-duration {
    width: var(--column-duration);
}

.account-list th.column-calls {
    width: var(--column-calls);
}

.account-list th.column-seen {
    width: var(--column-seen);
}

/* The count of arguments, under the name of the payload rather than beside it. */
.summary-count {
    display: block;
}

/* Trying an endpoint: what it takes, what is being sent, what came back —
   side by side where there is room, stacked in that order where there is not. */
.try-columns {
    display: grid;
    grid-template-columns:
        minmax(var(--width-arguments-column), 1fr)
        minmax(var(--width-request-column), 1.2fr)
        minmax(var(--width-answer-column), 1.4fr);
    gap: var(--gap);
    align-items: start;
}

.try-column h2 {
    color: var(--ink-quiet);
    font-size: var(--type-label);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
}

/* - - - Fields - - -

   A field is its name, the box it is typed into, and a line about it: the
   endpoint tryer's arguments and every editor's fields alike. In an editor
   they stand in a grid, where a short field shares a line and a long one takes
   a line of its own. */

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--width-field-least), 1fr));
    gap: var(--gap-tight) var(--gap);
    align-items: start;
}

.field {
    min-width: 0;
}

.field.wide {
    grid-column: 1 / -1;
}

.field-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--gap-inline);
}

.field label {
    display: block;
    font-weight: var(--weight-strong);
    font-size: var(--type-note);
}

/* A tick whose words sit beside it rather than over it. */
.field label.row {
    display: flex;
}

.field > input:not([type="checkbox"]), .field > select, .field > textarea {
    width: 100%;
    margin-top: var(--room-blurb-over);
}

.field .quiet {
    display: block;
    font-size: var(--type-aside);
    line-height: var(--line-note);
}

.field.required > label::after, .field.required .field-head label::after {
    content: " •";
    color: var(--accent);
}

/* A box for a passage, growing with what is in it up to a limit, so a long
   text is read whole rather than through a slot. */
textarea.growing {
    width: 100%;
    min-height: var(--height-growing-box-least);
    max-height: var(--height-growing-box-most);
    resize: vertical;
    line-height: var(--line-body);
}

h4 {
    font-size: var(--type-note);
    margin: 0;
}

/* A button that reads as a link: something to open, named by its own words. */
.text-button {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.text-button:hover {
    text-decoration: underline;
}

/* - - - Two panes - - -

   Where the window is wide, a list and what is open from it stand side by
   side, each at full height and scrolling on its own; until something is
   open, the list has the whole width. */

.two-panes {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--gap);
}

.two-panes.editing {
    grid-template-columns: minmax(var(--width-list-pane-least), var(--share-list-pane)) minmax(0, 1fr);
}

.pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pane.scrolls {
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pane > .card {
    margin-top: 0;
}

/* Beside an open editor the list is too narrow for every column, so the ones
   that only add detail step aside. */
.two-panes.editing .column-secondary {
    display: none;
}

/* A part's own choices, under its section's heading. */
.part-controls {
    margin-bottom: var(--gap-tight);
}

/* What is chosen in a list, and what can be done to all of it at once: always
   in place, so ticking the first row moves nothing, and on the chosen ground
   once anything is ticked. */
.bulk-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--gap-tight);
    padding: var(--gap-inline) var(--room-cell-side);
    margin-bottom: var(--gap-tight);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-control);
    background: var(--card);
    font-size: var(--type-control);
}

.bulk-bar.holding {
    background: var(--accent-soft);
    border-color: var(--accent-edge);
}

.bulk-bar .actions {
    margin-left: auto;
}

/* The lists of items, in Curation and Simulation and inside an editor: the
   title takes what the other columns leave, and each other column is sized by
   what it holds. Set on every cell, since a list may have no heading row to
   take its widths from. */
.item-list {
    table-layout: fixed;
}

.item-list .column-tick {
    width: var(--width-tick-column);
}

.item-list .column-name {
    width: var(--column-name);
}

.item-list .column-state {
    width: var(--column-state);
}

.item-list .column-when {
    width: var(--column-when);
}

.item-list .column-count {
    width: var(--column-count);
}

.item-list td.column-when, .item-list td.column-count {
    white-space: nowrap;
}

.item-list td > input:not([type="checkbox"]), .item-list td > select, .item-list td > textarea {
    width: 100%;
}

/* A title cut short after a set number of lines, so one long title cannot
   make its row a screen tall. Safari reads only the prefixed form. */
.clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--lines-row-title);
    line-clamp: var(--lines-row-title);
    overflow: hidden;
}

/* What saves the open item stays in view at the foot of its editor while the
   fields above it scroll. */
.editor-foot {
    position: sticky;
    bottom: 0;
    z-index: var(--layer-pinned);
    margin-top: var(--gap);
    padding: var(--gap-tight) 0;
    border-top: var(--line-hair) solid var(--edge);
    background: var(--card);
}

/* What a new recipe version changes, line by line. */
.diff-line {
    display: block;
}

.diff-added {
    background: var(--accent-soft);
}

.diff-removed {
    background: var(--stop-soft);
    color: var(--stop);
}

.code-box {
    width: 100%;
    min-height: var(--height-code-box);
    max-height: var(--height-code-box-most);
    overflow: auto;
    padding: var(--gap-tight);
    border: var(--line-hair) solid var(--edge);
    border-radius: var(--corner-control);
    background: var(--page);
    color: inherit;
    font-size: var(--type-aside);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.answer-ok {
    color: var(--accent);
}

.answer-refused {
    color: var(--stop);
}

/* - - - Narrower than a row of values - - -

   The first of two widths, written here because a media query cannot read a
   name. This is where content stops standing in rows: a table row becomes a
   small block with every value labelled by the column it came from, a pair of
   label and value stacks, and arguments, request and answer stop standing three
   abreast. A section keeps its name and the note about it on one line, and puts
   the controls on the next.

   Spacing is not among what changes at either width: the inset around the
   header, the choices and the panel is the one the wide layout uses, so the
   edges line up everywhere. */

@media (max-width: 1000px) {
    .try-columns {
        grid-template-columns: 1fr;
    }

    /* Two panes that cannot stand side by side stack, and scroll as one. An
       editor opened from a list opens under its row instead, so its panes
       never stack. */
    .two-panes.stacks {
        display: block;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .two-panes.stacks .pane.scrolls {
        overflow: visible;
    }

    .two-panes.stacks .pane + .pane {
        margin-top: var(--gap);
    }

    /* The note has nothing to be pushed across to any more: it follows the
       section's name, and the controls take the line below. */
    .section-note {
        margin-left: 0;
    }

    .section-controls {
        flex: 1 1 100%;
    }

    .pairs {
        grid-template-columns: 1fr;
        gap: 0 0;
    }

    .pairs dt {
        margin-top: var(--room-heading-under);
        font-size: var(--type-aside);
    }

    .facts .fact {
        flex-direction: column;
        gap: var(--gap-fact-lines);
    }

    .facts .value {
        text-align: left;
    }

    table, thead, tbody, tr, td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody tr {
        border: var(--line-hair) solid var(--edge);
        border-radius: var(--corner-control);
        margin-bottom: var(--gap-tight);
        padding: var(--gap-choices) 0;
    }

    tbody tr.chosen {
        border-color: var(--accent);
    }

    /* Stacked, a row is one block rather than a line of cells, so the tint
       belongs to the block and fills it to its own border. Tinting the cells
       instead leaves the row's padding untinted between them, which reads as
       several loose parts where there is one thing to press. */
    tbody tr.choosable:hover {
        background: var(--page);
    }

    tbody tr.chosen {
        background: var(--accent-soft);
    }

    /* Stacked, the chosen row no longer holds at the top either: its cells
       would each stick at the same place and pile on one another. */
    tr.choosable:hover td, tr.chosen td, tr.chosen td:first-child {
        background: transparent;
        box-shadow: none;
        position: static;
    }

    /* Under its row, an editor's foot stays in its place rather than cover a
       list that has only part of the window to scroll in. */
    .editor-foot {
        position: static;
    }

    /* A stacked row's cells each take the whole width, whatever share their
       column holds beside the others. */
    .item-list .column-tick, .item-list .column-name, .item-list .column-state,
    .item-list .column-when, .item-list .column-count {
        width: 100%;
    }

    /* Label above value rather than beside it: a description or a route is far
       too long to share a line at this width, and a ragged right edge on a
       sentence is worse than a second line. A value held to one line inside its
       column is not held to one line here, where it has the width of the whole
       block to wrap in. */
    td {
        border-top: 0;
        padding: var(--gap-choices) var(--gap-tight);
        text-align: left;
        white-space: normal;
    }

    td:empty {
        display: none;
    }

    td::before {
        content: attr(data-label);
        display: block;
        color: var(--ink-quiet);
        font-size: var(--type-label);
        text-transform: uppercase;
        letter-spacing: var(--tracking-column-label);
    }

}

/* - - - Narrower than a column beside a panel - - -

   The second width, and the narrower one: here nothing can stand beside
   anything. The section choices leave the side and become a row across the top,
   the header keeps only what it needs, and a box to type in takes a line of its
   own. Where a value differs at this width it is the same name given a narrow
   size, set once at the top of the query, so the rules below still read names
   only. */

@media (max-width: 760px) {
    :root {
        --header-height: 56px;
        --type-body: 16px;
        --type-brand: 16px;
        --type-page-title: 22px;
        --room-page-top: 28px;
        --room-page-side: 16px;
        --size-logo: 28px;
        --width-role-choice: 120px;
        --width-scan-code: 60vw;
    }

    body {
        font-size: var(--type-body);
    }

    .console-shell {
        flex-direction: column;
    }

    /* The choices are a bar of their own now, and each choice carries padding of
       its own: the bar's is reduced by exactly that, so the room above and below
       what you see is the same inset everything else on the page keeps. */
    .console-sections {
        flex: 0 0 auto;
        padding-top: calc(var(--gap) - var(--room-choice-y));
        padding-bottom: calc(var(--gap) - var(--room-choice-y));
        border-right: none;
        border-bottom: var(--line-hair) solid var(--edge);
    }

    .section-choices {
        flex: 0 0 auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /* Nothing sits beside the choices to carry a footing, and no page scrolls
       beneath to put one at the foot of. */
    .console-footing {
        display: none;
    }

    .section-choice {
        width: auto;
        white-space: nowrap;
    }

    .section-choice .section-blurb {
        display: none;
    }

    /* A section's parts take a line of their own under its name, scrolling
       across where they do not fit, as the sections above them do. */
    .part-choices {
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    header {
        gap: var(--gap-tight);
    }

    /* The page's own name is in the title bar and the heading; here the header
       has no room to say it a third time. */
    .header-centered-title {
        display: none;
    }

    .header-side {
        font-size: var(--type-aside);
    }

    /* An address is too long to sit beside a button at this width. */
    .header-side #who {
        display: none;
    }

    .row > input[type="email"],
    .row > input[type="search"] {
        flex: 1 1 100%;
    }

    /* Bigger at rest here, since a phone screen has the room and the code is
       the point of the page. Left alone once enlarged, which sizes itself. */
    div.qrcode:not(.enlarged) {
        width: var(--width-scan-code);
    }
}
