/*
 * Components: the building blocks every rebuilt page is made of.
 * Colors, sizes and spacing come from tokens.css only.
 *
 * 1. Header (app bar)     5. LED dot and status pill
 * 2. Page                 6. Fields (label plus input)
 * 3. Buttons              7. Notice (error message)
 * 4. Card                 8. Brand mark
 */

/* 1. Header: brand on the left, main links and Sign Out on the right */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2) var(--s-4);
    min-height: var(--h-main);
    padding: var(--s-1) var(--s-4);
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-line);
}

.app-bar-brand {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--h-touch);
    color: var(--c-text);
    font-weight: 600;
    text-decoration: none;
}

.ui .app-bar-brand {
    color: var(--c-text);
}

.app-bar-brand small {
    color: var(--c-muted);
    font-size: var(--t-small);
    font-weight: 400;
}

.app-bar-brand small:empty {
    display: none;
}

.app-bar-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-1);
}

.app-bar-link {
    display: flex;
    align-items: center;
    min-height: var(--h-touch);
    padding: 0 var(--s-3);
    border-radius: var(--r-2);
    font-size: var(--t-label);
    text-decoration: none;
}

.ui .app-bar-link {
    color: var(--c-muted);
}

.ui .app-bar-link[aria-current="page"] {
    background: var(--c-selected);
    color: var(--c-link);
    font-weight: 600;
}

/* 2. Page: centered column with the same side padding on every screen */
.page {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    width: 100%;
    max-width: var(--w-page);
    margin: 0 auto;
    padding: var(--s-5) var(--s-4);
}

.page-narrow {
    max-width: var(--w-form);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
}

.page-foot {
    padding-top: var(--s-3);
    border-top: 1px solid var(--c-line);
    color: var(--c-muted);
    font-size: var(--t-small);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}

/* 3. Buttons. A link may carry the same classes and looks identical. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--h-control);
    padding: 0 var(--s-4);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: var(--t-body);
    text-decoration: none;
}

.ui a.btn {
    color: var(--c-text);
}

/* The one main action on a screen */
.btn-primary,
.ui a.btn-primary {
    min-height: var(--h-main);
    border-color: var(--c-accent);
    border-radius: var(--r-3);
    background: var(--c-accent);
    color: var(--c-on-accent);
    font-size: 1.125rem;
    font-weight: 700;
}

/* Low-key actions such as Sign Out */
.btn-quiet {
    min-height: var(--h-touch);
    padding: 0 var(--s-3);
    font-size: var(--t-label);
}

/* An action that adds something, shown as an empty slot */
.btn-add {
    border-style: dashed;
    background: transparent;
}

/* Destructive actions */
.btn-danger,
.ui a.btn-danger {
    border-color: var(--c-danger-line);
    background: transparent;
    color: var(--c-danger-text);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn:disabled {
    border-color: var(--c-line);
    background: var(--c-surface);
    color: var(--c-disabled);
    font-weight: 400;
}

/* 4. Card */
.card {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-4);
    border: 1px solid var(--c-line);
    border-radius: var(--r-3);
    background: var(--c-surface);
}

/* 5. LED dot (always next to a word) and status pill */
.led {
    display: inline-block;
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c-off);
}

.led-on {
    background: var(--c-ok);
    box-shadow: 0 0 8px var(--c-ok);
}

.led-rec {
    background: var(--c-rec);
}

.pill {
    display: inline-block;
    padding: 3px var(--s-2);
    border-radius: var(--r-1);
    background: var(--c-raised);
    color: var(--c-text);
    font-size: var(--t-small);
    font-weight: 600;
    white-space: nowrap;
}

.pill-ok {
    background: var(--c-ok-bg);
    color: var(--c-ok-text);
}

.pill-warn {
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
}

/* 6. Fields: a label above its input */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--c-muted);
    font-size: var(--t-label);
}

.field input,
.field select {
    width: 100%;
    height: var(--h-control);
    padding: 0 var(--s-3);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: var(--t-body);
}

