/* ==============================================================================
   Subro component styles.

   Plain global classes rather than Razor CSS isolation, so that an app can
   restyle any component by declaring the same class later in the cascade,
   without ::deep and without touching the library.

   No literal colours here: everything resolves through the tokens in
   subro.tokens.css.
   ============================================================================== */

/* ------------------------------------------------------------------ button */

.s-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-2);
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--s-radius-md);
    font-family: inherit;
    font-size: var(--s-font-size);
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--s-duration), color var(--s-duration), border-color var(--s-duration), transform var(--s-duration);
}

.s-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-btn:disabled,
.s-btn-disabled,
.s-btn[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
}

/* sizes */
.s-btn-small {
    block-size: 2.25rem;
    padding-inline: var(--s-space-3);
}

.s-btn-medium {
    block-size: 2.5rem;
    padding-inline: var(--s-space-4);
}

.s-btn-large {
    block-size: 2.75rem;
    padding-inline: var(--s-space-6);
    font-size: 1rem;
}

.s-btn-block {
    inline-size: 100%;
}

/* variants */
.s-btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

    @media (hover: hover) {
        .s-btn-primary:hover {
            background-color: hsl(var(--primary) / 0.9);
        }
    }

.s-btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

    @media (hover: hover) {
        .s-btn-secondary:hover {
            background-color: hsl(var(--secondary) / 0.8);
        }
    }

.s-btn-outline {
    border-color: hsl(var(--border));
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
}

    @media (hover: hover) {
        .s-btn-outline:hover {
            background-color: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

.s-btn-ghost {
    background-color: transparent;
    color: hsl(var(--foreground));
}

    @media (hover: hover) {
        .s-btn-ghost:hover {
            background-color: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

.s-btn-link {
    background-color: transparent;
    color: hsl(var(--primary));
    text-underline-offset: 4px;
    padding-inline: 0;
    block-size: auto;
}

    @media (hover: hover) {
        .s-btn-link:hover {
            text-decoration: underline;
        }
    }

.s-btn-destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

    @media (hover: hover) {
        .s-btn-destructive:hover {
            background-color: hsl(var(--destructive) / 0.9);
        }
    }

/* Pressed: a touch screen shows no hover, so whatever can be clicked takes its hover look while a finger is on it (the :active
   twin after each hover rule), and every button gives way a little (--s-press-scale) with a mouse too; a card, which is
   larger, a third as far. Not a link-like button, which is text. iOS needs a touch listener on the page for :active at all:
   Subro.RazorBase.lib.module.js. */
.s-btn:active:not(:disabled, .s-btn-disabled, [aria-disabled="true"], .s-btn-link) {
    transform: scale(var(--s-press-scale, 0.97));
}

.s-card-interactive:active,
.s-stat-interactive:active {
    transform: scale(calc(1 - (1 - var(--s-press-scale, 0.97)) / 3));
}

.s-btn-primary:active {
    background-color: hsl(var(--primary) / 0.9);
}

.s-btn-secondary:active {
    background-color: hsl(var(--secondary) / 0.8);
}

.s-btn-outline:active,
.s-btn-ghost:active {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.s-btn-link:active {
    text-decoration: underline;
}

.s-btn-destructive:active {
    background-color: hsl(var(--destructive) / 0.9);
}

/* busy spinner */
.s-spinner {
    inline-size: 1em;
    block-size: 1em;
    border: 2px solid currentColor;
    border-block-start-color: transparent;
    border-radius: 50%;
    animation: s-spin 0.6s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .s-spinner {
        animation-duration: 1.5s;
    }
}

/* ------------------------------------------------------------- input field */

.s-field {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-label {
    font-size: var(--s-font-size);
    font-weight: 500;
    line-height: 1;
    color: hsl(var(--foreground));
}

.s-required {
    margin-inline-start: 0.2em;
    color: hsl(var(--destructive));
}

.s-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    border: 1px solid hsl(var(--input));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--background));
    padding-inline: var(--s-space-3);
    transition: border-color var(--s-duration), box-shadow var(--s-duration);
}

    .s-input-wrap:focus-within {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

.s-input {
    flex: 1 1 auto;
    min-inline-size: 0;
    border: none;
    background: transparent;
    color: hsl(var(--foreground));
    font-family: inherit;
    font-size: inherit;
    /* Less the wrap's two borders, so a field is as tall as a button of the same size and the two line up in a row. */
    block-size: calc(2.5rem - 2px);
}

    .s-input:focus {
        outline: none;
    }

    .s-input::placeholder {
        color: hsl(var(--muted-foreground));
    }

    /* A number field shows no spin buttons: the browser's are tiny, mouse-only and cannot be themed. The arrow keys
       still step the value. A field that should be stepped by buttons is an SNumberStepper. */
    .s-input[type="number"] {
        appearance: textfield;
    }

        .s-input[type="number"]::-webkit-outer-spin-button,
        .s-input[type="number"]::-webkit-inner-spin-button {
            appearance: none;
            margin: 0;
        }

.s-field-small .s-input {
    block-size: calc(2.25rem - 2px);
}

.s-field-large .s-input {
    block-size: calc(2.75rem - 2px);
    font-size: 1rem;
}

.s-input-adornment {
    display: inline-flex;
    align-items: center;
    color: hsl(var(--muted-foreground));
}

.s-input-wrap:has(.s-input-invalid) {
    border-color: hsl(var(--destructive));
}

.s-input-wrap:has(.s-input-disabled) {
    opacity: 0.5;
    background-color: hsl(var(--muted));
}

.s-input-disabled {
    cursor: not-allowed;
}

.s-help {
    margin: 0;
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.s-help-error {
    color: hsl(var(--destructive));
}

/* -------------------------------------------------------------------- card */

.s-card {
    display: flex;
    flex-direction: column;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: var(--s-shadow-sm);
}

.s-card-flat {
    box-shadow: none;
}

.s-card-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-space-1);
    padding: var(--s-space-6);
    padding-block-end: 0;
}

/* With nothing under it, the header closes the card and needs its own space below. */
.s-card-header:last-child {
    padding-block-end: var(--s-space-6);
}

.s-card-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.s-card-description {
    margin: 0;
    font-size: var(--s-font-size);
    color: hsl(var(--muted-foreground));
}

.s-card-content {
    padding: var(--s-space-6);
}

.s-card-footer {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    padding: var(--s-space-6);
    padding-block-start: 0;
}

.s-card-dense .s-card-header,
.s-card-dense .s-card-content,
.s-card-dense .s-card-footer {
    padding: 0;
}

/* ------------------------------------------------------------------ select */

.s-select {
    flex: 1 1 auto;
    min-inline-size: 0;
    border: none;
    background: transparent;
    color: hsl(var(--foreground));
    font-family: inherit;
    font-size: inherit;
    block-size: calc(2.5rem - 2px);
    cursor: pointer;
    /* The wrapper draws the border and focus ring, and a native arrow next to its padding
       reads as a second control; appearance:none removes it so one is drawn here instead. */
    appearance: none;
    padding-inline-end: var(--s-space-4);
}

    .s-select:focus {
        outline: none;
    }

    .s-select:disabled {
        cursor: not-allowed;
    }

    /* An <option> inherits the page's colours in some browsers and the system's in others;
       naming both keeps a dark theme readable when the list is open. */
    .s-select option {
        background-color: hsl(var(--popover));
        color: hsl(var(--popover-foreground));
    }

.s-select-wrap {
    position: relative;
}

    .s-select-wrap::after {
        content: "";
        position: absolute;
        inset-inline-end: var(--s-space-3);
        inline-size: 0.5rem;
        block-size: 0.5rem;
        border-inline-end: 1.5px solid hsl(var(--muted-foreground));
        border-block-end: 1.5px solid hsl(var(--muted-foreground));
        transform: translateY(-25%) rotate(45deg);
        pointer-events: none;
    }

.s-field-small .s-select {
    block-size: calc(2.25rem - 2px);
}

.s-field-large .s-select {
    block-size: calc(2.75rem - 2px);
    font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   SGrid
   A table, not a grid of divs: a real <table> keeps column widths consistent
   across rows without measuring anything in JavaScript, and screen readers
   already know how to navigate one.
   --------------------------------------------------------------------------- */

.s-grid {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
    inline-size: 100%;
}

.s-grid-scroll {
    position: relative;
    overflow-x: auto;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
}

.s-grid-table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: var(--s-font-size);
    color: hsl(var(--card-foreground));
}

.s-grid-th {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    padding: var(--s-space-3) var(--s-space-4);
    text-align: start;
    font-weight: 600;
    white-space: nowrap;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted));
    border-block-end: 1px solid hsl(var(--border));
}

.s-grid-sorted {
    color: hsl(var(--foreground));
}

/* The header is a button so it is reachable by keyboard and announces itself as
   clickable; it is stripped back to looking like the text it replaced. */
.s-grid-sort {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-grid-sort:hover {
            color: hsl(var(--foreground));
        }
    }

    .s-grid-sort:active {
        color: hsl(var(--foreground));
    }

    .s-grid-sort:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
        border-radius: var(--s-radius-md);
    }

/* Reserved whether or not this column is the sorted one, so the header text does
   not shift sideways when the marker appears. */
.s-grid-sort-marker {
    inline-size: 0.75em;
    font-size: 0.7em;
    line-height: 1;
}

.s-grid-td {
    padding: var(--s-space-3) var(--s-space-4);
    border-block-end: 1px solid hsl(var(--border));
    vertical-align: middle;
}

.s-grid-table tbody tr:last-child .s-grid-td {
    border-block-end: none;
}

.s-grid-start {
    text-align: start;
}

.s-grid-center {
    text-align: center;
}

.s-grid-end {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

/* A class rather than :nth-child, which group headers and the spacers of a virtualized list would throw off. */
.s-grid-striped tbody tr.s-grid-row-alt {
    background-color: hsl(var(--muted) / 0.4);
}

@media (hover: hover) {
    .s-grid-table tbody tr:hover {
        background-color: hsl(var(--accent) / 0.5);
    }
}

.s-grid-dense .s-grid-td,
.s-grid-dense .s-grid-th {
    padding: var(--s-space-2) var(--s-space-3);
}

.s-grid-empty td {
    padding: var(--s-space-6);
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.s-grid-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: hsl(var(--background) / 0.6);
    color: hsl(var(--muted-foreground));
    backdrop-filter: blur(1px);
}

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

.s-grid-range {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-variant-numeric: tabular-nums;
}

.s-grid-pager {
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
}

/* Square-ish and a fixed minimum, so the row does not reflow as the digit count
   grows from 9 to 10 to 100. */
.s-grid-page {
    min-inline-size: 2.25rem;
    padding-inline: var(--s-space-2);
    font-variant-numeric: tabular-nums;
}

.s-grid-gap {
    padding-inline: var(--s-space-1);
    color: hsl(var(--muted-foreground));
    user-select: none;
}

/* ------------------------------------------------------------------- badge */

.s-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    border: 1px solid transparent;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background-color var(--s-duration), color var(--s-duration), border-color var(--s-duration);
}

/* sizes */
.s-badge-small {
    block-size: 1.125rem;
    padding-inline: var(--s-space-2);
    font-size: 0.6875rem;
}

.s-badge-medium {
    block-size: 1.375rem;
    padding-inline: var(--s-space-2);
    font-size: 0.75rem;
}

.s-badge-large {
    block-size: 1.625rem;
    padding-inline: var(--s-space-3);
    font-size: 0.8125rem;
}

/* variants */
.s-badge-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.s-badge-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.s-badge-destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.s-badge-success {
    background-color: hsl(var(--success));
    color: hsl(var(--success-foreground));
}

.s-badge-outline {
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

/* The dot takes the badge's own text colour, so it needs no per-variant rule. */
.s-badge-dot::before {
    content: "";
    inline-size: 0.375rem;
    block-size: 0.375rem;
    border-radius: 9999px;
    background-color: currentColor;
    flex: none;
}

/* -------------------------------------------------------------------- chip */

/* Every chip derives its colours from one custom property that the component sets inline. The
   alphas live here rather than at the call site so that a row of tinted chips stays readable by
   construction: change them once and every chip in every app follows. */
.s-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    border: 1px solid transparent;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    max-inline-size: 100%;
}

.s-chip > * {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* sizes */
.s-chip-small {
    block-size: 1.25rem;
    padding-inline: var(--s-space-2);
    font-size: 0.75rem;
}

.s-chip-medium {
    block-size: 1.5rem;
    padding-inline: var(--s-space-2);
    font-size: 0.8125rem;
}

.s-chip-large {
    block-size: 1.75rem;
    padding-inline: var(--s-space-3);
    font-size: 0.875rem;
}

/* variants */
.s-chip-neutral {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-color: hsl(var(--border));
}

.s-chip-tinted {
    background-color: hsl(var(--s-chip-color) / 0.15);
    color: hsl(var(--s-chip-color));
    border-color: hsl(var(--s-chip-color) / 0.3);
}

.s-chip-solid {
    background-color: hsl(var(--s-chip-color));
    color: hsl(var(--s-chip-foreground, var(--primary-foreground)));
    border-color: transparent;
}

.s-chip-outline {
    background-color: transparent;
    color: hsl(var(--s-chip-color));
    border-color: hsl(var(--s-chip-color) / 0.5);
}

/* ------------------------------------------------------------ toggle group */

/* The items are radios or checkboxes laid over the labels that are drawn, invisible but on top, so a click or a
   tap lands on the input itself and the browser keeps the semantics, the tab stop and the arrow keys. Whether an
   item is chosen is read from its input with :has(:checked), so a template needs no state of its own. */
.s-toggle-field {
    margin: 0;
    padding: 0;
    border: 0;
    min-inline-size: 0;
}

    /* A rendered legend does not take part in the field's flex gap. */
    .s-toggle-field > legend {
        padding: 0;
        margin-block-end: var(--s-space-2);
    }

/* Its own width rather than the field's, which is a column that would stretch it. */
.s-toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-1);
    align-self: flex-start;
    max-inline-size: 100%;
}

.s-toggle-item {
    position: relative;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    font-size: var(--s-font-size);
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--s-duration), color var(--s-duration), border-color var(--s-duration), box-shadow var(--s-duration);
}

.s-toggle-input {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}

.s-toggle-item-content {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-2);
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.s-toggle-item:has(.s-toggle-input:focus-visible) {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-toggle-item:has(.s-toggle-input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.s-toggle-field-readonly .s-toggle-item {
    cursor: default;
}

.s-toggle-group-block {
    display: flex;
    flex-wrap: nowrap;
    align-self: stretch;
}

    .s-toggle-group-block .s-toggle-item {
        flex: 1 1 0;
        min-inline-size: 0;
    }

/* segmented: one track, the chosen item raised out of it. A track wider than a phone scrolls sideways rather than
   cutting its items short; its padding leaves just the room for the focus ring. */
.s-toggle-group-segmented {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.125rem;
    padding: 0.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--muted));
}

    .s-toggle-group-segmented:not(.s-toggle-group-block) .s-toggle-item {
        flex-shrink: 0;
    }

    .s-toggle-group-segmented .s-toggle-item {
        padding-inline: var(--s-space-3);
        border-radius: var(--s-radius-sm);
        color: hsl(var(--muted-foreground));
    }

        @media (hover: hover) {
            .s-toggle-group-segmented .s-toggle-item:hover {
                color: hsl(var(--foreground));
            }
        }

        .s-toggle-group-segmented .s-toggle-item:active {
            color: hsl(var(--foreground));
        }

        .s-toggle-group-segmented .s-toggle-item:has(:checked) {
            background-color: hsl(var(--background));
            color: hsl(var(--foreground));
            box-shadow: var(--s-shadow-sm);
        }

/* The track's padding plus an item make the heights of the inputs and buttons of the same size. */
.s-toggle-group-segmented.s-toggle-group-small .s-toggle-item {
    block-size: 1.75rem;
}

.s-toggle-group-segmented.s-toggle-group-medium .s-toggle-item {
    block-size: 2rem;
}

.s-toggle-group-segmented.s-toggle-group-large .s-toggle-item {
    block-size: 2.25rem;
    font-size: 1rem;
}

.s-toggle-field-invalid .s-toggle-group-segmented {
    box-shadow: inset 0 0 0 1px hsl(var(--destructive));
}

/* chips: separate pills, the chosen ones filled */
.s-toggle-group-chips .s-toggle-item {
    padding-inline: var(--s-space-3);
    border-color: hsl(var(--border));
    border-radius: 9999px;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
}

    @media (hover: hover) {
        .s-toggle-group-chips .s-toggle-item:not(:has(:checked)):hover {
            background-color: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

    .s-toggle-group-chips .s-toggle-item:not(:has(:checked)):active {
        background-color: hsl(var(--accent));
        color: hsl(var(--accent-foreground));
    }

    .s-toggle-group-chips .s-toggle-item:has(:checked) {
        border-color: hsl(var(--primary));
        background-color: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
    }

.s-toggle-group-chips.s-toggle-group-small .s-toggle-item {
    block-size: 1.75rem;
    padding-inline: var(--s-space-2);
    font-size: 0.75rem;
}

.s-toggle-group-chips.s-toggle-group-medium .s-toggle-item {
    block-size: 2rem;
    font-size: 0.8125rem;
}

.s-toggle-group-chips.s-toggle-group-large .s-toggle-item {
    block-size: 2.25rem;
}

.s-toggle-field-invalid .s-toggle-group-chips .s-toggle-item:not(:has(:checked)) {
    border-color: hsl(var(--destructive));
}

/* ---------------------------------------------- additions to button, card, badge, chip */

.s-btn-icon {
    flex: none;
    padding-inline: 0;
}

.s-btn-icon.s-btn-small {
    inline-size: 2.25rem;
}

.s-btn-icon.s-btn-medium {
    inline-size: 2.5rem;
}

.s-btn-icon.s-btn-large {
    inline-size: 2.75rem;
}

.s-btn-accent {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

    @media (hover: hover) {
        .s-btn-accent:hover {
            background-color: hsl(var(--accent) / 0.9);
        }
    }

.s-btn-accent:active {
    background-color: hsl(var(--accent) / 0.9);
}

/* A link or a button drawn as a card: neither brings the look a div has by default. */
.s-card-interactive {
    box-sizing: border-box;
    inline-size: 100%;
    padding: 0;
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--s-duration), transform var(--s-duration);
}

    @media (hover: hover) {
        .s-card-interactive:hover {
            border-color: hsl(var(--muted-foreground) / 0.5);
        }
    }

    .s-card-interactive:active {
        border-color: hsl(var(--muted-foreground) / 0.5);
    }

    .s-card-interactive:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

.s-card-accent {
    border-inline-start: 4px solid hsl(var(--s-card-accent));
}

/* A badge in the corner of what it sits on: a tab's icon, a bell. */
.s-badge-host {
    position: relative;
    display: inline-flex;
}

.s-badge-over {
    position: absolute;
    inset-block-start: -0.375rem;
    inset-inline-end: -0.375rem;
    padding-inline: 0.3125rem;
}

/* A dot alone, with no text beside it to be aligned with. */
.s-badge-lone-dot {
    box-sizing: border-box;
    inset-block-start: -0.125rem;
    inset-inline-end: -0.125rem;
    inline-size: 0.625rem;
    block-size: 0.625rem;
    padding: 0;
}

    .s-badge-lone-dot::before {
        display: none;
    }

.s-chip-remove {
    display: inline-flex;
    flex: none;
    inline-size: 0.875rem;
    block-size: 0.875rem;
    margin-inline-end: -0.125rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-chip-remove:hover {
            opacity: 1;
        }
    }

    .s-chip-remove:active {
        opacity: 1;
    }

    .s-chip-remove:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

    .s-chip-remove > svg {
        inline-size: 100%;
        block-size: 100%;
    }

/* ---------------------------------------------------- checkbox, switch, radio */

/* As in the toggle group: the real input lies invisible over what is drawn, and :has() reads its state. It covers only
   the box, so that a link in the text stays a link; the label passes a click on the text to the input. */
.s-check {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    font-size: var(--s-font-size);
    line-height: 1.25rem;
    cursor: pointer;
}

.s-check-end {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.s-check-readonly {
    cursor: default;
}

.s-check:has(.s-check-input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.s-check-input {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}

.s-check-box,
.s-radio-circle,
.s-switch-track {
    position: relative;
    box-sizing: border-box;
    flex: none;
    transition: background-color var(--s-duration), border-color var(--s-duration);
}

/* An unticked box is nothing but its border, so that takes a stronger colour than the border of a text field. */
.s-check-box {
    display: inline-flex;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    padding: 0.125rem;
    border: 1px solid hsl(var(--muted-foreground));
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--background));
    color: transparent;
}

    .s-check-box:has(:checked) {
        border-color: hsl(var(--primary));
        background-color: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
    }

.s-check-mark {
    inline-size: 100%;
    block-size: 100%;
}

.s-switch-track {
    inline-size: 2.25rem;
    block-size: 1.25rem;
    border-radius: 9999px;
    background-color: hsl(var(--muted-foreground) / 0.4);
}

    .s-switch-track:has(:checked) {
        background-color: hsl(var(--primary));
    }

.s-switch-thumb {
    position: absolute;
    inset-block-start: 0.125rem;
    inset-inline-start: 0.125rem;
    inline-size: 1rem;
    block-size: 1rem;
    border-radius: 50%;
    background-color: hsl(var(--background));
    box-shadow: var(--s-shadow-sm);
    transition: transform var(--s-duration);
}

.s-switch-track:has(:checked) .s-switch-thumb {
    transform: translateX(1rem);
}

:dir(rtl) .s-switch-track:has(:checked) .s-switch-thumb {
    transform: translateX(-1rem);
}

.s-radio-circle {
    display: inline-block;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    border: 1px solid hsl(var(--muted-foreground));
    border-radius: 50%;
    background-color: hsl(var(--background));
}

    .s-radio-circle:has(:checked) {
        border: 0.3125rem solid hsl(var(--primary));
    }

.s-check-box:has(:focus-visible),
.s-radio-circle:has(:focus-visible),
.s-switch-track:has(:focus-visible) {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-radio-group-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--s-space-2) var(--s-space-4);
}

.s-radio {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    line-height: 1.25rem;
    cursor: pointer;
}

.s-toggle-field-readonly .s-radio {
    cursor: default;
}

.s-radio:has(.s-check-input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.s-radio-text {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

.s-radio-description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.s-radio-group-cards .s-radio {
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    transition: border-color var(--s-duration), background-color var(--s-duration);
}

    .s-radio-group-cards .s-radio:has(:checked) {
        border-color: hsl(var(--primary));
        background-color: hsl(var(--muted) / 0.5);
    }

.s-radio-field-invalid .s-radio-circle {
    border-color: hsl(var(--destructive));
}

/* A finger needs more than the line of text is high. */
@media (pointer: coarse) {
    .s-check,
    .s-radio {
        align-items: center;
        min-block-size: 2.75rem;
    }
}

/* ---------------------------------------------------------------- text area */

.s-input-wrap .s-textarea {
    --s-textarea-padding: var(--s-space-2);
    box-sizing: border-box;
    block-size: auto;
    padding-block: var(--s-textarea-padding);
    line-height: 1.4;
    resize: vertical;
}

/* Where the browser has field-sizing it grows with its text between these; elsewhere rows holds and it scrolls. */
.s-input-wrap .s-textarea-grow {
    field-sizing: content;
    min-block-size: calc(var(--s-textarea-rows, 3) * 1.4em + 2 * var(--s-textarea-padding));
    max-block-size: calc(var(--s-textarea-max-rows, 1000) * 1.4em + 2 * var(--s-textarea-padding));
    resize: none;
}

/* Opens up on focus, and waits before closing: a button below should not move between the press and the release. Safari
   gives no focus to a clicked button, so that a focus-within around both is not enough, and only the wait helps there. */
.s-input-wrap .s-textarea-focus-grow {
    --s-textarea-rest: calc(var(--s-textarea-rows, 3) * 1.4em + 2 * var(--s-textarea-padding));
    transition: min-block-size var(--s-duration) ease 200ms;
}

.s-input-wrap .s-textarea-focus-grow:focus,
.s-chat-input:focus-within .s-input-wrap .s-textarea-focus-grow {
    min-block-size: max(var(--s-textarea-rest), min(calc(var(--s-textarea-focus-rows, var(--s-textarea-rows, 3)) * 1.4em + 2 * var(--s-textarea-padding)), 30dvh));
    transition-delay: 0s;
}

@media (max-width: 47.99rem) {
    .s-input-wrap .s-textarea-focus-grow:focus,
    .s-chat-input:focus-within .s-input-wrap .s-textarea-focus-grow {
        min-block-size: max(var(--s-textarea-rest), min(calc(var(--s-textarea-phone-focus-rows, var(--s-textarea-rows, 3)) * 1.4em + 2 * var(--s-textarea-padding)), 30dvh));
    }
}

.s-help-row {
    display: flex;
    justify-content: space-between;
    gap: var(--s-space-3);
}

.s-help-count {
    margin-inline-start: auto;
    white-space: nowrap;
}

/* --------------------------------------------------------------------- chat */

/* The buttons stay on the last line of the box, however far it opens up. A subject takes a line of its own. */
.s-chat-input {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--s-space-2);
}

.s-chat-input > .s-field {
    flex: 1 1 0;
    min-inline-size: 0;
}

.s-chat-input > .s-field:has(.s-chat-input-subject),
.s-chat-input > .s-message-quote,
.s-chat-input-files,
.s-chat-input-error {
    flex-basis: 100%;
}

.s-file-dropping {
    outline: 2px dashed hsl(var(--ring));
    outline-offset: 2px;
    border-radius: var(--s-radius-md);
}

.s-chat-input-files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.s-chat-input-file {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-2);
    max-inline-size: 14rem;
    padding: var(--s-space-1) var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--muted));
    font-size: 0.8125rem;
}

