/*
 * Global stylesheet — three concerns only:
 *   1. Design tokens for the two directions (light "Tichopis", dark "Osa").
 *   2. A minimal base reset + document typography.
 *   3. Boot-time infrastructure (loader, update banner, error UI) that must work
 *      before — or without — Blazor.
 * plus the canon primitives (2b): every pattern that appears on more than one screen
 * (canon.html §83). Everything else lives in component-scoped *.razor.css.
 *
 * Scoped CSS is rewritten to .x[b-xxxx] (0,2,0) and loads after this file, so a global
 * class below only takes effect where no component keeps a scoped copy of it. A component
 * composes these classes and keeps only what is its own.
 *
 * Redesign note: the two directions differ only in COLOR, type and a few surface
 * details — the LAYOUT is unified (same borders, spacing, no theme-specific
 * timeline). Structure is scale-driven (--pbp-sp-*, --pbp-text-*), not magic
 * numbers, so components compose consistently in both themes.
 */

/* ---------------------------------------------------------------------------
 * 1a. Scale tokens — theme-independent (spacing, type, radii, motion, layout).
 * One source of rhythm for every component.
 * ------------------------------------------------------------------------- */

:root {
    /* Spacing scale (4px base) */
    --pbp-sp-1: 4px;
    --pbp-sp-2: 8px;
    --pbp-sp-3: 12px;
    --pbp-sp-4: 16px;
    --pbp-sp-5: 24px;
    --pbp-sp-6: 32px;
    --pbp-sp-7: 48px;

    /* Type scale */
    --pbp-text-xs: 11px;
    --pbp-text-sm: 12.5px;
    --pbp-text-md: 14px;
    --pbp-text-lg: 17px;
    --pbp-text-xl: 22px;
    --pbp-text-2xl: 30px;
    --pbp-text-field: var(--pbp-text-md);   /* text typed into a field; 16 px on a phone (below) */
    --pbp-leading: 1.6;

    /* Radii */
    --pbp-rad: 14px;
    --pbp-rad2: 9px;
    --pbp-rad3: 6px;
    --pbp-av-rad: 12px;

    /* Motion */
    --pbp-t-fast: .12s ease;
    --pbp-t: .18s ease;

    /* Layout rails */
    --pbp-rail-w: 244px;
    --pbp-content-max: 760px;   /* a single-column form or settings page stops here (canon.html 83.2) */
    --pbp-topbar-h: 58px;
    --pbp-tabbar-h: 72px;   /* the phone's bottom bar, without the safe-area inset under it */
    --pbp-roombar-h: 53px;  /* a room's bar on a phone (phone §70): 36 px pills + sp-2 padding + border */

    /* The page gutter (canon.html 83.2): 16 px below the rail breakpoint, 32 px from it (below).
       .pbp-main pads with it and a page-level surface bleeds by it on a phone. */
    --pbp-gutter: var(--pbp-sp-4);

    /* One stacking scale (canon.html 83.7). In CSS only these tokens, never a bare number. */
    --pbp-z-sticky: 10;   /* sticky bars inside the page (a room's bar, a form's foot) */
    --pbp-z-bar: 20;      /* the app's top bar and bottom tab bar */
    --pbp-z-pop: 50;      /* popovers and the explanation bubble */
    --pbp-z-scrim: 60;
    --pbp-z-modal: 61;    /* a dialog or a pane, always above its scrim */
    --pbp-z-dev: 90;      /* the role switcher in development */
}

/* iOS Safari zooms the page into any field typed in below 16 px, and does not zoom back.
   On a phone the typed text is therefore 16 px (layout.html 79); labels and hints keep the scale.
   The same holds wherever a finger types - a phone on its side, a tablet (canon.html 83.15.6). */
@media (max-width: 560px) {
    :root {
        --pbp-text-field: 16px;
    }
}

@media (pointer: coarse) {
    :root {
        --pbp-text-field: 16px;
    }
}

@media (min-width: 960px) {
    :root {
        --pbp-gutter: var(--pbp-sp-6);
    }
}

/* Short screen - a phone on its side (canon.html 83.13). The bars keep their place and their job
   but get lower; every sticky offset, the page's bottom padding and the sticky form foot read these
   two tokens, so nothing else changes. The tab bar drops its labels (TabBar.razor.css). */
@media (max-height: 500px) {
    :root {
        --pbp-topbar-h: 44px;
        --pbp-tabbar-h: 48px;
    }
}

/* ---------------------------------------------------------------------------
 * 1b. Color tokens — the two directions.
 * :root carries the light direction; the media query switches to dark in System
 * mode; the [data-theme] attribute (set on .pbp-app from C#) overrides for a
 * manual choice. Only colors/fonts/shadow differ — never layout.
 * ------------------------------------------------------------------------- */

