/*
    Pepperkakebaking — mobile-first stylesheet, sharing its design system with StavangerTurer and
    RentalCalendar (same tokens, same components) so the apps read as one family. Shared
    part copied from StavangerTurer's app.css; this app's own components are at the end.

      - 16px minimum on form controls, or iOS Safari zooms the page on focus.
      - 44px minimum on anything tappable (Apple's HIG figure).
      - env(safe-area-inset-*) so the sticky header clears the notch.
      - Nothing wider than the viewport: the page never scrolls sideways.
*/

:root {
    --accent: #b3121f;
    --accent-contrast: #ffffff;

    /* Same accent, used wherever it colours text, an icon, a thin border or an outline
       rather than filling a solid shape. Identical to --accent in light mode; dark mode
       overrides it below. */
    --accent-text: var(--accent);
    --danger: #b3261e;
    --warning: #b26a00;

    /* Affirmative green ("valid", "done") — a separate hue from --accent so
       status reads at a glance, same treatment as --danger/--warning below. */
    --success: #2e7d32;
    --success-text: var(--success);

    --bg: #f6f6f8;
    --surface: #ffffff;
    --surface-alt: #f0f0f4;
    --text: #16161a;
    --text-muted: #6b6b76;
    --border: #e0e0e6;

    --radius: 12px;
    --radius-sm: 8px;

    --header-height: 52px;
    --tabbar-height: 56px;
    --tap: 44px;

    /* Tells the browser this page fully themes its own native form controls (date
       picker, checkbox) for both schemes — without this, some mobile browsers force
       their own dark-mode inversion onto native inputs regardless of our CSS, which is
       what caused near-invisible pale text in a completed trip's date field. */
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121216;
        --surface: #1c1c22;
        --surface-alt: #24242c;
        --text: #f2f2f5;
        --text-muted: #a0a0ad;
        --border: #34343e;

        /* Lighter tints of the same hues — the base colours are too dark to read
           clearly against a near-black page. */
        --accent-text: #e57373;
        --success-text: #66bb6a;
    }
}

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

html {
    /* Stops iOS bumping text size when the device is rotated. */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    overscroll-behavior-y: contain;
}

a,
button,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

h1 {
    font-size: 1.35rem;
    margin: 0 0 0.75rem;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 0.5rem;
}

h3 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/*
    The page title already shows in the sticky header, but the document still needs an
    <h1> — it's the focus target after navigation and the outline for screen readers.
    This keeps it available to assistive tech without drawing it twice.
*/
.visually-hidden-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

a {
    color: var(--accent-text);
}

/* ---- App shell ---------------------------------------------------------- */

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--header-height);
    padding: 0 0.75rem;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .who {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0.75rem;
    /* Clears the fixed tab bar plus the home indicator. */
    padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 1rem);
}

.app-main.no-tabbar {
    padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
}

/* ---- Bottom tab bar ------------------------------------------------------ */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tabbar-height);
    padding: 6px 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
}

.tabbar a.active {
    color: var(--accent-text);
}

.tabbar .icon {
    font-size: 1.15rem;
    line-height: 1;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap);
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: transparent;
    color: var(--accent-text);
    border-color: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-small {
    min-height: 34px;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Sub-navigation within a section, e.g. the account-settings sub-pages (Profile/Email/
   Password/...) — a wrapping row of chip-like links rather than Identity's default
   Bootstrap nav-pills list. */
.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.subnav a.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

/* ---- Forms -------------------------------------------------------------- */

.field {
    display: block;
    margin-bottom: 1rem;
}

.field > label,
.label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* input:not([type]) because Blazor's <InputText> renders a bare <input> with no type
   attribute, which none of the type-specific selectors below would match. */
input:not([type]),
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    /* 16px exactly — anything smaller makes iOS Safari zoom in on focus. */
    font-size: 1rem;
    font-family: inherit;
}

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

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

.invalid {
    outline: 1px solid var(--danger);
}

.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--success);
}

.validation-message {
    display: block;
    margin-top: 0.25rem;
    color: var(--danger);
    font-size: 0.8rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--radius-sm);
}

.blazor-error-boundary::after {
    content: "Det oppstod en feil.";
}

/* ---- Toggle switch ----------------------------------------------------- */

