/* ui.css — the shared look of the UI modules: always dark, near-black zinc surfaces, rounded panels,
   pill tabs, one soft blue accent. Tailwind's palette and scale are the tokens (--zinc-900, --space-4,
   --rounded-xl); components use the semantic names below them. Change a colour in one place: here.

   App layout (settings tools):
     <body class="app">
       <header class="topbar"> .brand, .tab-group (.group-label + .tabs > .tab), .icon-btn </header>
       <div class="workspace"> <nav class="sidebar"> .switch-card, .nav-item, .nav-divider </nav>
                               <main class="content"> <div class="content-inner"> ... </div> </main> </div>
       <footer class="bottombar"> .taskbar, .buttons (#status, buttons) </footer>
     </body> */

:root {
    color-scheme: dark;

    /* ----------------------------------------------------------------
       Tailwind's palette and scale
       ---------------------------------------------------------------- */

    --zinc-50: #fafafa;
    --zinc-100: #f4f4f5;
    --zinc-200: #e4e4e7;
    --zinc-300: #d4d4d8;
    --zinc-400: #a1a1aa;
    --zinc-500: #71717a;
    --zinc-600: #52525b;
    --zinc-700: #3f3f46;
    --zinc-800: #27272a;
    --zinc-850: #1f1f23;
    --zinc-900: #18181b;
    --zinc-925: #111113;
    --zinc-950: #09090b;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --amber-500: #f59e0b;
    --emerald-400: #34d399;
    --red-300: #fca5a5;
    --red-400: #f87171;
    --violet-300: #c4b5fd;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    --rounded-lg: 8px;
    --rounded-xl: 12px;
    --rounded-2xl: 16px;
    --rounded-full: 999px;

    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-lg: 15px;
    --text-2xl: 26px;

    /* ----------------------------------------------------------------
       What components use
       ---------------------------------------------------------------- */

    --bg: var(--zinc-950);
    --panel: var(--zinc-925);
    --raised: var(--zinc-900);
    --selected: var(--zinc-800);
    --field: #0c0c0e;
    --line: var(--zinc-800);
    --line-soft: var(--zinc-850);
    --line-strong: var(--zinc-700);

    --text: var(--zinc-100);
    --muted: var(--zinc-400);
    --faint: #8b8b94;

    --accent: var(--blue-500);
    --accent-text: var(--blue-400);
    --accent-line: rgba(59, 130, 246, 0.45);
    --accent-bg: rgba(59, 130, 246, 0.08);
    --primary-bg: var(--zinc-50);
    --primary-text: var(--zinc-950);
    --ok: var(--emerald-400);
    --err: var(--red-400);
    --err-text: var(--red-300);
    --err-bg: rgba(248, 113, 113, 0.1);
    --unsaved: var(--amber-500);
    --locked: var(--violet-300);
    --locked-bg: rgba(196, 181, 253, 0.12);

    --content-width: 860px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ----------------------------------------------------------------
   Base
   ---------------------------------------------------------------- */

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--zinc-700) transparent;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font: var(--text-base) / 1.45 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: var(--font-mono);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */

button {
    appearance: none;
    font: inherit;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--rounded-full);
    padding: 7px 16px;
    cursor: pointer;
}

button:hover {
    background: var(--raised);
}

button.primary {
    background: var(--primary-bg);
    border-color: var(--primary-bg);
    color: var(--primary-text);
}

button.primary:hover {
    background: var(--zinc-200);
}

button:disabled,
button:disabled:hover {
    opacity: 0.45;
    cursor: not-allowed;
    background: transparent;
}

/* The primary button keeps its background when disabled, so its dark text stays readable */
button.primary:disabled,
button.primary:disabled:hover {
    background: var(--primary-bg);
}

button.small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: var(--text-sm);
}

button.small .icon {
    width: 14px;
    height: 14px;
}

button.link {
    border: 0;
    padding: 0;
    border-radius: 0;
    color: var(--accent-text);
    background: none;
    font-weight: 500;
}

button.link:hover {
    text-decoration: underline;
    background: none;
}

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    padding: 0;
    color: var(--muted);
}

.icon-btn:hover {
    color: var(--text);
}

/* display: grid above would otherwise show a hidden button */
.icon-btn[hidden] {
    display: none;
}

/* ----------------------------------------------------------------
   Fields
   ---------------------------------------------------------------- */

input[type=text],
input[type=number],
input[type=password],
input[type=time],
select,
textarea {
    font: inherit;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 12px;
    min-height: 36px;
    width: 260px;
    max-width: 100%;
}

input::placeholder {
    color: var(--zinc-600);
}