.s-chat-input-file-picture {
    flex: none;
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: var(--s-radius-sm);
    object-fit: cover;
}

.s-chat-input-file-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.s-chat-input-file-remove {
    flex: none;
    padding: 0 var(--s-space-1);
    border: 0;
    background: none;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.s-chat-input-file-remove:focus-visible {
    outline: 2px solid hsl(var(--ring));
    border-radius: var(--s-radius-sm);
}

.s-chat-input-picker {
    position: relative;
    flex: none;
}

.s-chat-input-attach {
    cursor: pointer;
}

/* Out of sight rather than hidden, so that the keyboard reaches it and the button shows that it did. */
.s-chat-input-picker-field {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    overflow: hidden;
}

.s-chat-input-picker-field:focus-visible ~ .s-chat-input-attach {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* What is answered, above a reply or above the box. */
.s-message-quote {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    /* In the colours of what is around it, greyed: a balloon of any colour, or the page. */
    border-inline-start: 3px solid color-mix(in srgb, currentColor 45%, transparent);
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--s-message-quote-background));
    font-size: 0.8125rem;
}

.s-message-quote-body {
    display: flex;
    flex: 1 1 auto;
    justify-content: space-between;
    gap: var(--s-space-2);
    min-inline-size: 0;
    padding: var(--s-space-1) var(--s-space-2);
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
}

button.s-message-quote-body {
    cursor: pointer;
}

/* Fainter than the message it stands above. */
.s-message-quote-texts {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
    opacity: 0.8;
}

.s-message-quote-sender {
    font-weight: 600;
}

.s-message-quote-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.s-message-quote-image {
    flex: none;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: var(--s-radius-sm);
    object-fit: cover;
}

.s-message-quote-remove {
    flex: none;
    padding: var(--s-space-1) var(--s-space-2);
    border: 0;
    background: none;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.s-message-quote-body:focus-visible,
.s-message-quote-remove:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

/* The menu and the reply button stay out of the way until the message is pointed at; a finger cannot point. They have no
   height of their own then, as two icons above each other would make every short message taller, and hidden they take no
   clicks, as they can reach over the message next to it. */
.s-text-message-tools {
    flex: none;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    block-size: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--s-duration);
}

.s-text-message-tools:focus-within,
.s-text-message-tools:has([aria-expanded="true"]) {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: hover) {
    .s-text-message:hover > .s-text-message-tools {
        opacity: 1;
        pointer-events: auto;
    }
}

.s-text-message-tool {
    display: inline-flex;
    padding: 2px;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

@media (hover: hover) {
    .s-text-message-tool:hover {
        color: hsl(var(--foreground));
        background-color: hsl(var(--muted));
    }
}

.s-text-message-tool:active {
    color: hsl(var(--foreground));
    background-color: hsl(var(--muted));
}

.s-text-message-tool:focus-visible {
    outline: 2px solid hsl(var(--ring));
}

/* With a menu, a touch screen has only the dots beside each message, and Reply in the menu: icons on every message are a lot
   on a small screen. Their target is finger sized without making the row any taller. */
@media (hover: none) {
    .s-text-message-tools {
        block-size: auto;
        opacity: 1;
        pointer-events: auto;
    }

    .s-text-message-tools:has(.s-text-message-more) .s-text-message-reply {
        display: none;
    }

    .s-text-message-tool {
        position: relative;
    }

    .s-text-message-tool::after {
        content: "";
        position: absolute;
        inset: -12px;
    }
}

@media not (hover: none) {
    .s-menu-item.s-text-message-menu-reply {
        display: none;
    }
}

/* What happened to a message: copied, translated. In the balloon's own colour, as a muted one is lost on the blue of one's own. */
.s-text-message-note {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-1);
    font-size: 0.75rem;
    opacity: 0.75;
}

.s-text-message-note-button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.s-text-message-note-button:focus-visible {
    outline: 2px solid hsl(var(--ring));
}

/* One row as high as the buttons beside it, and never more than the room above a phone's keyboard. */
.s-chat-input .s-input-wrap .s-textarea {
    --s-textarea-padding: calc((2.5rem - 2px - 1.4em) / 2);
}

.s-chat-input .s-input-wrap .s-textarea-grow {
    max-block-size: min(calc(var(--s-textarea-max-rows, 1000) * 1.4em + 2 * var(--s-textarea-padding)), 40dvh);
}

.s-chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 2.25rem);
    gap: var(--s-space-1);
    padding: var(--s-space-2);
}

.s-chat-emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    block-size: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-md);
    background: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--s-duration);
}

@media (hover: hover) {
    .s-chat-emoji-item:hover {
        background-color: hsl(var(--muted));
    }
}

.s-chat-emoji-item:active {
    background-color: hsl(var(--muted));
}

.s-chat-emoji-item:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

/* A phone's keyboard has its own. */
@media (max-width: 47.99rem) {
    .s-popover-host.s-chat-emoji {
        display: none;
    }
}

/* ------------------------------------------------------------- image viewer */

/* Its size is a container's, so that a fitted picture knows its room whatever is around it. Needs a height from there. */
.s-image-viewer {
    display: flex;
    container-type: size;
    inline-size: 100%;
    block-size: 100%;
    overflow: hidden;
    touch-action: pan-x pan-y pinch-zoom;
}

.s-image-viewer-zoomed {
    overflow: auto;
    overscroll-behavior: contain;
}

/* margin: auto rather than centring the parent's way, which would put the top of a tall picture out of reach. */
.s-image-viewer-zoom {
    display: flex;
    flex: none;
    margin: auto;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.s-image-viewer-zoom:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-image-viewer img {
    display: block;
    block-size: auto;
    inline-size: auto;
    margin: auto;
    max-inline-size: 100cqi;
    max-block-size: 100cqb;
    object-fit: contain;
}

.s-image-viewer-zoomed .s-image-viewer-zoom {
    cursor: zoom-out;
}

.s-image-viewer-zoomed img {
    max-inline-size: none;
    max-block-size: none;
}

.s-image-viewer-failed {
    margin: auto;
    color: hsl(var(--muted-foreground));
}

/* ----------------------------------------------------------------- lightbox */

/* Dark in every theme, as a picture is best seen that way. Both classes, to win from the dialog's own further down. */
.s-dialog.s-lightbox {
    --s-lightbox-background: 0 0% 0%;
    --s-lightbox-foreground: 0 0% 100%;

    background-color: hsl(var(--s-lightbox-background) / 0.94);
    color: hsl(var(--s-lightbox-foreground));
}

.s-lightbox .s-dialog-body {
    position: relative;
    display: flex;
    padding: 0;
    overflow: hidden;
}

.s-lightbox-strip {
    display: flex;
    flex: 1;
    min-inline-size: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.s-lightbox-strip::-webkit-scrollbar {
    display: none;
}

.s-lightbox-strip:focus-visible {
    outline: none;
}

.s-lightbox-slide {
    flex: 0 0 100%;
    min-inline-size: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.s-lightbox-count,
.s-lightbox-caption {
    position: absolute;
    inset-inline: 0;
    margin: 0 auto;
    inline-size: fit-content;
    max-inline-size: calc(100% - 7rem);
    padding: var(--s-space-1) var(--s-space-2);
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--s-lightbox-background) / 0.5);
    font-size: 0.8125rem;
    pointer-events: none;
}

.s-lightbox-count {
    inset-block-start: var(--s-space-2);
}

.s-lightbox-caption {
    inset-block-end: var(--s-space-2);
    overflow-wrap: anywhere;
}

.s-lightbox-button {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: hsl(var(--s-lightbox-background) / 0.5);
    color: inherit;
    cursor: pointer;
}

@media (hover: hover) {
    .s-lightbox-button:hover {
        background-color: hsl(var(--s-lightbox-foreground) / 0.2);
    }
}

.s-lightbox-button:active {
    background-color: hsl(var(--s-lightbox-foreground) / 0.2);
}

.s-lightbox-button:focus-visible,
.s-lightbox .s-dialog-close:focus-visible {
    outline: 2px solid hsl(var(--s-lightbox-foreground));
    outline-offset: 2px;
}

.s-lightbox-download {
    inset-block-start: var(--s-space-2);
    inset-inline-end: 3.25rem;
}

.s-lightbox-previous,
.s-lightbox-next {
    inset-block-start: calc(50% - 1.25rem);
}

.s-lightbox-previous {
    inset-inline-start: var(--s-space-2);
}

.s-lightbox-next {
    inset-inline-end: var(--s-space-2);
}

.s-lightbox .s-dialog-close {
    z-index: 1;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: 50%;
    background-color: hsl(var(--s-lightbox-background) / 0.5);
    color: inherit;
}

/* A finger swipes. */
@media (hover: none) {
    .s-lightbox-previous,
    .s-lightbox-next {
        display: none;
    }
}

/* ------------------------------------------------------------------- thread */

.s-thread {
    --s-thread-indent: 1.75rem;
}

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

.s-thread-item {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    min-inline-size: 0;
}

.s-thread-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-3);
}

.s-thread-action,
.s-thread-more,
.s-thread-folded {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: hsl(var(--muted-foreground));
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

@media (hover: hover) {
    .s-thread-action:hover,
    .s-thread-more:hover,
    .s-thread-folded:hover {
        color: hsl(var(--foreground));
    }
}

.s-thread-action:active,
.s-thread-more:active,
.s-thread-folded:active {
    color: hsl(var(--foreground));
}

.s-thread-action:focus-visible,
.s-thread-more:focus-visible,
.s-thread-folded:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-thread-more {
    align-self: flex-start;
    margin-block-start: var(--s-space-2);
}

.s-thread-more:disabled {
    cursor: default;
}

.s-thread-folded-name {
    font-weight: 600;
    color: hsl(var(--foreground));
}

/* A finger needs more than the line of text is high. */
@media (pointer: coarse) {
    .s-thread-action,
    .s-thread-more,
    .s-thread-folded {
        min-block-size: 2.25rem;
    }
}

.s-thread-reply-box {
    padding-inline-start: var(--s-thread-indent);
}

.s-thread-branch {
    position: relative;
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

/* The line only shows where there is an indent to put it in, which is the CSS's to say below, by the width of the screen. */
.s-thread-line {
    display: none;
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: var(--s-thread-indent);
    padding: 0;
    border: 0;
    background: linear-gradient(hsl(var(--border)), hsl(var(--border))) no-repeat center / 2px 100%;
    cursor: pointer;
}

@media (hover: hover) {
    .s-thread-line:hover {
        background-image: linear-gradient(hsl(var(--muted-foreground)), hsl(var(--muted-foreground)));
    }
}

.s-thread-line:active {
    background-image: linear-gradient(hsl(var(--muted-foreground)), hsl(var(--muted-foreground)));
}

.s-thread-answers {
    display: none;
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

@media (min-width: 48rem) {
    .s-thread-indents {
        padding-inline-start: var(--s-thread-indent);
    }

    .s-thread-indents > .s-thread-line {
        display: block;
    }

    .s-thread-answers-wide {
        display: block;
    }
}

@media (max-width: 47.99rem) {
    .s-thread {
        --s-thread-indent: 1.25rem;
    }

    .s-thread-phone-indents {
        padding-inline-start: var(--s-thread-indent);
    }

    .s-thread-phone-indents > .s-thread-line {
        display: block;
    }

    .s-thread-answers-phone {
        display: block;
    }
}

/* ------------------------------------------------------------- message list */

.s-chat-list {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    block-size: 100%;
    min-block-size: 0;
}

/* column-reverse around one element: it starts at the bottom, and stays that far from it when something comes in above. */
.s-chat-list-scroller {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column-reverse;
    min-inline-size: 0;
    overflow-y: auto;
    overflow-anchor: none;
    overscroll-behavior: contain;
}

.s-chat-list-scroller:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

.s-chat-list-content {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
    padding: var(--s-space-3);
}

.s-chat-list-day-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

.s-chat-day {
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.s-chat-day-sticky {
    position: sticky;
    inset-block-start: var(--s-space-1);
    z-index: 1;
}

.s-chat-day-label {
    padding: 0.125rem var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background-color: hsl(var(--background));
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    line-height: 1.25rem;
    pointer-events: auto;
}

/* The browser skips drawing what is out of view, and remembers a height once it has seen it. */
.s-chat-list-item {
    content-visibility: auto;
    contain-intrinsic-size: auto 4rem;
}

/* Skipping also clips to the message, and a one-line message has less height than its menu and reply button. It is in view
   while it is pointed at, so there is nothing to skip then, and it goes above the next one for the buttons to reach over it. */
.s-chat-list-item:focus-within {
    content-visibility: visible;
    position: relative;
    z-index: 1;
}

@media (hover: hover) {
    .s-chat-list-item:hover {
        content-visibility: visible;
        position: relative;
        z-index: 1;
    }
}

.s-chat-list-item-continued {
    margin-block-start: calc(var(--s-space-3) * -1 + var(--s-space-1));
}

.s-chat-list-item-marked {
    border-radius: var(--s-radius-md);
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

.s-chat-list-older {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: var(--s-space-2);
    padding: var(--s-space-1) var(--s-space-3);
    border: 0;
    border-radius: var(--s-radius-md);
    background: none;
    color: hsl(var(--muted-foreground));
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.s-chat-list-older:disabled {
    cursor: default;
}

.s-chat-list-older:focus-visible,
.s-chat-list-jump:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-chat-list-state {
    display: flex;
    justify-content: center;
    padding: var(--s-space-4);
    color: hsl(var(--muted-foreground));
}

.s-chat-list-jump {
    position: absolute;
    inset-block-end: var(--s-space-3);
    inset-inline-end: var(--s-space-3);
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    min-block-size: 2.25rem;
    min-inline-size: 2.25rem;
    justify-content: center;
    padding: var(--s-space-1) var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: var(--s-shadow-md);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

/* The line between the list and the box, which keeps its height so that nothing moves when someone starts or stops. */
.s-chat-typing {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    min-inline-size: 0;
    padding-inline: var(--s-space-3);
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    line-height: 1.25rem;
}

.s-chat-typing-reserved {
    min-block-size: 1.25rem;
}

.s-chat-typing-text {
    min-inline-size: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.s-chat-typing-dots {
    display: inline-flex;
    flex: none;
    gap: 2px;
}

.s-chat-typing-dots span {
    inline-size: 4px;
    block-size: 4px;
    border-radius: 50%;
    background-color: currentColor;
    animation: s-chat-typing-dot 1.2s ease-in-out infinite;
}

.s-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.s-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes s-chat-typing-dot {
    0%, 60%, 100% {
        opacity: 0.35;
    }

    30% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .s-chat-typing-dots span {
        animation: none;
        opacity: 0.7;
    }
}

/* ------------------------------------------------------------ text messages */

/* The words, whatever is around them: chat and notifications alike. */
.s-text-content {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.s-text-content a {
    color: inherit;
    text-decoration: underline;
}

.s-text-content p,
.s-text-content ul,
.s-text-content ol {
    margin-block: 0 var(--s-space-2);
    white-space: normal;
}

.s-text-content ul,
.s-text-content ol {
    padding-inline-start: 1.25rem;
}

.s-text-message {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    color: hsl(var(--foreground));
    font-size: var(--s-font-size);
    line-height: 1.4;
}

.s-text-message-main {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
    min-inline-size: 0;
    flex: 1 1 auto;
}

.s-text-message-avatar {
    flex: none;
}

/* A message that continues the one before lines up with it, without a picture of its own. */
.s-text-message-continued {
    padding-inline-start: calc(var(--s-text-message-avatar-size, 2rem) + var(--s-space-2));
}

.s-text-message-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--s-space-2);
}

.s-text-message-sender {
    font-weight: 600;
}

.s-text-message-subject {
    font-weight: 600;
}

.s-text-message-time {
    display: inline-flex;
    gap: var(--s-space-1);
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.s-text-message-edited::before {
    content: "· ";
}

.s-text-message-editor-buttons {
    display: flex;
    gap: var(--s-space-2);
}

/* Two buttons beside the box would leave it little room on a phone. */
.s-text-message-editor-buttons-below {
    flex-basis: 100%;
    justify-content: flex-end;
}

.s-text-message-card {
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
}

/* A balloon is as wide as its words, up to most of the line, and one's own goes to the other side. */
.s-text-message-bubble {
    max-inline-size: 85%;
    inline-size: fit-content;
}

.s-text-message-bubble > .s-text-message-main {
    padding: var(--s-space-2) var(--s-space-3);
    border-radius: var(--s-bubble-radius);
    border-end-start-radius: var(--s-bubble-tail-radius);
    background-color: hsl(var(--s-bubble, var(--muted)));
    color: hsl(var(--s-bubble-foreground, var(--foreground)));
}

.s-text-message-square {
    --s-bubble-radius: var(--s-bubble-square-radius);
    --s-bubble-tail-radius: var(--s-bubble-square-radius);
}

.s-text-message-bubble .s-text-message-sender {
    font-size: 0.8125rem;
}

/* The picture's corners follow the balloon's, roughly: it sits inside it. */
.s-text-message-bubble .s-message-picture {
    border-radius: calc(var(--s-bubble-radius) * 0.6);
}

.s-text-message-bubble > .s-text-message-main > .s-text-message-time {
    align-self: flex-end;
}

.s-text-message-bubble.s-text-message-own {
    flex-direction: row-reverse;
    margin-inline-start: auto;
}

.s-text-message-bubble.s-text-message-own > .s-text-message-main {
    border-end-start-radius: var(--s-bubble-radius);
    border-end-end-radius: var(--s-bubble-tail-radius);
    background-color: hsl(var(--s-bubble-own, var(--primary)));
    color: hsl(var(--s-bubble-own-foreground, var(--primary-foreground)));
}

.s-text-message-bubble.s-text-message-own .s-text-message-time {
    color: inherit;
    opacity: 0.8;
}

/* Being edited, a balloon is only the box, on a whole line: it needs the room, and its buttons their usual background. */
.s-text-message-editing {
    max-inline-size: none;
    inline-size: auto;
}

.s-text-message-bubble.s-text-message-editing > .s-text-message-main {
    padding: 0;
    background: none;
    color: hsl(var(--foreground));
}

.s-message-attachments {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    min-inline-size: 0;
}

.s-message-files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-1) var(--s-space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
}

.s-message-file-open {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.s-message-file-size {
    opacity: 0.7;
}

/* One picture as it is, up to a size; several as even tiles. */
.s-message-pictures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-space-1);
    inline-size: 20rem;
    max-inline-size: 100%;
}

.s-message-picture {
    display: block;
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-md);
    background: none;
    overflow: hidden;
    cursor: pointer;
}

.s-message-picture:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-message-picture img {
    display: block;
    inline-size: 100%;
    block-size: auto;
    aspect-ratio: 1;
    object-fit: cover;
}

.s-message-pictures-one {
    display: block;
}

.s-message-pictures-one img {
    aspect-ratio: auto;
    max-block-size: 20rem;
    object-fit: contain;
}

.s-message-attachment {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    min-inline-size: 0;
    overflow-wrap: anywhere;
}

.s-message-attachment a {
    color: inherit;
    text-decoration: underline;
}

.s-message-sender {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

/* ------------------------------------------------------------------ stepper */

.s-stepper {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-2);
    align-self: flex-start;
}

.s-stepper-icon {
    inline-size: 1rem;
    block-size: 1rem;
}

.s-stepper-input {
    box-sizing: border-box;
    inline-size: 4rem;
    block-size: 2.5rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: inherit;
    font-size: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
    appearance: textfield;
}

    .s-stepper-input::-webkit-outer-spin-button,
    .s-stepper-input::-webkit-inner-spin-button {
        appearance: none;
        margin: 0;
    }

    .s-stepper-input:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

.s-field-small .s-stepper-input {
    block-size: 2.25rem;
}

.s-field-large .s-stepper-input {
    block-size: 2.75rem;
    font-size: 1rem;
}

.s-stepper-unit {
    color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------- tabs */

.s-tabs {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

/* The same track as a segmented toggle group. A list wider than a phone scrolls sideways. */
.s-tabs-list {
    box-sizing: border-box;
    display: inline-flex;
    align-self: flex-start;
    gap: 0.125rem;
    max-inline-size: 100%;
    padding: 0.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--muted));
}

.s-tabs-block .s-tabs-list {
    display: flex;
    align-self: stretch;
}

.s-tab {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-2);
    block-size: 2rem;
    padding-inline: var(--s-space-3);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--muted-foreground));
    font-family: inherit;
    font-size: var(--s-font-size);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--s-duration), color var(--s-duration), box-shadow var(--s-duration);
}

.s-tabs-block .s-tab {
    flex: 1 1 0;
}

@media (hover: hover) {
    .s-tab:hover {
        color: hsl(var(--foreground));
    }
}

.s-tab:active {
    color: hsl(var(--foreground));
}

.s-tab-active {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: var(--s-shadow-sm);
}

.s-tab:focus-visible,
.s-tab-panel:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.s-tab-count {
    min-inline-size: 1.125rem;
    padding-inline: var(--s-space-1);
    border-radius: 9999px;
    background-color: hsl(var(--muted));
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.125rem;
    text-align: center;
}

.s-tab-panel[hidden] {
    display: none;
}

/* -------------------------------------------------------------- collapsible */

.s-collapsible-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-3);
    padding-block: var(--s-space-3);
    list-style: none;
    cursor: pointer;
}

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

    .s-collapsible-summary:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
        border-radius: var(--s-radius-sm);
    }