:root,
[data-theme="light"] {
    --pbp-bg: #f7f2e9;
    --pbp-sur: #ffffff;
    --pbp-sur2: #f1ead9;
    --pbp-ink: #3a3934;
    --pbp-mut: #948b7c;
    --pbp-acc: #c25f38;
    --pbp-acc-soft: color-mix(in srgb, var(--pbp-acc) 12%, transparent);
    --pbp-acc-ink: color-mix(in srgb, var(--pbp-acc) 62%, var(--pbp-ink));
    --pbp-acc2-ink: color-mix(in srgb, var(--pbp-acc2) 55%, var(--pbp-ink));
    --pbp-ramp-1: #c7a89b;
    --pbp-ramp-2: #b89281;
    --pbp-ramp-3: #aa7d68;
    --pbp-ramp-4: #9c674f;
    --pbp-ramp-5: #8e5136;
    --pbp-on-acc: #241812;
    --pbp-acc2: #6f9463;
    --pbp-bd: #e7decd;
    --pbp-bd2: #d8cdb6;
    --pbp-ok: #6f9463;
    --pbp-warn: #c99a3a;
    --pbp-field: #fffdf8;
    --pbp-send-ink: #ffffff;
    --pbp-card-sh: 0 1px 2px #0000000d, 0 6px 20px #0000000a;
    --pbp-pop-sh: 0 12px 40px #00000022;
    --pbp-scrim: #2a241c66;
    --pbp-font-display: "Literata", Georgia, serif;
    --pbp-font-body: "Karla", "Segoe UI", sans-serif;
    --pbp-avatar-bg: linear-gradient(150deg, #d4744e, #b34f2b);
}

@media (prefers-color-scheme: dark) {
    :root {
        --pbp-bg: #121419;
        --pbp-sur: #1a1d23;
        --pbp-sur2: #23272f;
        --pbp-ink: #e9eaed;
        --pbp-mut: #8b909b;
        --pbp-acc: #ff8a3d;
        --pbp-acc-soft: color-mix(in srgb, var(--pbp-acc) 16%, transparent);
        --pbp-acc-ink: var(--pbp-acc);
        --pbp-acc2-ink: var(--pbp-acc2);
        --pbp-ramp-1: #714628;
        --pbp-ramp-2: #955831;
        --pbp-ramp-3: #b96a36;
        --pbp-ramp-4: #dc7c3a;
        --pbp-ramp-5: #ff8a3d;
        --pbp-on-acc: #121419;
        --pbp-acc2: #5fc7b0;
        --pbp-bd: #2b2f39;
        --pbp-bd2: #3a3f4b;
        --pbp-ok: #5fc7b0;
        --pbp-warn: #e2b24c;
        --pbp-field: #0e1013;
        --pbp-send-ink: #121419;
        --pbp-card-sh: none;
        --pbp-pop-sh: 0 12px 40px #00000066;
        --pbp-scrim: #00000088;
        --pbp-font-display: "Sora", "Segoe UI", sans-serif;
        --pbp-font-body: "Mulish", "Segoe UI", sans-serif;
        --pbp-avatar-bg: linear-gradient(150deg, #ff8a3d, #c65f1e);
    }
}

[data-theme="dark"] {
    --pbp-bg: #121419;
    --pbp-sur: #1a1d23;
    --pbp-sur2: #23272f;
    --pbp-ink: #e9eaed;
    --pbp-mut: #8b909b;
    --pbp-acc: #ff8a3d;
    --pbp-acc-soft: color-mix(in srgb, var(--pbp-acc) 16%, transparent);
    --pbp-acc-ink: var(--pbp-acc);
    --pbp-acc2-ink: var(--pbp-acc2);
    --pbp-ramp-1: #714628;
    --pbp-ramp-2: #955831;
    --pbp-ramp-3: #b96a36;
    --pbp-ramp-4: #dc7c3a;
    --pbp-ramp-5: #ff8a3d;
    --pbp-on-acc: #121419;
    --pbp-acc2: #5fc7b0;
    --pbp-bd: #2b2f39;
    --pbp-bd2: #3a3f4b;
    --pbp-ok: #5fc7b0;
    --pbp-warn: #e2b24c;
    --pbp-field: #0e1013;
    --pbp-send-ink: #121419;
    --pbp-card-sh: none;
    --pbp-pop-sh: 0 12px 40px #00000066;
    --pbp-scrim: #00000088;
    --pbp-font-display: "Sora", "Segoe UI", sans-serif;
    --pbp-font-body: "Mulish", "Segoe UI", sans-serif;
    --pbp-avatar-bg: linear-gradient(150deg, #ff8a3d, #c65f1e);
}

/* ---------------------------------------------------------------------------
 * --pbp-ramp-1..5: sekvencni rampa pro velikost (heatmapa, matice, grafy).
 * Jeden odstin, svetle -> tmave. Kroky NEJSOU odhadnute: prosly validatorem
 * ze skillu dataviz v rezimu --ordinal (monotonni svetlost, rozestup dL >= 0,06,
 * svetly konec >= 2:1 proti plose). Tichopis nad #ffffff, Osa nad #1a1d23.
 *
 * --pbp-acc-ink: akcent, ktery unese TEXT. Samotny --pbp-acc je stredni ton:
 * ve svetle direkci dava 4,21 : 1 s bilou a 4,11 : 1 s tmavou, takze na nem
 * ani nad nim neprojde male pismo. Vyplne, okraje a znacky si --pbp-acc
 * nechavaji; text a ikony berou tohle. V Ose je akcent na tmavem podkladu
 * svetly a kontrast ma bohaty, proto tam zustava beze zmeny.
 *
 * 1c. Derived tone. --pbp-mut sits at 3.02:1 on the light background, under the
 * 4.5:1 floor for body text. This one is mixed from the ink of whichever theme is
 * active, so it recedes exactly as far in both directions and stays readable.
 * Declared once, outside the theme blocks: the var() references resolve against
 * the tokens in force, so it follows the theme without a copy per block.
 *
 * The 75% is measured, not chosen: muted text also lands on --pbp-sur2, which is
 * darker than the page, and a lighter mix drops to 3.16:1 there. At 75% it clears
 * 4.5:1 on the page and on every surface above it, in both directions.
 * ------------------------------------------------------------------------- */

:root {
    --pbp-quiet: color-mix(in srgb, var(--pbp-ink) 75%, var(--pbp-bg));
}

/* ---------------------------------------------------------------------------
 * 2. Base
 * ------------------------------------------------------------------------- */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--pbp-bg);
    color: var(--pbp-ink);
    font-family: var(--pbp-font-body);
    font-size: var(--pbp-text-md);
    line-height: var(--pbp-leading);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Whatever is scrolled to — a focused field, a linked post — lands clear of the sticky top bar and,
   below the rail breakpoint, of the fixed tab bar. */
html {
    scroll-padding-top: var(--pbp-topbar-h);
}

@media (max-width: 959.98px) {
    html {
        scroll-padding-bottom: calc(var(--pbp-tabbar-h) + env(safe-area-inset-bottom));
    }
}

/* Document typography — display face for headings, body face for prose. */
h1, h2, h3, h4, h5 {
    font-family: var(--pbp-font-display);
    color: var(--pbp-ink);
    line-height: 1.25;
    margin: 0;
}

a {
    color: var(--pbp-acc-ink);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

::selection {
    background: var(--pbp-acc-soft);
}

/* Consistent, understated focus ring for keyboard users across the app. */
:focus-visible {
    outline: 2px solid var(--pbp-acc);
    outline-offset: 2px;
}

/* FocusOnNavigate moves focus to each page's h1 — keep that, minus the ring. */
h1:focus {
    outline: none;
}

/* Nativní zaškrtávátka a přepínače si prohlížeč barví po svém — accent-color je
 * jediný způsob, jak je poslat do tématu, aniž by se překreslovaly ručně. */
input[type="checkbox"], input[type="radio"], progress {
    accent-color: var(--pbp-acc-ink);
}

/* Reduced motion — the kit's global rule (_kit.css), so no component has to repeat it. */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }

    /* The loader fades in by animation; without it it would stay at opacity 0. */
    html:not(.first-run) .app-loader {
        opacity: 1;
    }
}

/* ---------------------------------------------------------------------------
 * 2b. Canon primitives — Templates/DesignSystem/screens/canon.html §83 and its
 * block "83 · Consistency canon" in _kit.css, with the older kit rules the block
 * builds on. One rule for each pattern that appears on more than one screen:
 * screens compose these classes instead of restyling them, and no component keeps
 * a scoped copy of anything defined here (a scoped copy outranks it).
 *
 * Breakpoints - the only allowed conditions (canon.html 83.1):
 *   viewport   phone (max-width: 560px) | (min-width: 561px)
 *              rail  (max-width: 959.98px) | (min-width: 960px)
 *              short (max-height: 500px) · coarse (pointer: coarse)
 *   container  row 420 · narrow 560 · split 760 - a container query needs an
 *              ancestor with container-type; none of the classes below is one,
 *              except .exits-col and .cq.
 * The viewport decides what depends on the device (gutter, phone bleed, surface
 * padding, sticky form foot, dialog -> sheet, field text size); the container
 * decides how a component arranges itself inside its box.
 * ------------------------------------------------------------------------- */

/* A query container for components that arrange themselves by their own width. */
.cq { container-type: inline-size; }

/* -- Page head. The way back, the one h1, the thing's state labels, its deeds, one sentence of
   context. Every screen has it in the same place, a collection and a screen about one thing alike;
   the h1 is then the thing's name. The hover pill hangs outside the text rail, so the chevron -
   not its box - starts on the rail. */
.screen-head { margin-bottom: var(--pbp-sp-4); }
.screen-head .row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: var(--pbp-sp-1) var(--pbp-sp-4); }
.screen-head h1 { font-family: var(--pbp-font-display); font-size: var(--pbp-text-xl); font-weight: 700; line-height: 1.2; }
.screen-head .row > :is(.chip, .lb) { align-self: center; }
.screen-head .acts { display: flex; flex-wrap: wrap; gap: var(--pbp-sp-2); margin-left: auto; }
/* The sentence takes its own line under the title. */
.screen-head .sub, .card-head .sub { flex: 0 0 100%; margin: 0; font-size: var(--pbp-text-sm); color: var(--pbp-quiet); }
.back { display: inline-flex; align-items: center; gap: var(--pbp-sp-1); min-height: 28px; margin: 0 0 var(--pbp-sp-3) -6px; padding: 2px var(--pbp-sp-2) 2px 6px; border: none; border-radius: var(--pbp-rad3); background: transparent; color: var(--pbp-quiet); font: inherit; font-size: var(--pbp-text-sm); line-height: 1; text-decoration: none; cursor: pointer; transition: background var(--pbp-t), color var(--pbp-t); }
.back:hover { background: var(--pbp-sur2); color: var(--pbp-acc-ink); text-decoration: none; }
.back .chev { font-size: var(--pbp-text-lg); line-height: 1; margin-top: -2px; }
/* A page head that names its collection as the way back (83.14) replaces the history "Zpět". */
.pbp-main:has(.screen-head > .back) > .back { display: none; }