/* The clock button inside a time field, readable on the dark field */
input[type=time] {
    color-scheme: dark;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

select {
    appearance: none;
    padding-right: 34px;
    cursor: pointer;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

select option {
    background: var(--raised);
}

textarea {
    width: 320px;
    resize: vertical;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* A field with a small round button inside its right edge: a password with "show" */
.field-with-button {
    position: relative;
    display: inline-flex;
    width: 260px;
    max-width: 100%;
}

.field-with-button input {
    width: 100%;
    padding-right: 40px;
}

.field-with-button .icon-button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

/* A button that is only an icon: show a password, remove a line */
button.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    color: var(--muted);
}

button.icon-button:hover {
    color: var(--text);
}

button.icon-button .icon {
    width: 16px;
    height: 16px;
}

/* Number fields in a size row: [unit] [width] x [height] */
.size-control {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.size-control select {
    width: 170px;
}

input.num {
    width: 90px;
}

.times {
    color: var(--faint);
}

/* A plain checkbox (rows of choices) */
input[type=checkbox] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* A switch: every on/off setting */
input.switch {
    appearance: none;
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: var(--rounded-full);
    background: var(--zinc-700);
    transition: background 0.15s;
    flex-shrink: 0;
}

input.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--zinc-50);
    transition: transform 0.15s;
}

input.switch:checked {
    background: var(--accent);
}

input.switch:checked::after {
    transform: translateX(18px);
}

input.switch:disabled,
input[type=checkbox]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* A switch with three positions (schema-form's threeWay): three radio buttons as click zones
   over a track, a knob that slides to the chosen one, and the chosen value's name before it */
.three-way-control {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.three-way-label {
    color: var(--muted);
    font-size: var(--text-sm);
}

.three-way {
    position: relative;
    display: flex;
    width: 58px;
    height: 22px;
    border-radius: var(--rounded-full);
    background: var(--zinc-700);
    transition: background 0.15s;
    flex-shrink: 0;
}

.three-way[data-position="1"] {
    background: var(--accent-line);
}

.three-way[data-position="2"] {
    background: var(--accent);
}

.three-way input {
    appearance: none;
    flex: 1;
    height: 100%;
    margin: 0;
    border-radius: var(--rounded-full);
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.three-way input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.three-way input:disabled {
    cursor: not-allowed;
}

.three-way-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--zinc-50);
    transition: transform 0.15s;
    pointer-events: none;
}

.three-way[data-position="1"] .three-way-knob {
    transform: translateX(18px);
}

.three-way[data-position="2"] .three-way-knob {
    transform: translateX(36px);
}

.three-way[data-position="-1"] .three-way-knob {
    display: none;
}

.three-way-control:has(input:disabled) {
    opacity: 0.5;
}

.check-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    max-width: 420px;
}

/* More than six choices: an even grid, under the setting's name (the row is .wide) */
.check-group.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px var(--space-4);
    max-width: none;
    width: 100%;
}

/* A list of text, one item per line */
textarea.line-list {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.check-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.not-allowed {
    color: var(--err-text);
}

/* ----------------------------------------------------------------
   App layout: top bar, workspace (sidebar + content), bottom bar
   ---------------------------------------------------------------- */

body.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-4) 28px;
    padding: 14px var(--space-5) var(--space-3);
    border-bottom: 1px solid var(--line-soft);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: var(--space-2);
    padding-bottom: 6px;
    min-width: 0;
}

.brand-name {
    font-weight: 600;
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
}

.brand-file {
    font-size: var(--text-xs);
    color: var(--faint);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The tab groups' holder lays its groups out as if they were the top bar's own children */
.tab-groups {
    display: contents;
}

.tab-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.group-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    padding-left: var(--space-3);
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-full);
}

.tab {
    position: relative;
    border: 0;
    color: var(--muted);
    padding: 7px 14px;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text);
    background: transparent;
}

.tab[aria-current=page] {
    background: var(--selected);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* A framework that is switched off */
.tab.off {
    color: var(--zinc-500);
}

/* The menu button and the shade behind the open drawer: phones only, on a page with body.nav-drawer
   (see the end of this file) */
.nav-toggle,
.nav-backdrop {
    display: none;
}

.topbar-actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
    align-self: flex-end;
}

.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: var(--space-5);
    padding: var(--space-5);
}

.sidebar {
    flex: 0 0 248px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-2xl);
    align-self: flex-start;
    max-height: 100%;
    overflow-y: auto;
}

.switch-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    border-radius: var(--rounded-xl);
    background: var(--raised);
    border: 1px solid var(--line-soft);
}

.switch-card .name {
    font-weight: 600;
}

.switch-card .desc {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: 2px;
}

.switch-card .locked-note {
    font-size: var(--text-xs);
    color: var(--locked);
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    text-align: left;
    padding: 9px var(--space-3);
}

.nav-item:hover {
    color: var(--text);
    background: var(--raised);
}

.nav-item[aria-current=page] {
    color: var(--text);
    background: var(--selected);
}

.nav-item .label {
    flex: 1;
}

/* The page shown: its label and icon in the accent (not a menu's arrow, which isn't a direct child) */
.nav-item[aria-current=page] > .label,
.nav-item[aria-current=page] > .icon {
    color: var(--accent-text);
}

.nav-divider {
    height: 1px;
    background: var(--line-soft);
    margin: var(--space-2) 6px;
}

/* A menu inside the sidebar (the panel's Server → Caddy, the dashboard's Caddy sites), folded open
   and shut by its item (.has-menu): an arrow down while shut, up while open. The entries
   (.nav-sub, with .nav-sub-divider between groups) hang on a line down from the item's icon; the
   one shown gets the highlight, and its item keeps only the tinted label. A dot (.nav-dot) on an
   entry with unsaved changes. */
.nav-chevron {
    display: flex;
    color: var(--faint);
    transform: rotate(90deg);
    transition: transform 0.15s;
}

.nav-chevron .icon {
    width: 14px;
    height: 14px;
}

.nav-item[aria-expanded=true] .nav-chevron {
    transform: rotate(-90deg);
}

.nav-item.has-menu[aria-current=page] {
    background: transparent;
}

.nav-item.has-menu[aria-current=page]:hover {
    background: var(--raised);
}

.nav-subs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 var(--space-2) 20px;
    padding-left: var(--space-2);
    border-left: 1px solid var(--line-strong);
}

.nav-sub {
    gap: var(--space-2);
    padding: 7px var(--space-3) 7px 10px;
    font-size: var(--text-sm);
}

.nav-sub .icon {
    width: 15px;
    height: 15px;
}