.switch {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 48px;
    height: 30px;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch .track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    /* --border rather than --surface-alt: in dark mode those two tokens sit too close
       together to read as a visible pill against the card behind it. */
    background: var(--border);
    border: 1px solid var(--border);
    transition: background 0.15s ease;
    pointer-events: none;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    /* Fixed light thumb regardless of theme — stays visible against the track above in
       both light and dark, rather than tracking --surface (near-black in dark mode,
       which made the thumb disappear into its own track). */
    background: #ffffff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
    transition: transform 0.15s ease;
}

.switch input:checked + .track {
    /* --success-text rather than --success: the base green reads as too dark/muddy on
       a near-black card in dark mode, where --success-text is already the lighter tint
       used everywhere else for that reason. */
    background: var(--success-text);
    border-color: var(--success-text);
}

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

.switch input:focus-visible + .track {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.switch.switch-small {
    width: 38px;
    height: 24px;
}

.switch.switch-small .track::after {
    width: 18px;
    height: 18px;
}

.switch.switch-small input:checked + .track::after {
    transform: translateX(14px);
}

/* ---- Radio rows ----------------------------------------------------------- */

.radio-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.radio-row input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* A labelled switch as its own row, e.g. "Admin" / "Active" toggles in a list. */
.switch-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: var(--tap);
    padding: 0.15rem 0;
}

.switch-row .name {
    flex: 1;
}

/* ---- Users / badges -------------------------------------------------------- */

.user-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-row .who {
    flex: 1;
    min-width: 0;
}

.user-row .who strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--surface-alt);
    color: var(--text-muted);
}

.badge.admin {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent-text);
}

.badge.inactive {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
}

/* ---- Cards and notices --------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
    margin-bottom: 0.75rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.empty {
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.notice {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.notice-error {
    color: var(--danger);
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.notice-warning {
    color: var(--warning);
    border-color: var(--warning);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.notice-ok {
    color: var(--success-text);
    border-color: var(--success-text);
    background: color-mix(in srgb, var(--success) 8%, transparent);
}

/* ---- Sign-in / register -------------------------------------------------- */

.login {
    max-width: 380px;
    margin: 0 auto;
    padding-top: 2rem;
}

.login h1 {
    text-align: center;
    font-size: 1.6rem;
}

.login .lead {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login .alt-links {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
}

.login .alt-links p {
    margin: 0.4rem 0;
}

/* ---- Identity scaffold compatibility ---------------------------------------
    The scaffolded account pages (Manage/*) were written against Bootstrap. These rules
    give the handful of Bootstrap classes they use the app's own look, so those pages
    don't each need rewriting.
*/

/* Bootstrap's floating label puts the <label> after the <input> in the markup; reversing
   the column shows it above the field instead, like .field does. */
.form-floating {
    display: flex;
    flex-direction: column-reverse;
    margin-bottom: 1rem;
}

.form-floating > label {
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* order: -1 puts it at the visual bottom of the reversed column, under the field. */
.form-floating .btn-link {
    order: -1;
    align-self: flex-start;
    margin-top: 0.5rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group-text {
    color: var(--success-text);
    font-weight: 700;
}

.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.w-100 { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success-text); }
.text-secondary { color: var(--text-muted); }

.btn-link {
    background: transparent;
    color: var(--accent-text);
    border-color: var(--border);
}

/* ---- Wider screens -------------------------------------------------------- */

@media (min-width: 700px) {
    :root {
        --header-height: 58px;
    }

    .app-main {
        /* padding-bottom set individually, not via the shorthand above — the shorthand
           would reset it to a flat 1.25rem and wipe out the tab bar clearance from the
           base rule, hiding whatever sits last on a page (e.g. the logout button) behind
           the fixed tab bar. */
        padding: 1.25rem;
        padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 1.25rem);
    }

    .app-main.no-tabbar {
        padding-bottom: calc(env(safe-area-inset-bottom) + 1.25rem);
    }
}


/* ==========================================================================
    Pepperkakebaking components — everything below is specific to this app.
   ========================================================================== */

/* Sub-navigation chips can also be <button>s (in-page tabs), not only NavLinks. */
.subnav .active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

.subnav .count {
    display: inline-block;
    min-width: 1.3em;
    padding: 0 0.35em;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 18%, transparent);
    font-size: 0.75rem;
    text-align: center;
}

.stack > * + * {
    margin-top: 0.5rem;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.page-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
}