/* A single-column form or settings page stops at a readable width, left-aligned. */
.form-width { max-width: var(--pbp-content-max, 760px); }

/* -- Surfaces. A .card in the page is a surface; a .card inside a surface is an inset box; nothing
   deeper is framed. overflow: clip, not hidden: it clips the corners without becoming a scroll
   container, so a sticky foot inside still sticks. */
.stack { display: flex; flex-direction: column; gap: var(--pbp-sp-4); }
.card { --card-px: var(--pbp-sp-5); background: var(--pbp-sur); border: 1px solid var(--pbp-bd); border-radius: var(--pbp-rad); overflow: clip; }
.card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--pbp-sp-2) var(--pbp-sp-3); padding: var(--pbp-sp-4) var(--card-px); border-bottom: 1px solid var(--pbp-bd); }
.card-head :is(h2, h3) { font-family: var(--pbp-font-display); font-size: var(--pbp-text-lg); font-weight: 700; line-height: 1.25; }
.card-head .acts { display: flex; flex-wrap: wrap; gap: var(--pbp-sp-2); margin-left: auto; }
/* Sections of a card: the hairline runs the full width of the card, the padding sits inside. */
.card-sec, .card-pad { padding: var(--card-px); }
.card-sec + .card-sec, .card-sec + .list-row, .list-row + .card-sec { border-top: 1px solid var(--pbp-bd); }
/* The sticky phone foot is left out (its negative bottom margin meets the card's edge), and so are
   the layers: a Modal rendered in place can end a section, and a dialog centres by its auto margins.
   The exclusion sits in :where so the reset keeps 0,2,0 and a component's scoped margin still wins. */
:is(.card-sec, .card-pad) > :last-child:not(:where(.form-foot, .scrim, .pane-scrim, .dialog, .pane)), .field:has(+ .actions) { margin-bottom: 0; }
/* The band at the bottom of a card that holds its deeds (room foot, queue bar, measurement foot).
   On a phone it folds like the other feet: no spacer, a hint on its own line, the deeds share the
   width instead of wrapping ragged to the right. Only the band's own children: a foot that holds a
   whole part (the room's composer) keeps its inner layout. */
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pbp-sp-3); padding: var(--pbp-sp-4) var(--card-px); border-top: 1px solid var(--pbp-bd); background: var(--pbp-sur2); }
@media (max-width: 560px) {
    .card { --card-px: var(--pbp-sp-4); }
    .card-head { padding-top: var(--pbp-sp-3); padding-bottom: var(--pbp-sp-3); }
    /* Phone: every surface of the page runs edge to edge; its text starts on the page rail.
       Matches any .card in the page that is not inside another card or a layer. */
    .pbp-main .card:not(:is(.card, .dialog, .pane, .pop) .card) { margin-inline: calc(-1 * var(--pbp-gutter, var(--pbp-sp-4))); border-radius: 0; border-left-width: 0; border-right-width: 0; }
    .card-foot > .spacer { display: none; }
    .card-foot > .hint { flex-basis: 100%; }
    .card-foot > .btn { flex: 1 1 auto; }
}
/* A card inside a surface - or inside a popover, a surface of its own - is an inset box. */
:is(.card, .pop) .card { --card-px: var(--pbp-sp-3); border-radius: var(--pbp-rad2); box-shadow: none; }
/* A preview shows a component as it renders on its page, so a previewed card keeps the surface
   radius and the page card's inset (24, on a phone 16). */
.vb-prev .card { --card-px: var(--pbp-sp-5); border-radius: var(--pbp-rad); }
@media (max-width: 560px) {
    .vb-prev .card { --card-px: var(--pbp-sp-4); }
}

