html, body {
    font-family: "Museo Sans", "Trebuchet MS", "Segoe UI", Roboto, sans-serif;
}

/* The loading screen: a trail to a tent walked as the app downloads, its name, the percentage and one scouting quote. Its own
   colours (the app's theme is not there yet): dark when the device is dark, or when the app was set to dark (js/loading.js). */
.rz-loading {
    --rz-loading-bg: #f6f7f2;
    --rz-loading-ink: #2b3a10;
    --rz-loading-accent: #587d18;
    --rz-loading-walked: #87a428;
    --rz-loading-track: #dfe4cf;
    --rz-loading-door: #f8c409;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 100vh;
    padding: 24px 16px;
    background: var(--rz-loading-bg);
    color: var(--rz-loading-ink);
    text-align: center;
}

:root[data-loading-theme="dark"] body:has(.rz-loading),
:root[data-loading-theme="dark"] .rz-loading {
    --rz-loading-bg: #32333d;
    --rz-loading-ink: #e8ebd9;
    --rz-loading-accent: #afca0b;
    --rz-loading-track: #4a4c55;
    background: #32333d;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-loading-theme="light"]) body:has(.rz-loading),
    :root:not([data-loading-theme="light"]) .rz-loading {
        --rz-loading-bg: #32333d;
        --rz-loading-ink: #e8ebd9;
        --rz-loading-accent: #afca0b;
        --rz-loading-track: #4a4c55;
        background: #32333d;
    }
}

.rz-trail {
    position: relative;
    width: 200px;
    height: 120px;
}

.rz-trail svg {
    display: block;
    width: 200px;
    height: 120px;
}

.rz-trail-path {
    fill: none;
    stroke: var(--rz-loading-track);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 2 9;
}

/* The walked part: the same path in full colour, uncovered from the left as far as the download got. */
.rz-trail-walked {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--blazor-load-percentage, 0%);
    overflow: hidden;
    transition: width 0.2s ease-out;
}

.rz-trail-walked .rz-trail-path {
    stroke: var(--rz-loading-walked);
    stroke-dasharray: none;
}

.rz-trail-tree {
    fill: var(--rz-loading-walked);
    opacity: 0.8;
}

.rz-trail-tent {
    fill: var(--rz-loading-accent);
}

.rz-trail-door {
    fill: var(--rz-loading-door);
}

.rz-loading-name {
    font-family: "Museo", "Museo Sans", "Trebuchet MS", sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--rz-loading-accent);
}

.rz-loading-percent {
    min-height: 1.2em;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

.rz-loading-percent::after {
    content: var(--blazor-load-percentage-text, "");
}

.rz-loading-quote {
    max-width: 22rem;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.rz-loading-quote q {
    quotes: "„" "”";
}

.rz-loading-quote cite {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    font-style: normal;
    opacity: 0.7;
}

.rz-loading-quote cite::before {
    content: "— ";
}

.rz-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .rz-trail-walked {
        transition: none;
    }
}

/* The footer under every page: the motto, the author and the legal links, quiet and small. */
.rz-footer {
    margin-top: 48px;
    padding: 16px 0 8px;
    border-top: 1px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

.rz-footer p {
    margin: 0 0 6px;
}

.rz-footer-motto {
    font-style: italic;
}

.rz-footer-motto span {
    font-style: normal;
    white-space: nowrap;
}

.rz-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;
}

.rz-footer a {
    color: var(--mud-palette-primary);
}

/* Bottom navigation on phones. */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}

.bottom-nav-item {
    min-height: 48px;
}

/* Native controls: the best pickers on phones, large tap targets. */
.rz-field {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    font-size: 0.95rem;
}

/* A long text under its label, across the whole width — not a narrow box in the middle. */
.rz-field-block {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.rz-field input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

/* Native checkboxes everywhere (tables too) in the theme's colour, not the browser's blue. */
input[type="checkbox"] {
    accent-color: var(--mud-palette-primary);
}

/* Keyboard focus is visible on MudBlazor controls, which drop the browser outline. */
.mud-button-root:focus-visible,
.mud-chip:focus-visible,
.mud-nav-link:focus-visible,
.mud-expand-panel-header:focus-visible,
.rz-select:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.rz-select {
    min-height: 40px;
    padding: 4px 8px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit;
}

#blazor-error-ui {
    background: #fff8d6;
    color: #1d1d1b;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui a {
    color: #0c5986;
    font-weight: 700;
}

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