.s-collapsible-heading {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-inline-size: 0;
}

.s-collapsible-title {
    font-weight: 500;
}

.s-collapsible-subtitle {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.s-collapsible-chevron {
    flex: none;
    inline-size: 1rem;
    block-size: 1rem;
    color: hsl(var(--muted-foreground));
    transition: transform var(--s-duration);
}

.s-collapsible[open] > .s-collapsible-summary .s-collapsible-chevron {
    transform: rotate(180deg);
}

.s-collapsible-content {
    padding-block-end: var(--s-space-3);
}

.s-collapsible-card {
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: var(--s-shadow-sm);
}

    .s-collapsible-card > .s-collapsible-summary,
    .s-collapsible-card > .s-collapsible-content {
        padding-inline: var(--s-space-4);
    }

/* ------------------------------------------------------------------- avatar */

.s-avatar {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 50%;
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    font-weight: 600;
    line-height: 1;
    user-select: none;
}

.s-avatar-colored {
    background-color: hsl(var(--s-avatar-color));
    color: hsl(var(--s-avatar-foreground));
}

.s-avatar-small {
    inline-size: 1.5rem;
    block-size: 1.5rem;
    font-size: 0.625rem;
}

.s-avatar-medium {
    inline-size: 2rem;
    block-size: 2rem;
    font-size: 0.75rem;
}

.s-avatar-large {
    inline-size: 2.5rem;
    block-size: 2.5rem;
    font-size: 0.875rem;
}

.s-avatar-xlarge {
    inline-size: 4rem;
    block-size: 4rem;
    font-size: 1.25rem;
}

.s-avatar-image {
    inline-size: 100%;
    block-size: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.s-avatar-group {
    display: inline-flex;
    align-items: center;
}

    .s-avatar-group .s-avatar {
        box-shadow: 0 0 0 2px hsl(var(--background));
    }

        .s-avatar-group .s-avatar + .s-avatar {
            margin-inline-start: -0.25rem;
        }

/* -------------------------------------------------------------- empty state */

.s-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-space-2);
    padding: var(--s-space-6);
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.s-empty-icon {
    display: inline-flex;
    inline-size: 1.5rem;
    block-size: 1.5rem;
}

    .s-empty-icon > svg {
        inline-size: 100%;
        block-size: 100%;
    }

.s-empty-title {
    margin: 0;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.s-empty-text {
    margin: 0;
}

.s-empty-action {
    margin-block-start: var(--s-space-2);
}

/* --------------------------------------------------------------------- mark */

/* A drawn mark (SMark): its parts fill with the text colour unless the drawing says; subro.mark.js moves them. */
.s-mark {
    display: inline-block;
    inline-size: var(--s-mark-size, 3rem);
    line-height: 0;
    vertical-align: middle;
}

/* overflow: a part that pops past its size, or a stroke's outline, may reach over the view box */
.s-mark > svg {
    display: block;
    inline-size: 100%;
    block-size: auto;
    overflow: visible;
}

/* ----------------------------------------------------------------- skeleton */

/* Hidden for --s-skeleton-delay, its space kept, so what loads sooner appears without a placeholder flashing first. */
.s-skeleton {
    display: block;
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
    animation:
        s-skeleton-appear 0s linear var(--s-skeleton-delay, 0ms) both,
        s-pulse-soft 2s ease-in-out var(--s-skeleton-delay, 0ms) infinite;
}

@keyframes s-skeleton-appear {
    from {
        visibility: hidden;
    }

    to {
        visibility: visible;
    }
}

.s-skeleton-line {
    inline-size: var(--s-skeleton-width, 100%);
    block-size: var(--s-skeleton-height, 0.875rem);
}

.s-skeleton-circle {
    inline-size: var(--s-skeleton-width, 2.5rem);
    block-size: var(--s-skeleton-height, var(--s-skeleton-width, 2.5rem));
    border-radius: 50%;
}

.s-skeleton-block {
    inline-size: var(--s-skeleton-width, 100%);
    block-size: var(--s-skeleton-height, 6rem);
    border-radius: var(--s-radius-md);
}

.s-skeleton-lines {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

    .s-skeleton-lines > .s-skeleton:last-child {
        inline-size: 60%;
    }

@keyframes s-pulse-soft {
    50% {
        opacity: 0.7;
    }
}

/* ----------------------------------------------------------------- progress */

.s-progress {
    overflow: hidden;
    inline-size: 100%;
    border-radius: 9999px;
    background-color: hsl(var(--muted));
}

.s-progress-small {
    block-size: 0.25rem;
}

.s-progress-medium {
    block-size: 0.5rem;
}

.s-progress-large {
    block-size: 0.75rem;
}

.s-progress-bar {
    inline-size: var(--s-progress-value, 0%);
    block-size: 100%;
    border-radius: inherit;
    background-color: hsl(var(--primary));
    transition: inline-size var(--s-duration);
}

.s-progress-unknown .s-progress-bar {
    inline-size: 40%;
    animation: s-progress-slide 1.6s ease-in-out infinite;
}

@keyframes s-progress-slide {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(250%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .s-skeleton {
        animation: none;
    }

    .s-progress-unknown .s-progress-bar {
        inline-size: 100%;
        animation: none;
        opacity: 0.5;
    }
}

/* -------------------------------------------------------------------- alert */

.s-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-3);
    padding: var(--s-space-3) var(--s-space-4);
    border: 1px solid hsl(var(--s-alert-color) / 0.35);
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--s-alert-color) / 0.1);
    color: hsl(var(--foreground));
}

.s-alert-info {
    --s-alert-color: var(--info);
}

.s-alert-success {
    --s-alert-color: var(--success);
}

.s-alert-warning {
    --s-alert-color: var(--warning);
}

.s-alert-danger {
    --s-alert-color: var(--destructive);
}

.s-alert-icon {
    display: inline-flex;
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    color: hsl(var(--s-alert-color));
}

    .s-alert-icon > svg {
        inline-size: 100%;
        block-size: 100%;
    }

.s-alert-body {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.s-alert-title {
    margin: 0;
    font-weight: 600;
}

.s-alert-text {
    margin: 0;
}

.s-alert-action {
    margin-block-start: var(--s-space-2);
}

    /* A button here wraps rather than running out of the alert: alerts are narrow on a phone, and translations long. */
    .s-alert-action .s-btn {
        max-inline-size: 100%;
        block-size: auto;
        min-block-size: 2.25rem;
        padding-block: var(--s-space-2);
        white-space: normal;
        line-height: 1.25;
    }

.s-alert-dismiss {
    flex: none;
    margin-block: calc(-1 * var(--s-space-2));
    margin-inline-end: calc(-1 * var(--s-space-2));
}

/* --------------------------------------------------------------------- list */

.s-list {
    display: flex;
    flex-direction: column;
}

.s-list-divided > .s-list-item + .s-list-item {
    border-block-start: 1px solid hsl(var(--border));
}

.s-list-cards {
    gap: var(--s-space-2);
}

    .s-list-cards > .s-list-item {
        border: 1px solid hsl(var(--border));
        border-radius: var(--s-radius-lg);
        background-color: hsl(var(--card));
        box-shadow: var(--s-shadow-sm);
    }

.s-list-item {
    display: flex;
    align-items: center;
    min-inline-size: 0;
    transition: background-color var(--s-duration);
}

.s-list-item-selected {
    background-color: hsl(var(--muted) / 0.6);
}

@media (hover: hover) {
    .s-list-item-interactive:hover {
        background-color: hsl(var(--muted) / 0.6);
    }
}

.s-list-item-interactive:active {
    background-color: hsl(var(--muted) / 0.6);
}

.s-list-item-disabled {
    opacity: 0.5;
}

.s-list-item-main {
    box-sizing: border-box;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: var(--s-space-3);
    min-inline-size: 0;
    min-block-size: 2.75rem;
    padding: var(--s-space-2) var(--s-space-3);
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    text-decoration: none;
}

a.s-list-item-main,
button.s-list-item-main {
    cursor: pointer;
}

button.s-list-item-main:disabled {
    cursor: not-allowed;
}

.s-list-item-main:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

.s-list-item-leading {
    display: inline-flex;
    flex: none;
}

.s-list-item-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.125rem;
    min-inline-size: 0;
}

/* The row's own sizes, not the page's: 14px to read and decide on, 12px for the line below that a reader may skip. */
.s-list-item-title {
    overflow: hidden;
    font-size: var(--s-text-sm);
    line-height: var(--s-text-sm-line);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.s-list-item-subtitle {
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    color: hsl(var(--muted-foreground));
}

.s-list-item-chevron {
    flex: none;
    inline-size: 1rem;
    block-size: 1rem;
    color: hsl(var(--muted-foreground));
}

.s-list-item-trailing {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--s-space-2);
    padding-inline-end: var(--s-space-3);
}

/* -------------------------------------------------------------- page header */

.s-page-header {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    padding-block: var(--s-space-3);
}

.s-page-header-sticky {
    position: sticky;
    inset-block-start: 0;
    z-index: 10;
    background-color: hsl(var(--background));
}

.s-page-heading {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.s-page-eyebrow {
    margin: 0 0 var(--s-space-1);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.s-page-subtitle {
    margin: var(--s-space-1) 0 0;
    color: hsl(var(--muted-foreground));
}

.s-page-actions {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--s-space-2);
}

/* --------------------------------------------------------------- action bar */

.s-action-bar {
    position: sticky;
    inset-block-end: var(--s-action-bar-offset, 0);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
    padding-block: var(--s-space-3) max(var(--s-space-3), env(safe-area-inset-bottom));
    border-block-start: 1px solid hsl(var(--border));
    background-color: hsl(var(--background));
}

.s-action-bar-static {
    position: static;
}

.s-action-bar-start,
.s-action-bar-end {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
}

.s-action-bar-end {
    margin-inline-start: auto;
}

/* --------------------------------------------------------------- check list */

.s-check-list-rows {
    max-block-size: var(--s-check-list-height, 16rem);
    padding: var(--s-space-1);
    overflow-y: auto;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
}

.s-check-list-invalid .s-check-list-rows {
    border-color: hsl(var(--destructive));
}

.s-check-list-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
}

.s-check-row {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    inline-size: 100%;
    min-block-size: 2.25rem;
    padding: var(--s-space-1) var(--s-space-2);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.25rem;
    text-align: start;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-check-row:hover {
            background-color: hsl(var(--muted));
        }
    }

    .s-check-row:active {
        background-color: hsl(var(--muted));
    }

    .s-check-row:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

    .s-check-row:disabled,
    .s-check-row:has(.s-check-input:disabled) {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .s-check-row[aria-pressed="true"] {
        font-weight: 500;
    }

.s-check-row-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-inline-size: 0;
}

.s-check-row-none {
    color: hsl(var(--muted-foreground));
}

.s-check-row-mark {
    flex: none;
    inline-size: 1rem;
    block-size: 1rem;
}

.s-check-row-create {
    font-weight: 500;
    color: hsl(var(--primary));
}

.s-check-list-group {
    padding: var(--s-space-2) var(--s-space-2) var(--s-space-1);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-check-list-note {
    margin: 0;
    padding: var(--s-space-2);
    color: hsl(var(--muted-foreground));
}

@media (pointer: coarse) {
    .s-check-row {
        min-block-size: 2.75rem;
    }
}

/* ----------------------------------------------------------------- combobox */

.s-combobox-host {
    display: flex;
}

    .s-combobox-host > .s-popover-trigger {
        flex: 1 1 auto;
        min-inline-size: 0;
    }

.s-combobox-trigger {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
    inline-size: 100%;
    block-size: 2.5rem;
    padding-inline: var(--s-space-3);
    border: 1px solid hsl(var(--input));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font: inherit;
    text-align: start;
    cursor: pointer;
}

    .s-combobox-trigger:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

    .s-combobox-trigger:disabled {
        opacity: 0.5;
        background-color: hsl(var(--muted));
        cursor: not-allowed;
    }

.s-field-small .s-combobox-trigger {
    block-size: 2.25rem;
}

.s-field-large .s-combobox-trigger {
    block-size: 2.75rem;
    font-size: 1rem;
}

.s-combobox-invalid .s-combobox-trigger {
    border-color: hsl(var(--destructive));
}

.s-combobox-value {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.s-combobox-placeholder {
    color: hsl(var(--muted-foreground));
}

.s-combobox-chevron {
    flex: none;
    inline-size: 1rem;
    block-size: 1rem;
    color: hsl(var(--muted-foreground));
}

.s-combobox-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-1);
}

/* As wide as the field where the browser can say so; a browser that cannot drops the line, and keeps the width above. */
.s-combobox-panel {
    min-inline-size: 16rem;
    min-inline-size: max(16rem, anchor-size(inline));
    max-inline-size: max(22rem, anchor-size(inline));
    padding: var(--s-space-2);
}

    .s-combobox-panel .s-check-list-rows {
        padding: 0;
        border: 0;
    }

@media (max-width: 47.99rem) {
    .s-combobox-panel.s-popover-sheet {
        min-inline-size: 0;
        max-inline-size: none;
    }

    .s-combobox-panel {
        --s-check-list-height: 55dvh;
    }

    .s-combobox-panel .s-check-row {
        min-block-size: 2.75rem;
    }
}

/* ------------------------------------------------------------- date and time */

.s-date-wrap {
    padding-inline-end: var(--s-space-1);
}

.s-date-range .s-input {
    inline-size: 100%;
}

.s-date-month {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-date-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.s-date-title {
    flex: 1 1 auto;
    padding-inline: var(--s-space-2);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.s-date-grid {
    display: grid;
    grid-template-columns: repeat(var(--s-date-columns, 7), 2.25rem);
    gap: 0.125rem;
    justify-content: center;
}

.s-date-weekday,
.s-date-weeknum {
    align-self: center;
    font-size: 0.75rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.s-date-weeknum {
    opacity: 0.7;
}

.s-date-day {
    box-sizing: border-box;
    inline-size: 100%;
    block-size: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--foreground));
    font: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-date-day:hover {
            background-color: hsl(var(--muted));
        }
    }

    .s-date-day:active {
        background-color: hsl(var(--muted));
    }

    .s-date-day:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

    .s-date-day:disabled {
        opacity: 0.35;
        background: transparent;
        cursor: not-allowed;
    }

.s-date-outside {
    color: hsl(var(--muted-foreground));
}

.s-date-today {
    border-color: hsl(var(--muted-foreground));
}

.s-date-between {
    background-color: hsl(var(--muted));
}

.s-date-chosen {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

@media (hover: hover) {
    .s-date-chosen:hover {
        background-color: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
    }
}

.s-date-chosen:active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

@media (max-width: 47.99rem) {
    .s-date-grid {
        grid-template-columns: repeat(var(--s-date-columns, 7), minmax(0, 1fr));
    }

    .s-date-day {
        block-size: 2.75rem;
    }
}

/* --------------------------------------------------------------- colour swatch */

.s-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-2);
}

.s-swatch {
    position: relative;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: 50%;
    background-color: var(--s-swatch-color);
    cursor: pointer;
}

    .s-swatch:has(:checked),
    .s-swatch-chosen {
        box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--foreground));
    }

    .s-swatch:has(:focus-visible) {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 5px;
    }

.s-swatch-custom:not(.s-swatch-chosen) {
    border: 1px dashed hsl(var(--muted-foreground));
    color: hsl(var(--muted-foreground));
}

    .s-swatch-custom > svg {
        inline-size: 1rem;
        block-size: 1rem;
    }

.s-swatches-invalid .s-label {
    color: hsl(var(--destructive));
}

/* --------------------------------------------------- sortable and editable list */

.s-sortable {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
}

.s-sortable-row {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    padding-block: 0.125rem;
    border-radius: var(--s-radius-sm);
    transition: opacity var(--s-duration);
}

.s-sortable-handle {
    display: inline-flex;
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    color: hsl(var(--muted-foreground));
    cursor: grab;
}

    .s-sortable-handle > svg {
        inline-size: 100%;
        block-size: 100%;
    }

.s-sortable-content,
.s-editable-content {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.s-sortable-moves {
    display: inline-flex;
    flex: none;
}

.s-sortable-dragged {
    opacity: 0.5;
}

.s-sortable-drop {
    box-shadow: inset 0 2px 0 hsl(var(--primary));
}

/* The browser's drag and drop does not work on a touch screen: the buttons are the way there. */
@media (pointer: coarse) {
    .s-sortable-handle {
        display: none;
    }
}

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

/* -------------------------------------------------------------------- icons */

.s-icon {
    display: inline-block;
    flex: none;
    vertical-align: -0.125em;
}

.s-icon-small {
    inline-size: 1rem;
    block-size: 1rem;
}

.s-icon-medium {
    inline-size: 1.25rem;
    block-size: 1.25rem;
}

.s-icon-large {
    inline-size: 1.5rem;
    block-size: 1.5rem;
}

.s-icon-field {
    align-items: flex-start;
}

.s-icon-trigger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    cursor: pointer;
}

    @media (hover: hover) {
        .s-icon-trigger:hover {
            background-color: hsl(var(--muted));
        }
    }

    .s-icon-trigger:active {
        background-color: hsl(var(--muted));
    }

    .s-icon-trigger:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

    .s-icon-trigger:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.s-icon-trigger-empty {
    inline-size: 1.25rem;
    block-size: 1.25rem;
    border: 1px dashed hsl(var(--muted-foreground));
    border-radius: var(--s-radius-sm);
}

.s-icon-panel {
    inline-size: 20rem;
}

.s-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
    gap: 0.125rem;
    max-block-size: 16rem;
    margin-block: var(--s-space-2);
    overflow-y: auto;
}

.s-icon-none {
    grid-column: 1 / -1;
}

.s-icon-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    block-size: 2.5rem;
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--foreground));
    cursor: pointer;
}

    @media (hover: hover) {
        .s-icon-option:hover {
            background-color: hsl(var(--muted));
        }
    }

    .s-icon-option:active {
        background-color: hsl(var(--muted));
    }

    .s-icon-option:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-icon-option-chosen {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

@media (hover: hover) {
    .s-icon-option-chosen:hover {
        background-color: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
    }
}

.s-icon-option-chosen:active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

@media (max-width: 47.99rem) {
    .s-icon-panel {
        inline-size: 100vw;
    }

    .s-icon-grid {
        max-block-size: 55dvh;
    }
}

/* --------------------------------------------------------- date navigator, week */

.s-navigator {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-2) var(--s-space-4);
    flex: 1 1 auto;
    min-inline-size: 0;
}

.s-navigator-buttons {
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
}

.s-navigator-step {
    font-size: 1.25rem;
}

.s-navigator-title {
    flex: 1 1 auto;
    min-inline-size: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.s-navigator-title-button {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    padding: var(--s-space-1) var(--s-space-2);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-navigator-title-button:hover {
            background-color: hsl(var(--muted));
        }
    }

    .s-navigator-title-button:active {
        background-color: hsl(var(--muted));
    }

    .s-navigator-title-button:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

.s-week-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--s-space-1);
}

.s-week-day {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    min-inline-size: 0;
    padding: var(--s-space-2) 0.125rem;
    border: 2px solid transparent;
    border-radius: var(--s-radius-md);
    background: transparent;
    color: hsl(var(--foreground));
    font: inherit;
}

button.s-week-day {
    cursor: pointer;
}

    @media (hover: hover) {
        button.s-week-day:hover {
            background-color: hsl(var(--muted));
        }
    }

    button.s-week-day:active {
        background-color: hsl(var(--muted));
    }

    button.s-week-day:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

.s-week-day-today {
    border-color: hsl(var(--ring) / 0.4);
}

.s-week-day-chosen {
    border-color: hsl(var(--ring));
}