/* 7. Notice: an error message. Takes no space while empty. */
.notice {
    padding: var(--s-3);
    border: 1px solid var(--c-danger-line);
    border-radius: var(--r-2);
    background: var(--c-danger-bg);
    color: var(--c-danger-text);
    font-size: var(--t-label);
}

.notice:empty {
    display: none;
}

/* 8. Brand mark */
.brand-mark {
    display: block;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

.brand-mark-large {
    width: 80px;
    height: 80px;
}

/* Phones: the brand name gives its room to the links; the mark stays. */
@media (max-width: 480px) {
    .app-bar-brand span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
}

/*
 * Device dashboard components
 *
 * 9. Tabs                 13. Recording banner
 * 10. Device head         14. Rows of controls
 * 11. Status row          15. Details and event list
 * 12. Player
 */

/* 9. Tabs: a bar fixed to the bottom of a phone; screens.css turns it into a
      side menu on wide screens. */
.tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4;
    display: flex;
    border-top: 1px solid var(--c-line);
    background: var(--c-surface);
}

.tabs a {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    border-top: 3px solid transparent;
    color: var(--c-muted);
    font-size: var(--t-small);
    text-decoration: none;
}

.tabs a[aria-current="page"] {
    border-top-color: var(--c-accent);
    color: var(--c-link);
    font-weight: 600;
}

/* 10. Device head: back link, device name and the online LED */
.device-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-1) var(--s-4);
}

.back-link {
    display: flex;
    align-items: center;
    min-height: var(--h-touch);
    font-size: var(--t-label);
    text-decoration: none;
}

.device-head .device-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2) var(--s-3);
    font-size: var(--t-body);
    font-weight: 600;
}

.presence {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--c-muted);
    font-size: var(--t-label);
    font-weight: 400;
}

.presence.is-online .led {
    background: var(--c-ok);
    box-shadow: 0 0 6px var(--c-ok);
}

/* 11. Status row (chips.js): one chip per fact. A chip is an icon, a short
       value only where a number is needed, and a detail box that opens when the
       chip is tapped or hovered. The chips wrap; .status-break starts a new line. */
.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

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

.status-break {
    flex-basis: 100%;
    height: 0;
}

.chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--h-touch);
    padding: var(--s-1) var(--s-3);
    border: 1px solid var(--c-line);
    border-radius: var(--r-2);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    cursor: pointer;
}

.chip-icon {
    display: inline-flex;
    flex: none;
    width: 24px;
    height: 24px;
}

.chip-icon-battery {
    width: 40px;
    height: 22px;
}

.chip-icon svg {
    width: 100%;
    height: 100%;
}

.chip strong {
    font-size: .9375rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip strong:empty {
    display: none;
}

/* States */
.chip[data-state="warning"] {
    border-color: var(--c-warn-line);
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
}

.chip[data-state="unknown"] {
    color: var(--c-disabled);
}

/* Parts of an icon that show only in one state */
.icon-slash,
.icon-check,
.battery-bolt {
    display: none;
}

.chip[data-off="true"] .icon-slash,
.chip[data-state="ok"][data-off="false"] .icon-check,
.chip[data-plugged="true"] .battery-bolt {
    display: inline;
}

/* Recording: a hollow ring, filled in red while recording */
.chip[data-on="true"] .chip-icon {
    color: var(--c-rec);
}

.chip[data-on="true"] .icon-record {
    fill: currentColor;
}

/* Wi-Fi strength: the arcs above the level are dimmed */
.chip[data-level="0"] .arc-1,
.chip[data-level="0"] .arc-2,
.chip[data-level="0"] .arc-3,
.chip[data-level="1"] .arc-2,
.chip[data-level="1"] .arc-3,
.chip[data-level="2"] .arc-3 {
    opacity: .3;
}

/* Battery: the fill sits behind the number */
.battery-fill {
    opacity: .35;
}

.chip[data-plugged="true"] .battery-fill {
    opacity: .2;
}

/* Thermometer chips: the icon is wider, for the mark beside the thermometer.
   The fill takes a color for cold, fine, warm and hot; its height says the
   same, so the color is never the only sign. */
.chip-icon-thermo {
    width: 34px;
    height: 24px;
}

.thermo-fill {
    fill: currentColor;
    stroke: none;
}

.chip[data-heat="cold"] .thermo-fill {
    fill: #378ADD;
}

.chip[data-heat="fine"] .thermo-fill {
    fill: var(--c-ok);
}

.chip[data-heat="warm"] .thermo-fill {
    fill: #EF9F27;
}

.chip[data-heat="hot"] .thermo-fill {
    fill: var(--c-danger-line);
}

.battery-text {
    fill: currentColor;
    font-size: 11px;
    font-weight: 700;
}

/* The detail box */
.chip-detail {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 7;
    width: max-content;
    max-width: min(280px, 80vw);
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-raised);
    color: var(--c-text);
    font-size: var(--t-label);
    font-weight: 400;
    text-align: left;
    white-space: normal;
}