.rz-muted {
    color: var(--mud-palette-text-secondary);
}

.rz-text {
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit;
    resize: vertical;
}

/* Uncertain declension: a wavy underline, like a spell checker. */
.rz-uncertain {
    text-decoration: underline wavy #f8c409;
    text-underline-offset: 3px;
    cursor: help;
}

/* Editor: form and A4 preview side by side on wide screens, tabs on phones. */
.rz-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.rz-editor[data-tab="edit"] .rz-preview,
.rz-editor[data-tab="preview"] .rz-edit {
    display: none;
}

@media (min-width: 960px) {
    .rz-editor {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .rz-editor[data-tab] .rz-edit,
    .rz-editor[data-tab] .rz-preview {
        display: block;
    }

    .rz-preview {
        position: sticky;
        top: 64px;
        align-self: start;
        max-height: calc(100vh - 80px);
        overflow: auto;
    }
}

/* The A4 page. */
.rz-a4 {
    background: #fff;
    color: #1d1d1b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    padding: 32px 36px;
    font-family: "Museo", "Trebuchet MS", sans-serif;
    font-size: 0.92rem;
    line-height: 1.45;
}

.rz-a4 p {
    margin: 0 0 6px;
}

.rz-a4-right {
    text-align: right;
}

.rz-a4-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 18px 0 14px;
}

.rz-a4-section {
    font-weight: 700;
    margin-top: 10px !important;
}

.rz-a4-subsection {
    margin-top: 6px !important;
}

.rz-a4-point {
    cursor: pointer;
}

.rz-a4-item {
    padding-left: 1.5em;
}

.rz-a4-note {
    padding-left: 1.5em;
}

.rz-a4-signature {
    margin-left: 50% !important;
    text-align: center;
}

.rz-a4-signature:first-of-type {
    margin-top: 18px !important;
}

.rz-a4-quote {
    font-weight: 700;
    color: #0c5986;
    text-align: center;
    margin: 10px 12% !important;
}

.rz-a4-center {
    text-align: center;
}

/* The point form: a bottom sheet on phones, a side panel on desktop. */
.rz-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1290;
}

.rz-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    overflow: auto;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.25);
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    z-index: 1300;
}

/* A person's forms opened from an order: a dialog over the point form. */
.rz-dialog-backdrop {
    z-index: 1390;
}

.rz-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 32px));
    max-height: 90vh;
    overflow: auto;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    padding: 16px;
    z-index: 1400;
}

.rz-uncertain-link {
    cursor: pointer;
}

/* Long option texts never push the form past a phone's edge. */
.rz-sheet .rz-select {
    max-width: 100%;
}

@media (min-width: 960px) {
    .rz-sheet {
        left: auto;
        top: 0;
        width: 520px;
        max-height: none;
        border-radius: 0;
    }
}

/* Snackbars above the bottom navigation on phones, not under it. */
@media (max-width: 599.98px) {
    .mud-snackbar-location-bottom-center {
        bottom: calc(64px + env(safe-area-inset-bottom)) !important;
    }
}

/* The unit switcher in the app bar: the name as written, cut short on a phone, the arrow next to it. */
.rz-unit-switcher {
    min-width: 0;
}

.rz-unit-switcher .mud-button-root {
    max-width: 60vw;
    text-transform: none;
}

.rz-unit-switcher .mud-button-label {
    min-width: 0;
}

.rz-unit-switcher .rz-unit-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Excerpts of a higher order: set apart from the order's own text, as the templates ask — and smaller, as printed. */
.rz-a4-excerpt {
    margin-left: 2em;
    font-style: italic;
    font-size: 0.82em;
}

/* A wide table (the initial state) scrolls sideways on its own, never the page. */
.rz-table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

/* The district's units: tighter cells, so the table fits a desktop next to the menu. */
.mud-simple-table.rz-units-table table * tr > td,
.mud-simple-table.rz-units-table table * tr > th {
    padding: 4px 6px;
}