.page-title h1,
.page-title h2 {
    margin: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    font-size: 0.9rem;
    text-decoration: none;
}

/* Two fields side by side once there is room for it; stacked on a phone. */
.field-pair {
    display: grid;
    gap: 0 0.75rem;
}

@media (min-width: 520px) {
    .field-pair {
        grid-template-columns: 1fr 1fr;
    }
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.check-list .radio-row {
    min-height: var(--tap);
}

.check-list input[type="checkbox"],
.radio-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
    flex: 0 0 auto;
}

.badge.ok {
    background: color-mix(in srgb, var(--success-text) 15%, transparent);
    color: var(--success-text);
}

.badge.pending {
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    color: var(--warning);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.toolbar .field {
    flex: 1 1 200px;
    margin-bottom: 0;
}

.form-note {
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}

/* ==========================================================================
    Christmas-red theme
   ========================================================================== */

:root {
    --xmas-red: #b3121f;
    --xmas-red-dark: #7f0c15;
    --gold: #e0b252;
    --bg: #fbf6f1;
    --surface-alt: #f5ece4;
    --border: #eadbd0;
    --header-height: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #160f10;
        --surface: #211819;
        --surface-alt: #2b2021;
        --border: #3d2d2e;
        --accent-text: #ff8a8f;
    }
}

body {
    /* Faint red dots on the page background, like snow on a tablecloth. */
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--xmas-red) 7%, transparent) 0 2px, transparent 3px),
        radial-gradient(circle at 70% 80%, color-mix(in srgb, var(--xmas-red) 5%, transparent) 0 1.5px, transparent 2.5px);
    background-size: 90px 90px, 60px 60px;
}

.app-header {
    background: linear-gradient(180deg, var(--xmas-red), var(--xmas-red-dark));
    backdrop-filter: none;
    border-bottom: 3px solid var(--gold);
    color: #fff;
    padding-left: 1rem;
    padding-right: 1rem;
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-size: 1.15rem;
    letter-spacing: 0.3px;
}

.app-header .brand img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.tabbar a.active {
    color: var(--accent-text);
    font-weight: 700;
}

/* ---- Login ---------------------------------------------------------------- */

.login-hero {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-hero img {
    width: 96px;
    height: 96px;
    filter: drop-shadow(0 4px 10px rgba(127, 12, 21, 0.35));
}

.login h1,
.login .lead,
.login .alt-links {
    text-align: center;
}

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

.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.entry-tile {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.entry-tile:hover,
.entry-tile:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(127, 12, 21, 0.15);
}

.entry-tile-image {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-alt);
}

/* Absolute, so a portrait image cannot stretch the 4:3 frame (aspect-ratio yields to content height). */
.entry-tile-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.entry-tile-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: repeating-linear-gradient(45deg, var(--surface-alt) 0 14px, color-mix(in srgb, var(--xmas-red) 6%, var(--surface-alt)) 14px 28px);
}

.year-badge {
    position: absolute;
    left: 0.6rem;
    top: 0.6rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--xmas-red);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 0 0 2px var(--gold);
}