.s-week-name {
    overflow: hidden;
    max-inline-size: 100%;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-week-number {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.25;
}

.s-week-dots {
    display: flex;
    gap: 0.125rem;
    block-size: 0.5rem;
    align-items: center;
}

.s-week-dot {
    inline-size: 0.375rem;
    block-size: 0.375rem;
    border-radius: 50%;
}

/* ------------------------------------------------------------- offset input */

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

.s-offset .s-field {
    gap: 0;
}

.s-offset-word {
    color: hsl(var(--muted-foreground));
}

/* ------------------------------------------------------------- scroll strip */

.s-strip {
    min-inline-size: 0;
}

.s-strip-scroller {
    display: flex;
    gap: var(--s-space-3);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

    .s-strip-scroller::-webkit-scrollbar {
        display: none;
    }

    .s-strip-scroller:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

    .s-strip-scroller > * {
        flex: 0 0 var(--s-strip-item-width, auto);
        min-inline-size: 0;
    }

.s-strip-snap-start .s-strip-scroller,
.s-strip-snap-center .s-strip-scroller {
    scroll-snap-type: x mandatory;
}

.s-strip-snap-start .s-strip-scroller > * {
    scroll-snap-align: start;
}

.s-strip-snap-center .s-strip-scroller > * {
    scroll-snap-align: center;
}

.s-strip-arrows {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-space-1);
    margin-block-end: var(--s-space-1);
}

.s-strip-arrow {
    font-size: 1.25rem;
}

/* Each arrow only while there is more on its side (data-more-* from the module); none before the module has looked. */
.s-strip:not([data-more-before]) .s-strip-arrow-start,
.s-strip:not([data-more-after]) .s-strip-arrow-end {
    visibility: hidden;
}

.s-strip-arrows-above:not([data-more-before]):not([data-more-after]) .s-strip-arrows {
    display: none;
}

/* Over the edges, half way down: round, on the card colour, so they read over any item. */
.s-strip-arrows-sides {
    position: relative;
}

    .s-strip-arrows-sides .s-strip-arrow {
        position: absolute;
        inset-block-start: 50%;
        z-index: 1;
        inline-size: 2rem;
        block-size: 2rem;
        padding: 0;
        border: 1px solid hsl(var(--border));
        border-radius: 9999px;
        background-color: hsl(var(--card));
        color: hsl(var(--card-foreground));
        box-shadow: var(--s-shadow-md);
        transform: translateY(-50%);
    }

        @media (hover: hover) {
            .s-strip-arrows-sides .s-strip-arrow:hover {
                background-color: hsl(var(--muted));
            }
        }

        .s-strip-arrows-sides .s-strip-arrow:active {
            background-color: hsl(var(--muted));
        }

    .s-strip-arrows-sides .s-strip-arrow-start {
        inset-inline-start: calc(-1 * var(--s-space-2));
    }

    .s-strip-arrows-sides .s-strip-arrow-end {
        inset-inline-end: calc(-1 * var(--s-space-2));
    }

/* A finger scrolls the strip itself. */
@media (pointer: coarse) {
    .s-strip-arrows,
    .s-strip-arrows-sides .s-strip-arrow {
        display: none;
    }
}

/* From a display type on (SScrollStrip.GridFrom), the items wrap into a grid: on a large screen, all of them in sight. */
@media (min-width: 64rem) {
    .s-strip-grid-desktop .s-strip-scroller {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--s-strip-grid-min, var(--s-card-min-width))), 1fr));
        overflow: visible;
    }

    .s-strip-grid-desktop .s-strip-arrow,
    .s-strip-grid-desktop .s-strip-arrows {
        display: none;
    }
}

@media (min-width: 96rem) {
    .s-strip-grid-wide .s-strip-scroller {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--s-strip-grid-min, var(--s-card-min-width))), 1fr));
        overflow: visible;
    }

    .s-strip-grid-wide .s-strip-arrow,
    .s-strip-grid-wide .s-strip-arrows {
        display: none;
    }
}

/* ------------------------------------------------------------- swipe actions */

/* On touch, one sideways scroll: the row fills it, and the actions wait past its end. */
.s-swipe {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

    .s-swipe::-webkit-scrollbar {
        display: none;
    }

.s-swipe-content {
    flex: 0 0 100%;
    min-inline-size: 0;
    scroll-snap-align: start;
}

.s-swipe-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--s-space-1);
    padding-inline-start: var(--s-space-2);
    scroll-snap-align: end;
}

/* With a mouse there is no swiping: the actions stand beside the row. */
@media (hover: hover) and (pointer: fine) {
    .s-swipe {
        overflow: visible;
    }

    .s-swipe-content {
        flex: 1 1 auto;
    }
}

/* A card that is swiped to choose (SSwipeCard): it follows the finger sideways, and what letting go would choose shows
   behind it, in its colour once far enough. The page still scrolls up and down over it. */
.s-swipe-card {
    position: relative;
    border-radius: var(--s-radius-lg);
}

.s-swipe-card-active {
    overflow: hidden;
    touch-action: pan-y;
}

.s-swipe-card-content {
    position: relative;
    transition: transform var(--s-duration);
}

.s-swipe-card-dragging .s-swipe-card-content {
    transition: none;
}

.s-swipe-card-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    padding-inline: var(--s-space-4);
    border-radius: inherit;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted));
    opacity: 0;
    transition: opacity var(--s-duration), background-color var(--s-duration), color var(--s-duration);
}

.s-swipe-card-hint-right {
    justify-content: flex-start;
}

.s-swipe-card-hint-left {
    justify-content: flex-end;
}

.s-swipe-card[data-swipe="toward-right"] .s-swipe-card-hint-right,
.s-swipe-card[data-swipe="toward-left"] .s-swipe-card-hint-left {
    opacity: 1;
}

.s-swipe-card[data-swipe="right"] .s-swipe-card-hint-right {
    opacity: 1;
    color: hsl(var(--success-foreground));
    background-color: hsl(var(--success));
}

.s-swipe-card[data-swipe="left"] .s-swipe-card-hint-left {
    opacity: 1;
    color: hsl(var(--destructive-foreground));
    background-color: hsl(var(--destructive));
}

@media (prefers-reduced-motion: reduce) {
    .s-swipe-card-content {
        transition: none;
    }
}

/* ------------------------------------------------------------------- wizard */

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

.s-wizard-head {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-wizard-count {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-wizard-title {
    margin: var(--s-space-2) 0 0;
    font-size: 1.25rem;
    font-weight: 600;
    outline: none;
}

.s-wizard-description {
    margin: 0;
    color: hsl(var(--muted-foreground));
}

/* ------------------------------------------------------------------ QR code */

/* Dark on light in every theme, through the tokens: plenty of scanners do not read an inverted code. */
.s-qr {
    display: block;
    inline-size: var(--s-qr-size, 12rem);
    block-size: var(--s-qr-size, 12rem);
    background-color: hsl(var(--s-qr-background));
    fill: hsl(var(--s-qr-foreground));
}

/* ---------------------------------------------------------------- file drop */

.s-file-drop {
    position: relative;
}

/* Out of sight rather than hidden, as it has to take the focus and the keyboard. */
.s-file-drop-field {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    overflow: hidden;
}

.s-file-drop-area {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-2);
    min-block-size: 7rem;
    padding: var(--s-space-4);
    border: 1px dashed hsl(var(--muted-foreground));
    border-radius: var(--s-radius-md);
    color: hsl(var(--muted-foreground));
    text-align: center;
    cursor: pointer;
    transition: background-color var(--s-duration);
}

    @media (hover: hover) {
        .s-file-drop-area:hover {
            background-color: hsl(var(--muted) / 0.6);
        }
    }

    .s-file-drop-area:active {
        background-color: hsl(var(--muted) / 0.6);
    }

.s-file-drop-field:focus-visible ~ .s-file-drop-area {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-file-drop-disabled .s-file-drop-area {
    opacity: 0.5;
    background: transparent;
    cursor: not-allowed;
}

.s-file-drop-invalid .s-file-drop-area {
    border-color: hsl(var(--destructive));
}

.s-file-dropping .s-file-drop-area {
    background-color: hsl(var(--muted));
}

.s-file-drop-icon {
    inline-size: 1.5rem;
    block-size: 1.5rem;
}

.s-file-drop-uploads {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.s-file-drop-upload {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6rem auto;
    align-items: center;
    gap: var(--s-space-2);
}

.s-file-drop-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------- tree */

.s-tree-level {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .s-tree-level .s-tree-level {
        padding-inline-start: var(--s-space-4);
    }

.s-tree-row {
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
    min-block-size: 2.25rem;
    border-radius: var(--s-radius-sm);
}

    .s-tree-row-selected {
        background-color: hsl(var(--muted) / 0.6);
    }

    @media (hover: hover) {
        .s-tree-row:hover {
            background-color: hsl(var(--muted) / 0.6);
        }
    }

    .s-tree-row:active {
        background-color: hsl(var(--muted) / 0.6);
    }

.s-tree-row-selected {
    font-weight: 500;
}

.s-tree-toggle,
.s-tree-toggle-space {
    flex: none;
    inline-size: 1.75rem;
    block-size: 1.75rem;
}

.s-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

    .s-tree-toggle:focus-visible,
    .s-tree-main:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-tree-chevron {
    inline-size: 1rem;
    block-size: 1rem;
    transition: transform var(--s-duration);
}

.s-tree-toggle[aria-expanded="true"] .s-tree-chevron {
    transform: rotate(90deg);
}

:dir(rtl) .s-tree-chevron {
    transform: scaleX(-1);
}

:dir(rtl) .s-tree-toggle[aria-expanded="true"] .s-tree-chevron {
    transform: rotate(90deg);
}

.s-tree-main {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: var(--s-space-2);
    min-inline-size: 0;
    padding: var(--s-space-1);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    text-decoration: none;
}

a.s-tree-main,
button.s-tree-main {
    cursor: pointer;
}

.s-tree-trailing {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--s-space-1);
    padding-inline-end: var(--s-space-2);
}

@media (pointer: coarse) {
    .s-tree-row {
        min-block-size: 2.75rem;
    }

    .s-tree-toggle {
        inline-size: 2.5rem;
        block-size: 2.5rem;
    }
}

/* ------------------------------------------------------------------- slider */

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

.s-slider-value {
    margin-inline-start: auto;
    font-variant-numeric: tabular-nums;
    color: hsl(var(--muted-foreground));
}

.s-slider {
    inline-size: 100%;
    margin: 0;
    accent-color: hsl(var(--primary));
    cursor: pointer;
}

    .s-slider:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .s-slider:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

/* ------------------------------------------------------------ embedded video */

.s-embed {
    position: relative;
    overflow: hidden;
    inline-size: 100%;
    aspect-ratio: var(--s-embed-ratio, 16 / 9);
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--muted));
}

.s-embed-frame,
.s-embed-start {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    border: 0;
}

.s-embed-start {
    padding: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

    .s-embed-start:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-embed-poster {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
}

.s-embed-play {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    display: inline-flex;
    padding: var(--s-space-3);
    border-radius: 50%;
    background-color: hsl(var(--background) / 0.85);
    color: hsl(var(--foreground));
    box-shadow: var(--s-shadow-md);
    transform: translate(-50%, -50%);
}

    .s-embed-play > svg {
        inline-size: 1.5rem;
        block-size: 1.5rem;
    }

.s-embed-note {
    position: absolute;
    inset-block-end: var(--s-space-2);
    inset-inline-end: var(--s-space-2);
    max-inline-size: calc(100% - 2 * var(--s-space-2));
    padding: var(--s-space-1) var(--s-space-2);
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--background) / 0.85);
    color: hsl(var(--foreground));
    font-size: 0.75rem;
}

/* -------------------------------------------------------------- video player */

.s-video {
    position: relative;
    container-type: inline-size;
    inline-size: 100%;
}

.s-video-file {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    object-fit: contain;
}

    .s-video-file:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-video-failed {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: var(--s-space-3);
    text-align: center;
    color: hsl(var(--muted-foreground));
}

    .s-video-failed > p {
        margin: 0;
    }

.s-video-first-play {
    pointer-events: none;
}

.s-video[data-started] .s-video-first-play {
    display: none;
}

.s-video-cues {
    position: absolute;
    inset-inline: var(--s-space-3);
    inset-block-end: var(--s-space-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-space-1);
    text-align: center;
    pointer-events: none;
    transition: inset-block-end 400ms ease;
}

    .s-video-cues[hidden] {
        display: none;
    }

    .s-video-cues > span {
        padding: var(--s-space-1) var(--s-space-2);
        border-radius: var(--s-radius-sm);
        background-color: hsl(var(--background) / 0.85);
        color: hsl(var(--foreground));
        white-space: pre-line;
    }

/* Clear of the bar for as long as it is there. */
.s-video-always .s-video-cues,
.s-video-auto-hide:not([data-idle]) .s-video-cues {
    inset-block-end: 5.5rem;
}

.s-video-bar {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    box-sizing: border-box;
    padding: var(--s-space-2) var(--s-space-3);
    color: hsl(var(--foreground));
}

.s-video-auto-hide .s-video-bar,
.s-video-always .s-video-bar {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    padding-block-start: var(--s-space-6);
    border-end-start-radius: var(--s-radius-lg);
    border-end-end-radius: var(--s-radius-lg);
    background: linear-gradient(to top, hsl(var(--background) / 0.92) 60%, hsl(var(--background) / 0));
}

/* Quickly back, slowly away. */
.s-video-auto-hide .s-video-bar {
    transition: opacity 150ms ease;
}

.s-video-auto-hide[data-idle] {
    cursor: none;
}

    .s-video-auto-hide[data-idle] .s-video-bar {
        opacity: 0;
        pointer-events: none;
        transition: opacity 900ms ease;
    }

.s-video-below .s-embed {
    border-end-start-radius: 0;
    border-end-end-radius: 0;
}

.s-video-below .s-video-bar {
    border-end-start-radius: var(--s-radius-lg);
    border-end-end-radius: var(--s-radius-lg);
    background-color: hsl(var(--muted));
}

.s-video-buttons {
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
}

.s-video-spacer {
    flex: 1;
}

.s-video-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-inline-size: 2rem;
    block-size: 2rem;
    padding: 0 var(--s-space-1);
    border: 0;
    border-radius: var(--s-radius-md);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-video-button:hover,
        .s-video-menu-item:hover {
            background-color: hsl(var(--foreground) / 0.12);
        }
    }

    .s-video-button:active,
    .s-video-menu-item:active {
        background-color: hsl(var(--foreground) / 0.12);
    }

    .s-video-button > svg {
        inline-size: 1.25rem;
        block-size: 1.25rem;
    }

    .s-video-button:focus-visible,
    .s-video-menu-item:focus-visible,
    .s-video-position:focus-visible,
    .s-video-volume:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

.s-video-when-on,
.s-video[data-playing] .s-video-play > .s-video-when-off,
.s-video[data-muted] .s-video-mute > .s-video-when-off,
.s-video[data-fullscreen] .s-video-fullscreen > .s-video-when-off {
    display: none;
}

.s-video[data-playing] .s-video-play > .s-video-when-on,
.s-video[data-muted] .s-video-mute > .s-video-when-on,
.s-video[data-fullscreen] .s-video-fullscreen > .s-video-when-on {
    display: block;
}

.s-video-time {
    padding-inline: var(--s-space-1);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.s-video-position,
.s-video-volume {
    --s-video-fill: 0%;
    appearance: none;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

.s-video-position {
    inline-size: 100%;
    block-size: 1rem;
}

    .s-video-position:disabled {
        cursor: default;
    }

.s-video-volume {
    flex: 0 1 5rem;
    min-inline-size: 2.5rem;
    block-size: 2rem;
}

.s-video-position::-webkit-slider-runnable-track,
.s-video-volume::-webkit-slider-runnable-track {
    block-size: 0.25rem;
    border-radius: 999px;
    background: linear-gradient(to right, hsl(var(--primary)) var(--s-video-fill), hsl(var(--foreground) / 0.3) var(--s-video-fill));
}

.s-video-position::-moz-range-track,
.s-video-volume::-moz-range-track {
    block-size: 0.25rem;
    border-radius: 999px;
    background: linear-gradient(to right, hsl(var(--primary)) var(--s-video-fill), hsl(var(--foreground) / 0.3) var(--s-video-fill));
}

.s-video-position::-webkit-slider-thumb,
.s-video-volume::-webkit-slider-thumb {
    appearance: none;
    inline-size: 0.875rem;
    block-size: 0.875rem;
    margin-block-start: -0.3125rem;
    border-radius: 50%;
    background-color: hsl(var(--primary));
}

.s-video-position::-moz-range-thumb,
.s-video-volume::-moz-range-thumb {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    border: 0;
    border-radius: 50%;
    background-color: hsl(var(--primary));
}

.s-video-position:disabled::-webkit-slider-thumb {
    visibility: hidden;
}

.s-video-position:disabled::-moz-range-thumb {
    visibility: hidden;
}

.s-video-menu-holder {
    position: relative;
    display: inline-flex;
}

.s-video-menu {
    position: absolute;
    inset-block-end: calc(100% + var(--s-space-1));
    inset-inline-end: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-block-size: 12rem;
    overflow-y: auto;
    padding: var(--s-space-1);
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: var(--s-shadow-md);
}

    .s-video-menu[hidden] {
        display: none;
    }

.s-video-menu-item {
    flex: none;
    padding: var(--s-space-1) var(--s-space-3);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8125rem;
    text-align: start;
    white-space: nowrap;
    cursor: pointer;
}

    .s-video-menu-item[data-chosen] {
        font-weight: 600;
        color: hsl(var(--primary));
    }

/* The volume is the hardware's where there is no pointer, and a phone may not let a page change it anyway. */
@media (hover: none) {
    .s-video-volume {
        display: none;
    }
}

@container (max-width: 28rem) {
    .s-video-volume {
        display: none;
    }
}

@container (max-width: 18rem) {
    .s-video-total,
    .s-video-speed-holder {
        display: none;
    }
}

.s-video:fullscreen {
    display: flex;
    flex-direction: column;
    background-color: hsl(var(--background));
}

    .s-video:fullscreen .s-embed {
        flex: 1;
        min-block-size: 0;
        aspect-ratio: auto;
        border-radius: 0;
    }

    .s-video:fullscreen .s-video-bar {
        border-radius: 0;
    }

@media (prefers-reduced-motion: reduce) {
    .s-video-bar,
    .s-video-auto-hide[data-idle] .s-video-bar,
    .s-video-cues {
        transition: none;
    }
}

/* ------------------------------------------------------------ video gallery */

.s-video-gallery {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    inline-size: 100%;
}

.s-video-strip {
    display: flex;
    gap: var(--s-space-2);
    overflow-x: auto;
    padding-block-end: var(--s-space-1);
}

.s-video-strip-item {
    flex: none;
    display: grid;
    place-items: center;
    inline-size: 5rem;
    aspect-ratio: 16 / 9;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: var(--s-radius-md);
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    font: inherit;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-video-strip-item:hover {
            color: hsl(var(--foreground));
        }
    }

    .s-video-strip-item:active {
        color: hsl(var(--foreground));
    }

    .s-video-strip-item:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

    .s-video-strip-item > img {
        inline-size: 100%;
        block-size: 100%;
        object-fit: cover;
    }

.s-video-strip-active {
    border-color: hsl(var(--primary));
    color: hsl(var(--foreground));
}

.s-video-strip-number {
    font-size: var(--s-text-sm, 0.875rem);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ video cue list */

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

.s-cue-line {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    inline-size: 100%;
    box-sizing: border-box;
    padding: var(--s-space-1) var(--s-space-2);
    border: 0;
    border-radius: var(--s-radius-md);
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: var(--s-text-sm-line, 1.5);
    text-align: start;
}

.s-cue-seek {
    cursor: pointer;
}

    @media (hover: hover) {
        .s-cue-seek:hover {
            background-color: hsl(var(--muted) / 0.6);
        }
    }

    .s-cue-seek:active {
        background-color: hsl(var(--muted) / 0.6);
    }

    @media (hover: hover) {
        .s-cue-seek:hover .s-cue-time {
            text-decoration: underline;
        }
    }

    .s-cue-seek:active .s-cue-time {
        text-decoration: underline;
    }

    .s-cue-seek:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-cue-number {
    flex: none;
    display: inline-grid;
    place-items: center;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    margin-block-start: 0.125rem;
    border-radius: 50%;
    background-color: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    font-size: 0.75rem;
    font-weight: 500;
}

.s-cue-text {
    flex: 1;
    min-inline-size: 0;
}

.s-cue-time {
    margin-inline-start: 0.25em;
    color: hsl(var(--muted-foreground));
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- separator */

.s-separator {
    margin-block: var(--s-space-3);
    border: 0;
    border-block-start: 1px solid hsl(var(--border));
}

.s-separator-vertical {
    display: inline-block;
    align-self: stretch;
    min-block-size: 1em;
    margin: 0 var(--s-space-2);
    border-block-start: 0;
    border-inline-start: 1px solid hsl(var(--border));
    vertical-align: middle;
}

.s-separator-text {
    display: flex;
    align-items: center;
    gap: var(--s-space-3);
    border: 0;
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

    .s-separator-text::before,
    .s-separator-text::after {
        content: "";
        flex: 1 1 0;
        border-block-start: 1px solid hsl(var(--border));
    }

/* --------------------------------------------------------------- grid selection */

.s-grid-select {
    inline-size: 2.5rem;
    line-height: 0;
}

.s-grid-table tbody tr.s-grid-row-selected {
    background-color: hsl(var(--muted) / 0.8);
}

.s-grid-row-clickable {
    cursor: pointer;
}

/* Inside the row, as a table clips what is drawn outside its rows. */
.s-grid-row-clickable:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

/* ------------------------------------------------------------- field selector */

.s-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: var(--s-space-3);
    align-items: stretch;
    min-block-size: 16rem;
}

.s-fields-pane {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    min-inline-size: 0;
    padding: var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    transition: border-color 0.1s ease, background-color 0.1s ease;
}

    .s-fields-pane.s-fields-drop {
        border-color: hsl(var(--ring));
        background-color: hsl(var(--accent) / 0.3);
    }

.s-fields-heading {
    margin: 0;
    padding-inline: var(--s-space-1);
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
}

.s-fields-list {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-block-size: 0;
    max-block-size: 24rem;
    overflow-y: auto;
}

.s-fields-row {
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
    min-block-size: 2.25rem;
    padding-inline: var(--s-space-1);
    border-radius: var(--s-radius-md);
    cursor: grab;
}

    @media (hover: hover) {
        .s-fields-row:hover {
            background-color: hsl(var(--accent) / 0.5);
        }
    }

    .s-fields-row .s-field {
        flex: 1 1 auto;
        min-inline-size: 0;
    }

/* Where a dragged field will land: a line above the row it is over. */
.s-fields-drop-before {
    box-shadow: inset 0 2px 0 hsl(var(--ring));
}

.s-fields-part {
    padding-inline-start: var(--s-space-4);
}

.s-fields-toggle,
.s-fields-toggle-space {
    flex: none;
    inline-size: 1.5rem;
    block-size: 1.5rem;
}

.s-fields-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: var(--s-radius-md);
    background: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

    .s-fields-toggle:disabled {
        opacity: 0.3;
        cursor: default;
    }

    .s-fields-toggle:focus-visible {
        outline: 2px solid hsl(var(--ring));
    }

    .s-fields-toggle > svg {
        transition: transform 0.15s ease;
    }

    .s-fields-toggle[aria-expanded="true"] > svg {
        transform: rotate(90deg);
    }

[dir="rtl"] .s-fields-toggle[aria-expanded="false"] > svg,
[dir="rtl"] .s-fields-move-across svg {
    transform: scaleX(-1);
}

.s-fields-parent {
    flex: 1 1 auto;
    color: hsl(var(--muted-foreground));
}

.s-fields-required {
    display: inline-flex;
    color: hsl(var(--muted-foreground));
}

.s-fields-empty {
    margin: 0;
    padding: var(--s-space-3) var(--s-space-2);
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.s-fields-moves {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--s-space-2);
}

/* On a phone the lists are stacked and the buttons between them turn a quarter, to point down and up. */
@media (max-width: 39.99rem) {
    .s-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .s-fields-moves {
        flex-direction: row;
        justify-content: center;
    }

        .s-fields-moves .s-fields-move-across svg {
            transform: rotate(90deg);
        }

    .s-fields-row {
        cursor: default;
    }
}

@media (prefers-reduced-motion: reduce) {
    .s-fields-pane,
    .s-fields-toggle > svg {
        transition: none;
    }
}

/* ------------------------------------------------- grid actions, groups, editing */

.s-grid-actions {
    inline-size: 1%;
    padding-block: 0;
    text-align: end;
    white-space: nowrap;
}

.s-grid-edit-buttons {
    display: inline-flex;
    gap: var(--s-space-1);
}

.s-grid-table tbody tr.s-grid-row-editing {
    background-color: hsl(var(--accent) / 0.35);
}

    .s-grid-row-editing > .s-grid-td {
        padding-block: var(--s-space-1);
    }

/* An editor fills its cell rather than sizing it: an input's own width (twenty characters) would widen every column
   of the table the moment a row is edited. A percentage width gives a table cell no minimum to grow to. */
.s-grid-td .s-field {
    margin: 0;
}

.s-grid-row-editing .s-input {
    inline-size: 100%;
    min-inline-size: 3rem;
}

.s-grid-editor {
    display: block;
}

.s-grid-edit-error td {
    padding: var(--s-space-1) var(--s-space-4) var(--s-space-2);
    color: hsl(var(--destructive));
    font-size: 0.875rem;
}

.s-grid-table tbody tr.s-grid-group {
    background-color: hsl(var(--muted) / 0.7);
}

.s-grid-group-cell {
    padding: 0;
    border-block-end: 1px solid hsl(var(--border));
}

.s-grid-group-toggle {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    inline-size: 100%;
    padding: var(--s-space-2) var(--s-space-4);
    padding-inline-start: calc(var(--s-space-3) + var(--s-grid-group-level, 0) * 1.25rem);
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

    .s-grid-group-toggle:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-grid-group-chevron {
    flex: none;
    transition: transform 0.15s ease;
}

.s-grid-group-toggle[aria-expanded="true"] .s-grid-group-chevron {
    transform: rotate(90deg);
}

[dir="rtl"] .s-grid-group-toggle[aria-expanded="false"] .s-grid-group-chevron {
    transform: scaleX(-1);
}

.s-grid-group-title {
    color: hsl(var(--muted-foreground));
}

    .s-grid-group-title::after {
        content: ":";
    }

.s-grid-group-value {
    font-weight: 600;
}

.s-grid-group-continued,
.s-grid-group-count {
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
}

.s-grid-group-count {
    margin-inline-start: auto;
    font-variant-numeric: tabular-nums;
}

.s-grid-dense .s-grid-group-toggle {
    padding-block: var(--s-space-1);
}

/* Shown when the grid can group: what it is grouped by, as chips to remove, and the columns to add. */
.s-grid-groupbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-2);
    min-block-size: 2.25rem;
}

.s-grid-groupbar-label {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.s-grid-groupbar-end {
    display: inline-flex;
    gap: var(--s-space-1);
    margin-inline-start: auto;
}

@media (prefers-reduced-motion: reduce) {
    .s-grid-group-chevron {
        transition: none;
    }
}

/* ------------------------------------------------------ page column */

/* A page's column, centred, with the gutter at its sides: as wide as readable text by default, as wide as the display type
   allows (--s-page-max-width) for a page of overviews or columns (.s-page-wide). */
.s-page {
    box-sizing: border-box;
    inline-size: 100%;
    max-inline-size: min(var(--s-page-max-width), calc(var(--s-readable-width) + 2 * var(--s-page-gutter)));
    margin-inline: auto;
    padding-inline: var(--s-page-gutter);
}

.s-page-wide {
    max-inline-size: var(--s-page-max-width);
}

/* Text read or acted on, within a wider page: no wider than lines stay easy to follow. */
.s-readable {
    max-inline-size: var(--s-readable-width);
}

/* Cards to scan: as many columns as fit at --s-card-min-width (SCardGrid's MinWidth), one on a narrow screen. */
.s-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--s-card-min-width)), 1fr));
    gap: var(--s-space-3);
}