.nav-sub[aria-current=true],
.nav-sub[aria-current=page] {
    color: var(--text);
    background: var(--selected);
}

.nav-sub[aria-current=true] > .label,
.nav-sub[aria-current=true] > .icon {
    color: var(--accent-text);
}

.nav-sub-divider {
    height: 1px;
    margin: var(--space-1) 10px;
    background: var(--line);
}

.nav-dot {
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--unsaved);
}

/* An error count on a tab, nav item or icon button */
.badge {
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--rounded-full);
    background: var(--err);
    color: var(--zinc-950);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* A count of running things, not of problems */
.badge.info {
    background: var(--accent);
    color: var(--zinc-50);
}

.tab .badge,
.icon-btn .badge {
    position: absolute;
    top: -6px;
    right: -6px;
}

.content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

.content-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding-bottom: var(--space-6);
}

.bottombar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--line-soft);
    background: rgba(9, 9, 11, 0.92);
}

.bottombar .buttons {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

/* Next to the buttons, the save status keeps a little room */
.bottombar .buttons > #status {
    margin-right: var(--space-2);
}

#status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: var(--text-sm);
}

#status.dirty::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--unsaved);
}

#status.ok {
    color: var(--ok);
}

#status.err {
    color: var(--err-text);
}

/* ----------------------------------------------------------------
   A page: heading, notes, cards
   ---------------------------------------------------------------- */

.crumb {
    font-size: var(--text-sm);
    color: var(--faint);
}

.page-title {
    margin-top: 2px;
    font-size: var(--text-2xl);
    letter-spacing: -0.02em;
}

.lead {
    margin: 6px 0 0;
    color: var(--muted);
    max-width: 640px;
}

.page {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* What a page's settings add up to, e.g. the Content Security Policy as it will be sent */
.preview {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--rounded-xl);
    background: var(--field);
    border: 1px solid var(--line);
    color: var(--zinc-300);
    font: var(--text-sm) / 1.6 var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-label {
    font-size: var(--text-xs);
    color: var(--faint);
    margin: var(--space-3) 0 6px;
}

.preview-label:first-child {
    margin-top: 0;
}

/* A setting the project's code overrides (the panel's Electron tab: what main.ts sets) */
.code-override {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--unsaved);
}

/* Pictures with a caption under each, in a row that wraps (the panel's icon previews) */
.icon-figures {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-5);
    margin-bottom: var(--space-3);
}

.icon-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    max-width: 100%;
}

.icon-figure figcaption {
    font-size: var(--text-xs);
    color: var(--faint);
    text-align: center;
}

.icon-canvas {
    display: block;
    max-width: 100%;
    border-radius: var(--rounded-lg);
}

.card-body.padded {
    padding: var(--space-2) var(--space-5) var(--space-5);
}

/* A page's own on/off switch, above its settings */
.page-switch {
    margin-bottom: 0;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--rounded-2xl);
    background: var(--panel);
}

/* A framework switched off, or a page that isn't there yet (TBA) */
.notice {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-2xl);
    color: var(--muted);
}

.notice strong {
    color: var(--text);
}

.banner:empty {
    display: none;
}

.banner {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--rounded-xl);
    background: var(--err-bg);
    color: var(--err-text);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-2xl);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-4) var(--space-5) 6px;
}

.card-title {
    font-weight: 600;
    font-size: var(--text-lg);
}

.card.invalid > .card-head .card-title {
    color: var(--err-text);
}

.card-description {
    margin: 0;
    padding: 0 var(--space-5) var(--space-3);
    color: var(--muted);
    max-width: 680px;
}

/* Notes at the bottom of a card, below its rows: the background to what the card asks for */
.card-note {
    padding: var(--space-3) var(--space-5) var(--space-5);
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: var(--text-sm);
}

/* The line runs the card's full width; the text keeps a readable length */
.card-note p {
    margin: var(--space-2) 0 0;
    max-width: 680px;
}

.card-note strong {
    color: var(--text);
    font-weight: 500;
}

.card.plain .card-body {
    padding-top: 6px;
}

/* A page's first choice, which the rest of the page depends on (the server's role) */
.page.accent > .card {
    border-color: var(--accent-line);
    background: var(--accent-bg);
}

.page.accent .row-name {
    color: var(--accent-text);
    font-weight: 600;
}

.page-box {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-2xl);
    overflow: hidden;
}

/* ----------------------------------------------------------------
   Rows: name and description on the left, the control on the right
   ---------------------------------------------------------------- */

/* display: flex below would otherwise show a hidden row */
.row[hidden] {
    display: none;
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-6);
    padding: 14px var(--space-5);
    border-top: 1px solid var(--line-soft);
}

.card-head + .card-body > .row:first-of-type,
.card-body > .row:first-child,
.card-description + .field-error + .row,
.card-body > .field-error:first-child + .row,
.box-body > .row:first-child {
    border-top: 0;
}

.row-text {
    flex: 1 1 260px;
    min-width: 0;
}

.row-name {
    font-weight: 500;
    width: fit-content;
}

.row-desc {
    font-size: var(--text-sm);
    color: var(--muted);
    margin-top: 3px;
}

.row-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* The control under the text, full width. Blocks, not flex: flex would size a grid of
   choices at its narrowest, one per line, and keep that height */
.row.wide {
    display: block;
}

.row.wide .row-control {
    display: block;
    margin-top: var(--space-3);
}

.row.locked .row-name,
.row.locked .row-desc {
    color: var(--faint);
}

.lock-note {
    font-size: var(--text-xs);
    color: var(--locked);
    background: var(--locked-bg);
    border-radius: var(--rounded-full);
    padding: 3px 10px;
    max-width: 320px;
}