.chip[data-align="right"] .chip-detail {
    right: 0;
    left: auto;
}

.chip:hover .chip-detail,
.chip[data-open="true"] .chip-detail {
    display: block;
}

.chip .chip-detail:empty {
    display: none;
}

/* Signal bars (chips.js): four bars, as many filled as the signal is strong */
.signal-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.signal-bars i {
    width: 4px;
    border-radius: 1px;
    background: var(--c-line-strong);
}

.signal-bars i:nth-child(1) {
    height: 25%;
}

.signal-bars i:nth-child(2) {
    height: 50%;
}

.signal-bars i:nth-child(3) {
    height: 75%;
}

.signal-bars i:nth-child(4) {
    height: 100%;
}

.signal-bars[data-level="1"] i:nth-child(-n+1),
.signal-bars[data-level="2"] i:nth-child(-n+2),
.signal-bars[data-level="3"] i:nth-child(-n+3),
.signal-bars[data-level="4"] i {
    background: var(--c-text);
}

/* 12. Player: the live picture is two 16:9 halves side by side (32:9).
       While the player link is renewed, the next player loads behind the
       visible one (is-incoming) and is then promoted. */
.player {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--c-line);
    border-radius: var(--r-2);
    background: var(--c-player);
}

.player.is-wide {
    aspect-ratio: 32 / 9;
}

.player iframe {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.player iframe.is-incoming {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* The large notice in the player area: what the stream is doing right now. */
.live-notice {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-1);
    padding: var(--s-3);
    background: var(--c-player);
    color: #9FB0BE;
    text-align: center;
}

.live-notice strong {
    color: #EEF3F7;
    font-size: clamp(1.25rem, 4.5vw, 2.4rem);
    line-height: 1.15;
}

.live-notice span {
    font-size: clamp(.875rem, 2vw, 1.1rem);
}

.player.is-playing .live-notice {
    display: none;
}

/* 13. Recording banner: red means recording and nothing else */
.rec-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 10px var(--s-3);
    border: 1px solid var(--c-danger-line);
    border-radius: var(--r-2);
    background: var(--c-danger-bg);
    color: var(--c-danger-text);
    font-weight: 700;
}

.rec-banner-state {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rec-banner-time {
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

/* The main button while recording */
.btn-stop,
.btn-primary.btn-stop {
    border-color: var(--c-stop);
    background: var(--c-stop);
    color: var(--c-on-stop);
}

/* 14. Rows of controls */
.title-row {
    display: flex;
    align-items: flex-end;
    gap: var(--s-2);
}

.title-row .field {
    flex: 1 1 auto;
    min-width: 0;
}

.check-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--h-touch);
}

.check-row input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--c-accent);
}

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

.input {
    width: 100%;
    height: var(--h-control);
    padding: 0 var(--s-3);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-bg);
    color: var(--c-text);
    font-size: var(--t-body);
}

/* 15. Details: a collapsed section, and the list of stream events inside it */
.details {
    padding: 0 var(--s-4);
    border: 1px solid var(--c-line);
    border-radius: var(--r-3);
    background: var(--c-surface);
    color: var(--c-muted);
    font-size: var(--t-label);
}

