/* « Carnet de voyage pop »: bright sticker colours, a rounded font, thick outlines and offset shadows. */
:root {
    --color-bg: #fff4e6;
    --color-dot: #f6dfc4;
    --color-surface: #ffffff;
    --color-text: #2b1d3a;
    --color-muted: #75668a;
    /* Outlines and offset shadows. */
    --color-border: #2b1d3a;
    /* Separators inside a list. */
    --color-line: #eedfcf;
    --color-accent: #ff6b4a;
    --color-accent-contrast: #2b1d3a;
    /* Text on the bright sticker colours, the same in both themes. */
    --color-ink: #2b1d3a;
    --color-danger: #c0262d;
    --color-danger-bg: #ffe1e1;
    --color-success: #136c43;
    --color-success-bg: #d6f7e6;

    --color-sun: #ffc83d;
    /* The marker stroke under the titles. */
    --color-marker: var(--color-sun);
    --color-mint: #4ade9b;
    --color-sky: #5cc8ff;
    --color-lilac: #c4a5ff;
    --color-pink: #ff8fb1;

    --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --tap-size: 44px;
    --radius: 16px;
    --outline: 2px;
    --shadow: 3px 3px 0 var(--color-border);
    --shadow-lg: 4px 4px 0 var(--color-border);
    --tabbar-height: 56px;
    --tabbar-gap: 0.75rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1c1530;
        --color-dot: #2a2145;
        --color-surface: #2a2045;
        --color-text: #fff3e3;
        --color-muted: #b9abcf;
        --color-border: #0b0716;
        --color-line: #3b2f5c;
        --color-accent: #ff7a5c;
        --color-danger: #ff9b94;
        --color-danger-bg: #4a1f2a;
        --color-success: #7ee8b0;
        --color-success-bg: #173a2b;

        --color-sun: #ffd25e;
        /* Light text over yellow would be unreadable. */
        --color-marker: #5b3fa6;
        --color-mint: #5ee6a8;
        --color-sky: #74d1ff;
        --color-lilac: #c9adff;
        --color-pink: #ff9cbc;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    background-color: var(--color-bg);
    background-image: radial-gradient(var(--color-dot) 1.5px, transparent 1.75px);
    background-size: 22px 22px;
    color: var(--color-text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.4;
}

.page {
    max-width: 40rem;
    margin: 0 auto;
    padding:
        calc(1.25rem + env(safe-area-inset-top))
        calc(1rem + env(safe-area-inset-right))
        calc(var(--tabbar-height) + var(--tabbar-gap) + 1.5rem + env(safe-area-inset-bottom))
        calc(1rem + env(safe-area-inset-left));
}

/* A marker stroke under the title, drawn behind the letters and on each line of a long name. */
h1 {
    margin: 0 0 1rem;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-decoration-line: underline;
    text-decoration-color: var(--color-marker);
    text-decoration-thickness: 0.4em;
    text-underline-offset: -0.25em;
    text-decoration-skip-ink: none;
}

a {
    color: inherit;
    font-weight: 600;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

/* Messages */

.flash {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 600;
}

.flash--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.flash--error::before {
    content: "😬";
    content: "😬" / "";
}

.flash--success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.flash--success::before {
    content: "🎉";
    content: "🎉" / "";
}

/* Forms */

/* minmax(0, 1fr): a grid track otherwise grows to its widest field, and iOS gives date inputs a wide minimum width. */
.form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

.field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
}

.field__label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="date"] {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.5rem 0.875rem;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: inherit;
    /* 16px at least, otherwise iOS zooms the page on focus. */
    font: inherit;
    font-size: 1rem;
}

input::placeholder {
    color: var(--color-muted);
}

/* iOS Safari draws date inputs natively, with their own minimum width and centred text. */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    min-width: 0;
}

input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

input:focus-visible,
button:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap-size);
    padding: 0.5rem 1.25rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

/* Pressed: the sticker sinks onto its shadow. */
.button:active {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--color-border);
}

.button--primary {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
}