.row.invalid input,
.row.invalid select,
.row.invalid textarea {
    border-color: var(--err);
}

/* A plain group inside a card: its rows, under a line */
.subsection > .row:first-of-type {
    border-top: 1px solid var(--line);
}

/* A switch that has settings (Start, iOS, a target): its row, and its settings indented below */
.switch-box > .box-title .row-name {
    font-weight: 600;
}

.switch-box > .box-body {
    margin: 0 var(--space-5) var(--space-3);
    border: 1px solid var(--line-soft);
    border-radius: var(--rounded-xl);
    background: var(--raised);
}

.switch-box > .box-body .row {
    padding: var(--space-3) var(--space-4);
}

.switch-box > .box-body .switch-box > .box-body {
    margin: 0 var(--space-4) var(--space-3);
    background: var(--panel);
}

.card-body > .switch-box,
.box-body > .switch-box,
.subsection > .switch-box {
    border-top: 1px solid var(--line-soft);
}

.card-body > .switch-box:first-child,
.card-body > .field-error:first-child + .switch-box {
    border-top: 0;
}

/* Advanced settings, folded away at the end of a group */
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line-soft);
    border-radius: 0;
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: var(--space-3) var(--space-5);
    text-align: left;
}

.advanced-toggle:hover {
    color: var(--text);
    background: transparent;
}

.advanced-toggle .chevron {
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s;
    margin: 0 3px;
}

.advanced-toggle[aria-expanded=true] .chevron {
    transform: rotate(45deg);
}

.advanced-toggle .count {
    font-size: var(--text-xs);
    color: var(--faint);
    background: var(--line-soft);
    border-radius: var(--rounded-full);
    padding: 1px 8px;
}

/* ----------------------------------------------------------------
   Errors and attention
   ---------------------------------------------------------------- */

.field-error:empty {
    display: none;
}

.field-error {
    margin-top: 6px;
    color: var(--err-text);
    font-size: var(--text-sm);
}

.card-body > .field-error,
.page-error {
    margin: 0 var(--space-5) var(--space-2);
}

.page-error:empty {
    display: none;
}

.flash {
    animation: flash 1.4s ease-out;
}

@keyframes flash {
    from {
        background: rgba(59, 130, 246, 0.25);
    }

    to {
        background: transparent;
    }
}

/* ----------------------------------------------------------------
   Dialogs, tooltips, errors that block the page
   ---------------------------------------------------------------- */

.dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: var(--space-5);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--rounded-2xl);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.dialog.wide {
    width: min(760px, calc(100vw - 32px));
}

.dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.dialog h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-3);
}

.dialog .actions,
.error-box .actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.dialog .card {
    border-color: var(--line);
}

/* A dialog's title names its card already */
.dialog .card > .card-head {
    display: none;
}

.dialog .card-description {
    padding-top: var(--space-4);
}

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

.change-head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
}

.change-head strong {
    font-weight: 600;
}

.change-reason {
    color: var(--muted);
    font-size: var(--text-sm);
    margin-top: 2px;
}

.tooltip {
    position: fixed;
    z-index: 10;
    max-width: 380px;
    padding: var(--space-2) var(--space-3);
    border-radius: 10px;
    background: var(--zinc-800);
    border: 1px solid var(--line-strong);
    color: var(--zinc-200);
    font-size: var(--text-sm);
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
}

.tooltip.show {
    opacity: 1;
}

[data-tip] {
    cursor: help;
}

.error-box {
    padding: var(--space-5);
    border-radius: var(--rounded-2xl);
    background: var(--err-bg);
    color: var(--err-text);
}

.error-box pre {
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text);
}

/* The tool's server has stopped: covers the page */
.stopped {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(9, 9, 11, 0.9);
    color: var(--text);
    font-size: var(--text-lg);
}

/* ----------------------------------------------------------------
   Commands (the panel's run.js): buttons on the pages, the task window
   each opens, the taskbar in the bottom bar, the Run dialog
   ---------------------------------------------------------------- */

.dialog:focus-visible {
    outline: none;
}

/* A card's buttons on a page, and a group's in the Run dialog */
.run-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 6px;
}

.card > .run-buttons {
    padding: 0 var(--space-5) var(--space-5);
}

.run-button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "label script dot" "when when dot" "scope scope dot";
    align-content: start;
    align-items: center;
    column-gap: var(--space-2);
    text-align: left;
    border-radius: var(--rounded-xl);
    border-color: var(--line-soft);
    background: var(--raised);
    padding: 8px 12px;
}

.run-button:hover {
    background: var(--selected);
}

.run-label {
    grid-area: label;
}

.run-script {
    grid-area: script;
    font: var(--text-xs) / 1.4 var(--font-mono);
    color: var(--faint);
}

/* When to use it, under the label (run-commands.js, `when`) */
.run-when {
    grid-area: when;
    margin-top: 2px;
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--muted);
}

/* What a command changes and leaves alone (run-commands.js, `changes`, `leaves`), under `when` */
.run-scope {
    grid-column: 1 / 3;
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--faint);
}

.run-scope b {
    font-weight: 600;
    color: var(--muted);
}

/* A small button with its icon (a kiosk's box), or a plain one in a card of a page's own */
.task-button.inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 var(--space-2) var(--space-2) 0;
}

.task-button.inline .icon {
    width: 14px;
    height: 14px;
}

.task-button.small .run-dot:not([hidden]),
.task-button.inline .run-dot:not([hidden]) {
    display: inline-block;
}

/* The list a card's commands run on (the kiosks), above its buttons */
.run-pick {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-5) var(--space-3);
    color: var(--muted);
    font-size: var(--text-sm);
}