/* Its lists show their long entries (Tipi's function names) only when open: closed, they stay narrow, so the table fits a
   desktop without hiding its last column. */
.rz-state-table .rz-select {
    max-width: 10rem;
}

.rz-state-table .rz-add-function {
    max-width: 8.5rem;
}

.rz-group-row td {
    background: var(--mud-palette-background-gray);
}

/* Step-by-step instructions (how to make Tipi's person report): numbered steps, the columns as a bulleted list. */
.rz-howto { list-style: decimal; padding-left: 1.5rem; font-size: .875rem; line-height: 1.5; }
.rz-howto ul { list-style: disc; padding-left: 1.25rem; }
.rz-howto li { margin: .15rem 0; }
.rz-howto a { color: var(--mud-palette-primary); }
.rz-howto-box > summary { cursor: pointer; font-size: .875rem; font-weight: 500; color: var(--mud-palette-primary); }

/* Switching to a new version: a running bar with what it is doing, in the update banner and in Settings. */
.rz-update-progress { display: flex; flex-direction: column; gap: .25rem; min-width: 12rem; flex: 1 1 12rem; font-size: .875rem; }

/* The people as a table on a phone: the table scrolls sideways on its own, the page does not; names stay on one line. */
.rz-members .mud-table-container { overflow-x: auto; }
.rz-members td, .rz-members th { white-space: nowrap; }

/* The terms and the privacy policy: as wide as the other pages, with room between the lines. */
.rz-legal { line-height: 1.6; }
.rz-legal h1 { font-size: 1.5rem; margin: 0 0 1rem; text-wrap: balance; }
.rz-legal h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.rz-legal ol { padding-left: 1.5rem; list-style: decimal; }
.rz-legal li, .rz-legal p { margin: .35rem 0; }
.rz-legal a { color: var(--mud-palette-primary); }

/* „wkrótce” next to a choice that is coming later (the wizard's chorągiew and obóz). */
.rz-soon { margin-left: .4rem; font-size: .7rem; text-transform: none; letter-spacing: 0; opacity: .85; }

/* The unit's logo in the settings. */
.rz-logo-preview { max-height: 72px; max-width: 180px; object-fit: contain; }

/* A patrol's name in its colour (the list of people) and its swatch (the patrols' tab); the border keeps white visible. */
.rz-patrol { display: inline-block; padding: 0 0.55em; border-radius: 999px; border: 1px solid rgba(0, 0, 0, 0.2); line-height: 1.6; white-space: nowrap; }
.rz-patrol-swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid rgba(127, 127, 127, 0.5); }

/* Functions in the list of people, each with the cord worn for it. */
.rz-function { display: inline-flex; align-items: center; gap: 0.2em; margin-right: 0.7em; white-space: nowrap; }

/* A district's people hold many long functions: one per line, wrapping, so the column stays narrow. */
.rz-function-list { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15em; }
.rz-function-list .rz-function { white-space: normal; margin-right: 0; }
.rz-function-list .mud-chip { height: auto; min-height: 24px; white-space: normal; text-align: left; }
/* A district's table fits beside the menu: a long function wraps within its column, a long double surname after its hyphen. */
.rz-members-district .rz-function-list { min-width: 12rem; max-width: 20rem; }
.rz-members-district td:first-child { white-space: normal; }
.rz-members-district td:first-child a { display: inline-block; min-width: 8rem; max-width: 12rem; }
.rz-cord { flex: none; }

/* Icons of scout badges and trails from SIM; a scout badge framed in its level's colour (1* navy, 2* green, 3* red, 4* black). */
.rz-sim-icon { width: 1.6rem; height: 1.6rem; flex: none; vertical-align: middle; }
.rz-sim-icon.rz-level-1, .rz-sim-icon.rz-level-2, .rz-sim-icon.rz-level-3, .rz-sim-icon.rz-level-4 { border-radius: 50%; box-shadow: 0 0 0 2.5px var(--rz-level); }
.rz-sim-icon.rz-level-1 { --rz-level: #1A237E; }
.rz-sim-icon.rz-level-2 { --rz-level: #2E7D32; }
.rz-sim-icon.rz-level-3 { --rz-level: #C62828; }
.rz-sim-icon.rz-level-4 { --rz-level: #000000; }