select {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.5rem 0.875rem;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: inherit;
    font: inherit;
    font-size: 1rem;
}

.form--inline {
    margin-bottom: 1.5rem;
}

.form--danger {
    margin-top: 2.5rem;
}

.button--danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

a.button {
    text-decoration: none;
}

h2 {
    margin: 0 0 0.625rem;
    font-size: 1.25rem;
    font-weight: 800;
}

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

/* Checkboxes: a rounded box that fills with mint, the tick popping in. */

.row__label input[type="checkbox"],
.bag-filter input[type="checkbox"],
.kit-always input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    display: grid;
    flex: none;
    place-content: center;
    width: 1.625rem;
    height: 1.625rem;
    margin: 0;
    border: var(--outline) solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.row__label input[type="checkbox"]::before,
.bag-filter input[type="checkbox"]::before,
.kit-always input[type="checkbox"]::before {
    content: "";
    width: 0.45rem;
    height: 0.8rem;
    margin-top: -0.15rem;
    border-right: 3px solid var(--color-ink);
    border-bottom: 3px solid var(--color-ink);
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.8, 0.64, 1);
}

.row__label input[type="checkbox"]:checked,
.bag-filter input[type="checkbox"]:checked,
.kit-always input[type="checkbox"]:checked {
    background: var(--color-mint);
}

.row__label input[type="checkbox"]:checked::before,
.bag-filter input[type="checkbox"]:checked::before,
.kit-always input[type="checkbox"]:checked::before {
    transform: rotate(45deg) scale(1);
}

.row__label input[type="checkbox"]:disabled {
    cursor: default;
    opacity: 0.75;
}

/* Lists */

.group {
    margin-bottom: 1.75rem;
}

.list {
    margin: 0;
    padding: 0;
    list-style: none;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
}

/* Dashed, like the tear line of a ticket. */
.list > li:not([hidden]) ~ li:not([hidden]) {
    border-top: 2px dashed var(--color-line);
}

.list__link {
    display: flex;
    align-items: center;
    min-height: var(--tap-size);
    padding: 0.5rem 1rem;
    color: inherit;
    font-weight: 500;
    text-decoration: none;
}

.list__link::after {
    content: "›";
    content: "›" / "";
    margin-left: auto;
    padding-left: 1rem;
    color: var(--color-muted);
    font-size: 1.25rem;
    font-weight: 700;
}

.list--cards {
    display: grid;
    gap: 0.875rem;
    border: 0;
    background: none;
    box-shadow: none;
}

.list--cards > li:not([hidden]) ~ li:not([hidden]) {
    border-top: var(--outline) solid var(--color-border);
}

/* Each card gets its own luggage-tag colour. */
.list--cards > li:nth-child(5n + 1) { --tag: var(--color-sky); }
.list--cards > li:nth-child(5n + 2) { --tag: var(--color-pink); }
.list--cards > li:nth-child(5n + 3) { --tag: var(--color-mint); }
.list--cards > li:nth-child(5n + 4) { --tag: var(--color-lilac); }
.list--cards > li:nth-child(5n + 5) { --tag: var(--color-sun); }

.card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: var(--outline) solid var(--color-border);
    border-left-width: 10px;
    border-left-color: var(--tag, var(--color-sky));
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.card:has(> a:active) {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--color-border);
}

.card .form--inline {
    margin-bottom: 0;
}

/* Login */

.login {
    margin-top: 10vh;
}

.login__title {
    margin-bottom: 1.5rem;
    font-size: 3rem;
    text-align: center;
}

.login__title::before {
    content: "🧳";
    content: "🧳" / "";
    /* Inline-block, so the title's marker stroke does not reach it; the full width puts it on its own line. */
    display: inline-block;
    width: 100%;
    margin-bottom: 0.25rem;
    font-size: 4rem;
    animation: wobble 2.4s ease-in-out infinite;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-6deg) translateY(0); }
    50% { transform: rotate(6deg) translateY(-6px); }
}

/* Bottom tab bar: a floating pill above the home indicator. */