/* A grid of things inside a surface (characters on Home, shelves): as many columns as fit from
   260 px, measured on the surface, not the viewport (canon.html 83.15.4). */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--pbp-sp-3); }

/* Page-level lists and trees are surfaces too: the same radius as a card. Inside a surface or a
   layer they stay inset boxes (9 px). */
.pbp-main :is(.np, .sp-list, .shelf-card):not(:is(.card, .dialog, .pane, .pop) *) { border-radius: var(--pbp-rad); }

/* Side column card (the room's column beside the stream): one frame, one heading. */
.side-card { padding: var(--pbp-sp-3) var(--pbp-sp-4); }

/* -- Headings and quiet text. Nothing inside a surface is larger than 17 px: the 22 px name belongs
   to .screen-head. A form inside a page or a dialog, and the selected thing in a list-detail, head
   themselves at 17 px. */
.form-top :is(h2, h3), .queue-title :is(h2, h3) { font-size: var(--pbp-text-lg); }
/* Section label: a small bold label opening a block inside a surface, with an optional count. */
.sec-head, .card-sec > h3, .side-card > b, .vb-step > b, .mx-sec > b { display: flex; align-items: baseline; gap: var(--pbp-sp-2); margin: 0 0 var(--pbp-sp-3); font-family: var(--pbp-font-body); font-size: var(--pbp-text-sm); font-weight: 700; line-height: 1.3; }
/* The count beside a heading or in a band: small, quiet, tabular, pushed right. */
.count, .sec-head em, .card-sec > h3 em, .side-card > b em, .vb-step > b em, .mx-sec > b em, .queue-head em, .np-head .q { margin-left: auto; font-style: normal; font-weight: 400; font-size: var(--pbp-text-xs); color: var(--pbp-quiet); font-variant-numeric: tabular-nums; }
/* The quiet line under a row's or option's title: one rule for every copy. */
.subline, .list-row .nm i, .queue-item i, .choice i, .sp-row .sub, .exit i { display: block; margin-top: 2px; font-style: normal; font-weight: 400; font-size: var(--pbp-text-xs); color: var(--pbp-quiet); }
.hint { display: block; font-size: var(--pbp-text-xs); color: var(--pbp-quiet); }
/* Reading content keeps its own scale (canon.html 83.15.1): the 17 px cap is for the interface, not
   for what an author wrote. The author's levels step down from the page h1: ## 22 px, ### about
   19.5 px, deeper 17 px bold; an author's # is drawn as ## (the page already has its h1). */
:is(.reader-text, .md) :is(h1, h2, h3, h4, h5, h6) { font-family: var(--pbp-font-display); font-weight: 700; line-height: 1.25; margin: 1.4em 0 .45em; }
:is(.reader-text, .md) :is(h1, h2) { font-size: var(--pbp-text-xl); }
:is(.reader-text, .md) h3 { font-size: calc((var(--pbp-text-lg) + var(--pbp-text-xl)) / 2); }
:is(.reader-text, .md) :is(h4, h5, h6) { font-size: var(--pbp-text-lg); }
:is(.reader-text, .md) > :first-child { margin-top: 0; }

/* -- Fields: one shape for every text input, select and text area. A field that sits inside a row
   (inline rename, a table cell) is the compact one. Typed text is 16 px on a phone (79). A checkbox
   or radio nested in a field keeps its native shape and focus ring: the exclusion sits in :where so
   it adds no specificity and a component's scoped field rule still wins as before. */
.field { display: block; margin-bottom: var(--pbp-sp-4); }
.field > span { display: block; margin-bottom: var(--pbp-sp-2); font-size: var(--pbp-text-sm); font-weight: 600; }
/* A hint inside a field is not its label: .field > span would make it bold. */
.field > span.hint { margin: 4px 0 0; font-size: var(--pbp-text-xs); font-weight: 400; color: var(--pbp-quiet); }
.field :is(input, textarea, select):not(:where([type="checkbox"], [type="radio"])) { width: 100%; padding: 9px var(--pbp-sp-3); border: 1px solid var(--pbp-bd2); border-radius: var(--pbp-rad2); background: var(--pbp-field); color: var(--pbp-ink); font: inherit; font-size: var(--pbp-text-field, var(--pbp-text-md)); }
.field textarea { min-height: 84px; resize: vertical; }
.field :is(input, textarea)::placeholder { color: var(--pbp-quiet); }
.field :is(input, textarea, select):not(:where([type="checkbox"], [type="radio"])):focus { border-color: var(--pbp-acc-ink); outline: none; }
.field.compact { margin: 0; }
.field.compact :is(input, select):not(:where([type="checkbox"], [type="radio"])) { padding-top: 5px; padding-bottom: 5px; }
/* Refused by the server: the edge marks the field, the sentence under it says why. */
.field.bad :is(input, textarea, select):not(:where([type="checkbox"], [type="radio"])) { border-color: var(--pbp-acc-ink); }
.field .bad-msg { display: block; margin-top: var(--pbp-sp-2); font-size: var(--pbp-text-xs); font-style: normal; }
/* The wording of a question in the questionnaire editor is a text area at every width: two lines
   to start, growing with the text where the browser can (field-sizing), resizable where it cannot. */
.q-card .field textarea.q-text { min-height: calc(2lh + 20px); field-sizing: content; resize: vertical; }
/* A field with its one button (a room's password or answer, adding a language; canon.html 83.15.3):
   the field is as wide as its answer, the button stands beside it, and the two go under each other
   only when the row is too narrow. */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--pbp-sp-2) var(--pbp-sp-3); }
.inline-form > .field { flex: 1 1 14ch; max-width: 28ch; margin: 0; }
.inline-form > .btn { flex: none; }

/* -- Choosing. Four controls, each for one job (canon.html 83.5):
   - .check: an on/off inside a form that is saved later;
   - a settings row (.list-row): an on/off that applies at once says its state in words and offers
     the opposite as a button. No switch;
   - .choice: one of several, or an independent on/off (.choice.multi, square mark), when each
     option needs a sentence of its own;
   - .opt-chip: one of a few short options with nothing to explain.
   Hover is the surface tint everywhere; selected is the accent edge + tint. */