.run-pick select {
    width: min(320px, 100%);
}

/* A group's one line about what its commands touch (run-commands.js, `about`) */
.run-group-about {
    margin: 0 0 var(--space-2) 2px;
    font-size: var(--text-xs);
    color: var(--faint);
}

/* Running (pulsing), done, failed */
.run-dot {
    grid-area: dot;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--zinc-600);
}

.run-dot[hidden] {
    display: none;
}

.run-dot.running {
    background: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}

.run-dot.ok {
    background: var(--ok);
}

.run-dot.failed {
    background: var(--err);
}

@keyframes pulse {
    50% {
        opacity: 0.35;
    }
}

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

/* "Which one?": a card with the guide's intro, its situations folded open by a button */
.run-guide-body {
    padding: 0 var(--space-5) var(--space-5);
}

.run-guide-body > button .icon {
    transition: transform 0.15s;
}

.run-guide-body > button.open .icon {
    transform: rotate(90deg);
}

.run-guide {
    margin-top: var(--space-4);
    color: var(--muted);
    line-height: 1.5;
}

.run-guide-intro {
    margin: 0 0 var(--space-4);
    max-width: 640px;
}

.run-guide dl {
    margin: 0 0 var(--space-4);
    display: grid;
    grid-template-columns: minmax(180px, 2fr) 3fr;
    gap: var(--space-3) var(--space-4);
}

.run-guide dt {
    color: var(--text);
    font-weight: 500;
}

.run-guide dd {
    margin: 0;
}

.run-guide-use {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

/* A command in the guide: opens its task */
button.run-guide-command {
    padding: 1px 10px;
    border: 1px solid var(--line);
    border-radius: var(--rounded-full);
    background: var(--selected);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 500;
}

button.run-guide-command:hover {
    border-color: var(--line-strong);
}

/* ----------------------------------------------------------------
   The task window: what the command does, then its live output
   ---------------------------------------------------------------- */

.dialog.task-dialog {
    width: min(980px, calc(100vw - 32px));
    height: min(720px, calc(100vh - 64px));
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.task-dialog:not([open]) {
    display: none;
}

/* Before it starts: only as tall as its questions (fit-content: a modal dialog sits between top
   and bottom 0, so auto would stretch it) */
.dialog.task-dialog.waiting {
    height: fit-content;
    max-height: calc(100vh - 64px);
}

.task-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.task-head h3 {
    margin: 0;
    font-size: 20px;
}

.task-head .run-title {
    flex: 1;
}

/* The folder's icon, coloured by the run's state */
.task-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: var(--rounded-xl);
    background: var(--raised);
    border: 1px solid var(--line-soft);
    color: var(--muted);
}

.task-icon.running {
    color: var(--accent-text);
    border-color: var(--accent-line);
}

.task-icon.ok {
    color: var(--ok);
}

.task-icon.failed {
    color: var(--err);
}

.task-about {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 30%;
    overflow-y: auto;
    flex: none;
}

.task-about p {
    margin: 0;
}

.task-when {
    color: var(--text);
}

.task-hint {
    margin-top: 4px !important;
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: 1.5;
    max-width: 760px;
}

.run-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.run-command {
    font: var(--text-xs) / 1.4 var(--font-mono);
    color: var(--faint);
}

.run-actions {
    display: flex;
    gap: var(--space-2);
}

/* How long the command has run (MM:SS), after its command line; digits of one width, so it doesn't jitter */
.run-timer {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.run-ask {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--rounded-xl);
    background: var(--raised);
    border: 1px solid var(--line);
}

.run-ask p {
    margin: 0;
}

.task-confirm {
    color: var(--text);
    font-weight: 500;
}

/* "I understand: ...": ticked before Run is on (run-commands.js, `confirmCheck`) */
.task-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--rounded-xl);
    background: var(--err-bg);
    color: var(--text);
    cursor: pointer;
}

.task-check input {
    flex: none;
    margin-top: 3px;
}

.run-ask-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: var(--text-sm);
}

.run-ask-field input {
    width: 100%;
}

.run-ask-buttons,
.task-foot {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Another command holds the folder: what it is, and a way to it */
.task-busy {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--muted);
}

.task-busy > span {
    flex: 1;
}

.task-busy > .icon {
    flex: none;
    width: 16px;
    height: 16px;
}

.run-error {
    color: var(--err-text);
    background: var(--err-bg);
    border-radius: var(--rounded-xl);
    padding: var(--space-2) var(--space-3);
}

.run-log {
    flex: 1;
    min-height: 120px;
    margin: 0;
    overflow: auto;
    padding: var(--space-3);
    border-radius: var(--rounded-xl);
    background: var(--field);
    border: 1px solid var(--line-soft);
    color: var(--zinc-300);
    font: 12.5px / 1.55 var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
}

.run-input {
    display: flex;
    gap: var(--space-2);
}

.run-input input {
    flex: 1;
    width: auto;
}

/* ----------------------------------------------------------------
   The taskbar: one entry per command started, its folder's icon with
   its state in the corner; a finished one has a × to close it
   ---------------------------------------------------------------- */

.taskbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.task {
    position: relative;
}

button.task-open {
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--rounded-xl);
    border-color: var(--line-soft);
    background: var(--raised);
    color: var(--muted);
}

button.task-open:hover {
    background: var(--selected);
    color: var(--text);
}

.task.running button.task-open {
    border-color: var(--accent-line);
    color: var(--accent-text);
}

.task-open > .icon {
    width: 18px;
    height: 18px;
}

.task-mark {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--line);
}

.task-mark .icon {
    width: 11px;
    height: 11px;
    stroke-width: 3;
}