/* SPageColumns: one column below a desktop; from it the main part at the readable width and the side part taking the rest,
   at least --s-aside-min-width, so that a wide screen widens the side and not the lines. */
.s-page-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-space-6);
    align-items: start;
}

.s-page-columns-main,
.s-page-columns-aside {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

@media (min-width: 64rem) {
    .s-page-columns {
        grid-template-columns: minmax(0, var(--s-readable-width)) minmax(var(--s-aside-min-width), 1fr);
    }
}

/* Shown only below a desktop, or only from one: for a part a desktop puts elsewhere, drawn in both places. */
@media (min-width: 64rem) {
    .s-below-desktop {
        display: none !important;
    }
}

@media (max-width: 63.99rem) {
    .s-from-desktop {
        display: none !important;
    }
}

/* ------------------------------------------------------ action card, count card */

/* A to-do row: icon, title and why, then its actions and a ⋮ menu. Titles in the heading font when the app sets one. */
.s-action-card {
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-3);
    padding: var(--s-space-4);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
}

.s-action-card-icon {
    flex: none;
    display: inline-flex;
    padding-block-start: 0.125rem;
    color: hsl(var(--muted-foreground));
}

.s-action-card-body {
    flex: 1 1 auto;
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

/* One line, cut off: the description under it says the rest, and the card keeps its height on a phone. */
.s-action-card-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--s-font-heading, inherit);
    font-size: var(--s-text-sm);
    line-height: var(--s-text-sm-line);
    font-weight: 600;
    letter-spacing: -0.025em;
}

.s-action-card-description {
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    color: hsl(var(--muted-foreground));
}

.s-action-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-1);
    margin-block-start: 0.375rem;
}

.s-action-card-actions {
    flex: none;
    align-self: center;
    display: flex;
    align-items: center;
    gap: var(--s-space-1);
}

/* The ⋮ beside the action: square and muted, so the action stays the thing to press. */
.s-action-card-actions .s-menu-trigger {
    inline-size: 2rem;
    block-size: 2rem;
    padding: 0;
    color: hsl(var(--muted-foreground));
}

/* How many new things since last time: the count in the accent colour, where, what, and a link to them. */
.s-count-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    block-size: 100%;
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
}

.s-count-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
}

.s-count-card-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 2rem;
    block-size: 1.75rem;
    padding-inline: var(--s-space-2);
    border-radius: 9999px;
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    font-size: var(--s-text-xs);
    font-weight: 600;
}

.s-count-card-category {
    display: inline-flex;
    align-items: center;
    gap: var(--s-space-1);
    min-inline-size: 0;
    overflow: hidden;
    color: hsl(var(--muted-foreground));
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    letter-spacing: 0.025em;
    text-transform: uppercase;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.s-count-card-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-family: var(--s-font-heading, inherit);
    font-size: var(--s-text-sm);
    line-height: 1.25;
    font-weight: 600;
}

.s-count-card-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-block-start: auto;
}

.s-count-card-description {
    overflow: hidden;
    color: hsl(var(--muted-foreground));
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.s-count-card-action {
    display: flex;
    align-items: center;
    block-size: 1.75rem;
    padding-inline: var(--s-space-2);
    border: none;
    border-radius: var(--s-radius-md);
    background: transparent;
    color: hsl(var(--s-count-card-link, var(--accent)));
    font: inherit;
    font-size: var(--s-text-sm);
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--s-duration);
}

    @media (hover: hover) {
        .s-count-card-action:hover {
            background-color: hsl(var(--s-count-card-link, var(--accent)) / 0.1);
        }
    }

    .s-count-card-action:active {
        background-color: hsl(var(--s-count-card-link, var(--accent)) / 0.1);
    }

    .s-count-card-action:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

/* ------------------------------------------------------ stat tile, fact grid */

.s-stat {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
    padding: var(--s-space-4);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    font: inherit;
    text-align: start;
    text-decoration: none;
}

.s-stat-interactive {
    cursor: pointer;
    transition: border-color var(--s-duration), transform var(--s-duration);
}

    @media (hover: hover) {
        .s-stat-interactive:hover {
            border-color: hsl(var(--muted-foreground) / 0.5);
        }
    }

    .s-stat-interactive:active {
        border-color: hsl(var(--muted-foreground) / 0.5);
    }

    .s-stat-interactive:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 2px;
    }

.s-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
}

.s-stat-label,
.s-fact-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-stat-icon {
    display: inline-flex;
    color: hsl(var(--muted-foreground));
}

.s-stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
}

.s-stat-delta {
    display: inline-flex;
    gap: var(--s-space-1);
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.s-stat-delta-up {
    color: hsl(var(--success));
}

.s-stat-delta-down {
    color: hsl(var(--destructive));
}

.s-stat-period {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.s-facts {
    display: grid;
    grid-template-columns: repeat(var(--s-facts-columns, 3), minmax(0, 1fr));
    gap: var(--s-space-4);
    margin: 0;
    padding: var(--s-space-4);
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--muted) / 0.4);
}

.s-fact {
    min-inline-size: 0;
}

.s-fact-value {
    margin: var(--s-space-1) 0 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

@media (max-width: 47.99rem) {
    .s-facts {
        grid-template-columns: repeat(min(var(--s-facts-columns, 3), 2), minmax(0, 1fr));
    }
}

/* ----------------------------------------------------------------- sidebar */

/* The whole collapse behaviour is two custom properties and a media query. No component measures
   anything, so the layout is correct in the first prerendered frame rather than after a round trip
   to the browser and back. */
.s-sidebar-layout {
    --s-sidebar-width: 16rem;
    --s-sidebar-rail-width: 3.25rem;
    display: flex;
    align-items: stretch;
    min-block-size: 100%;
    inline-size: 100%;
}

.s-sidebar {
    display: flex;
    flex-direction: column;
    flex: none;
    inline-size: var(--s-sidebar-width);
    /* A flex item defaults to min-inline-size:auto, which refuses to shrink below the widest
       nowrap thing inside - the header wordmark, an item label. Without this the sidebar simply
       ignores the rail width when it collapses. */
    min-inline-size: 0;
    background-color: hsl(var(--sidebar-background, var(--card)));
    color: hsl(var(--sidebar-foreground, var(--card-foreground)));
    border-inline-end: 1px solid hsl(var(--sidebar-border, var(--border)));
    overflow: hidden;
    /* Transitions the physical width, not inline-size: Chrome does not settle a transition on the
       logical property, leaving the rail stuck at the expanded width. Everything else here stays
       logical - only the animated property has to be physical. */
    transition: width var(--s-duration) ease, transform var(--s-duration) ease;
}

.s-sidebar-header,
.s-sidebar-footer {
    flex: none;
    padding: var(--s-space-3);
    min-block-size: 3.5rem;
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    white-space: nowrap;
}

.s-sidebar-header {
    border-block-end: 1px solid hsl(var(--sidebar-border, var(--border)));
}

.s-sidebar-footer {
    border-block-start: 1px solid hsl(var(--sidebar-border, var(--border)));
}

.s-sidebar-content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--s-space-2);
    display: flex;
    flex-direction: column;
    gap: var(--s-space-4);
}

.s-sidebar-group-label {
    padding: var(--s-space-1) var(--s-space-2);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: hsl(var(--sidebar-foreground, var(--muted-foreground)) / 0.65);
    white-space: nowrap;
}

.s-sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.s-sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    inline-size: 100%;
    min-block-size: 2.25rem;
    padding-inline: var(--s-space-2);
    border: 0;
    border-radius: var(--s-radius-sm);
    background-color: transparent;
    color: inherit;
    font-family: inherit;
    font-size: var(--s-font-size);
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--s-duration), color var(--s-duration);
}

@media (hover: hover) {
    .s-sidebar-item:hover {
        background-color: hsl(var(--sidebar-accent, var(--accent)) / 0.5);
    }
}

.s-sidebar-item:active {
    background-color: hsl(var(--sidebar-accent, var(--accent)) / 0.5);
}

.s-sidebar-item:focus-visible {
    outline: 2px solid hsl(var(--sidebar-ring, var(--ring)));
    outline-offset: -2px;
}

.s-sidebar-item-active {
    background-color: hsl(var(--sidebar-accent, var(--accent)));
    color: hsl(var(--sidebar-primary, var(--accent-foreground)));
    font-weight: 500;
}

.s-sidebar-item-disabled,
.s-sidebar-item:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.s-sidebar-item-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 1.25rem;
    block-size: 1.25rem;
}

.s-sidebar-item-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.s-sidebar-item-end {
    flex: none;
    display: inline-flex;
    align-items: center;
}

/* trigger */
.s-sidebar-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    flex: none;
    border: 0;
    border-radius: var(--s-radius-sm);
    background-color: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color var(--s-duration);
}

@media (hover: hover) {
    .s-sidebar-trigger:hover {
        background-color: hsl(var(--accent) / 0.5);
    }
}

.s-sidebar-trigger:active {
    background-color: hsl(var(--accent) / 0.5);
}

.s-sidebar-trigger:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Three bars from one element: the middle bar is the box itself and the other two are absolutely
   positioned pseudo-elements. Cheaper than an SVG, and it inherits currentColor for free. */
.s-sidebar-trigger-glyph,
.s-sidebar-trigger-glyph::before,
.s-sidebar-trigger-glyph::after {
    display: block;
    inline-size: 1rem;
    block-size: 2px;
    border-radius: 1px;
    background-color: currentColor;
}

.s-sidebar-trigger-glyph {
    position: relative;
}

.s-sidebar-trigger-glyph::before,
.s-sidebar-trigger-glyph::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
}

.s-sidebar-trigger-glyph::before {
    inset-block-start: -5px;
}

.s-sidebar-trigger-glyph::after {
    inset-block-start: 5px;
}

/* The scrim only exists below the breakpoint; the media query at the end reveals it. */
.s-sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    background-color: hsl(0 0% 0% / 0.4);
}

/* ------------------------------------------------ sidebar: collapsed, wide */

/* A rail: the icons stay, everything that needs width goes. The labels are hidden with clip-path
   rather than display:none so they stay in the accessibility tree - a collapsed sidebar loses its
   labels on screen, not to a screen reader. */
.s-sidebar-collapsed .s-sidebar-rail {
    inline-size: var(--s-sidebar-rail-width);
}

.s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item-text,
.s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item-end,
.s-sidebar-collapsed .s-sidebar-rail .s-sidebar-group-label {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item {
    justify-content: center;
    padding-inline: 0;
}

/* Without a rail there is nothing useful left at zero width, so it leaves the layout entirely. */
.s-sidebar-collapsed .s-sidebar:not(.s-sidebar-rail) {
    inline-size: 0;
    border-inline-end-width: 0;
}

/* -------------------------------------------- sidebar: narrow screens */

/* Below the breakpoint the sidebar stops taking part in the layout and overlays the page, because
   16rem out of a phone is most of the page. The same Expanded flag now means "on screen" rather
   than "full width", which is why the component needs no second piece of state. */
@media (max-width: 47.99rem) {
    .s-sidebar-layout .s-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 40;
        inline-size: var(--s-sidebar-width);
        border-inline-end-width: 1px;
    }

    .s-sidebar-collapsed .s-sidebar {
        transform: translateX(-100%);
    }

    /* The rail rules above must not apply here - a phone gets the whole panel or none of it. */
    .s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item-text,
    .s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item-end,
    .s-sidebar-collapsed .s-sidebar-rail .s-sidebar-group-label {
        position: static;
        inline-size: auto;
        block-size: auto;
        margin: 0;
        overflow: visible;
        clip-path: none;
    }

    .s-sidebar-collapsed .s-sidebar-rail .s-sidebar-item {
        justify-content: flex-start;
        padding-inline: var(--s-space-2);
    }

    .s-sidebar-expanded .s-sidebar-scrim {
        display: block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .s-sidebar {
        transition: none;
    }
}

/* ---------------------------------------------------------------------------
   SCalendar
   Grids all the way down and nothing measured in JavaScript. A month row and
   the all-day row are CSS grids whose bars span their days with grid-column;
   the time grid places blocks absolutely in a day column from the minutes the
   layout worked out. Item colours come in through --s-cal-color, an HSL
   triplet as for chips, so the alphas live here.
   --------------------------------------------------------------------------- */

.s-cal {
    --s-cal-color: var(--primary);
    --s-cal-gutter: 3.5rem;
    --s-cal-bar-height: 1.25rem;
    --s-cal-weeknum-width: 2rem;
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
    inline-size: 100%;
    color: hsl(var(--foreground));
}

.s-cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-2) var(--s-space-4);
}

/* clip rather than hidden: hidden would make this the scroll container, and the time grid's sticky header would
   then stick to a box that never scrolls instead of to the page. */
.s-cal-body {
    position: relative;
    overflow: clip;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
}

.s-cal-loading {
    position: absolute;
    inset-block-start: var(--s-space-2);
    inset-inline-end: var(--s-space-2);
    z-index: 3;
    padding: var(--s-space-1) var(--s-space-2);
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

.s-cal-clickable {
    cursor: pointer;
}

/* ------------------------------------------------------------ calendar: items */

.s-cal-item {
    display: flex;
    align-items: baseline;
    gap: var(--s-space-1);
    min-inline-size: 0;
    overflow: hidden;
    padding-inline: var(--s-space-1);
    border-inline-start: 3px solid hsl(var(--s-cal-color));
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--s-cal-color) / 0.14);
    color: hsl(var(--card-foreground));
    font-size: 0.75rem;
    line-height: var(--s-cal-bar-height);
    white-space: nowrap;
}

    @media (hover: hover) {
        .s-cal-item.s-cal-clickable:hover {
            background-color: hsl(var(--s-cal-color) / 0.24);
        }
    }

    .s-cal-item.s-cal-clickable:active {
        background-color: hsl(var(--s-cal-color) / 0.24);
    }

    .s-cal-item:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