.check { display: flex; align-items: center; gap: var(--pbp-sp-2); min-height: 26px; }
.check input { width: auto; }
.choice { position: relative; display: flex; gap: var(--pbp-sp-3); align-items: flex-start; margin-bottom: var(--pbp-sp-2); padding: var(--pbp-sp-3); border: 1px solid var(--pbp-bd); border-radius: var(--pbp-rad2); cursor: pointer; transition: border-color var(--pbp-t), background var(--pbp-t); }
.choice:hover { background: var(--pbp-sur2); }
.choice.on, .choice:focus-within { border-color: var(--pbp-acc-ink); }
.choice.on { background: var(--pbp-acc-soft); }
/* The real input stays for the keyboard and the screen reader; the mark draws it. Visually hidden,
   not display: none, which would take it out of the focus order too. */
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice input:focus-visible ~ .mark { outline: 2px solid var(--pbp-acc); outline-offset: 2px; }
.choice .mark { width: 15px; height: 15px; flex: none; margin-top: 2px; border: 1px solid var(--pbp-bd2); border-radius: 999px; background: var(--pbp-sur); }
.choice.on .mark { border: 5px solid var(--pbp-acc); }
.choice.multi .mark { border-radius: 3px; }
.choice.multi.on .mark { border: none; background: var(--pbp-acc-ink); }
.choice b { display: block; font-size: var(--pbp-text-sm); }
.choice.on i { color: var(--pbp-ink); }
.opts { display: flex; flex-wrap: wrap; gap: var(--pbp-sp-2); }
.opt-chip { padding: 5px var(--pbp-sp-3); border: 1px solid var(--pbp-bd2); border-radius: var(--pbp-rad2); background: var(--pbp-sur); color: var(--pbp-ink); font: inherit; font-size: var(--pbp-text-sm); cursor: pointer; }
.opt-chip:hover { background: var(--pbp-sur2); }
.opt-chip.on { border-color: var(--pbp-acc-ink); background: var(--pbp-acc-soft); font-weight: 600; }
/* A count is ink, not decoration: it counts only what the reader may see (US-70). */
.opt-chip em { margin-left: 5px; font-style: normal; color: var(--pbp-quiet); font-variant-numeric: tabular-nums; }
.opt-chip.on em { color: var(--pbp-ink); }

/* -- Buttons. The plain button is the outlined one, primary (and danger) the filled one, quiet the
   frameless one. Disabled without opacity: a see-through button fails contrast and still looks
   pressable. A link-button is an inline control: accent text without a frame. */
.btn { display: inline-block; padding: 8px var(--pbp-sp-4); border: 1px solid transparent; border-radius: var(--pbp-rad2); background: transparent; color: var(--pbp-ink); font: inherit; font-size: var(--pbp-text-sm); font-weight: 600; text-decoration: none; cursor: pointer; transition: background var(--pbp-t), border-color var(--pbp-t); }
.btn:hover { background: var(--pbp-sur2); text-decoration: none; }
.btn.primary, .btn.danger { background: var(--pbp-acc-ink); color: var(--pbp-send-ink); }
.btn.outline { border-color: var(--pbp-bd2); }
.btn.quiet { color: var(--pbp-quiet); }
.btn[disabled], .btn.primary[disabled], .btn.danger[disabled] { background: var(--pbp-sur2); border-color: var(--pbp-bd2); color: var(--pbp-quiet); cursor: not-allowed; }
.link-btn { display: inline-flex; align-items: center; min-height: 26px; padding: 0 var(--pbp-sp-1); border: none; background: none; color: var(--pbp-acc-ink); font: inherit; font-size: var(--pbp-text-sm); cursor: pointer; }

/* -- Action rows. Inside content the group starts at the left and the deed comes first; in a foot
   (.form-foot, .card-foot, .confirm-foot) the group ends at the right and the deed comes last.
   Either way the deed sits on the outer edge. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pbp-sp-2); margin-top: var(--pbp-sp-3); }
.spacer { flex: 1; }
/* The save state of a form: quiet when stored, ink when something is not saved yet. */
.form-state { margin-left: auto; flex: none; font-size: var(--pbp-text-xs); color: var(--pbp-quiet); white-space: nowrap; }
.form-state.dirty { color: var(--pbp-ink); font-weight: 600; }
/* The foot of a form holds the save state and at most two deeds, nothing else (canon.html
   83.15.7-8): hints and further deeds stand in the form above it. The state sits first, at the left,
   beside the button that changes it and in view while the form scrolls. */
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pbp-sp-3); padding-top: var(--pbp-sp-4); border-top: 1px solid var(--pbp-bd); }
.form-foot .btn { white-space: nowrap; }
.form-foot .form-state { order: -1; margin: 0 auto 0 0; }
/* Phone: the save control must never end up below the fold of a long form, so it sticks to the
   bottom of its surface, clear of the tab bar - one small line of state over one row of deeds.
   Keyed on the viewport: a narrow form beside other content on a wide screen keeps the desktop foot. */
@media (max-width: 560px) {
    .form-foot { position: sticky; z-index: var(--pbp-z-sticky); bottom: calc(var(--pbp-tabbar-h) + env(safe-area-inset-bottom)); margin: 0 calc(-1 * var(--card-px, var(--pbp-sp-4))) calc(-1 * var(--card-px, var(--pbp-sp-4))); padding: var(--pbp-sp-3) var(--card-px, var(--pbp-sp-4)); background: var(--pbp-sur2); }
    .form-foot .btn { flex: 1 1 0; }
    .form-foot .spacer { display: none; }
    .form-foot .form-state, .form-foot .hint { flex-basis: 100%; }
}

/* -- List rows: flush with the surface's edges, a full-width hairline between rows, text on the
   surface's rail. Regular rows are records and settings, compact rows are trees, pickers and menus.
   A row's deed wraps under the text when the text would get less than 160 px. */
.list-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--pbp-sp-2) var(--pbp-sp-3); width: 100%; min-height: 44px; padding: var(--pbp-sp-3) var(--card-px, var(--pbp-sp-4)); border: none; border-top: 1px solid var(--pbp-bd); background: none; color: var(--pbp-ink); font: inherit; text-align: left; text-decoration: none; }
/* The head, or the back band above a detail, already draws the line above the first row. */
.list-row:first-child, :is(.card-head, .view-back, .queue-back, .pp-back) + .list-row { border-top: none; }
:is(a, button).list-row { cursor: pointer; transition: background var(--pbp-t); }
:is(a, button).list-row:hover { background: var(--pbp-sur2); text-decoration: none; }
.list-row.on { background: var(--pbp-acc-soft); }
.list-row .nm { flex: 1 1 160px; min-width: 0; font-weight: 600; }
.list-row .end { flex: none; margin-left: auto; font-size: var(--pbp-text-sm); color: var(--pbp-quiet); font-variant-numeric: tabular-nums; }
.list-row > .error-notice { flex-basis: 100%; }
.list-row.compact { min-height: 36px; padding: var(--pbp-sp-2) var(--pbp-sp-3); font-size: var(--pbp-text-sm); }
.list-row.compact .nm { flex-basis: auto; font-weight: 400; }
.list-row.compact.on .nm { font-weight: 600; }
/* A tree in the list column of a master-detail is navigation: compact rows, one line each at 260 px,
   indented by --depth (canon.html 83.15.2). Ordering acts on the selected node, so it stands in that
   node's detail head (.card-head .acts), not on every row. */