.task-mark.running {
    color: var(--accent-text);
}

.task-mark.running .icon {
    animation: spin 1s linear infinite;
}

.task-mark.ok {
    color: var(--ok);
}

.task-mark.failed {
    color: var(--err);
}

/* Shown while the pointer is on a finished entry */
button.task-close {
    position: absolute;
    top: -6px;
    right: -6px;
    display: none;
    place-items: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    background: var(--zinc-700);
    border-color: var(--line-strong);
    color: var(--text);
}

button.task-close .icon {
    width: 11px;
    height: 11px;
    stroke-width: 3;
}

.task:hover button.task-close,
button.task-close:focus-visible {
    display: grid;
}

/* ----------------------------------------------------------------
   The Run dialog (the hammer): tabs of groups of buttons
   ---------------------------------------------------------------- */

.dialog.run-dialog {
    width: min(1040px, calc(100vw - 32px));
    height: min(760px, calc(100vh - 64px));
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.run-dialog:not([open]) {
    display: none;
}

.run-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.run-head h3 {
    margin: 0;
    font-size: 20px;
}

.run-head-note {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: var(--text-sm);
}

.run-tabs {
    align-self: flex-start;
}

.run-groups {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding-right: var(--space-1);
}

.run-group .group-label {
    display: block;
    padding: 0 0 6px 2px;
}

/* Terminal colours (libs/ansi.js) */
.ansi-bold { font-weight: 700; }
.ansi-dim { opacity: 0.6; }
.ansi-30, .ansi-90 { color: var(--zinc-500); }
.ansi-31, .ansi-91 { color: #f87171; }
.ansi-32, .ansi-92 { color: #4ade80; }
.ansi-33, .ansi-93 { color: #facc15; }
.ansi-34, .ansi-94 { color: #60a5fa; }
.ansi-35, .ansi-95 { color: #e879f9; }
.ansi-36, .ansi-96 { color: #22d3ee; }
.ansi-37, .ansi-97 { color: var(--zinc-100); }

/* ----------------------------------------------------------------
   Narrow windows and phones (the dashboards on a phone): the page scrolls as a whole, so the
   browser's address bar can fold away; the sidebar becomes a strip of pills under the top bar that
   scrolls sideways and stays at the top (a menu's entries follow its item in the strip), or, on a
   page with body.nav-drawer, a drawer behind a menu button (at the end); rows, dialogs and the
   bottom bar get less padding
   ---------------------------------------------------------------- */

@media (max-width: 760px) {
    body.app {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .topbar {
        align-items: center;
        gap: var(--space-2) var(--space-4);
        padding: 10px var(--space-4);
    }

    .brand {
        padding-bottom: 0;
    }

    .workspace {
        flex-direction: column;
        gap: var(--space-3);
        padding: var(--space-3);
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 5;
        flex: none;
        flex-direction: row;
        align-items: center;
        align-self: stretch;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 5px;
        border-radius: var(--rounded-full);
        box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.8);
        scrollbar-width: none;
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: none;
        width: auto;
        white-space: nowrap;
        padding: 7px var(--space-3);
        border-radius: var(--rounded-full);
    }

    .nav-item .label {
        flex: none;
    }

    .nav-divider,
    .nav-sub-divider {
        flex: none;
        width: 1px;
        height: 20px;
        margin: 0 var(--space-1);
    }

    .nav-subs {
        flex: none;
        flex-direction: row;
        align-items: center;
        margin: 0;
        padding-left: var(--space-1);
    }

    .switch-card {
        flex: none;
        margin: 0;
        padding: var(--space-1) 10px;
        border-radius: var(--rounded-full);
    }

    .content {
        overflow: visible;
    }

    .row {
        gap: var(--space-2) var(--space-4);
        padding: var(--space-3) var(--space-4);
    }

    .row-text {
        flex-basis: 200px;
    }

    .row-control {
        min-width: 0;
        max-width: 100%;
    }

    .row-control input,
    .row-control select,
    .row-control textarea {
        max-width: 100%;
    }

    /* A text field takes the whole width under its name, not its desktop size beside it (switches,
       times and numbers keep theirs) */
    .row-control:has(> input:not([type=checkbox], [type=radio], [type=time], [type=number]), > textarea) {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .row-control > input:not([type=checkbox], [type=radio], [type=time], [type=number]),
    .row-control > textarea {
        flex: 1 1 100%;
        width: 100%;
    }

    .dialog,
    .dialog.wide {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    /* Only the plain class: a dialog with padding of its own (the Kiosk Dashboard's kiosk window) keeps it */
    .dialog {
        padding: var(--space-4);
    }

    .dialog .actions {
        flex-wrap: wrap;
    }

    /* A command's window, the Run dialog and a kiosk's window fill the screen; the guide's situations stack */
    .dialog.task-dialog,
    .dialog.run-dialog,
    .dialog.direct-kiosk-dialog {
        width: calc(100vw - 16px);
        height: calc(100dvh - 16px);
    }

    .run-guide dl {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-1);
    }

    .run-guide dd {
        margin-bottom: var(--space-3);
    }

    .bottombar {
        position: sticky;
        bottom: 0;
        padding: var(--space-2) var(--space-4);
    }

    /* A page with body.nav-drawer (the server dashboard and the Kiosk Dashboard) has a menu button
       (.nav-toggle) first in the top bar instead of the strip: the top bar stays at the top, and the
       sidebar, as on a computer, slides in under it from the left while body has .nav-open, over a
       shade (.nav-backdrop). The page sets --nav-top to the top bar's height when it opens it. */
    .nav-drawer .topbar {
        position: sticky;
        top: 0;
        z-index: 16;
        flex-wrap: nowrap;
        background: var(--bg);
    }

    .nav-drawer:not(.signed-out) .nav-toggle {
        display: grid;
        flex: none;
        margin-left: -6px;
    }

    .nav-drawer .brand {
        min-width: 0;
    }

    .nav-drawer .brand > * {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-drawer .sidebar {
        position: fixed;
        top: var(--nav-top, 60px);
        bottom: 0;
        left: 0;
        z-index: 15;
        width: min(300px, 85vw);
        flex-direction: column;
        align-items: stretch;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 10px;
        border-width: 0 1px 0 0;
        border-radius: 0;
        box-shadow: none;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0.2s;
    }

    .nav-drawer.nav-open .sidebar {
        transform: none;
        visibility: visible;
        box-shadow: 16px 0 48px rgba(0, 0, 0, 0.6);
    }

    .nav-drawer.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: var(--nav-top, 60px) 0 0;
        z-index: 14;
        background: rgba(0, 0, 0, 0.55);
    }

    /* The page under the open drawer doesn't scroll */
    .nav-drawer.nav-open {
        overflow: hidden;
    }

    .nav-drawer .nav-item {
        width: 100%;
        white-space: normal;
        padding: 10px var(--space-3);
        border-radius: 10px;
    }

    .nav-drawer .nav-item .label {
        flex: 1;
    }

    .nav-drawer .nav-divider {
        width: auto;
        height: 1px;
        margin: var(--space-2) 6px;
    }

    .nav-drawer .nav-sub-divider {
        width: auto;
        height: 1px;
        margin: var(--space-1) 10px;
    }

    .nav-drawer .nav-subs {
        flex-direction: column;
        align-items: stretch;
        margin: 2px 0 var(--space-2) 20px;
        padding-left: var(--space-2);
    }
}

/* ----------------------------------------------------------------
   Lists of steps, and lists of editable lines (the Server tab's guide and dashboard accounts)
   ---------------------------------------------------------------- */

.guide-steps {
    margin: 0;
    padding: var(--space-3) var(--space-5) var(--space-5) calc(var(--space-5) + 18px);
    color: var(--muted);
    line-height: 1.6;
}

.guide-steps li + li {
    margin-top: var(--space-2);
}

/* A project's Caddy site (the Server tab): whose it is, seag's editor (its own editor.css) or the
   text alone, and "Back to the generated site" */
.site-body {
    padding: var(--space-3) var(--space-5) var(--space-4);
}

.site-lead {
    margin: 0;
    padding: var(--space-4) var(--space-5) 0;
    color: var(--muted);
}

.site-foot {
    padding: 0 var(--space-5) var(--space-4);
}

/* A button under a guide's steps (the Server tab's "More tips") */
.guide-more {
    padding: 0 var(--space-5) var(--space-5);
}

/* A card that explains rather than sets: paragraphs, small headings, lists and code (the Docker
   tab's "Why do we need it") */
.explain {
    padding: var(--space-1) var(--space-5) var(--space-5);
    color: var(--muted);
    line-height: 1.6;
}

.explain p,
.explain ul,
.explain ol {
    margin: var(--space-2) 0 0;
    max-width: 720px;
}

.explain ul,
.explain ol {
    padding-left: 22px;
}

.explain li + li {
    margin-top: var(--space-2);
}

.explain h4 {
    margin: var(--space-4) 0 0;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text);
}

.explain strong {
    color: var(--text);
    font-weight: 500;
}

.explain a {
    color: var(--accent-text);
    text-decoration: none;
    font-weight: 500;
}

.explain a:hover {
    text-decoration: underline;
}

/* A folded section: its summary a quiet link, its text set off by a line on the left */
.explain details {
    margin-top: var(--space-3);
}

.explain summary {
    cursor: pointer;
    color: var(--accent-text);
    font-weight: 500;
    width: fit-content;
}

.explain details[open] > summary {
    margin-bottom: var(--space-1);
}

.explain details > div {
    padding-left: var(--space-3);
    border-left: 2px solid var(--line);
}

.explain details > div > :first-child {
    margin-top: 0;
}

.explain code,
.explain pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text);
}

.explain code {
    padding: 1px 5px;
    background: var(--raised);
    border-radius: var(--rounded-lg);
}

.explain pre {
    margin: var(--space-2) 0 0;
    padding: var(--space-3) var(--space-4);
    background: var(--raised);
    border-radius: var(--rounded-xl);
    white-space: pre-wrap;
}

/* Tips in a dialog: a title and paragraphs each, with a line between */
.tips {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: var(--space-2);
}

.tip + .tip {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line-soft);
}

.tip h4 {
    margin: 0 0 var(--space-2);
    font-size: var(--text-base);
    font-weight: 600;
}

.tip p {
    margin: var(--space-2) 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.tip code,
.tip pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text);
}

.tip code {
    padding: 1px 5px;
    background: var(--raised);
    border-radius: var(--rounded-lg);
}

.tip pre {
    margin: var(--space-2) 0 0;
    padding: var(--space-3) var(--space-4);
    background: var(--raised);
    border-radius: var(--rounded-xl);
    overflow-x: auto;
}

.account-list {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5) 0;
}

.account {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.account > input,
.account > .field-with-button {
    flex: 1 1 0;
    width: auto;
}

.account-actions {
    padding: var(--space-3) var(--space-5) var(--space-5);
}

.account-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.account-actions .icon {
    width: 14px;
    height: 14px;
}

/* A link to a dashboard on the server, under a card's buttons */
.dashboard-link {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 var(--space-5) var(--space-5);
    color: var(--muted);
}

.dashboard-link .icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.dashboard-link a {
    color: var(--accent-text);
    text-decoration: none;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.dashboard-link a:hover {
    text-decoration: underline;
}

/* ----------------------------------------------------------------
   Kiosks (the panel's Kiosk tab, Direct): a card per kiosk, and its
   window (Overview, Settings), in the Kiosk Dashboard's look (kiag's
   dashboard.css: .kiosk-card, .kiosk-dialog), under names of their
   own, as seag's dashboard has its .site-card; a restart schedule as
   fields
   ---------------------------------------------------------------- */

/* A button at the right end of a card's head (Kiosks: Check all) */
.card-head > .card-head-action {
    margin-left: auto;
}

.direct-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5) 0;
}

.direct-search {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--rounded-full);
    background: var(--field);
    color: var(--faint);
}

.direct-search input {
    flex: 1;
    width: auto;
    border: 0;
    background: transparent;
    padding-left: 0;
    padding-right: 0;
}

.direct-search .icon {
    width: 15px;
    height: 15px;
}

.direct-toolbar select {
    width: auto;
}

.direct-kiosks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5) 0;
}