.s-cal-item-title {
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.s-cal-item-time {
    flex: none;
    color: hsl(var(--muted-foreground));
    font-variant-numeric: tabular-nums;
}

.s-cal-item-bar {
    align-self: start;
    block-size: var(--s-cal-bar-height);
    margin: 1px 2px;
}

/* A bar cut off at a row's edge loses its corners and stripe on that side, so it reads as going on. */
.s-cal-item-bar.s-cal-item-before {
    border-inline-start-width: 0;
    border-start-start-radius: 0;
    border-end-start-radius: 0;
    margin-inline-start: 0;
}

.s-cal-item-bar.s-cal-item-after {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
    margin-inline-end: 0;
}

.s-cal-item-block {
    position: absolute;
    z-index: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block: 0.125rem;
    line-height: 1rem;
    white-space: normal;
    /* A ring in the column's colour, so blocks side by side or end to end stay apart. */
    box-shadow: 0 0 0 1px hsl(var(--card));
}

    /* Wrapped between words only: a word too long for a narrow block is cut off with an ellipsis rather than split. */
    .s-cal-item-block .s-cal-item-title {
        flex: none;
    }

.s-cal-item-block.s-cal-item-before {
    border-start-start-radius: 0;
    border-start-end-radius: 0;
}

.s-cal-item-block.s-cal-item-after {
    border-end-start-radius: 0;
    border-end-end-radius: 0;
}

.s-cal-item-agenda {
    padding: var(--s-space-1) var(--s-space-2);
    font-size: var(--s-font-size);
    line-height: 1.4;
    white-space: normal;
}

/* ------------------------------------------------------------ calendar: month */

.s-cal-weekdays,
.s-cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.s-cal-month-weeknumbers .s-cal-weekdays,
.s-cal-month-weeknumbers .s-cal-week {
    grid-template-columns: var(--s-cal-weeknum-width) repeat(7, minmax(0, 1fr));
}

/* A quiet strip down the left, the number level with the dates. */
.s-cal-weeknum,
.s-cal-weeknum-head {
    background-color: hsl(var(--muted) / 0.45);
}

/* Flex, because a button centres its content vertically otherwise, and the number belongs level with the dates. */
.s-cal-weeknum {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    grid-column: 1;
    grid-row: 1 / -1;
    padding: var(--s-space-1) 0 0;
    border: none;
    color: hsl(var(--muted-foreground));
    font: inherit;
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.5rem;
    text-align: center;
}

button.s-cal-weeknum {
    cursor: pointer;
}

    @media (hover: hover) {
        button.s-cal-weeknum:hover {
            background-color: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

    button.s-cal-weeknum:active {
        background-color: hsl(var(--accent));
        color: hsl(var(--accent-foreground));
    }

    button.s-cal-weeknum:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: -2px;
    }

.s-cal-weekdays {
    border-block-end: 1px solid hsl(var(--border));
}

.s-cal-weekday {
    overflow: hidden;
    padding: var(--s-space-2) var(--s-space-1);
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.s-cal-week {
    min-block-size: 6.5rem;
    border-block-end: 1px solid hsl(var(--border));
}

    .s-cal-week:last-child {
        border-block-end: none;
    }

/* The cells fill their whole column behind the dates and bars, which come later in the markup and so paint on top. */
.s-cal-day {
    grid-row: 1 / -1;
    border-inline-start: 1px solid hsl(var(--border));
}

    .s-cal-week > .s-cal-day:first-child {
        border-inline-start: none;
    }

    .s-cal-day.s-cal-day-outside {
        background-color: hsl(var(--muted) / 0.45);
    }

    .s-cal-day.s-cal-day-today {
        background-color: hsl(var(--accent) / 0.6);
    }

    @media (hover: hover) {
        .s-cal-day.s-cal-clickable:hover {
            background-color: hsl(var(--accent) / 0.8);
        }
    }

    .s-cal-day.s-cal-clickable:active {
        background-color: hsl(var(--accent) / 0.8);
    }

.s-cal-date {
    grid-row: 1;
    justify-self: start;
    min-inline-size: 1.5rem;
    block-size: 1.5rem;
    margin: var(--s-space-1);
    padding-inline: 0.25rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8125rem;
    line-height: 1.5rem;
    text-align: center;
}

button.s-cal-date {
    cursor: pointer;
}

    @media (hover: hover) {
        button.s-cal-date:hover {
            background-color: hsl(var(--accent));
        }
    }

    button.s-cal-date:active {
        background-color: hsl(var(--accent));
    }

.s-cal-date.s-cal-day-outside {
    color: hsl(var(--muted-foreground));
}

.s-cal-date.s-cal-date-today {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-weight: 600;
}

@media (hover: hover) {
    button.s-cal-date.s-cal-date-today:hover {
        background-color: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
        font-weight: 600;
    }
}

button.s-cal-date.s-cal-date-today:active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-weight: 600;
}

.s-cal-more {
    align-self: start;
    justify-self: start;
    margin-inline: var(--s-space-1);
    padding-inline: var(--s-space-1);
    border: none;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--muted-foreground));
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: var(--s-cal-bar-height);
}

button.s-cal-more {
    cursor: pointer;
}

    @media (hover: hover) {
        button.s-cal-more:hover {
            background-color: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

    button.s-cal-more:active {
        background-color: hsl(var(--accent));
        color: hsl(var(--accent-foreground));
    }

/* -------------------------------------------------------- calendar: time grid */

.s-cal-tg-head,
.s-cal-tg-allday,
.s-cal-tg-body {
    display: grid;
    grid-template-columns: var(--s-cal-gutter) repeat(var(--s-cal-days), minmax(0, 1fr));
}

.s-cal-tg-head {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    border-block-end: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
}

.s-cal-tg-dayhead {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    min-inline-size: 0;
    padding-block: var(--s-space-2);
    border-inline-start: 1px solid hsl(var(--border));
}

.s-cal-tg-dayopen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0 var(--s-space-2);
    border: none;
    border-radius: var(--s-radius-md);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

    @media (hover: hover) {
        .s-cal-tg-dayopen:hover {
            background-color: hsl(var(--accent));
        }
    }

    .s-cal-tg-dayopen:active {
        background-color: hsl(var(--accent));
    }

.s-cal-tg-dayname {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 500;
}

.s-cal-tg-daynum {
    min-inline-size: 2rem;
    block-size: 2rem;
    border-radius: 999px;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 2rem;
    text-align: center;
}

.s-cal-tg-dayhead.s-cal-day-today .s-cal-tg-daynum {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.s-cal-tg-allday {
    padding-block: 0.125rem;
    border-block-end: 1px solid hsl(var(--border));
}

.s-cal-tg-allday-label {
    grid-column: 1;
    align-self: center;
    padding-inline: var(--s-space-1) var(--s-space-2);
    color: hsl(var(--muted-foreground));
    font-size: 0.6875rem;
    text-align: end;
}

.s-cal-tg-gutter {
    position: relative;
    grid-column: 1;
}

.s-cal-tg-hour {
    position: absolute;
    inset-inline: 0;
    padding-block-start: 0.125rem;
    padding-inline-end: var(--s-space-2);
    color: hsl(var(--muted-foreground));
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-align: end;
}

/* Hour lines, and fainter half-hour lines, as the column's background rather than as elements. */
.s-cal-tg-col {
    position: relative;
    border-inline-start: 1px solid hsl(var(--border));
    background-image:
        linear-gradient(to bottom, hsl(var(--border)) 1px, transparent 1px),
        linear-gradient(to bottom, hsl(var(--border) / 0.45) 1px, transparent 1px);
    background-size:
        100% var(--s-cal-hour-height),
        100% calc(var(--s-cal-hour-height) / 2);
}

    .s-cal-tg-col.s-cal-day-today {
        background-color: hsl(var(--accent) / 0.5);
    }

/* --------------------------------------------------------- calendar: agenda */

.s-cal-agenda-day {
    display: grid;
    grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr);
    gap: var(--s-space-3);
    padding: var(--s-space-3) var(--s-space-4);
    border-block-end: 1px solid hsl(var(--border));
}

    .s-cal-agenda-day:last-child {
        border-block-end: none;
    }

.s-cal-agenda-date {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    align-self: start;
    gap: 0.125rem;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
}

button.s-cal-agenda-date {
    cursor: pointer;
}

    @media (hover: hover) {
        button.s-cal-agenda-date:hover .s-cal-agenda-monthday {
            text-decoration: underline;
        }
    }

    button.s-cal-agenda-date:active .s-cal-agenda-monthday {
        text-decoration: underline;
    }

.s-cal-agenda-dayname {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 500;
}

.s-cal-agenda-monthday {
    font-weight: 600;
}

.s-cal-agenda-day.s-cal-day-today .s-cal-agenda-dayname,
.s-cal-agenda-day.s-cal-day-today .s-cal-agenda-monthday {
    color: hsl(var(--primary));
}

.s-cal-agenda-items {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.s-cal-agenda-row {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    align-items: center;
    gap: var(--s-space-2);
}

.s-cal-agenda-time {
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.s-cal-empty {
    margin: 0;
    padding: var(--s-space-6);
    color: hsl(var(--muted-foreground));
    text-align: center;
}

/* ------------------------------------------------ calendar: narrow screens */

@media (max-width: 39.99rem) {
    .s-cal {
        --s-cal-gutter: 2.75rem;
        --s-cal-weeknum-width: 1.5rem;
    }

    /* A month cell is a seventh of a phone: the title is worth more than the time there. */
    .s-cal-month .s-cal-item-time {
        display: none;
    }

    .s-cal-agenda-day {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--s-space-2);
        padding-inline: var(--s-space-3);
    }

    .s-cal-agenda-row {
        grid-template-columns: 6.5rem minmax(0, 1fr);
    }
}

/* ---------------------------------------------------------------------------
   Overlays: SDialog, SPopover, SMenu, STooltip
   Everything floats in the browser's top layer, so there are no z-indexes to
   win here. Which form an overlay takes on which screen is decided by the
   media queries below and nowhere else; the JavaScript module asks the CSS
   (--s-overlay-sheet) rather than measuring the screen itself.
   --------------------------------------------------------------------------- */

html:has(.s-dialog:modal, .s-popover:modal) {
    overflow: hidden;
}

.s-dialog,
.s-popover {
    box-sizing: border-box;
    color: hsl(var(--popover-foreground));
    background-color: hsl(var(--popover));
    font-family: var(--s-font-sans);
    font-size: var(--s-font-size);
    box-shadow: var(--s-shadow-md);
}

.s-dialog::backdrop {
    background-color: hsl(0 0% 0% / 0.4);
}

/* With nothing inside to focus, the browser focuses the overlay itself; that is not a place to show a ring. */
.s-dialog:focus-visible,
.s-popover:focus-visible {
    outline: none;
}

/* A panel is a <dialog> too, and browsers dim behind those by default. Only its phone sheet should. */
.s-popover::backdrop {
    background-color: transparent;
}

/* ------------------------------------------------------------------- dialog */

.s-dialog {
    --s-dialog-size: 32rem;
    --s-dialog-enter: translateY(0.5rem);

    padding: 0;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    max-inline-size: none;
    max-block-size: none;
    overflow: hidden;
}

/* Only while open: display on the bare class would show a closed dialog. */
.s-dialog[open] {
    display: flex;
    transition: opacity var(--s-duration), transform var(--s-duration);
}

@starting-style {
    .s-dialog[open] {
        opacity: 0;
        transform: var(--s-dialog-enter);
    }
}

.s-dialog-small { --s-dialog-size: 24rem; }
.s-dialog-large { --s-dialog-size: 48rem; }

/* Fills the <dialog>, so that a click on the <dialog> itself can only be its backdrop. */
.s-dialog-surface {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-inline-size: 0;
    min-block-size: 0;
}

.s-dialog-handle {
    display: none;
    flex: none;
    inline-size: 2.5rem;
    block-size: 0.25rem;
    margin: var(--s-space-2) auto 0;
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--border));
}

.s-dialog-header {
    flex: none;
    padding: var(--s-space-4) var(--s-space-4) 0;
    padding-inline-end: calc(var(--s-space-4) + 2rem);
}

.s-dialog-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.s-dialog-description {
    margin: var(--s-space-1) 0 0;
    color: hsl(var(--muted-foreground));
}

.s-dialog-body {
    flex: 1;
    min-block-size: 0;
    padding: var(--s-space-4);
    overflow-y: auto;
}

/* Header and footer keep their distance by themselves when there is no body to do it. */
.s-dialog-header:has(+ .s-dialog-footer) {
    padding-block-end: var(--s-space-4);
}

.s-dialog-footer {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--s-space-2);
    padding: 0 var(--s-space-4) var(--s-space-4);
}