/* The row that is pressed: the title on the left, an arrow on the right that
   turns down while the section is open. */
.details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--h-control);
    color: var(--c-text);
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.details > summary::-webkit-details-marker {
    display: none;
}

.details > summary::after {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    margin-right: var(--s-1);
    border-right: 2px solid var(--c-muted);
    border-bottom: 2px solid var(--c-muted);
    transform: rotate(-45deg);
    transition: transform .15s;
}

.details[open] > summary::after {
    transform: rotate(45deg);
}

.details[open] {
    padding-bottom: var(--s-4);
}

.details > * + * {
    margin-top: var(--s-2);
}

/* Long content scrolls inside the section, so the page does not grow without end. */
.details > .list,
.details > pre,
.details > .event-list {
    max-height: 60vh;
    overflow: auto;
}

.details-error {
    margin: 0;
    padding: var(--s-3);
    overflow-x: auto;
    border: 1px solid var(--c-danger-line);
    border-radius: var(--r-2);
    background: var(--c-danger-bg);
    color: var(--c-danger-text);
    font: var(--t-small)/1.5 ui-monospace, Consolas, monospace;
    white-space: pre-wrap;
}

.event-list {
    max-height: 16rem;
    padding: var(--s-2) var(--s-3);
    overflow-y: auto;
    border: 1px solid var(--c-line);
    border-radius: var(--r-2);
    background: var(--c-bg);
    font: var(--t-small)/1.6 ui-monospace, Consolas, monospace;
}

.event-list .terminal-row > div {
    display: flex;
    flex-wrap: wrap;
    gap: 2px var(--s-3);
}

.event-list .terminal-fail strong {
    color: var(--c-danger-text);
}

.event-list .terminal-pass strong {
    color: var(--c-ok);
}

/*
 * 16. Row with two ends     18. Menu (More)
 * 17. Accent button         19. Files tab and segmented choice
 */

/* 16. A row with something at each end, for example a name and its value */
.row-between {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2) var(--s-3);
}

/* 17. A normal-size button in the accent color, for the main action of a card */
.btn-accent {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-on-accent);
    font-weight: 600;
}

/* 18. Menu: a "More" button that opens a list of further actions below it */
.menu summary {
    display: inline-flex;
    list-style: none;
    cursor: pointer;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-top: var(--s-2);
    padding-top: var(--s-3);
    border-top: 1px solid var(--c-line);
}

.menu-items .btn {
    justify-content: flex-start;
}

/* 19. Files tab: icon buttons in two columns and the progress bar. Live tab: a
       segmented choice (several buttons joined into one, one of them pressed). */
.btn-icon {
    flex: none;
    width: var(--s-5);
    height: var(--s-5);
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* A button that holds only an icon */
.btn-square {
    width: var(--h-touch);
    padding: 0;
}

/* A quieter detail inside a button, such as a file's size */
.btn-note {
    color: var(--c-muted);
    font-size: var(--t-small);
}

/* Two buttons beside each other where there is room, one per line on a narrow phone. */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--s-2);
}

.button-grid .btn {
    padding: 0 var(--s-2);
    white-space: nowrap;
}

.progress {
    display: block;
    width: 100%;
    height: var(--s-3);
    border: 0;
    border-radius: var(--r-1);
    background: var(--c-raised);
    overflow: hidden;
    appearance: none;
}

.progress::-webkit-progress-bar {
    background: var(--c-raised);
}

.progress::-webkit-progress-value {
    background: var(--c-accent);
}

.progress::-moz-progress-bar {
    background: var(--c-accent);
}

/* Paused: the bar keeps its length and loses its color. */
.progress-paused::-webkit-progress-value {
    background: var(--c-off);
}

.progress-paused::-moz-progress-bar {
    background: var(--c-off);
}

.segmented {
    display: inline-flex;
}