button.direct-kiosk {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-4);
    border: 1px solid var(--accent-line);
    border-radius: var(--rounded-2xl);
    background: var(--accent-bg);
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

button.direct-kiosk:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* Not deployed from here yet: quieter */
button.direct-kiosk.quiet {
    border-style: dashed;
    opacity: 0.8;
}

.direct-kiosk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-width: 0;
}

.direct-kiosk-name {
    font-weight: 600;
    font-size: var(--text-lg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.direct-kiosk-lines {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.direct-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--muted);
}

.direct-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.direct-info .icon {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--accent-text);
}

.direct-info.warn,
.direct-info.warn .icon {
    color: var(--unsaved);
}

.direct-info.bad,
.direct-info.bad .icon {
    color: var(--err-text);
}

.direct-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.direct-flag {
    padding: 2px 8px;
    border-radius: var(--rounded-full);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 400;
}

.direct-flag.warn {
    color: var(--unsaved);
    border-color: var(--unsaved);
}

.direct-flag.bad {
    color: var(--err-text);
    border-color: var(--err);
}

/* The state: deployed, app running, failed, ... */
.direct-state {
    flex: none;
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--rounded-full);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
}

.direct-state.good {
    color: var(--ok);
    border-color: var(--ok);
}

.direct-state.warn {
    color: var(--unsaved);
    border-color: var(--unsaved);
}