.s-dialog-close {
    position: absolute;
    inset-block-start: var(--s-space-2);
    inset-inline-end: var(--s-space-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2rem;
    block-size: 2rem;
    padding: 0;
    border: 0;
    border-radius: var(--s-radius-md);
    color: hsl(var(--muted-foreground));
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

@media (hover: hover) {
    .s-dialog-close:hover {
        color: hsl(var(--accent-foreground));
        background-color: hsl(var(--accent));
    }
}

.s-dialog-close:active {
    color: hsl(var(--accent-foreground));
    background-color: hsl(var(--accent));
}

.s-dialog-close:focus-visible,
.s-dialog-option:focus-visible,
.s-menu-item:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -2px;
}

.s-dialog-options {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-dialog-option {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    inline-size: 100%;
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    color: inherit;
    background: transparent;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

@media (hover: hover) {
    .s-dialog-option:hover {
        background-color: hsl(var(--accent));
    }
}

.s-dialog-option:active {
    background-color: hsl(var(--accent));
}

.s-dialog-option-text {
    font-weight: 500;
}

.s-dialog-option-description {
    color: hsl(var(--muted-foreground));
}

.s-dialog-option-destructive .s-dialog-option-text {
    color: hsl(var(--destructive));
}

/* ------------------------------------------------- dialog: the keyboard
   An on-screen keyboard covers the bottom of the screen without the page
   getting smaller (iOS, Chrome on Android). The module says what it leaves
   (--s-keyboard-inset, --s-visible-top, --s-visible-block-size; see the
   keyboard in subro.overlays.js), and every overlay stays within that: a
   sheet sits on the keyboard, a dialog is centred in what is left, and none
   is taller. Without a keyboard they are 0 and 100dvh, which changes nothing. */

:root {
    --s-overlay-max-block-size: min(85dvh, calc(var(--s-visible-block-size, 100dvh) - var(--s-space-4)));
}

:root[data-s-keyboard] .s-dialog:modal {
    inset-block: var(--s-visible-top, 0px) var(--s-keyboard-inset, 0px);
}

@media (max-width: 47.99rem) {
    :root[data-s-keyboard] .s-popover-sheet {
        inset-block: auto var(--s-keyboard-inset, 0px);
        padding-block-end: var(--s-space-3);
    }

    /* The keyboard covers the safe area at the bottom too. */
    :root[data-s-keyboard] .s-dialog-phone-bottom,
    :root[data-s-keyboard] .s-dialog-phone-full {
        padding-block-end: 0;
    }
}

/* ------------------------------------------- dialog: where it sits, wide */

@media (min-width: 48rem) {
    .s-dialog-at-center {
        inline-size: min(var(--s-dialog-size), calc(100vw - 2 * var(--s-space-4)));
        max-block-size: var(--s-overlay-max-block-size);
        margin: auto;
    }

    .s-dialog-at-bottom {
        --s-dialog-enter: translateY(100%);

        inline-size: min(var(--s-dialog-size), 100vw);
        max-block-size: var(--s-overlay-max-block-size);
        margin: auto auto 0;
        border-end-start-radius: 0;
        border-end-end-radius: 0;
    }

    .s-dialog-at-bottom .s-dialog-handle {
        display: block;
    }

    .s-dialog-at-top {
        --s-dialog-enter: translateY(-100%);

        inline-size: min(var(--s-dialog-size), 100vw);
        max-block-size: var(--s-overlay-max-block-size);
        margin: 0 auto auto;
        border-start-start-radius: 0;
        border-start-end-radius: 0;
    }

    .s-dialog-at-right {
        --s-dialog-enter: translateX(100%);

        inline-size: min(var(--s-dialog-size), 100vw);
        block-size: var(--s-visible-block-size, 100dvh);
        max-block-size: var(--s-visible-block-size, 100dvh);
        margin: 0;
        margin-inline-start: auto;
        border-radius: 0;
    }

    .s-dialog-at-full {
        inline-size: 100vw;
        block-size: var(--s-visible-block-size, 100dvh);
        max-block-size: var(--s-visible-block-size, 100dvh);
        margin: 0;
        border: 0;
        border-radius: 0;
    }
}

/* ------------------------------------------ dialog: where it sits, phone */

@media (max-width: 47.99rem) {
    .s-dialog-phone-center {
        inline-size: calc(100vw - 2 * var(--s-space-4));
        max-block-size: var(--s-overlay-max-block-size);
        margin: auto;
    }

    .s-dialog-phone-bottom {
        --s-dialog-enter: translateY(100%);

        inline-size: 100vw;
        max-block-size: var(--s-overlay-max-block-size);
        margin: auto 0 0;
        padding-block-end: env(safe-area-inset-bottom);
        border-end-start-radius: 0;
        border-end-end-radius: 0;
    }

    .s-dialog-phone-bottom .s-dialog-handle {
        display: block;
    }

    .s-dialog-phone-top {
        --s-dialog-enter: translateY(-100%);

        inline-size: 100vw;
        max-block-size: var(--s-overlay-max-block-size);
        margin: 0 0 auto;
        padding-block-start: env(safe-area-inset-top);
        border-start-start-radius: 0;
        border-start-end-radius: 0;
    }

    .s-dialog-phone-right {
        --s-dialog-enter: translateX(100%);

        inline-size: min(var(--s-dialog-size), 100vw);
        block-size: var(--s-visible-block-size, 100dvh);
        max-block-size: var(--s-visible-block-size, 100dvh);
        margin: 0;
        margin-inline-start: auto;
        border-radius: 0;
    }

    .s-dialog-phone-full {
        inline-size: 100vw;
        block-size: var(--s-visible-block-size, 100dvh);
        max-block-size: var(--s-visible-block-size, 100dvh);
        margin: 0;
        padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
        border: 0;
        border-radius: 0;
    }

    /* Thumbs: the actions share the width. */
    .s-dialog-footer > * {
        flex: 1;
    }
}

/* ------------------------------------------------------------------ popover */

.s-popover-host {
    display: inline-flex;
    vertical-align: middle;
}

.s-popover-trigger {
    display: inline-flex;
}

.s-popover {
    position: fixed;
    inset: auto;
    margin: var(--s-space-1);
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    inline-size: max-content;
    max-inline-size: min(22rem, calc(100vw - 2 * var(--s-space-4)));
    max-block-size: calc(var(--s-visible-block-size, 100dvh) - 2 * var(--s-space-4));
    overflow: auto;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
}

.s-popover-at-bottomstart { position-area: block-end span-inline-end; }
.s-popover-at-bottomend { position-area: block-end span-inline-start; }
.s-popover-at-bottom { position-area: block-end; justify-self: anchor-center; }
.s-popover-at-topstart { position-area: block-start span-inline-end; }
.s-popover-at-topend { position-area: block-start span-inline-start; }
.s-popover-at-top { position-area: block-start; justify-self: anchor-center; }
.s-popover-at-start { position-area: inline-start; align-self: anchor-center; }
.s-popover-at-end { position-area: inline-end; align-self: anchor-center; }

/* At least as wide as what opens it, as a menu under a switcher (SMenu.TriggerWidth); the module does the same where the
   browser lacks anchor positioning. */
.s-popover-trigger-width {
    min-inline-size: max(var(--s-popover-min-width, 0px), anchor-size(inline));
    margin-inline: 0;
}

/* In the size of the trigger's text (SMenu.TriggerTextSize): the module measures it as the panel opens. */
.s-popover-trigger-text {
    font-size: var(--s-popover-font-size, var(--s-font-size));
}

/* Set by the module where the browser lacks anchor positioning: it writes left and top itself. */
.s-popover-placed {
    margin: 0;
    position-area: none;
    position-try-fallbacks: none;
}

@media (max-width: 47.99rem) {
    .s-popover-sheet {
        --s-overlay-sheet: 1;

        inset: auto 0 0;
        inline-size: 100vw;
        max-inline-size: none;
        max-block-size: var(--s-overlay-max-block-size);
        margin: 0;
        padding-block-end: calc(var(--s-space-3) + env(safe-area-inset-bottom));
        border-width: 1px 0 0;
        border-radius: var(--s-radius-lg) var(--s-radius-lg) 0 0;
        position-area: none;
        position-try-fallbacks: none;
    }

    .s-popover-sheet::backdrop {
        background-color: hsl(0 0% 0% / 0.4);
    }

    /* The grab handle, as on a bottom sheet. */
    .s-popover-sheet::before {
        content: "";
        display: block;
        inline-size: 2.5rem;
        block-size: 0.25rem;
        margin: 0 auto var(--s-space-2);
        border-radius: var(--s-radius-sm);
        background-color: hsl(var(--border));
    }

    /* A sheet is not next to its trigger, so it keeps the usual size. */
    .s-popover-sheet.s-popover-trigger-text {
        font-size: var(--s-font-size);
    }

    /* Thumbs: an action sheet's rows are finger-sized. */
    .s-popover-sheet .s-menu-item {
        min-block-size: 2.75rem;
    }
}

/* --------------------------------------------------------------------- menu */

.s-menu {
    --s-popover-min-width: 11rem;

    min-inline-size: var(--s-popover-min-width);
    padding: var(--s-space-1);
}

.s-menu.s-popover-trigger-width {
    min-inline-size: max(var(--s-popover-min-width), anchor-size(inline));
}

.s-menu-trigger {
    padding-inline: var(--s-space-2);
}

/* What a long press opens a menu on (SContextMenu, subro.overlays.js): on a touch screen the press is the menu's, so it
   starts no text selection and shows no callout of the system's, such as iOS's link preview. */
@media (pointer: coarse) {
    [data-s-context-menu] {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

.s-menu-item {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    inline-size: 100%;
    padding: var(--s-space-2);
    border: 0;
    border-radius: var(--s-radius-sm);
    color: inherit;
    background: transparent;
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}

.s-menu-item:focus:not(:disabled) {
    color: hsl(var(--accent-foreground));
    background-color: hsl(var(--accent));
}

@media (hover: hover) {
    .s-menu-item:hover:not(:disabled) {
        color: hsl(var(--accent-foreground));
        background-color: hsl(var(--accent));
    }
}

.s-menu-item:active:not(:disabled) {
    color: hsl(var(--accent-foreground));
    background-color: hsl(var(--accent));
}

.s-menu-item:focus:not(:focus-visible) {
    outline: none;
}

.s-menu-item:disabled {
    cursor: not-allowed;
}

/* Faded, but not the line under it, which may say why it cannot be chosen: a touch screen shows no tooltip. */
.s-menu-item:disabled > .s-menu-item-icon,
.s-menu-item:disabled .s-menu-item-text,
.s-menu-item:disabled > .s-menu-item-check {
    opacity: 0.5;
}

.s-menu-item-destructive,
.s-menu-item-destructive:focus:not(:disabled) {
    color: hsl(var(--destructive));
}

@media (hover: hover) {
    .s-menu-item-destructive:hover:not(:disabled) {
        color: hsl(var(--destructive));
    }
}

.s-menu-item-destructive:active:not(:disabled) {
    color: hsl(var(--destructive));
}

.s-menu-item-icon {
    display: inline-flex;
    flex: none;
}

.s-menu-item-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-inline-size: 0;
}

.s-menu-item-description {
    color: hsl(var(--muted-foreground));
    font-size: calc(0.75em / 0.875);
}

.s-menu-item-check {
    flex: none;
    margin-inline-start: var(--s-space-3);
}

.s-menu-separator {
    block-size: 1px;
    margin: var(--s-space-1) calc(-1 * var(--s-space-1));
    background-color: hsl(var(--border));
}

.s-menu-label {
    padding: var(--s-space-1) var(--s-space-2);
    color: hsl(var(--muted-foreground));
    font-size: calc(0.75em / 0.875);
    font-weight: 600;
}

/* ------------------------------------------------------------------ tooltip */

.s-tooltip-host {
    position: relative;
    display: inline-flex;
}

.s-tooltip {
    position: absolute;
    z-index: 50;
    inline-size: max-content;
    max-inline-size: 16rem;
    padding: var(--s-space-1) var(--s-space-2);
    border-radius: var(--s-radius-sm);
    color: hsl(var(--primary-foreground));
    background-color: hsl(var(--primary));
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    text-align: start;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--s-duration);
}

/* Only where hovering exists: a tap on a touch screen would otherwise leave it standing. */
@media (hover: hover) {
    .s-tooltip-host:hover > .s-tooltip {
        visibility: visible;
        opacity: 1;
    }
}

.s-tooltip-wide > .s-tooltip {
    max-inline-size: 28rem;
}

.s-tooltip-host:has(:focus-visible) > .s-tooltip {
    visibility: visible;
    opacity: 1;
}

/* Without anchor positioning: against the content, where an overflow: hidden can clip it. */
.s-tooltip-at-top > .s-tooltip { inset-block-end: calc(100% + var(--s-space-1)); inset-inline-start: 50%; translate: -50% 0; }
.s-tooltip-at-bottom > .s-tooltip { inset-block-start: calc(100% + var(--s-space-1)); inset-inline-start: 50%; translate: -50% 0; }
.s-tooltip-at-start > .s-tooltip { inset-inline-end: calc(100% + var(--s-space-1)); inset-block-start: 50%; translate: 0 -50%; }
.s-tooltip-at-end > .s-tooltip { inset-inline-start: calc(100% + var(--s-space-1)); inset-block-start: 50%; translate: 0 -50%; }

/* With it: fixed to the viewport, so nothing around it clips it, and flipped when it does not fit. */
@supports (anchor-name: --a) and (position-area: block-end) {
    .s-tooltip-host {
        position: static;
    }

    .s-tooltip {
        position: fixed;
        margin: var(--s-space-1);
        position-try-fallbacks: flip-block, flip-inline;
    }

    .s-tooltip-at-top > .s-tooltip { inset: auto; translate: none; position-area: block-start; justify-self: anchor-center; }
    .s-tooltip-at-bottom > .s-tooltip { inset: auto; translate: none; position-area: block-end; justify-self: anchor-center; }
    .s-tooltip-at-start > .s-tooltip { inset: auto; translate: none; position-area: inline-start; align-self: anchor-center; }
    .s-tooltip-at-end > .s-tooltip { inset: auto; translate: none; position-area: inline-end; align-self: anchor-center; }
}

/* ==============================================================================
   Messages: toasts and heads-ups, in the top layer as manual popovers.
   The regions let everything through but their cards. A phone is the same
   media query as the overlays; --s-message-bottom is what an app has fixed along
   the bottom of a phone, its bottom nav.
   ============================================================================== */

.s-messages-live {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.s-messages {
    position: fixed;
    inset: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    overflow: visible;
    color: inherit;
    pointer-events: none;
    inline-size: min(24rem, calc(100vw - 2 * var(--s-space-4)));
}

.s-messages:popover-open {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-messages-toast {
    inset-block-end: calc(var(--s-space-4) + env(safe-area-inset-bottom));
    inset-inline-end: var(--s-space-4);
}

.s-messages-headsup {
    inset-block-start: calc(var(--s-space-4) + env(safe-area-inset-top));
    inset-inline-end: var(--s-space-4);
}

/* Above an on-screen keyboard, which covers whatever the app has along the bottom as well. In a phone's dialog they are at
   the top already. */
:root[data-s-keyboard] .s-messages-toast:not(.s-messages-in-dialog) {
    inset-block-end: calc(var(--s-space-2) + var(--s-keyboard-inset, 0px));
}

@media (max-width: 47.99rem) {
    .s-messages {
        inset-inline: var(--s-space-2);
        inline-size: auto;
    }

    .s-messages-toast {
        inset-block-end: calc(var(--s-space-2) + var(--s-message-bottom, 0px) + env(safe-area-inset-bottom));
    }

    .s-messages-headsup {
        inset-block-start: calc(var(--s-space-2) + env(safe-area-inset-top));
    }

    /* A sheet has its buttons at the bottom. */
    .s-messages-toast.s-messages-in-dialog {
        inset-block: calc(var(--s-space-2) + env(safe-area-inset-top)) auto;
    }
}

.s-message {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
    padding: var(--s-space-3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: var(--s-shadow-md);
    font-family: var(--s-font-sans);
    font-size: var(--s-font-size);
    pointer-events: auto;
    animation: s-message-rise var(--s-duration) ease-out;
}

.s-messages-headsup .s-message {
    animation-name: s-message-drop;
}

@keyframes s-message-rise {
    from { opacity: 0; translate: 0 var(--s-space-2); }
}

@keyframes s-message-drop {
    from { opacity: 0; translate: 0 calc(-1 * var(--s-space-4)); }
}

.s-message-icon {
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    line-height: 1.25rem;
    text-align: center;
    font-weight: 600;
}

.s-message-success > .s-message-icon { color: hsl(var(--success)); }
.s-message-info > .s-message-icon { color: hsl(var(--info)); }
.s-message-warning > .s-message-icon { color: hsl(var(--warning)); }
.s-message-error > .s-message-icon { color: hsl(var(--destructive)); }

.s-message-content {
    flex: 1;
    min-inline-size: 0;
}

.s-message-texts,
.s-message-open {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.s-message-open {
    inline-size: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.s-message-open:focus-visible,
.s-message-close:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
    border-radius: var(--s-radius-sm);
}

.s-message-title {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.s-message-text {
    color: hsl(var(--muted-foreground));
    overflow-wrap: anywhere;
}

.s-messages-headsup .s-message-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.s-message-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-2);
    margin-block-start: var(--s-space-2);
}

.s-message-count {
    flex: none;
    min-inline-size: 1.25rem;
    padding-inline: var(--s-space-1);
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    line-height: 1.25rem;
    text-align: center;
}

.s-message-close {
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    padding: 0;
    border: 0;
    background: none;
    color: hsl(var(--muted-foreground));
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

/* ==============================================================================
   Timers. The digits are of one width, so that a number stands still while it
   changes. Which form shows depends on how the screen is held, and the digits'
   size on the room there is (cqi), so prerendering needs no idea of the screen.
   ============================================================================== */

.s-counter {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.s-counter-label {
    margin-block-start: 0.25em;
    color: hsl(var(--muted-foreground));
    font-size: var(--s-font-size);
    font-weight: 500;
}

.s-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--s-time-size, 1em);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.s-time-digits {
    display: inline-flex;
    align-items: flex-start;
    justify-content: center;
}

.s-time-lone {
    font-size: calc(1em * var(--s-time-lone-scale, 1.7));
}

/* The colour of the digits, a little less of it, so that it also holds for a block's colour. A colon is drawn for lower case, so it
   sits low beside digits. Raised by what that comes to in Segoe UI, Roboto, Arial and San Francisco alike. */
.s-time-separator {
    opacity: var(--s-time-separator-opacity, 0.6);
    translate: 0 calc(-1 * var(--s-time-separator-raise, 0.1em));
}

/* A beat a second from when the class comes, which is as the number changes, so that they stay in step. */
.s-time-pulse {
    animation: s-time-pulse 1s ease-out infinite;
}

@keyframes s-time-pulse {
    from {
        transform: scale(var(--s-time-pulse-scale, 1.08));
    }

    to {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .s-time-pulse {
        animation: none;
    }
}

.s-time-landscape {
    display: none;
}

@media (orientation: landscape) {
    .s-time-portrait {
        display: none;
    }

    .s-time-landscape {
        display: inline-flex;
    }
}

.s-segments {
    display: flex;
    gap: var(--s-space-1);
    inline-size: 100%;
}

.s-segment {
    flex: 1;
    min-inline-size: 0;
    block-size: var(--s-segment-height, 1.75rem);
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
    transition: background-color var(--s-duration);
}

.s-segment-on {
    background-color: var(--s-segment-color, hsl(var(--primary)));
}

.s-timer-next {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-size: var(--s-font-size);
    font-weight: 500;
}

.s-timer-blocks {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.s-timer-block {
    display: inline-flex;
    gap: var(--s-space-1);
    padding: var(--s-space-1) var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.s-timer-block-current {
    border-color: hsl(var(--s-timer-color, var(--primary)));
    color: hsl(var(--s-timer-color, var(--primary)));
    font-weight: 600;
}

.s-timer-block-done {
    opacity: 0.5;
}

/* The colours to theme: --s-timer-work and --s-timer-pause by kind, as bare HSL like the other tokens. A kind of an application's own sets
   --s-timer-color under its class. The urgency colours only reach the bar, as the digits keep saying what kind of time it is. */
.s-timer,
.s-timer-kind-work {
    --s-timer-color: var(--s-timer-work, var(--primary));
}

.s-timer-kind-pause {
    --s-timer-color: var(--s-timer-pause, var(--info));
}

.s-timer {
    --s-time-size: min(26cqi, 8.25rem);
    --s-time-lone-scale: 1.73;

    container-type: inline-size;
    position: relative;
    display: flex;
    flex-direction: column;
    block-size: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.s-timer:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.s-timer .s-segments {
    --s-segment-color: hsl(var(--s-timer-color));
}

.s-timer-urgency-warning .s-segments {
    --s-segment-color: hsl(var(--s-timer-warning, var(--warning)));
}

.s-timer-urgency-caution .s-segments {
    --s-segment-color: hsl(var(--s-timer-caution));
}

.s-timer-urgency-danger .s-segments {
    --s-segment-color: hsl(var(--s-timer-danger, var(--destructive)));
}

.s-timer-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-4);
    min-inline-size: 0;
    padding: var(--s-space-4) var(--s-space-6);
}

.s-timer-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-4);
    inline-size: 100%;
    max-inline-size: 36rem;
}

.s-timer-tappable {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* The room of the largest form, so that nothing around it moves when the minutes go. */
.s-timer-face .s-time {
    min-block-size: calc(1em * var(--s-time-lone-scale));
    color: hsl(var(--s-timer-color));
}

.s-timer-paused .s-time {
    opacity: 0.6;
}

.s-timer-label {
    margin: 0;
    color: hsl(var(--s-timer-color));
    font-size: var(--s-font-size);
    font-weight: 700;
    letter-spacing: 0.35em;
    text-transform: uppercase;
}

.s-timer-round {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-size: 0.6875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.s-timer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-2);
}

.s-timer-start {
    min-inline-size: 9rem;
}

.s-timer-mute {
    position: absolute;
    z-index: 1;
    inset-block-start: var(--s-space-4);
    inset-inline-end: var(--s-space-4);
}

.s-timer-aside {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 var(--s-space-4) var(--s-space-6);
}

.s-timer-icon {
    flex: none;
    inline-size: 1.125rem;
    block-size: 1.125rem;
}

.s-timer-adjust {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

.s-timer-adjust-actions {
    display: flex;
    gap: var(--s-space-2);
}

.s-timer-adjust-resume {
    flex: 1;
}

.s-timer-stepper {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    padding: var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-md);
}

.s-timer-stepper-label {
    flex: 1;
    min-inline-size: 0;
    color: hsl(var(--muted-foreground));
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.s-timer-stepper-value {
    min-inline-size: 3.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

@media (orientation: landscape) {
    .s-timer {
        --s-time-size: min(30vh, 11rem, 22cqi);
        flex-direction: row;
    }

    .s-timer-mute {
        inset-inline: var(--s-space-4) auto;
    }

    .s-timer-aside {
        flex: none;
        justify-content: center;
        margin-block: var(--s-space-6);
        padding: 0 var(--s-space-4);
        border-inline-start: 1px solid hsl(var(--border));
        overflow-y: auto;
    }

    .s-timer-has-mute .s-timer-main {
        padding-inline-start: 4.5rem;
    }
}

/* ==============================================================================
   Translations: the keys of an audit, where each stands per language, and the form
   to write one in.
   ============================================================================== */

.s-translation-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--s-space-3);
    padding: var(--s-space-3) var(--s-space-4);
}

.s-translation-search {
    min-inline-size: 18rem;
}

.s-translation-toggles {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
}

/* A name to read, not something to click. */
.s-translation-key {
    color: hsl(var(--foreground));
    font-weight: 500;
    overflow-wrap: break-word;
}

.s-translation-note,
.s-translation-caption,
.s-translation-count {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

.s-translation-note {
    margin-block-start: 0.125rem;
}

.s-translation-caption {
    margin-block-end: var(--s-space-1);
    font-weight: 500;
}

.s-translation-count {
    margin: 0;
    padding: var(--s-space-3) var(--s-space-4);
}

.s-translation-text {
    max-inline-size: 32rem;
    white-space: pre-line;
}

/* The theme's pairs rather than a colour on a tint of itself: dark themes make --destructive too dark to read as text. */
.s-translation-warning,
.s-text-context-undefined {
    color: hsl(var(--destructive-foreground));
    background-color: hsl(var(--destructive));
}

.s-translation-warning {
    padding: 0.0625rem 0.375rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.s-translation-states,
.s-text-context-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-1);
}

.s-translation-state {
    padding: 0.0625rem 0.375rem;
    border: 0;
    border-radius: 999px;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted));
    font: inherit;
    font-size: 0.75rem;
}

button.s-translation-state {
    cursor: pointer;
}

button.s-translation-state:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 1px;
}

@media (hover: hover) {
    button.s-translation-state:hover {
        box-shadow: inset 0 0 0 1px currentColor;
    }
}

button.s-translation-state:active {
    box-shadow: inset 0 0 0 1px currentColor;
}

.s-translation-state-current {
    color: hsl(var(--success-foreground));
    background-color: hsl(var(--success));
}

.s-translation-state-missing,
.s-translation-state-invalid {
    color: hsl(var(--destructive-foreground));
    background-color: hsl(var(--destructive));
}

.s-translation-state-stale {
    color: hsl(var(--warning-foreground, 38 92% 10%));
    background-color: hsl(var(--warning));
}

.s-translation-editor {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

.s-translation-source {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
    padding: var(--s-space-3);
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
}

.s-translation-form {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

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

.s-text-context-select {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

/* ==============================================================================
   Feedback log
   ============================================================================== */

.s-feedback {
    display: flex;
    flex-direction: column;
    inline-size: 100%;
    gap: var(--s-space-2);
}

.s-feedback-title {
    font-weight: 600;
}

/* The scrolling element, which Virtualize watches. Its height is --s-feedback-height. */
.s-feedback-rows {
    max-block-size: var(--s-feedback-height, 24rem);
    overflow-y: auto;
    font-size: 0.875rem;
}

.s-feedback-row {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    min-block-size: 1.75rem;
}

.s-feedback-toggle,
.s-feedback-toggle-space {
    flex: none;
    inline-size: 1.25rem;
    block-size: 1.25rem;
}

.s-feedback-toggle {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.s-feedback-toggle svg {
    display: block;
    transition: transform 120ms;
}

.s-feedback-toggle[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

.s-feedback-text {
    flex: 1 1 0;
    min-inline-size: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.s-feedback-level {
    flex: none;
    padding: 0.0625rem 0.375rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.s-feedback-warning > .s-feedback-row > .s-feedback-level {
    box-shadow: inset 0 0 0 1px hsl(var(--warning));
}

.s-feedback-error > .s-feedback-row > .s-feedback-level {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.s-feedback-detail > .s-feedback-row > .s-feedback-text {
    color: hsl(var(--muted-foreground));
}

.s-feedback-progress {
    flex: 0 1 8rem;
}

.s-feedback-count,
.s-feedback-duration,
.s-feedback-time {
    flex: none;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.s-feedback-children {
    padding-inline-start: 1.25rem;
}

.s-feedback-error-details {
    margin: 0 0 var(--s-space-2) 1.75rem;
    padding: var(--s-space-2);
    overflow-x: auto;
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
    font-size: 0.75rem;
}

.s-feedback-empty {
    margin: 0;
    color: hsl(var(--muted-foreground));
}

/* ==============================================================================
   Errors: SErrorPanel, SErrorDetails, SErrorReportForm, SErrorReportList
   ============================================================================== */

.s-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-2);
}

.s-error-panel-details {
    margin-block-start: var(--s-space-2);
}

.s-error-details {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    min-inline-size: 0;
    font-size: 0.8125rem;
}

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

.s-error-details-title {
    min-inline-size: 0;
}

.s-error-details code,
.s-error-source {
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 0.75rem;
}

.s-error-type {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.s-error-message {
    margin: var(--s-space-1) 0 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.s-error-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--s-space-1) var(--s-space-3);
    margin: 0;
}

.s-error-facts dt {
    color: hsl(var(--muted-foreground));
}

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

.s-error-comment {
    white-space: pre-wrap;
}

.s-error-heading {
    margin: var(--s-space-2) 0 0;
    font-weight: 600;
}

.s-error-where {
    display: block;
    overflow-wrap: anywhere;
}

.s-error-source {
    margin: 0;
    padding: var(--s-space-2) 0;
    overflow-x: auto;
    border-radius: var(--s-radius-sm);
    background-color: hsl(var(--muted));
}

.s-error-source-line {
    display: block;
    padding-inline-end: var(--s-space-2);
    white-space: pre;
}

.s-error-source-current {
    background-color: hsl(var(--destructive) / 0.15);
}

.s-error-source-number {
    display: inline-block;
    inline-size: 4ch;
    margin-inline-end: var(--s-space-2);
    padding-inline-end: var(--s-space-1);
    text-align: end;
    color: hsl(var(--muted-foreground));
    user-select: none;
}

.s-error-frames {
    margin: 0;
    padding-inline-start: 0;
    list-style: none;
}

.s-error-frames ol {
    margin: var(--s-space-1) 0 0;
    padding-inline-start: var(--s-space-4);
    list-style: none;
}

.s-error-frame {
    padding-block: 0.125rem;
    overflow-wrap: anywhere;
}

.s-error-frame-external,
.s-error-frame-external code {
    color: hsl(var(--muted-foreground));
}

.s-error-frame-external summary {
    cursor: pointer;
}

.s-error-inner {
    padding-inline-start: var(--s-space-3);
    border-inline-start: 2px solid hsl(var(--border));
}

.s-error-report {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

.s-error-report-contents {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
}

.s-error-report-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-space-2);
}

.s-error-report-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-error-report-group-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-space-2);
    margin-block-end: var(--s-space-2);
}

/* ==============================================================================
   Run control
   ============================================================================== */

.s-run-control {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-run-heading,
.s-run-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-2);
}

.s-run-name {
    font-weight: 600;
}

/* ==============================================================================
   Sign-in pages
   ============================================================================== */

/* Tabs that are links */
a.s-tab {
    text-decoration: none;
}

/* From the top rather than centred: a form of another height, or an error, must not move what is above it. */
.s-signin-page {
    box-sizing: border-box;
    display: grid;
    justify-items: center;
    align-items: start;
    /* dvh: a phone's 100vh is the screen with its browser bars gone, taller than what shows while they are there. The space
       above is of the smallest the screen gets (svh), so the form does not move as the bars come and go. */
    min-block-size: 100dvh;
    margin: 0;
    padding: clamp(var(--s-space-4), 8svh, 5rem) var(--s-space-4) var(--s-space-4);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: var(--s-font-sans);
    font-size: var(--s-font-size);
}

    .s-signin-page main {
        inline-size: min(24rem, 100%);
    }

    /* The script shows these once it knows the browser can use passkeys; flex and grid would show them regardless. */
    .s-signin-page [hidden] {
        display: none !important;
    }

.s-signin-card .s-card-header {
    align-items: center;
    text-align: center;
}

.s-signin-card .s-card-content,
.s-signin-form,
.s-signin-providers {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-4);
}

.s-signin-providers {
    gap: var(--s-space-2);
}

.s-signin-logo {
    display: block;
    block-size: 4rem;
    inline-size: auto;
    margin-block-end: var(--s-space-2);
}

.s-signin-title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 600;
}

.s-signin-description,
.s-signin-empty {
    margin: 0;
    font-size: 0.875rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.s-signin-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-space-2);
    margin: 0;
    font-size: 0.875rem;
}

    .s-signin-links a {
        color: hsl(var(--primary));
    }

.s-signin-who {
    margin: 0;
    text-align: center;
    font-weight: 600;
}

.s-signin-passkeys {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .s-signin-passkeys li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--s-space-4);
        padding-block: var(--s-space-3);
        border-block-end: 1px solid hsl(var(--border));
    }

    .s-signin-passkeys small {
        display: block;
        font-size: 0.75rem;
        color: hsl(var(--muted-foreground));
    }

.s-alert-text p {
    margin: 0;
}

.s-provider svg {
    inline-size: 1rem;
    block-size: 1rem;
}

.s-provider-vipps {
    border-color: #ff5b24;
    background-color: #ff5b24;
    color: #fff;
}

@media (hover: hover) {
    .s-provider-vipps:hover {
        border-color: #ff5b24;
        background-color: #ff5b24;
        color: #fff;
    }
}

.s-provider-vipps:active {
    border-color: #ff5b24;
    background-color: #ff5b24;
    color: #fff;
}

.s-input-code {
    block-size: 3rem;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    text-align: center;
}

.s-password-toggle {
    display: inline-flex;
    padding: var(--s-space-1);
    border: 0;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

    @media (hover: hover) {
        .s-password-toggle:hover {
            color: hsl(var(--foreground));
        }
    }

    .s-password-toggle:active {
        color: hsl(var(--foreground));
    }

    .s-password-toggle:focus-visible {
        outline: 2px solid hsl(var(--ring));
    }

    .s-password-toggle svg {
        inline-size: 1.125rem;
        block-size: 1.125rem;
    }

    .s-password-toggle .s-password-hide,
    .s-password-toggle[aria-pressed="true"] .s-password-show {
        display: none;
    }

    .s-password-toggle[aria-pressed="true"] .s-password-hide {
        display: block;
    }

/* ------------------------------------------------------------ formatted text */

/* What FormattedText holds, shown alike in a message and in the editor that wrote it. */
.s-text-content h2,
.s-editor-area h2 {
    margin-block: var(--s-space-3) var(--s-space-2);
    font-size: 1.35em;
    font-weight: 600;
    line-height: 1.25;
    white-space: normal;
}

.s-text-content h3,
.s-editor-area h3 {
    margin-block: var(--s-space-3) var(--s-space-1);
    font-size: 1.12em;
    font-weight: 600;
    line-height: 1.3;
    white-space: normal;
}

.s-text-content blockquote,
.s-editor-area blockquote {
    margin: 0 0 var(--s-space-2);
    padding-inline-start: var(--s-space-3);
    border-inline-start: 3px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
    white-space: normal;
}

.s-text-content code,
.s-editor-area code {
    padding: 0.1em 0.3em;
    border-radius: var(--s-radius-sm, 0.25rem);
    background-color: hsl(var(--muted));
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 0.9em;
}

.s-text-content > :first-child,
.s-editor-area > :first-child {
    margin-block-start: 0;
}

.s-text-content > :last-child {
    margin-block-end: 0;
}

/* ------------------------------------------------------------ editor */

.s-input-wrap.s-editor {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
}

.s-editor-body {
    position: relative;
    display: flex;
    align-items: flex-end;
}

.s-editor-area {
    --s-editor-padding: var(--s-space-2);
    position: relative;
    box-sizing: border-box;
    flex: 1 1 auto;
    min-inline-size: 0;
    padding: var(--s-editor-padding) var(--s-space-3);
    color: hsl(var(--foreground));
    line-height: 1.4;
    overflow-wrap: anywhere;
    overflow-y: auto;
    outline: none;
}

.s-editor-area p,
.s-editor-area ul,
.s-editor-area ol {
    margin-block: 0 var(--s-space-2);
}

.s-editor-area ul,
.s-editor-area ol {
    padding-inline-start: 1.25rem;
}

.s-editor-area a {
    color: hsl(var(--primary));
    text-decoration: underline;
}

.s-editor-area:empty::before,
.s-editor-area.s-editor-empty::before {
    content: attr(data-placeholder);
    position: absolute;
    inset-inline-start: var(--s-space-3);
    inset-block-start: var(--s-editor-padding);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

/* It grows with its text between its rows and its largest, as a text area does. */
.s-editor-grow .s-editor-area {
    min-block-size: calc(var(--s-editor-rows, 3) * 1.4em + 2 * var(--s-editor-padding));
    max-block-size: calc(var(--s-editor-max-rows, 1000) * 1.4em + 2 * var(--s-editor-padding));
}

.s-editor:not(.s-editor-grow) .s-editor-area {
    block-size: calc(var(--s-editor-rows, 3) * 1.4em + 2 * var(--s-editor-padding));
    resize: vertical;
}

.s-editor-focus-grow .s-editor-area {
    --s-editor-rest: calc(var(--s-editor-rows, 3) * 1.4em + 2 * var(--s-editor-padding));
    transition: min-block-size var(--s-duration) ease 200ms;
}

.s-editor-focus-grow:focus-within .s-editor-area {
    min-block-size: max(var(--s-editor-rest), min(calc(var(--s-editor-focus-rows, var(--s-editor-rows, 3)) * 1.4em + 2 * var(--s-editor-padding)), 30dvh));
    transition-delay: 0s;
}

@media (max-width: 47.99rem) {
    .s-editor-focus-grow:focus-within .s-editor-area {
        min-block-size: max(var(--s-editor-rest), min(calc(var(--s-editor-phone-focus-rows, var(--s-editor-rows, 3)) * 1.4em + 2 * var(--s-editor-padding)), 30dvh));
    }
}

.s-input-disabled.s-editor .s-editor-area {
    cursor: not-allowed;
    opacity: 0.6;
}

.s-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: var(--s-space-1);
    border-block-end: 1px solid hsl(var(--border));
}

.s-editor-toolbar-separator {
    inline-size: 1px;
    block-size: 1.25rem;
    margin-inline: var(--s-space-1);
    background-color: hsl(var(--border));
}

.s-editor-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-inline-size: 2rem;
    block-size: 2rem;
    padding: 0 var(--s-space-1);
    border: 0;
    border-radius: var(--s-radius-sm, 0.25rem);
    background: none;
    color: hsl(var(--foreground));
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

@media (hover: hover) {
    .s-editor-tool:hover:not(:disabled) {
        background-color: hsl(var(--accent));
        color: hsl(var(--accent-foreground));
    }
}

.s-editor-tool:active:not(:disabled) {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.s-editor-tool:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 1px;
}

.s-editor-tool[aria-pressed="true"],
.s-editor-toolbar-toggle[aria-expanded="true"] {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.s-editor-tool:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.s-editor-tool-caret {
    opacity: 0.6;
}

.s-editor-toolbar-toggle {
    flex: none;
    margin: 0 var(--s-space-1) calc((2.5rem - 2px - 2rem) / 2) 0;
    font-size: 0.85rem;
}

.s-editor-menu-h2 {
    font-size: 1.2em;
    font-weight: 600;
}

.s-editor-menu-h3 {
    font-weight: 600;
}

.s-editor-swatch-panel {
    padding: var(--s-space-2);
}

.s-editor-swatch-none {
    display: block;
    inline-size: 100%;
    margin-block-end: var(--s-space-2);
    padding: var(--s-space-1) var(--s-space-2);
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-sm, 0.25rem);
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.s-editor-swatches {
    display: grid;
    grid-template-columns: repeat(6, 1.75rem);
    gap: var(--s-space-1);
}

.s-editor-swatch {
    inline-size: 1.75rem;
    block-size: 1.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: 50%;
    background-color: var(--s-swatch-color);
    cursor: pointer;
}

.s-editor-swatch:focus-visible,
.s-editor-swatch-none:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Without a toolbar, the panel for a link stands under the text. */
.s-editor-link:has(.s-editor-link-anchor) {
    position: absolute;
    inset-inline-start: var(--s-space-3);
    inset-block-end: 0;
}

.s-editor-link-anchor {
    display: block;
    inline-size: 1px;
    block-size: 1px;
}

.s-editor-link-form {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
    inline-size: min(20rem, 80vw);
    padding: var(--s-space-3);
}

.s-editor-link-buttons {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-space-2);
}

/* In a chat, one row as high as the buttons beside it, as the text area is there. */
.s-chat-input .s-editor-area {
    --s-editor-padding: calc((2.5rem - 2px - 1.4em) / 2);
}

.s-chat-input .s-editor-grow .s-editor-area {
    max-block-size: min(calc(var(--s-editor-max-rows, 1000) * 1.4em + 2 * var(--s-editor-padding)), 40dvh);
}

.s-chat-input .s-editor-area p:last-child,
.s-chat-input .s-editor-area ul:last-child,
.s-chat-input .s-editor-area ol:last-child {
    margin-block-end: 0;
}

/* A button inside a box of several lines stays at its last line, by the caret, as in every chat. */
.s-input-wrap:has(> .s-textarea-adornment) {
    align-items: flex-end;
}

.s-textarea-adornment,
.s-editor-adornment {
    flex: none;
    align-self: flex-end;
}

.s-editor-adornment {
    margin-block-end: calc((2.5rem - 2px - 2.25rem) / 2);
}

/* Inside the box the emoji button is as quiet as the formatting button beside it. */
.s-input-adornment .s-chat-emoji-trigger {
    min-inline-size: 2rem;
    block-size: 2.25rem;
    padding-inline: var(--s-space-1);
    color: hsl(var(--muted-foreground));
}

@media (hover: hover) {
    .s-input-adornment .s-chat-emoji-trigger:hover:not(:disabled) {
        color: hsl(var(--foreground));
    }
}

.s-input-adornment .s-chat-emoji-trigger:active:not(:disabled) {
    color: hsl(var(--foreground));
}

/* ------------------------------------------------------------------- lookup */
/* SLookup: a text field whose list hangs under it in the top layer (a manual popover anchored to the field's box). */

.s-lookup-text {
    flex: 0 1 auto;
    min-inline-size: 0;
    max-inline-size: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.s-lookup-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    padding: 0;
    border: none;
    border-radius: var(--s-radius-sm);
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

    @media (hover: hover) {
        .s-lookup-button:hover {
            color: hsl(var(--foreground));
            background-color: hsl(var(--accent));
        }
    }

    .s-lookup-button:active {
        color: hsl(var(--foreground));
        background-color: hsl(var(--accent));
    }

    .s-lookup-button svg {
        inline-size: 1rem;
        block-size: 1rem;
    }

.s-lookup-spinner {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: 50%;
    animation: s-lookup-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .s-lookup-spinner { animation-duration: 2s; }
}

/* Text that stands for no record: marked as a warning, as the old search code fields did, and said under the field. Its
   own box only: the advanced search is rendered inside the field and has boxes of its own. */
.s-lookup-unresolved > .s-input-wrap {
    border-color: hsl(var(--warning));
    box-shadow: inset 3px 0 0 hsl(var(--warning));
}

.s-help-warning {
    color: hsl(var(--foreground));
}

    .s-help-warning::before {
        content: "\26A0\FE0E";
        margin-inline-end: 0.35em;
        color: hsl(var(--warning));
    }

.s-lookup-list {
    /* flush with the field, just below it, rather than the popover's margin all round */
    margin: var(--s-space-1) 0 0;
    padding: var(--s-space-1);
    min-inline-size: anchor-size(width);
    max-inline-size: min(40rem, calc(100vw - 2 * var(--s-space-4)));
    max-block-size: min(24rem, 60dvh);
}

/* The rows share their columns, so a code, a name and a city line up from row to row. */
.s-lookup-rows {
    display: grid;
    grid-template-columns: repeat(var(--s-lookup-columns, 1), minmax(0, auto));
    column-gap: var(--s-space-4);
}

.s-lookup-option {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    align-items: baseline;
    padding: var(--s-space-2) var(--s-space-3);
    border-radius: var(--s-radius-sm);
    cursor: pointer;
}

    .s-lookup-option.s-lookup-active {
        color: hsl(var(--accent-foreground));
        background-color: hsl(var(--accent));
    }

    @media (hover: hover) {
        .s-lookup-option:hover {
            color: hsl(var(--accent-foreground));
            background-color: hsl(var(--accent));
        }
    }

    .s-lookup-option:active {
        color: hsl(var(--accent-foreground));
        background-color: hsl(var(--accent));
    }

.s-lookup-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.s-lookup-cell-wide {
    grid-column: 1 / -1;
}

.s-lookup-code {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.s-lookup-extra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2);
    color: hsl(var(--muted-foreground));
}

    .s-lookup-extra kbd {
        font-family: inherit;
        font-size: 0.75rem;
        padding: 0 var(--s-space-1);
        border: 1px solid hsl(var(--border));
        border-radius: var(--s-radius-sm);
    }

.s-lookup-status {
    grid-column: 1 / -1;
    margin: 0;
    padding: var(--s-space-2) var(--s-space-3);
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.s-lookup-dialog .s-lookup-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: var(--s-space-3);
    margin-block-end: var(--s-space-3);
}

.s-lookup-dialog .s-lookup-lifts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-space-4);
    margin-block-end: var(--s-space-3);
}

/* ----------------------------------------------------------- record picker */
/* SRecordPicker: a lookup of records by name; for several kinds of record, the kind first, on the same row. */

.s-record-picker {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-2);
}

.s-record-picker-row {
    display: flex;
    align-items: flex-start;
    gap: var(--s-space-2);
}

    .s-record-picker-row > .s-lookup {
        flex: 1 1 auto;
        min-inline-size: 0;
    }

    .s-record-picker-row > .s-field:first-child {
        flex: 0 0 auto;
    }

/* ----------------------------------------------------------- dev tools */
/* What the dev flags of the library show (RazorDevFlags), while they are on: only while developing. */

.s-dev-info {
    display: inline-block;
    margin-inline-start: var(--s-space-1);
    padding-inline: var(--s-space-1);
    border: 1px dashed hsl(var(--ring) / 0.6);
    border-radius: var(--s-radius-sm);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    color: hsl(var(--muted-foreground));
    vertical-align: middle;
    white-space: nowrap;
}

.s-dev-outlines [class^="s-"],
.s-dev-outlines [class*=" s-"] {
    outline: 1px dashed hsl(var(--ring) / 0.45);
    outline-offset: -1px;
}

/* ----------------------------------------------------------- theme editor */
/* SThemeEditor: a theme's tokens, a row each: swatch, name, value, contrast, undo. */

.s-theme-editor {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
    font-size: var(--s-text-sm);
    line-height: var(--s-text-sm-line);
}

.s-theme-editor-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-space-3);
}

    .s-theme-editor-tools > .s-field:first-child {
        flex: 1 1 12rem;
    }