.segmented .btn {
    min-height: var(--h-touch);
    padding: 0 var(--s-3);
    border-radius: 0;
    font-size: var(--t-label);
}

.segmented .btn + .btn {
    margin-left: -1px;
}

.segmented .btn:first-child {
    border-radius: var(--r-2) 0 0 var(--r-2);
}

.segmented .btn:last-child {
    border-radius: 0 var(--r-2) var(--r-2) 0;
}

.segmented .btn[aria-pressed="true"] {
    position: relative;
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-on-accent);
    font-weight: 600;
}

/* Locked (a recording runs): the chosen one stays recognizable. */
.segmented .btn[aria-pressed="true"]:disabled {
    border-color: var(--c-line-strong);
    background: var(--c-selected);
    color: var(--c-text);
}

.text-end {
    text-align: right;
}

/*
 * 20. List: rows inside one frame, for example saved networks
 * 21. Small parts: a card laid out as a row, section titles
 */

/* 20. List */
.list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--c-line);
    border-radius: var(--r-3);
    background: var(--c-surface);
}

.list-row {
    padding: var(--s-3) var(--s-4);
    border: 0;
    border-bottom: 1px solid var(--c-line);
    background: transparent;
    color: var(--c-text);
    text-align: left;
}

.list-row:last-child {
    border-bottom: 0;
}

/* The visible line of a row: a name at the left, a state or hint at the right */
.list-row-head,
.menu summary.list-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    min-height: var(--h-touch);
    width: 100%;
}

.list-row:disabled {
    color: var(--c-disabled);
}

/* 21. Small parts */
.card-row {
    flex-direction: row;
    align-items: center;
}

.section-title {
    margin-top: var(--s-2);
    color: var(--c-muted);
}

/*
 * 22. Small parts for forms and cards
 */

/* A field that takes only the room it needs, beside others in a row */
.field-inline {
    flex: 1 1 10rem;
}

/* A card that holds a destructive action */
.card-danger {
    border-color: var(--c-danger-frame);
    background: transparent;
}

/* A check row with the label at the left and the box at the right */
.check-row.row-between {
    flex-wrap: nowrap;
    border-bottom: 1px solid var(--c-line);
}

.diagnostic-view {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.diagnostic-view:empty {
    display: none;
}

/*
 * 23. Form pages and forms inside a menu
 */

/* A page that is one column of forms: narrower than a list page */
.page-form {
    max-width: 640px;
}

/* A form that opens under a menu button */
.menu-form {
    margin-top: var(--s-3);
}

.menu > form.menu-items {
    display: flex;
}

/*
 * 24. Dialog: the shared message and confirmation box
 */
.dialog {
    width: min(100% - 2rem, 26rem);
    padding: var(--s-5);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-3);
    background: var(--c-surface);
    color: var(--c-text);
}

.dialog::backdrop {
    background: rgb(0 0 0 / 70%);
}

.dialog h2 {
    font-size: 1.125rem;
}

.dialog p {
    margin-top: var(--s-2);
}

.dialog-buttons {
    justify-content: flex-end;
    margin-top: var(--s-5);
}

/*
 * Platform Console and staff pages
 *
 * 25. Wide page and filter bar     28. Sub-tabs
 * 26. Table                        29. Keypad
 * 27. Facts (label and value)      30. Small parts
 */

/* 25. A page for tables, and the row of search fields above them */
.page-wide {
    max-width: 1280px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--s-3);
}

.filter-bar .field {
    flex: 1 1 12rem;
}

/* 26. Table. On a narrow screen it scrolls sideways inside its box. */
.table-box {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-label);
}

.table th,
.table td {
    padding: var(--s-2) var(--s-3);
    border-bottom: 1px solid var(--c-line);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--c-muted);
    font-weight: 600;
    white-space: nowrap;
}

.table-detail {
    display: block;
    color: var(--c-muted);
    font-size: var(--t-small);
}

/* 27. Facts: a list of labels with their values */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    gap: var(--s-3);
    margin: 0;
}