.tabbar {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right));
    bottom: calc(var(--tabbar-gap) + env(safe-area-inset-bottom));
    left: calc(1rem + env(safe-area-inset-left));
    display: flex;
    gap: 0.25rem;
    max-width: 30rem;
    margin: 0 auto;
    padding: 0.3rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
}

.tabbar__link {
    display: flex;
    flex: 1;
    gap: 0.375rem;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--tabbar-height) - 0.6rem - 2 * var(--outline));
    border-radius: 999px;
    color: var(--color-muted);
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.tabbar__link::before {
    font-size: 1.125rem;
    transition: transform 0.2s cubic-bezier(0.34, 1.8, 0.64, 1);
}

.tabbar__link:nth-child(1)::before { content: "✈️"; content: "✈️" / ""; }
.tabbar__link:nth-child(2)::before { content: "🎒"; content: "🎒" / ""; }
.tabbar__link:nth-child(3)::before { content: "🧦"; content: "🧦" / ""; }

.tabbar__link.is-active {
    background: var(--color-sun);
    color: var(--color-ink);
}

.tabbar__link.is-active::before {
    transform: scale(1.2) rotate(-8deg);
}

/* Toast (filled by the toast Stimulus controller) */

#toast {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--tabbar-height) + var(--tabbar-gap) + 1rem + env(safe-area-inset-bottom));
    left: 1rem;
    max-width: 30rem;
    margin: 0 auto;
    pointer-events: none;
}

.toast__message {
    margin: 0;
    padding: 0.75rem 1rem;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-text);
    color: var(--color-bg);
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.25s cubic-bezier(0.34, 1.6, 0.64, 1);
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(1rem) scale(0.9); }
}

/* Trips */

.trip-card {
    padding: 0;
}

.trip-card__link {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.125rem 1rem;
    min-height: var(--tap-size);
    padding: 0.875rem 1rem;
    color: inherit;
    text-decoration: none;
}

.trip-card__name {
    font-size: 1.0625rem;
    font-weight: 800;
}

.trip-card__count {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    padding: 0.125rem 0.625rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--tag, var(--color-sky));
    color: var(--color-ink);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.trip-card__progress {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

/* Progress of the packing: on a trip card, and under the counter of a trip. */

.progress {
    height: 0.75rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);
    overflow: hidden;
}

.progress__bar {
    display: block;
    height: 100%;
    border-right: var(--outline) solid var(--color-border);
    background: repeating-linear-gradient(-45deg, var(--tag, var(--color-mint)) 0 8px, color-mix(in srgb, var(--tag, var(--color-mint)) 75%, white) 8px 16px);
    transition: width 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.progress__bar[style*="width: 0%"] {
    border-right: 0;
}

/* Kits */

.kit-card {
    padding: 0;
}

.kit-card__link {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.125rem 1rem;
    min-height: var(--tap-size);
    padding: 0.875rem 1rem;
    color: inherit;
    text-decoration: none;
}

.kit-card__name {
    font-size: 1.0625rem;
    font-weight: 800;
}

.kit-card__count {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    padding: 0.125rem 0.625rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--tag, var(--color-sky));
    color: var(--color-ink);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.kit-card__always::before {
    content: "⭐ ";
    content: "⭐ " / "";
}

.kit-always {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.kit-always__label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--tap-size);
    font-weight: 600;
}

/* « Importer un kit »: with JavaScript the summary opens a sheet; without it, it unfolds the kits. */
.kit-import > summary {
    list-style: none;
}

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

.kit-import[open] {
    flex-basis: 100%;
}

.kit-import > .choices {
    margin-top: 0.75rem;
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    overflow: hidden;
}

.kit-choice {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-weight: 600;
}

.kit-choice__name::before {
    content: "🎒 ";
    content: "🎒 " / "";
}

.kits-reminder {
    margin-bottom: 1rem;
}

.trip-header {
    margin-bottom: 1.75rem;
}

.trip-header h1 {
    margin-bottom: 0.25rem;
}

.trip-header p {
    margin: 0 0 0.5rem;
}