.list-row.compact .nm { padding-left: calc(var(--depth, 0) * var(--pbp-sp-4)); }
@container (max-width: 420px) {
    .list-row.wrap .nm { flex-basis: 100%; }
    .list-row.wrap .end { margin-left: 0; font-size: var(--pbp-text-xs); }
}

/* Subject list: who stands here, who holds a grant. */
.sp-list { border: 1px solid var(--pbp-bd); border-radius: var(--pbp-rad2); background: var(--pbp-sur); overflow: hidden; }
.sp-row { display: flex; align-items: center; gap: var(--pbp-sp-3); padding: var(--pbp-sp-2) var(--pbp-sp-3); border-top: 1px solid var(--pbp-bd); font-size: var(--pbp-text-sm); }
.sp-row:first-child { border-top: none; }
.sp-av { width: 26px; height: 26px; border-radius: var(--pbp-av-rad); background: var(--pbp-avatar-bg); flex: none; }
.sp-av.role { border-radius: var(--pbp-rad3); background: var(--pbp-sur2); border: 1px dashed var(--pbp-bd2); }
.sp-row .who { font-weight: 600; }
.sp-row .rm { margin-left: auto; }

/* -- Exit rows (travel 1): a hover pill. In a side card its text sits on the card's rail and the
   pill hangs into the padding, as .back does. In a narrow column (.exits-col) the length goes
   under the name. */
.exit { display: flex; align-items: center; gap: var(--pbp-sp-3); width: 100%; min-height: 44px; padding: var(--pbp-sp-2) var(--pbp-sp-3); border: none; border-radius: var(--pbp-rad3); background: none; color: var(--pbp-ink); font: inherit; text-align: left; cursor: pointer; }
.exit:hover { background: var(--pbp-sur2); }
.exit b { font-weight: 600; font-size: var(--pbp-text-md); }
.exit .len { margin-left: auto; font-size: var(--pbp-text-sm); color: var(--pbp-quiet); font-variant-numeric: tabular-nums; white-space: nowrap; }
.exit.shut { cursor: default; }
.exit.shut b, .exit.shut .len { color: var(--pbp-quiet); }
.side-card .exit { width: calc(100% + 2 * var(--pbp-sp-3)); margin-inline: calc(-1 * var(--pbp-sp-3)); }
.exits-col { container-type: inline-size; }
@container (max-width: 420px) {
    .exits-col .exit { flex-wrap: wrap; row-gap: 2px; }
    .exits-col .exit > span:first-child { flex-basis: 100%; }
    .exits-col .exit .len { margin-left: 0; font-size: var(--pbp-text-xs); }
}

/* -- Master-detail. One fold: below 760 px of container the list and the detail become two views;
   the detail opens with one back band naming the list, and the open thing quietly on the right.
   The list column is 260 px. Form | preview is not master-detail: it stacks. */
.view-back, .queue-back, .pp-back { display: none; align-items: center; gap: var(--pbp-sp-2); width: 100%; margin: 0; padding: var(--pbp-sp-3) var(--card-px, var(--pbp-sp-4)); border: none; border-bottom: 1px solid var(--pbp-bd); border-radius: 0; background: var(--pbp-sur2); color: var(--pbp-ink); font: inherit; font-size: var(--pbp-text-sm); font-weight: 600; text-align: left; cursor: pointer; }
:is(.view-back, .queue-back, .pp-back) .q { margin-left: auto; font-weight: 400; color: var(--pbp-quiet); }
@container (max-width: 760px) {
    .view-back, .queue-back, .pp-back { display: flex; }
}

/* -- Reading an article (77): the text keeps a reading measure; from 761 px of container the
   reading state and the article's place sit beside it, below that above it. */
.reader { display: grid; grid-template-columns: minmax(0, 68ch) minmax(220px, 280px); gap: var(--pbp-sp-6); justify-content: space-between; }
.reader-text { min-width: 0; }
.reader-aside { display: flex; flex-direction: column; gap: var(--pbp-sp-3); padding-left: var(--pbp-sp-5); border-left: 1px solid var(--pbp-bd); font-size: var(--pbp-text-sm); }
.reader-aside .k { font-size: var(--pbp-text-xs); color: var(--pbp-quiet); }
@container (max-width: 760px) {
    .reader { grid-template-columns: minmax(0, 1fr); gap: var(--pbp-sp-4); }
    .reader-aside { order: -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--pbp-sp-2) var(--pbp-sp-4); padding: 0 0 var(--pbp-sp-3); border-left: none; border-bottom: 1px solid var(--pbp-bd); }
    .reader-aside .k { display: none; }
}
@container (min-width: 761px) {
    .reader { grid-template-columns: minmax(0, 68ch) minmax(220px, 280px); gap: var(--pbp-sp-6); }
    .reader-aside { order: 0; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: var(--pbp-sp-3); padding: 0 0 0 var(--pbp-sp-5); border-left: 1px solid var(--pbp-bd); border-bottom: none; }
    .reader-aside .k { display: block; }
}

/* -- Labels. A label (.chip, also spelled .lb) says what a thing is or what state it is in and is
   never pressed. Plain = the thing's state now (ok / warn tones); .prov = not live yet (dashed);
   .meta (= .plain) = a classification. The app's Chip renders the plain state label as .chip
   alone: .state is StateControl's panel, so a .chip.state is pinned back to a label here. */
:is(.chip, .lb) { display: inline-flex; align-items: center; gap: 5px; padding: 2px var(--pbp-sp-2); border-radius: 999px; background: var(--pbp-acc-soft); color: var(--pbp-ink); font-size: var(--pbp-text-xs); font-weight: 700; white-space: nowrap; }
.chip.state, .lb.state { padding: 2px var(--pbp-sp-2); }
:is(.chip, .lb):is(.meta, .plain) { background: var(--pbp-sur2); color: var(--pbp-quiet); font-weight: 600; }
:is(.chip, .lb).prov { background: none; border: 1px dashed var(--pbp-bd2); color: var(--pbp-quiet); font-weight: 600; }
:is(.chip, .lb).ok { background: color-mix(in srgb, var(--pbp-ok) 18%, transparent); }
:is(.chip, .lb).warn { background: color-mix(in srgb, var(--pbp-warn) 22%, transparent); }