.facts dt {
    color: var(--c-muted);
    font-size: var(--t-small);
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* 28. Sub-tabs: links that switch between the parts of one record */
.subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1);
}

.subtabs a {
    display: flex;
    align-items: center;
    min-height: var(--h-touch);
    padding: 0 var(--s-3);
    border-radius: var(--r-2);
    color: var(--c-muted);
    font-size: var(--t-label);
    text-decoration: none;
}

.subtabs a[aria-current="page"] {
    background: var(--c-selected);
    color: var(--c-link);
    font-weight: 600;
}

/* 29. Keypad for the staff PIN, and the row of dots above it */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-2);
}

.keypad .btn {
    min-height: var(--h-main);
    font-size: 1.25rem;
}

.pin-display {
    display: block;
    font-size: 1.75rem;
    letter-spacing: .35em;
    text-align: center;
}

/* 30. Small parts */
.notice-ok {
    border-color: var(--c-ok);
    background: var(--c-ok-bg);
    color: var(--c-ok-text);
}

ul.list {
    margin: 0;
    padding: 0;
    list-style: none;
}

ul.list:empty {
    display: none;
}

.ui h3 {
    margin: 0;
    color: var(--c-muted);
    font-size: var(--t-label);
    font-weight: 600;
}

/* 31. Notifications (notify.js): messages that float at the bottom of the
       window and never move the page. On a phone they span the width above the
       tab bar; screens.css moves them to the bottom right on wide screens. */
.toast-stack {
    position: fixed;
    right: var(--s-4);
    bottom: 76px;
    left: var(--s-4);
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    /* The empty parts of the stack let clicks through to the page. */
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--h-touch);
    margin: 0;
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-raised);
    color: var(--c-text);
    font-size: var(--t-label);
    pointer-events: auto;
}

.toast-success {
    border-color: var(--c-ok);
    background: var(--c-ok-bg);
    color: var(--c-ok-text);
}

.toast-warning {
    border-color: var(--c-warn-line);
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
}

.toast-error {
    border-color: var(--c-danger-line);
    background: var(--c-danger-bg);
    color: var(--c-danger-text);
}

.toast-text {
    flex: 1 1 auto;
}

/* The X of an error, which stays until it is closed. */
.toast-close {
    flex: none;
    min-width: var(--h-touch);
    min-height: var(--h-touch);
    margin: calc(-1 * var(--s-2)) calc(-1 * var(--s-3)) calc(-1 * var(--s-2)) 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: var(--t-title);
    line-height: 1;
    cursor: pointer;
}

/* The turning ring of a "working" notification. */
.toast-spinner {
    flex: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--c-line-strong);
    border-top-color: var(--c-text);
    border-radius: 50%;
    animation: toast-spin .8s linear infinite;
}

@keyframes toast-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 32. Field error: a message that belongs to one form. Its room is always
       kept, so showing it does not move what is below. */
.field-error {
    min-height: 1.4em;
    margin: 0;
    color: var(--c-danger-text);
    font-size: var(--t-label);
}

/* 33. Event Log: one row per event. Pressing a row opens its details. */
.pill-error {
    background: var(--c-danger-bg);
    color: var(--c-danger-text);
}

.event-row summary {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    list-style: none;
    cursor: pointer;
}

.event-row summary::-webkit-details-marker {
    display: none;
}

.event-time {
    flex: none;
    min-width: 9ch;
    color: var(--c-muted);
    font-size: var(--t-small);
}

.event-text {
    flex: 1 1 auto;
    min-width: 0;
}

.event-row > * + * {
    margin-top: var(--s-2);
}

/* 34. Activity lights (activity.js): a framed row of small lights in the device
       head. Gray at rest; a light fades to its color and back while its kind of
       communication runs; the Live light is solid while the stream is live. */
.activity {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: var(--s-2);
    padding: 4px var(--s-2);
    border: 1px solid var(--c-line);
    border-radius: 999px;
    background: var(--c-surface);
    vertical-align: middle;
}

.activity-led {
    width: 20px;
    min-width: 0;
    height: 20px;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--c-line-strong);
    color: var(--c-bg);
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
}