.trip-header .progress {
    margin-bottom: 1rem;
}

.counter {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.counter::before {
    content: "🧳 ";
    content: "🧳 " / "";
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

/* Category headings: a tilted sticker, its colour changing from one category to the next. */
h3 {
    display: inline-block;
    margin: 0 0 0.625rem 0.25rem;
    padding: 0.125rem 0.625rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--chip, var(--color-sun));
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transform: rotate(-1.5deg);
}

.group:nth-of-type(5n + 2) > h3 { --chip: var(--color-sky); }
.group:nth-of-type(5n + 3) > h3 { --chip: var(--color-pink); }
.group:nth-of-type(5n + 4) > h3 { --chip: var(--color-mint); }
.group:nth-of-type(5n + 5) > h3 { --chip: var(--color-lilac); }

.group:nth-of-type(even) > h3 {
    transform: rotate(1.5deg);
}

/* "Dans le sac" heading, with the toggle hiding checked items */

.bag-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: 1rem;
    margin-bottom: 0.5rem;
}

.bag-header h2 {
    margin: 0;
}

/* Needs JavaScript: without it the page shows every item. */
.bag-filter {
    display: none;
}

.js .bag-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--tap-size);
    color: var(--color-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.js .bag-filter input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 6px;
}

.js .bag-filter input[type="checkbox"]::before {
    width: 0.35rem;
    height: 0.6rem;
    border-width: 0 2.5px 2.5px 0;
}

/* Checklist and picker rows */

.row {
    display: flex;
    align-items: center;
}

.row form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.row__pack,
.row__add {
    flex: 1;
    min-width: 0;
}