.entry-tile-body {
    padding: 0.7rem 0.8rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.entry-excerpt {
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entry-counts {
    display: flex;
    gap: 0.8rem;
    margin-top: auto;
    padding-top: 0.25rem;
}

/* ---- Entry page --------------------------------------------------------------- */

.entry {
    border-top: 4px solid var(--xmas-red);
}

.entry-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.entry-head h1 {
    margin: 0;
}

.year-chip {
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    background: var(--xmas-red);
    color: #fff;
    font-weight: 800;
}

.entry-description {
    white-space: pre-line;
    margin: 0 0 0.25rem;
}

.confirm {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.section-head h2 {
    margin: 0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.gallery-item {
    margin: 0;
}

.gallery-item a {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--surface-alt);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.gallery-item a:hover img {
    transform: scale(1.04);
}

.gallery-item figcaption {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.3;
}

.image-edit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-edit-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.image-edit-row > img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex: none;
}

.image-edit-fields {
    flex: 1;
    min-width: 0;
}

.image-edit-fields .row-actions {
    margin-top: 0.4rem;
}

.upload {
    margin-top: 0.9rem;
}

.upload-btn {
    position: relative;
    overflow: hidden;
}

/* The real file input covers the button, invisible, so a tap anywhere opens the picker. */
.upload-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

/* ---- Comments ------------------------------------------------------------------- */

.comment-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.comment {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.comment:last-child {
    border-bottom: none;
}

.comment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    align-items: baseline;
}

.comment-body {
    white-space: pre-line;
    margin: 0.2rem 0 0;
}

.comment-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.2rem;
}

.btn-link {
    border: none;
    background: none;
    padding: 0.25rem 0;
    color: var(--accent-text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 32px;
}

.btn-link.danger {
    color: var(--danger);
}

.comment textarea {
    margin-top: 0.4rem;
}

/* ---- Admin ------------------------------------------------------------------------ */

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

.user-item {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.user-item:last-child {
    border-bottom: none;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 34px;
    font-size: 0.85rem;
}

.who-head {
    display: flex;
    flex-direction: column;
}

/* ---- Lightbox (app.js) -------------------------------------------------------------- */

.lb-locked,
.lb-locked body {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 4, 5, 0.94);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.lightbox.open {
    display: flex;
}

.lb-figure {
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lb-img {
    max-width: 100vw;
    max-height: calc(100dvh - 6rem);
    object-fit: contain;
    display: block;
    user-select: none;
}

.lb-caption {
    color: #f3e9e0;
    text-align: center;
    padding: 0.6rem 1rem 0;
    font-size: 0.95rem;
    max-width: 700px;
}

.lb-caption:empty {
    display: none;
}

.lb-close,
.lb-prev,
.lb-next {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover {
    background: var(--xmas-red);
}

.lb-close {
    top: calc(env(safe-area-inset-top) + 0.75rem);
    right: 0.75rem;
}

.lb-prev {
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

.lb-next {
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

.lb-prev[hidden],
.lb-next[hidden] {
    display: none;
}

.lb-count {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 1.2rem);
    left: 1rem;
    color: #f3e9e0;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .lb-prev,
    .lb-next {
        top: auto;
        bottom: calc(env(safe-area-inset-bottom) + 0.75rem);
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .entry-tile,
    .gallery-item img {
        transition: none;
    }
}

/* .btn sets display, which would otherwise override the hidden attribute. */
.upload-btn[hidden] {
    display: none;
}

/* ---- Admin: Excel import, bulk invites, inactive users -------------------- */

.import-details summary {
    cursor: pointer;
    margin-top: 0.75rem;
}

.table-scroll {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.import-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.import-table th,
.import-table td {
    text-align: left;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.import-table th {
    font-weight: 600;
    white-space: nowrap;
}

.import-table .problem {
    color: var(--danger);
}

.list-actions {
    margin: 0 0 0.75rem;
}

.bulk-progress,
.confirm-bulk {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.notice-close {
    border: none;
    background: none;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.25rem;
    cursor: pointer;
}

/* ---- Compact user list (Admin → Brukere), like the Liverbirds member list -- */

.user-line {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    overflow: hidden;
}

.user-line-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.user-line-head:hover {
    background: color-mix(in srgb, currentColor 5%, transparent);
}

.user-line-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-line.is-inactive .user-line-name {
    color: var(--text-muted);
}

.led-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: none;
    width: 4.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.led {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--text-muted) 35%, transparent);
    vertical-align: middle;
}

.led-active {
    background: #2e7d32;
    box-shadow: 0 0 0 2px color-mix(in srgb, #2e7d32 25%, transparent);
}

.led-admin {
    background: var(--xmas-red);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--xmas-red) 25%, transparent);
}

.chevron {
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    margin: 0 0.15rem 0.2rem;
    transition: transform 0.15s;
}

.user-line.open .chevron {
    transform: rotate(-135deg);
    margin-bottom: -0.2rem;
}

.user-line-body {
    padding: 0.25rem 0.85rem 0.85rem;
    border-top: 1px solid var(--border);
}

.user-contact {
    margin: 0.5rem 0 0.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.detail-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    cursor: pointer;
}

.user-line-body .row-actions {
    margin-top: 0.5rem;
}

/* The legend replaces the LED labels on phones, where the name needs the room. */
.led-legend {
    display: none;
    gap: 1rem;
    font-size: 0.8rem;
    margin: 0 0 0.4rem;
}

@media (max-width: 480px) {
    .led-label {
        width: auto;
    }

    .led-text {
        display: none;
    }

    .led-legend {
        display: flex;
    }
}