.direct-state.bad {
    color: var(--err-text);
    border-color: var(--err);
}

/* ----------------------------------------------------------------
   A kiosk's window: its name, tabs, and the tab's cards
   ---------------------------------------------------------------- */

.dialog.direct-kiosk-dialog {
    width: min(920px, calc(100vw - 32px));
    height: min(820px, calc(100vh - 48px));
    max-height: none;
    padding: 0;
}

.direct-kiosk-dialog[open] {
    display: flex;
    flex-direction: column;
}

.direct-kiosk-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4) 0 var(--space-5);
}

.direct-kiosk-dialog-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    min-width: 0;
}

.direct-kiosk-dialog-title h2 {
    margin: 0;
    font-size: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.direct-kiosk-dialog-tabs {
    display: flex;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--line-soft);
}

.direct-kiosk-dialog-tabs .tab .badge {
    margin-left: 6px;
}

.direct-kiosk-dialog-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5) var(--space-5);
}

/* The body scrolls; its cards keep their height */
.direct-kiosk-dialog-body > * {
    flex: none;
}

/* ui.css hides a dialog's card titles (its dialogs hold one card); a kiosk's window holds several */
.direct-kiosk-dialog .card > .card-head {
    display: flex;
}

.direct-kiosk-dialog .card-head + .card-description {
    padding-top: 0;
}

.direct-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-3) var(--space-5);
    padding: var(--space-4) var(--space-5);
}

.direct-fact {
    display: grid;
    gap: 2px;
    font-size: var(--text-sm);
    min-width: 0;
    overflow-wrap: anywhere;
}

.direct-fact-label {
    color: var(--faint);
    font-size: var(--text-xs);
}

.direct-fact .direct-state {
    justify-self: start;
}

.direct-fact.warn > :last-child {
    color: var(--unsaved);
}

.direct-fact.bad > :last-child {
    color: var(--err-text);
}

.direct-kiosk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: 0 var(--space-5) var(--space-5);
}

/* What kiag would refuse in its settings, as it is typed */
.direct-problems {
    display: grid;
    gap: 4px;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--rounded-xl);
    background: var(--err-bg);
    color: var(--err-text);
}

.direct-problems[hidden] {
    display: none;
}

.direct-kiosk-dialog button.danger {
    color: var(--err-text);
    border-color: var(--err);
    background: var(--err-bg);
}

.kiosk-id {
    color: var(--faint);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: var(--text-xs);
}

.kiosk-schedule {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-2);
}

.kiosk-schedule select,
.kiosk-schedule input:not(.switch) {
    width: auto;
}

/* A time with a line under it ("03:30 in UTC is 04:30 your time"), and a kiosk's "Its own" switch */
.kiosk-time,
.kiosk-own {
    display: grid;
    gap: 6px;
    justify-items: end;
}

.kiosk-time-note {
    font-size: var(--text-xs);
    color: var(--faint);
    text-align: right;
}

.kiosk-time-note:empty {
    display: none;
}

.kiosk-own-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--muted);
    cursor: pointer;
}

.kiosk-own-body .muted {
    font-size: var(--text-sm);
}