/* -- A section that scrolls sideways says so (73): the next column peeks in and a soft shadow sits
   on the edge that hides more. The shadows are the section's own background, so they move with the
   scroll and vanish at either end. */
.hscroll { overflow-x: auto; background:
    linear-gradient(to right, var(--pbp-sur) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--pbp-sur) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--pbp-ink) 16%, transparent), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--pbp-ink) 16%, transparent), transparent) right center / 14px 100% no-repeat scroll;
    background-color: var(--pbp-sur); }

/* -- The brake before an irreversible choice: the sentence to tick, under the choice it belongs to.
   The component renders it only with that choice selected. */
.brake { display: flex; align-items: flex-start; gap: var(--pbp-sp-2); margin: var(--pbp-sp-2) 0 0; padding: var(--pbp-sp-3); border-radius: var(--pbp-rad2); background: var(--pbp-sur2); font-size: var(--pbp-text-sm); }
.brake input { margin-top: 3px; }

/* Count pill. */
.badge { display: inline-block; min-width: 19px; padding: 1px 6px; border-radius: 999px; background: var(--pbp-acc-ink); color: var(--pbp-send-ink); font-size: var(--pbp-text-xs); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* -- Empty. A whole surface or page with nothing in it says what fills it and offers that action;
   one empty list among others is a single quiet line (.empty.inline). */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--pbp-sp-2); padding: var(--pbp-sp-7) var(--pbp-sp-4); text-align: center; color: var(--pbp-quiet); }
.empty b { font-family: var(--pbp-font-display); font-size: var(--pbp-text-lg); color: var(--pbp-ink); }
.empty p { margin: 0; max-width: 46ch; font-size: var(--pbp-text-sm); }
.empty .btn { margin-top: var(--pbp-sp-2); }
.empty.inline { display: block; margin: 0; padding: var(--pbp-sp-3) var(--card-px, var(--pbp-sp-4)); text-align: left; font-size: var(--pbp-text-sm); }

/* -- Key hints describe a keyboard: shown beside a list where one works, never on touch (83.13). */
.keys { display: flex; flex-wrap: wrap; gap: var(--pbp-sp-3); align-items: center; margin-top: auto; padding: var(--pbp-sp-3) var(--pbp-sp-4); border-top: 1px solid var(--pbp-bd); font-size: var(--pbp-text-xs); color: var(--pbp-quiet); }
.kbd { display: inline-block; padding: 1px 6px; margin-right: 3px; border: 1px solid var(--pbp-bd2); border-radius: var(--pbp-rad3); background: var(--pbp-sur); font-size: var(--pbp-text-xs); font-weight: 600; }
@container (max-width: 560px) {
    .keys { display: none; }
}

/* -- Layers: one scrim, one modal shape, one popover shape, one z-index scale (83.7):
   sticky bars in the page < app bars < popover and explanation bubble < scrim < modal.
   A modal is a dialog (a question with a deed) or a pane (content to pick from); both are a card
   centred in the window from 561 px and a sheet off the bottom edge below. Centred by inset +
   auto margins, never by a transform: a transform would become the containing block of fixed
   descendants (the explanation bubble is position: fixed). Only one modal is open at a time. */
.scrim, .pane-scrim { position: fixed; inset: 0; z-index: var(--pbp-z-scrim); background: var(--pbp-scrim); }
.dialog { position: fixed; z-index: var(--pbp-z-modal); inset: 0; margin: auto; width: min(460px, calc(100vw - 2 * var(--pbp-sp-4))); height: fit-content; max-height: calc(100vh - 2 * var(--pbp-sp-4)); max-height: calc(100dvh - 2 * var(--pbp-sp-4)); display: flex; flex-direction: column; border: 1px solid var(--pbp-bd); border-radius: var(--pbp-rad); background: var(--pbp-sur); box-shadow: var(--pbp-pop-sh); overflow: hidden; outline: none; }
/* Never taller than the window: the body scrolls and the foot with the deed stays in reach. */
.dialog > .confirm-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.confirm-body { padding: var(--pbp-sp-5); }
.confirm-body :is(h2, h3) { margin: 0 0 var(--pbp-sp-2); font-size: var(--pbp-text-lg); }
.confirm-body > p { margin: 0 0 var(--pbp-sp-4); font-size: var(--pbp-text-sm); color: var(--pbp-quiet); }
.confirm-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--pbp-sp-3); padding: var(--pbp-sp-4) var(--pbp-sp-5); border-top: 1px solid var(--pbp-bd); background: var(--pbp-sur2); }
.pane { position: fixed; z-index: var(--pbp-z-modal); left: 0; right: 0; bottom: 0; max-height: 80vh; max-height: 80dvh; display: flex; flex-direction: column; border-radius: var(--pbp-rad) var(--pbp-rad) 0 0; background: var(--pbp-sur); box-shadow: var(--pbp-pop-sh); outline: none; }
.pane-head { display: flex; align-items: baseline; gap: var(--pbp-sp-2); padding: var(--pbp-sp-4) var(--pbp-sp-4) var(--pbp-sp-2); font-size: var(--pbp-text-sm); font-weight: 600; }
.pane-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--pbp-sp-2) var(--pbp-sp-2); }
.pane-foot { padding: var(--pbp-sp-3) var(--pbp-sp-4) var(--pbp-sp-4); border-top: 1px solid var(--pbp-bd); background: var(--pbp-sur2); }
.pane-foot .btn { width: 100%; }
@media (min-width: 561px) {
    .pane { top: 0; margin: auto; width: min(460px, calc(100vw - 2 * var(--pbp-sp-4))); height: fit-content; max-height: calc(100vh - 2 * var(--pbp-sp-4)); max-height: calc(100dvh - 2 * var(--pbp-sp-4)); border-radius: var(--pbp-rad); }
}
/* Phone: a sheet off the bottom edge, and the way out comes nearest the thumb. */
@media (max-width: 560px) {
    .dialog { top: auto; left: 0; right: 0; bottom: 0; width: auto; margin: 0; max-height: 80vh; max-height: 80dvh; border-bottom: none; border-radius: var(--pbp-rad) var(--pbp-rad) 0 0; }
    .confirm-body { padding: var(--pbp-sp-4); }
    .confirm-foot { flex-direction: column-reverse; flex-wrap: nowrap; align-items: stretch; padding: var(--pbp-sp-4); }
    .confirm-foot .btn { width: 100%; }
    .confirm-foot .spacer { display: none; }
    /* The sheet clears the home indicator. A foot that ends the sheet reaches down behind the inset,
       so the strip under the buttons keeps the foot's tone instead of the sheet's. */
    .dialog, .pane { padding-bottom: env(safe-area-inset-bottom); }
    :is(.dialog, .pane) > :is(.confirm-foot, .pane-foot):last-child { margin-bottom: calc(-1 * env(safe-area-inset-bottom)); padding-bottom: calc(var(--pbp-sp-4) + env(safe-area-inset-bottom)); }
}
.pop { position: absolute; z-index: var(--pbp-z-pop); min-width: 200px; max-width: min(320px, calc(100vw - 2 * var(--pbp-sp-4))); padding: var(--pbp-sp-2); border: 1px solid var(--pbp-bd2); border-radius: var(--pbp-rad2); background: var(--pbp-sur); box-shadow: var(--pbp-pop-sh); }
.pop .list-row { border-top: none; border-radius: var(--pbp-rad3); }
.xb { z-index: var(--pbp-z-pop); }