.row__label {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    min-height: var(--tap-size);
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.row--readonly .row__label {
    flex: 1;
    cursor: default;
}

.row__name {
    font-weight: 500;
    transition: color 0.2s ease;
}

.row__add .row__name {
    flex: 1;
    padding: 0.5rem 1rem;
    overflow-wrap: anywhere;
}

.row__pack:has(input:checked) .row__name,
.row--readonly:has(input:checked) .row__name {
    color: var(--color-muted);
}

/* Struck through while packing; an old trip keeps its checked items readable. */
.row__pack:has(input:checked) .row__name {
    text-decoration: line-through;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
}

/* An item of a kit: its name (or the choice of a category), then « Retirer ». */
.row--kit > .row__name {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
    min-height: var(--tap-size);
    padding: 0.5rem 1rem;
    overflow-wrap: anywhere;
}

.row--kit .row__sort {
    padding-left: 1rem;
}

/* An archived catalogue item kept in a kit: never imported. */
.row__tag {
    flex: none;
    padding: 0.125rem 0.5rem;
    border: var(--outline) solid var(--color-border);
    border-radius: 999px;
    background: var(--color-danger-bg);
    color: var(--color-danger);
    font-size: 0.75rem;
    font-weight: 700;
}

.row__tag[hidden] {
    display: none;
}

/* An item without category: the checkbox alone, then its name, which opens the choice of a category. */
.row--sortable .row__pack {
    flex: none;
}

.row--sortable .row__label {
    padding-right: 0.75rem;
}

/* Open (only without JavaScript), the choice shows under the name: the checkbox and "Retirer" stay level with the name. */
.row--sortable:has(.row__sort[open]) {
    align-items: flex-start;
}

.row__sort {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0;
}

.row__sort summary {
    display: flex;
    align-items: center;
    min-height: calc(var(--tap-size) - 1rem);
    list-style: none;
    overflow-wrap: anywhere;
    text-decoration: underline dotted var(--color-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.25em;
    cursor: pointer;
}

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

.row .row__sort-form {
    display: block;
    margin-top: 0.5rem;
}

.row__sort .choices {
    border: var(--outline) solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.row--sortable:has(.row__pack input:checked) .row__name {
    color: var(--color-muted);
    text-decoration-line: line-through;
}

/* Buttons inside a row: plain, no sticker. */
.row__plus,
.row__save,
.row__remove-button {
    min-width: var(--tap-size);
    padding: 0.25rem 0.75rem;
    border-color: transparent;
    background: none;
    box-shadow: none;
}

.row__plus:active,
.row__save:active,
.row__remove-button:active {
    transform: scale(0.9);
    box-shadow: none;
}

.row__plus {
    width: 2rem;
    min-width: 0;
    height: 2rem;
    min-height: 0;
    margin-right: 0.75rem;
    padding: 0;
    border-color: var(--color-border);
    background: var(--color-mint);
    color: var(--color-ink);
    font-size: 1.375rem;
    font-weight: 800;
    line-height: 1;
    position: relative;
}

/* Keeps a tap area of --tap-size around the small round « + ». */
.row__plus::after {
    content: "";
    position: absolute;
    inset: calc((2rem - var(--tap-size)) / 2);
}

.row__remove-button {
    color: var(--color-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.row__remove {
    padding-right: 0.25rem;
}

.quick-add {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.js .row__save {
    display: none;
}

/* With JavaScript the button only shows up when the typed name matches no item. */
.js .quick-add__button:not(.is-visible) {
    display: none;
}

/* A new item, shown at once while the server creates it: not actionable yet. */
.row--pending {
    opacity: 0.6;
}

/* An archived item: its name, then its buttons to bring it back to the catalogue or delete it for
   good, which move under the name when the row is too narrow for all three. */
.row--archived {
    flex-wrap: wrap;
    padding: 0 0.25rem 0 0;
}

.row--archived > .row__name {
    flex: 1 1 8rem;
    min-width: 0;
    padding: 0.5rem 1rem;
    overflow-wrap: anywhere;
}

.row__actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.25rem 0 0.25rem 0.75rem;
}

/* Choice of a category: the sort dialog, or the list under the name of a row without JavaScript */

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

.choices > li + li {
    border-top: 2px dashed var(--color-line);
}

.choice {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.5rem 1rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.choice:active {
    background: var(--color-bg);
}

/* A bottom sheet over the page, above the tab bar and clear of the home indicator. */
.sheet {
    width: 100%;
    max-width: 40rem;
    max-height: calc(100dvh - 3rem - env(safe-area-inset-top));
    margin: auto auto 0;
    padding: 0;
    border: var(--outline) solid var(--color-border);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 -4px 0 var(--color-border);
}

.sheet[open] {
    display: flex;
    flex-direction: column;
    animation: sheet-up 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes sheet-up {
    from { transform: translateY(40%); opacity: 0; }
}

/* The grab handle. */
.sheet::before {
    content: "";
    flex: none;
    width: 2.5rem;
    height: 5px;
    margin: 0.625rem auto 0;
    border-radius: 999px;
    background: var(--color-line);
}

.sheet::backdrop {
    background: rgb(28 21 48 / 0.45);
}

.sheet__title {
    margin: 0;
    padding: 0.75rem calc(1rem + env(safe-area-inset-right)) 0.75rem calc(1rem + env(safe-area-inset-left));
    border-bottom: 2px dashed var(--color-line);
    overflow-wrap: anywhere;
}

.sheet__choices {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sheet__footer {
    padding: 0.75rem calc(1rem + env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    border-top: 2px dashed var(--color-line);
}

.sheet__cancel {
    width: 100%;
}

/* The page behind an open dialog does not scroll. */
html:has(dialog[open]) {
    overflow: hidden;
}

/* Everything packed: a burst of confetti (assets/support/confetti.js). */

.confetti {
    position: fixed;
    inset: 0;
    z-index: 10;
    overflow: hidden;
    pointer-events: none;
}

.confetti__piece {
    position: absolute;
    top: -2rem;
    left: var(--x);
    font-size: var(--size);
    animation: confetti-fall var(--duration) cubic-bezier(0.25, 0.6, 0.4, 1) var(--delay) forwards;
}

.confetti__piece--paper {
    width: 0.6rem;
    height: 0.9rem;
    border-radius: 2px;
    background: var(--color);
}

@keyframes confetti-fall {
    to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

[hidden] {
    display: none !important;
}