.activity-led[data-activity="server"] {
    --led: var(--c-act-server);
}

.activity-led[data-activity="device"] {
    --led: var(--c-act-device);
}

.activity-led[data-activity="check"] {
    --led: var(--c-act-check);
}

.activity-led[data-activity="live"] {
    --led: var(--c-act-live);
}

.activity-led[data-state="on"] {
    background: var(--led);
}

.activity-led[data-state="busy"] {
    animation: activity-pulse 1s ease-in-out infinite;
}

@keyframes activity-pulse {
    0%,
    100% {
        background: var(--c-line-strong);
    }

    50% {
        background: var(--led);
    }
}

/* 35. Performance Monitor (performance.js): one graph, each value as a share of
       its own range. A line's color belongs to its value (data-series 1 to 7).
       The three temperatures share color 3 and differ by their stroke (data-dash). */
[data-series="1"] {
    --series: var(--c-series-1);
}

[data-series="2"] {
    --series: var(--c-series-2);
}

[data-series="3"] {
    --series: var(--c-series-3);
}

[data-series="4"] {
    --series: var(--c-series-4);
}

[data-series="5"] {
    --series: var(--c-series-5);
}

[data-series="6"] {
    --series: var(--c-series-6);
}

[data-series="7"] {
    --series: var(--c-series-7);
}

/* The legend: one switch per value. Off: the key and the name fade. */
.series-switches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.series-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--h-touch);
    padding: 0 var(--s-3);
    border: 1px solid var(--c-line);
    border-radius: var(--r-2);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: var(--t-label);
    cursor: pointer;
}

.series-switch[aria-pressed="false"] {
    color: var(--c-disabled);
}

.series-switch[aria-pressed="false"] .series-key {
    opacity: .25;
}

/* A short stroke of the line's color, in the legend and the readout. */
.series-key {
    flex: none;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: var(--series);
}

.performance-box {
    position: relative;
}

.performance-graph {
    display: block;
    width: 100%;
    height: auto;
    touch-action: pan-y;
}

.graph-grid {
    stroke: var(--c-line);
    stroke-width: 1;
}

.graph-label {
    fill: var(--c-muted);
    font-size: 10px;
}

.graph-line {
    fill: none;
    stroke: var(--series);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.graph-line[data-dash="long"] {
    stroke-dasharray: 8 5;
}

.graph-line[data-dash="dots"] {
    stroke-dasharray: 1 5;
}

/* The same strokes in the legend and the readout. */
.series-key[data-dash] {
    width: 22px;
    background: none;
}

.series-key[data-dash="long"] {
    background: linear-gradient(90deg, var(--series) 0 8px, transparent 8px 13px, var(--series) 13px 22px);
}

.series-key[data-dash="dots"] {
    background: radial-gradient(circle, var(--series) 1.5px, transparent 1.6px) 0 50% / 5.5px 3px repeat-x;
}

.graph-hair {
    stroke: var(--c-line-strong);
    stroke-width: 1;
}

/* The two bands under the graph; each has its name at the left. */
.graph-band-recording {
    fill: var(--c-rec);
}

.graph-band-live {
    fill: var(--c-ok);
}

/* The readout beside the crosshair: every shown value at that time. */
.graph-readout {
    position: absolute;
    top: var(--s-2);
    z-index: 2;
    min-width: 150px;
    margin-left: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-2);
    background: var(--c-raised);
    color: var(--c-text);
    font-size: var(--t-small);
    pointer-events: none;
}

.graph-readout.is-left {
    margin-right: var(--s-2);
    margin-left: 0;
}

.graph-readout p {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin: 0;
}

.graph-readout-time {
    margin-bottom: var(--s-1);
    color: var(--c-muted);
}

/* On a phone the readout sits under the graph, so it never covers the lines. */
@media (max-width: 600px) {
    .graph-readout,
    .graph-readout.is-left {
        position: static;
        margin: var(--s-2) 0 0;
    }
}