.s-theme-editor-heading {
    margin: var(--s-space-2) 0 0;
    font-size: var(--s-text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.s-theme-editor-rows {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr) minmax(0, 1.2fr) auto auto;
    align-items: center;
    gap: var(--s-space-1) var(--s-space-2);
}

.s-theme-editor-row {
    display: contents;
}

.s-theme-editor-swatch,
.s-theme-editor-swatch-space {
    inline-size: 1.75rem;
    block-size: 1.75rem;
}

.s-theme-editor-swatch {
    padding: 0;
    border: 1px solid hsl(var(--border));
    border-radius: var(--s-radius-sm);
    background: none;
    cursor: pointer;
}

    .s-theme-editor-swatch::-webkit-color-swatch-wrapper {
        padding: 2px;
    }

    .s-theme-editor-swatch::-webkit-color-swatch {
        border: none;
        border-radius: calc(var(--s-radius-sm) - 2px);
    }

.s-theme-editor-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: var(--s-text-xs);
}

.s-theme-editor-row-changed > .s-theme-editor-name {
    font-weight: 700;
    color: hsl(var(--primary));
}

.s-theme-editor-value {
    min-inline-size: 0;
    block-size: 1.75rem;
    padding-inline: var(--s-space-2);
    border: 1px solid hsl(var(--input));
    border-radius: var(--s-radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: var(--s-text-xs);
}

    .s-theme-editor-value:focus-visible {
        outline: 2px solid hsl(var(--ring));
        outline-offset: 1px;
    }

.s-theme-editor-contrast {
    grid-column: 4;
    min-inline-size: 2.25rem;
    padding-inline: var(--s-space-1);
    border-radius: var(--s-radius-sm);
    background: hsl(var(--muted));
    font-size: var(--s-text-xs);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.s-theme-editor-contrast-low {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.s-theme-editor-reset,
.s-theme-editor-reset-space {
    grid-column: 5;
    inline-size: 1.75rem;
    block-size: 1.75rem;
}

.s-theme-editor-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: var(--s-radius-sm);
    background: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

    @media (hover: hover) {
        .s-theme-editor-reset:hover {
            background: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
        }
    }

    .s-theme-editor-reset:active {
        background: hsl(var(--accent));
        color: hsl(var(--accent-foreground));
    }

    .s-theme-editor-reset svg {
        inline-size: 1rem;
        block-size: 1rem;
    }

.s-theme-editor-empty {
    margin: 0;
    color: hsl(var(--muted-foreground));
}

/* ===== SSettingsEditor ===== */

.s-settings-editor {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-6);
}

.s-settings-editor-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-3);
}

.s-settings-editor-heading {
    margin: 0;
    font-size: var(--s-text-sm);
    line-height: var(--s-text-sm-line);
    font-weight: 600;
    color: hsl(var(--foreground));
}

.s-settings-editor-rows {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-4);
}

.s-settings-editor-row {
    display: flex;
    flex-direction: column;
    gap: var(--s-space-1);
}

.s-settings-editor-meta {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    min-height: 1.5rem;
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    color: hsl(var(--muted-foreground));
}

.s-settings-editor-row-own .s-settings-editor-source {
    color: hsl(var(--primary));
}

/* A change that is held, not stored yet. */
.s-settings-editor-row-pending .s-settings-editor-source {
    color: hsl(var(--foreground));
    font-weight: 600;
}

.s-settings-editor-empty {
    margin: 0;
    color: hsl(var(--muted-foreground));
}

/* Apply and discard the held changes. Stays in view at the bottom of what scrolls while its container is on screen;
   an application with something fixed there, such as a tab bar, says how far to stay above it. */
.s-settings-apply {
    position: sticky;
    bottom: var(--s-settings-apply-bottom, var(--s-space-3));
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-space-2) var(--s-space-4);
    padding: var(--s-space-3) var(--s-space-4);
    border: 1px solid hsl(var(--primary) / 0.5);
    border-radius: var(--s-radius-lg);
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: var(--s-shadow-md);
    font-size: var(--s-text-sm);
    line-height: var(--s-text-sm-line);
}

.s-settings-apply-text {
    font-weight: 500;
}

.s-settings-apply-actions {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    margin-inline-start: auto;
}

/* ==============================================================================
   Charts (SChart): an SVG laid out in .NET (Subro.Core/Charts) at the width it
   is given, with its tooltip, legend and table in HTML. The series colours are
   the theme's chart-1 to chart-6; a theme without them gets them derived from
   its primary, with the same numbers as ChartPalette in Subro.Core:
   --s-chart-own-N is unset when the theme has no chart-N, and then the derived
   colour applies.
   ============================================================================== */

.s-chart {
    --s-chart-own-1: hsl(var(--chart-1));
    --s-chart-own-2: hsl(var(--chart-2));
    --s-chart-own-3: hsl(var(--chart-3));
    --s-chart-own-4: hsl(var(--chart-4));
    --s-chart-own-5: hsl(var(--chart-5));
    --s-chart-own-6: hsl(var(--chart-6));
    --s-chart-1: var(--s-chart-own-1, oklch(from hsl(var(--primary)) 0.62 0.13 h));
    --s-chart-2: var(--s-chart-own-2, oklch(from hsl(var(--primary)) 0.72 0.13 calc(h + 180)));
    --s-chart-3: var(--s-chart-own-3, oklch(from hsl(var(--primary)) 0.55 0.13 calc(h + 60)));
    --s-chart-4: var(--s-chart-own-4, oklch(from hsl(var(--primary)) 0.78 0.13 calc(h + 240)));
    --s-chart-5: var(--s-chart-own-5, oklch(from hsl(var(--primary)) 0.5 0.13 calc(h + 120)));
    --s-chart-6: var(--s-chart-own-6, oklch(from hsl(var(--primary)) 0.68 0.13 calc(h + 300)));

    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-inline-size: 0;
}

.s-chart-canvas {
    inline-size: 100%;
}

.s-chart-surface {
    position: relative;
    block-size: 100%;
    border-radius: calc(var(--radius) - 2px);
    outline: none;
    touch-action: pan-y;
}

.s-chart-surface:focus-visible {
    box-shadow: 0 0 0 2px hsl(var(--ring));
}

.s-chart-svg {
    display: block;
    overflow: visible;
    max-inline-size: 100%;
    user-select: none;
}

.s-chart-grid {
    stroke: hsl(var(--border));
    stroke-width: 1;
}

.s-chart-tick,
.s-chart-axis-title {
    fill: hsl(var(--muted-foreground));
}

.s-chart-area {
    fill-opacity: 0.2;
}

.s-chart-line {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.s-chart-band {
    fill: hsl(var(--muted));
}

.s-chart-crosshair {
    stroke: hsl(var(--muted-foreground) / 0.6);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.s-chart-active-dot {
    stroke: hsl(var(--background));
    stroke-width: 2;
}

.s-chart-active-dot-current {
    stroke-width: 3;
}

.s-chart-hit {
    fill: transparent;
    pointer-events: all;
    cursor: pointer;
}

.s-chart-loading .s-chart-svg {
    opacity: 0.5;
    transition: opacity 150ms;
}

.s-chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: hsl(var(--muted-foreground));
    font-size: var(--s-text-sm);
    pointer-events: none;
}

.s-chart-tooltip {
    position: absolute;
    z-index: 1;
    min-inline-size: 8rem;
    max-inline-size: min(18rem, 70%);
    padding: 0.5rem 0.625rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: 0 4px 12px hsl(0 0% 0% / 0.1);
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
    pointer-events: none;
}

.s-chart-tooltip-pinned {
    pointer-events: auto;
    box-shadow: 0 0 0 1px hsl(var(--ring) / 0.4), 0 4px 12px hsl(0 0% 0% / 0.1);
}

.s-chart-tooltip-title {
    margin-block-end: 0.25rem;
    color: hsl(var(--muted-foreground));
}

.s-chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.s-chart-tooltip-current .s-chart-tooltip-series {
    font-weight: 600;
}

.s-chart-tooltip-value {
    margin-inline-start: auto;
    padding-inline-start: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.s-chart-swatch {
    flex: none;
    inline-size: 0.625rem;
    block-size: 0.625rem;
    border-radius: 2px;
    background: var(--s-chart-color);
}

.s-chart-detail {
    margin-block-start: 0.375rem;
    padding-block-start: 0.375rem;
    border-block-start: 1px solid hsl(var(--border));
}

.s-chart-detail-title {
    font-weight: 600;
}

.s-chart-detail-rows {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.75rem;
    margin: 0.25rem 0 0;
}

.s-chart-detail-rows dt {
    color: hsl(var(--muted-foreground));
}

.s-chart-detail-rows dd {
    margin: 0;
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.s-chart-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.s-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: var(--s-text-xs);
    line-height: var(--s-text-xs-line);
}

.s-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0;
    border: 0;
    background: none;
    color: hsl(var(--foreground));
    font: inherit;
}

button.s-chart-legend-item {
    cursor: pointer;
}

button.s-chart-legend-item:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
    border-radius: 2px;
}

.s-chart-legend-item[aria-pressed="false"] {
    color: hsl(var(--muted-foreground));
    text-decoration: line-through;
}

.s-chart-legend-item[aria-pressed="false"] .s-chart-swatch {
    opacity: 0.35;
}

.s-chart-table-toggle {
    margin-inline-start: auto;
}

.s-chart-table-wrap {
    overflow-x: auto;
}

.s-chart-table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: var(--s-text-sm);
    font-variant-numeric: tabular-nums;
}

.s-chart-table th,
.s-chart-table td {
    padding: 0.25rem 0.5rem;
    border-block-end: 1px solid hsl(var(--border));
    text-align: end;
}

.s-chart-table th[scope="row"] {
    text-align: start;
    font-weight: 500;
}

.s-chart-caption {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
    .s-chart-animate .s-chart-mark {
        animation: s-chart-in 400ms ease-out both;
    }

    @keyframes s-chart-in {
        from {
            opacity: 0;
            transform: translateY(6px);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }
}

/* ==============================================================================
   Touch screens: no zooming in on a field
   iOS zooms the page in on a field whose text is smaller than 16px, as soon as
   it is focused, and leaves it zoomed. So on a touch screen what is typed in is
   at least that large; the rest of the text keeps its size. Last in the file,
   and with :root in front, to come before the fields' own sizes.
   ============================================================================== */

@media (pointer: coarse) {
    :root :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]),
        textarea, select, [contenteditable]:not([contenteditable="false"])) {
        font-size: max(16px, 1em);
    }
}