/* -- Touch (83.13): every inline control a finger has to hit is at least 32 px tall, at any width.
   Text-like controls grow their box (they have no frame, so nothing changes to the eye); framed
   small ones keep their look and get an invisible hit area. The device overrides the component's
   own size here, which is why these few declarations carry !important: the component keeps its
   scoped base rule, and a scoped rule would otherwise outrank this one. */
@media (pointer: coarse) {
    .mk, .po-acts .window { min-height: 32px !important; }
    .np-sub, .xq { position: relative; }
    .np-sub::after { content: ""; position: absolute; inset: -5px -2px; }
    .xq::after { content: ""; position: absolute; inset: -3px; }
    /* The same invisible hit area for the remaining framed or frameless controls under 32 px:
       the top bar's bell, avatar and way back, text links, the card-mode order arrows and the
       sign-in close. Their look does not change. (.close is already absolutely positioned.) */
    .bell, .trigger, .back, .link-btn, .ord-btn { position: relative; }
    :is(.bell, .trigger, .back, .link-btn, .ord-btn, .close)::after { content: ""; position: absolute; }
    .bell::after, .link-btn::after, .ord-btn::after { inset: -3px; }
    .trigger::after { inset: -1px; }
    .back::after { inset: -2px 0; }
    .close::after { inset: -4px; }
    /* Key hints describe a keyboard; on a touch screen they are noise. The keys still work. */
    .keys { display: none !important; }
}

/* -- The "hraje" chip stands in the top bar only beside the rail; below 960 px the user menu opens
   on "Hraješ za" and carries it. One threshold, no shrinking chip (canon.html 83.15.5). */
@media (max-width: 959.98px) {
    .topbar .playing { display: none; }
}

/* Thin, token-tinted scrollbars. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--pbp-bd2) transparent;
}

/* Loader-only fallbacks (used before the tokens above resolve to real colors). */
:root {
    --app-loader-track: #e0e0e0;
    --app-loader-bar: #c25f38;
}

/* ---------------------------------------------------------------------------
 * 3a. Startup loader — ONE piece of markup (index.html), TWO styles:
 *  - download mode (html.first-run without .downloaded): the ring arc follows
 *    --blazor-load-percentage* set by the Blazor runtime, download texts shown;
 *  - startup mode (everything else): the very same ring spins as an
 *    indeterminate quarter arc, startup text shown.
 * The loader disappears when Blazor renders and replaces the #app content.
 * ------------------------------------------------------------------------- */

.app-loader {
    text-align: center;
    padding-top: 20vh;
}

html:not(.first-run) .app-loader {
    opacity: 0;
    animation: app-loader-appear 0.2s ease-out 0.4s forwards;
}

@keyframes app-loader-appear {
    to { opacity: 1; }
}

.app-loader-ring {
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 0 auto 1rem auto;
}

.app-loader-ring circle {
    fill: none;
    stroke: var(--app-loader-track);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
}

.app-loader-ring circle:last-child {
    stroke: var(--app-loader-bar);
    transform: rotate(-90deg);
    stroke-dasharray: 63%, 500%;
    transition: stroke-dasharray 0.1s linear;
}

html.first-run:not(.downloaded) .app-loader-ring circle:last-child {
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
}

html:not(.first-run) .app-loader-ring,
html.downloaded .app-loader-ring {
    animation: app-loader-spin 0.9s linear infinite;
}

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

.app-loader-percentage {
    height: 1.5rem;
    font-weight: bold;
    margin-top: -5.4rem;
    margin-bottom: 4rem;
}

html.first-run:not(.downloaded) .app-loader-percentage::after {
    content: var(--blazor-load-percentage-text, "…");
}

.app-loader-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.app-loader-detail {
    max-width: 28rem;
    margin: 0 auto;
    opacity: 0.7;
}

.when-downloading {
    display: none;
}

html.first-run:not(.downloaded) .when-downloading {
    display: inline;
}

html.first-run:not(.downloaded) .when-starting {
    display: none;
}

/* ---------------------------------------------------------------------------
 * 3b. "New version available" banner + Blazor error UI (must run without Blazor)
 * ------------------------------------------------------------------------- */

#update-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    padding: 0.75rem 1.25rem;
    background: #323232;
    color: #ffffff;
    text-align: center;
}

#update-banner.visible {
    display: block;
}

#update-banner button {
    margin-left: 1rem;
    padding: 0.35rem 1rem;
    border: none;
    border-radius: 4px;
    background: var(--app-loader-bar);
    color: #ffffff;
    cursor: pointer;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2100;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    background: #b32121;
    color: #ffffff;
}

#blazor-error-ui .reload {
    color: #ffffff;
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Presence controls (enter / pause / resume), shared by rooms and roads (US-06). */
.play-controls {
    display: flex;
    align-items: center;
    gap: var(--pbp-sp-3);
    flex-wrap: wrap;
    margin: var(--pbp-sp-3) 0;
    padding: var(--pbp-sp-3) var(--pbp-sp-4);
    border: 1px solid var(--pbp-bd);
    border-radius: var(--pbp-rad2);
    background: var(--pbp-sur);
}

.play-controls .hint {
    flex: 1;
    min-width: 12ch;
    font-size: var(--pbp-text-sm);
    color: var(--pbp-quiet);
}
