/* ==========================================================================
   Ourside — "Darkroom". Mobile-first stylesheet, no framework, no build step.

   Thesis: the chrome is neutral so the photographs carry all the colour.
   Every surface here is an uncoloured grey, the way a photographer judges a
   print against neutral card rather than warm paper. Exactly one thing in the
   interface is warm — the accent, which is the safelight.

   Sections: Fonts · Tokens · Base · Shells · Buttons · Surfaces · Status ·
   Forms · Gallery · Lightbox · Upload · QR · Account · Poster · Plumbing
   ========================================================================== */

/* --- Fonts -------------------------------------------------------------- */
/* Self-hosted variable faces. Variable rather than static instances is
   deliberate: the weights below (450/550/650) only exist on a variable font;
   on a system stack they silently snap to 400/500/700. Both SIL OFL 1.1. */

@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                   U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                   U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
                   U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/instrument-sans-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                   U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/instrument-sans-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                   U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
                   U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Tokens ------------------------------------------------------------- */
/* Each colour is declared once via light-dark(), which resolves against the
   used color-scheme. Switching theme is then a single color-scheme flip on
   :root — see the inline script in App.razor. */

:root {
    color-scheme: light dark;

    --bg: light-dark(#ececeb, #0d0e10);
    --surface: light-dark(#ffffff, #17181b);
    --surface-2: light-dark(#e2e2e0, #212227);
    --surface-sunken: light-dark(#d4d4d1, #08090a);
    --border: light-dark(#d6d6d3, #2a2c31);
    --border-strong: light-dark(#b6b6b2, #3d4046);

    --text: light-dark(#16171a, #f0f0ee);
    --text-muted: light-dark(#5e6066, #9b9ea6);
    --text-faint: light-dark(#8b8d93, #6c6f77);

    /* The safelight. The only warm thing in the interface. */
    --accent: light-dark(#bf3d16, #ff7a45);
    --accent-hover: light-dark(#a5330f, #ff9166);
    --accent-contrast: light-dark(#ffffff, #2a0f04);
    --accent-soft: light-dark(#fbe6dc, #2e1a12);

    --danger: light-dark(#b3261e, #e5766c);
    --success: light-dark(#2f6b46, #6fbb8f);
    --warning: light-dark(#8a5a00, #e0b062);

    /* Colour goes inside light-dark(), geometry stays outside it. */
    --shadow-1: light-dark(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.44));
    --shadow-2: light-dark(rgb(0 0 0 / 0.05), rgb(0 0 0 / 0.36));
    --shadow-sm: 0 1px 2px var(--shadow-1), 0 1px 3px var(--shadow-2);
    --shadow: 0 2px 6px var(--shadow-1), 0 8px 24px var(--shadow-2);
    --shadow-lg: 0 8px 40px var(--shadow-2);

    /* Scrims sit over photographs, so they are absolute, not themed. */
    --scrim: rgb(0 0 0 / 0.55);
    --on-scrim: #ffffff;
    --stage: #0b0b0c;

    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    --s1: 0.25rem;
    --s2: 0.5rem;
    --s3: 0.75rem;
    --s4: 1rem;
    --s5: 1.5rem;
    --s6: 2rem;
    --s7: 3rem;
    --s8: 4rem;

    --bar-h: 60px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);

    --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Bricolage Grotesque", "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Manual override. The inline head script sets data-theme before first paint. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* --- Base --------------------------------------------------------------- */

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    overscroll-behavior-y: none;
    /* Nothing in this design is ever wider than the viewport. */
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    margin: 0 0 0.5em;
    font-family: var(--font-display);
    line-height: 1.12;
    font-weight: 650;
    letter-spacing: -0.025em;
}

h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.12rem + 0.8vw, 1.6rem); }
h3 { font-size: 1.075rem; letter-spacing: -0.015em; }

p { margin: 0 0 var(--s4); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img, video, svg { max-width: 100%; height: auto; display: block; }

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

code, .mono { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* <FocusOnNavigate> moves focus to the h1 on every navigation so screen readers announce
   the new page. That is not a keyboard journey, and a ring around the title reads as an
   error, so the heading is the one focus target left unmarked. */
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible { outline: none; }

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

/* An eyebrow: small, tracked-out, above a heading. Used sparingly. */
.eyebrow {
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: var(--s2);
}

/* --- App shells --------------------------------------------------------- */

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

.shell-body {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin-inline: auto;
    padding: var(--s4) var(--s4) var(--s5);
}

/* Full-bleed variant for gallery grids that should run edge to edge on phones. */
.shell-body.bleed { max-width: none; padding-inline: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: var(--bar-h);
    padding: 0 var(--s4);
    padding-top: var(--safe-t);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-family: var(--font-display);
    font-weight: 650;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.topbar-sub {
    display: block;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 450;
    letter-spacing: 0;
    color: var(--text-muted);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.035em;
    color: var(--text);
    text-decoration: none;
    font-size: 1.15rem;
}

.brand-dot {
    width: 0.62em; height: 0.62em;
    border-radius: 50%;
    background: var(--accent);
    /* The safelight actually glows. */
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Sticky bottom action bar; clears the iPhone home indicator. */
.actionbar {
    position: sticky;
    bottom: 0;
    z-index: 30;
    display: flex;
    gap: var(--s2);
    padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--border);
}

.actionbar .btn { flex: 1; }

/* Floating dock: the guest "Add photos" pill hovers over the gallery rather
   than occupying a band of the screen. Wrapper ignores pointer events so the
   photos underneath stay tappable. */
.dock {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 35;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b));
    pointer-events: none;
    background: linear-gradient(to top, color-mix(in srgb, var(--bg) 92%, transparent), transparent);
}

.dock > * { pointer-events: auto; max-width: min(100%, 30rem); width: 100%; }
/* Scoped to the action cluster: the strip's own small buttons must keep their natural size. */
.dock-actions > .btn { width: 100%; box-shadow: var(--shadow); }

/* Keeps the last row of photos clear of the dock. */
.dock-spacer { height: calc(84px + var(--safe-b)); flex: 0 0 auto; }

/* Organizer navigation: bottom tabs on phones, sidebar on desktop. */
.tabbar {
    position: sticky;
    bottom: 0;
    z-index: 30;
    display: flex;
    padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--border);
}

/* Scoped to direct children plus .tabbar-link so nested .btn controls keep their own look. */
.tabbar > a, .tabbar .tabbar-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--bar-h);
    padding: var(--s1);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 550;
    color: var(--text-muted);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
}

.tabbar > a.active { color: var(--accent); }
.tabbar > a svg, .tabbar .tabbar-link svg { width: 22px; height: 22px; }
.tabbar .tabbar-foot { display: none; }

@media (min-width: 860px) {
    .shell.with-tabs { flex-direction: row; }
    .shell.with-tabs > .shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

    .tabbar {
        position: sticky;
        top: 0;
        bottom: auto;
        align-self: flex-start;
        flex-direction: column;
        width: 216px;
        height: 100dvh;
        padding: var(--s4) var(--s3);
        gap: var(--s1);
        border-top: 0;
        border-right: 1px solid var(--border);
    }

    .tabbar > a, .tabbar .tabbar-link {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: var(--s3);
        min-height: 44px;
        padding: 0 0.85rem;
        font-size: 0.925rem;
        border-radius: var(--radius);
        text-align: left;
        width: 100%;
    }

    .tabbar > a.active { background: var(--accent-soft); }
    .tabbar > a:hover:not(.active), .tabbar .tabbar-link:hover { background: var(--surface-2); }

    /* Theme and sign-out live at the foot of the sidebar, where desktop users look. */
    .tabbar .tabbar-foot {
        display: flex;
        flex-direction: column;
        gap: var(--s1);
        margin-top: auto;
        padding-top: var(--s3);
        border-top: 1px solid var(--border);
    }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 44px;
    padding: 0.6rem 1.1rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, transform .08s, opacity .15s;
    user-select: none;
}

.btn:hover { color: var(--text); }
.btn:active { transform: scale(0.975); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--danger) 84%, #000); border-color: transparent; color: #fff; }

.btn-lg { min-height: 52px; font-size: 1.05rem; padding-inline: var(--s5); }
.btn-sm { min-height: 36px; font-size: 0.85rem; padding: 0.3rem 0.8rem; }
.btn-icon { min-height: 44px; width: 44px; padding: 0; border-radius: 50%; }
.btn-block { width: 100%; }

.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn-lg svg { width: 20px; height: 20px; }
.btn-sm svg { width: 15px; height: 15px; }

.icon-lead { width: 24px; height: 24px; flex: 0 0 auto; color: var(--accent); margin-top: 3px; }

/* Theme toggle. The only rule set that cannot use light-dark(), because it switches
   display rather than colour, so both branches are spelled out. Shows the theme you
   are about to move to, not the one you are in. */
.theme-toggle .to-light { display: none; }
.theme-toggle .to-dark { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .to-dark { display: none; }
    :root:not([data-theme="light"]) .theme-toggle .to-light { display: block; }
}

:root[data-theme="dark"] .theme-toggle .to-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .to-light { display: block; }
:root[data-theme="light"] .theme-toggle .to-dark { display: block; }
:root[data-theme="light"] .theme-toggle .to-light { display: none; }

/* The language switch has to be a form (it posts the choice to the server), but the topbar
   and the sidebar foot lay out their children directly. display: contents takes the wrapper
   out of the box tree so the button sits where a bare button like .theme-toggle would. */
.language-toggle { display: contents; }

/* --- Cards & surfaces --------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 0.85rem; }

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .15s, transform .08s;
}
.card-link:hover { border-color: var(--border-strong); color: inherit; }
.card-link:active { transform: scale(0.995); }

.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row-nowrap { flex-wrap: nowrap; }
.row-top { align-items: flex-start; }
.row-center { justify-content: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.spacer { flex: 1; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 0.85rem; }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.measure { max-width: 34rem; margin-inline: auto; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s1);
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.pill-open { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.pill-closed { background: var(--surface-sunken); color: var(--text-faint); }

/* Page header: title on the left, one action on the right, wraps on narrow. */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s3);
    flex-wrap: wrap;
    margin-bottom: var(--s5);
}
.page-head h1, .page-head h2 { margin-bottom: 0; }
.page-head p { margin-bottom: 0; }
.page-head .eyebrow { margin-bottom: var(--s1); }

.section-head { margin-top: var(--s6); }
.qr-actions { margin-top: var(--s4); }
.detail-actions { margin: 1.25rem 0; }
.dialog-actions { margin-top: 1.25rem; }
.dialog-actions .btn { flex: 1; }

/* --- Landing ------------------------------------------------------------ */

.hero { text-align: center; padding: var(--s6) 0 var(--s4); }
.hero h1 { text-wrap: balance; }
.hero-mark { color: var(--accent); }
.hero-actions { margin-top: 1.25rem; }

.join-card { margin-top: var(--s6); }
.join-form { margin-top: var(--s3); }
.join-input {
    flex: 1;
    min-width: 0;
    text-transform: uppercase;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    letter-spacing: 0.12em;
    text-align: center;
}
.join-input::placeholder { letter-spacing: 0.1em; opacity: 0.5; }

.feature-list { margin-top: var(--s6); }
.feature-list h3 { margin-bottom: var(--s1); }

.error-actions { margin-top: var(--s5); }
.error-ref { margin-top: var(--s5); }

.poster-toolbar { margin-bottom: 1.25rem; }
.poster-footnote { margin-top: 1.25rem; }

/* --- Empty & status states --------------------------------------------- */

.empty {
    text-align: center;
    padding: var(--s7) 1.25rem;
    color: var(--text-muted);
}
.empty svg { width: 44px; height: 44px; margin: 0 auto 0.85rem; color: var(--text-faint); }
.empty h3 { color: var(--text); }
.empty .btn { margin-top: var(--s4); }

.alert {
    padding: 0.8rem var(--s4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.925rem;
}
.alert + .alert, .alert + .card, .card + .alert { margin-top: 0.85rem; }
.alert-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.alert-success { border-color: color-mix(in srgb, var(--success) 45%, transparent); background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.alert-warning { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); color: var(--warning); }

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

.field { display: block; margin-bottom: var(--s4); }
.field > label, .form-label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.field-hint { display: block; margin-top: 0.3rem; color: var(--text-faint); font-size: 0.8rem; }

.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="number"], input[type="tel"],
input[type="url"], textarea, select {
    display: block;
    width: 100%;
    font: inherit;
    /* 16px minimum: anything smaller makes iOS Safari zoom the viewport on focus. */
    font-size: 16px;
    min-height: 46px;
    padding: 0.6rem 0.8rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}

textarea { min-height: 90px; resize: vertical; }

.form-control:focus, input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.form-control.invalid, .invalid:not(form) { border-color: var(--danger); }
.validation-message { display: block; margin-top: 0.3rem; color: var(--danger); font-size: 0.825rem; }
.validation-errors { list-style: none; margin: 0 0 var(--s4); padding: 0; color: var(--danger); font-size: 0.875rem; }
.validation-errors:empty { display: none; }

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.55rem 0;
    cursor: pointer;
}
.checkbox input[type="checkbox"] {
    width: 22px; height: 22px;
    margin: 1px 0 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}
.checkbox span { font-size: 0.925rem; }
.checkbox .faint { display: block; }

/* Form footers keep their buttons full-width on a phone, inline on desktop. */
.form-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s5); }
.form-actions .btn { width: 100%; }

@media (min-width: 560px) {
    .form-actions { flex-direction: row; }
    .form-actions .btn { width: auto; }
    .form-actions .btn:first-child { order: 2; }
    .form-actions .btn:not(:first-child) { order: 1; }
    .form-actions::before { content: ""; flex: 1; order: 0; }
}

/* --- Gallery ------------------------------------------------------------ */

/* Inside a .bleed container, restore the normal gutter for prose-like blocks. */
.bleed-pad { padding: var(--s4) var(--s4) 0; }

.gallery-head {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4);
}
.gallery-more { padding: 1.25rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 2px;
}

@media (min-width: 700px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px; }
}

.tile {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--surface-sunken);
    border: 0;
    padding: 0;
    cursor: pointer;
    display: block;
    /* Stops the iOS text-selection callout on long-press-to-select. */
    -webkit-touch-callout: none;
    user-select: none;
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .25s ease;
}

.tile:hover img { transform: scale(1.04); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* The signature moment. A tile whose thumbnail was still being generated when
   the page loaded comes up like a print in the developer tray the instant the
   background worker finishes. Only applied to genuine Pending -> Ready
   transitions, so a gallery of already-processed photos stays still. */
@keyframes develop {
    from { opacity: 0.12; filter: contrast(0.35) brightness(0.45) saturate(0.4); }
    60%  { opacity: 1; }
    to   { opacity: 1; filter: none; }
}

.tile-developed img { animation: develop .75s cubic-bezier(.22, .61, .36, 1) both; }

.tile-badge {
    position: absolute;
    right: 5px;
    bottom: 5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    background: var(--scrim);
    color: var(--on-scrim);
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(4px);
}
.tile-badge svg { width: 12px; height: 12px; }

.tile-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-faint);
    background: repeating-linear-gradient(45deg, var(--surface-sunken), var(--surface-sunken) 8px, var(--surface-2) 8px, var(--surface-2) 16px);
}
.tile-placeholder svg { width: 26px; height: 26px; }

/* Still developing: a slow breath, not a marketing shimmer. */
.tile-pending::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent);
    animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.tile-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile-selected img { transform: scale(0.92); border-radius: var(--radius-sm); }
.tile:hover.tile-selected img { transform: scale(0.92); }

.tile-check {
    position: absolute; top: 5px; left: 5px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent); color: var(--accent-contrast);
    display: flex; align-items: center; justify-content: center;
    z-index: 1;
}
.tile-check svg { width: 14px; height: 14px; }

/* Unselected tiles in select mode get an empty ring, so the mode is legible. */
.grid-selecting .tile:not(.tile-selected) .tile-check {
    background: var(--scrim);
    color: transparent;
    box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.85);
}

/* Selection action bar: floats over the grid, same family as .dock. */
.selectbar {
    position: sticky;
    bottom: 0;
    z-index: 32;
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--border);
}
.selectbar .selectbar-count { font-weight: 650; font-variant-numeric: tabular-nums; }

/* --- Lightbox ----------------------------------------------------------- */

.lightbox {
    padding: 0;
    border: 0;
    width: 100dvw;
    max-width: 100dvw;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--stage);
    color: var(--on-scrim);
    overflow: hidden;
}

.lightbox::backdrop { background: rgb(0 0 0 / 0.85); }

.lightbox-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

.lightbox-stage img, .lightbox-stage video {
    max-width: 100dvw;
    max-height: 100dvh;
    width: auto;
    height: auto;
    object-fit: contain;
}

.lightbox-bar {
    position: absolute;
    left: 0; right: 0;
    display: flex;
    align-items: center;
    gap: var(--s1);
    padding: 0.6rem var(--s3);
    background: linear-gradient(to bottom, rgb(0 0 0 / 0.62), transparent);
    z-index: 2;
}
.lightbox-bar.top { top: 0; padding-top: max(0.6rem, var(--safe-t)); }
.lightbox-bar.bottom {
    bottom: 0;
    top: auto;
    background: linear-gradient(to top, rgb(0 0 0 / 0.62), transparent);
    padding-bottom: max(0.6rem, var(--safe-b));
    justify-content: center;
}

.lightbox .btn {
    background: rgb(255 255 255 / 0.12);
    border-color: transparent;
    color: var(--on-scrim);
}
.lightbox .btn:hover { background: rgb(255 255 255 / 0.22); color: var(--on-scrim); }

/* Read as a frame number on a contact sheet, not a pagination widget. */
.lightbox-count {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: rgb(255 255 255 / 0.72);
    font-variant-numeric: tabular-nums;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: none;
}
.lightbox-nav.prev { left: var(--s3); }
.lightbox-nav.next { right: var(--s3); }

@media (min-width: 700px) and (hover: hover) {
    .lightbox-nav { display: inline-flex; }
}

/* --- Upload panel ------------------------------------------------------- */

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: var(--s6) 1.25rem;
    text-align: center;
    color: var(--text-muted);
    transition: border-color .15s, background-color .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }

.uploads { list-style: none; margin: 0.85rem 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }

/* The dock's action cluster. Doubles as the drag-and-drop target. */
.dock-actions {
    border-radius: var(--radius-pill);
    transition: box-shadow .15s;
}
.dock-actions.dragover {
    box-shadow: 0 0 0 3px var(--accent);
}
.dock-hint {
    margin: var(--s2) 0 0;
    text-align: center;
    font-size: 0.75rem;
}

/* Docked upload list: a short scrolling strip, never a growing page. */
.upload-strip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--s2) var(--s3);
    box-shadow: var(--shadow);
}
.upload-strip-head { padding: var(--s1) var(--s1) var(--s2); }

.uploads-docked {
    margin: 0;
    max-height: min(40dvh, 16rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: var(--s1);
}

.upload-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    padding: var(--s2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.uploads-docked .upload-row { border-color: transparent; padding-inline: var(--s1); }
.upload-row-main { min-width: 0; }

.upload-thumb {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-sunken);
}

.upload-name {
    font-size: 0.85rem;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-meta { font-size: 0.75rem; color: var(--text-muted); }
.upload-meta.error { color: var(--danger); }

.progress {
    height: 4px;
    margin-top: 4px;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    overflow: hidden;
}
.progress > div {
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width .2s ease;
}

.upload-status svg { width: 20px; height: 20px; }
.upload-status.done { color: var(--success); }
.upload-status.error { color: var(--danger); }

.upload-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Event covers (organizer dashboard) --------------------------------- */

/* Each event wears its own photographs: one large frame plus two stacked. */
.cover {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    aspect-ratio: 2 / 1;
    background: var(--surface-sunken);
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover > :first-child { grid-row: span 2; }

/* One or two photos fill the frame rather than leaving a hole in the mosaic. */
.cover-1 { grid-template-columns: 1fr; }
.cover-2 { grid-template-columns: 1fr 1fr; }
.cover-2 > * { grid-row: span 2; }

.cover-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 2 / 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: var(--text-faint);
    background:
        repeating-linear-gradient(45deg, var(--surface-sunken), var(--surface-sunken) 10px, var(--surface-2) 10px, var(--surface-2) 20px);
}
.cover-empty svg { width: 30px; height: 30px; }

.event-card { padding: 0; overflow: hidden; }
.event-card .event-card-body { padding: var(--s4); }
.event-card h3 { margin: 0; }
.event-card .faint { margin: 0.35rem 0 0; }
.event-card .join-line { margin-top: var(--s1); }

.event-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 0.85rem;
}

.loading-block { padding: var(--s6); }

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

.qr-card { text-align: center; }

.qr-card img {
    width: min(260px, 70vw);
    margin: 0 auto 0.85rem;
    border-radius: var(--radius);
    /* QR readers need real white behind the modules, in either theme. */
    background: #fff;
    padding: 10px;
}

.join-code {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.join-url { font-size: 0.85rem; color: var(--text-muted); word-break: break-all; }

/* --- Account & auth ----------------------------------------------------- */

/* Signed-out flows: one narrow column, centred, nothing else on screen. */
.auth {
    width: 100%;
    max-width: 26rem;
    margin-inline: auto;
    padding-block: var(--s5) var(--s7);
}
.auth h1 { text-align: center; margin-bottom: var(--s5); }
.auth .card + .auth-alt { margin-top: var(--s4); }
.auth-alt { text-align: center; font-size: 0.9rem; color: var(--text-muted); margin-top: var(--s4); }
.auth-alt a { font-weight: 600; }
.auth-submit { margin-top: var(--s2); }
.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s2) var(--s4);
    margin: var(--s4) 0 0;
    font-size: 0.875rem;
}
.external-logins { margin-top: var(--s4); }

/* "OR" rule between password and passkey sign-in. */
.rule {
    display: flex;
    align-items: center;
    gap: var(--s3);
    margin: var(--s4) 0;
    color: var(--text-faint);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.rule::before, .rule::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Account settings nav: a scrolling segmented strip on a phone, a list on desktop. */
.segmented {
    display: flex;
    gap: var(--s1);
    margin: 0 0 var(--s5);
    padding: 0 0 var(--s2);
    list-style: none;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented a {
    display: block;
    white-space: nowrap;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--accent); color: var(--accent-contrast); }

.manage-signout { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--border); }

@media (min-width: 860px) {
    .manage-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s6); align-items: start; }
    .segmented { flex-direction: column; overflow: visible; margin: 0; padding: 0; }
    .segmented a { border-radius: var(--radius); background: transparent; }
    .segmented a:hover:not(.active) { background: var(--surface-2); }
    /* The sidebar already carries sign-out at this width. */
    .manage-signout { display: none; }
}

/* One-time codes: tracked out and tabular so six digits are easy to check. */
.code-input {
    font-family: var(--font-mono);
    letter-spacing: 0.22em;
    font-variant-numeric: tabular-nums;
}

.field-hint.confirmed { display: inline-flex; align-items: center; gap: var(--s1); color: var(--success); }
.field-hint.confirmed svg { width: 14px; height: 14px; }
.verify-btn { margin-top: var(--s2); }
.two-factor-actions { margin-top: var(--s4); }
.add-passkey { margin-top: var(--s4); }
.recovery-codes { margin-top: var(--s4); }

/* Recovery codes and authenticator keys: readable, selectable, wrapping. */
.code-block {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    word-break: break-all;
    user-select: all;
    padding: var(--s3);
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.code-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--s2);
    list-style: none;
    margin: 0;
    padding: 0;
}
.code-list li {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: center;
    padding: var(--s2);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    user-select: all;
}

/* A titled row with an action on the right; replaces the scaffold's tables. */
.list-row {
    display: flex;
    align-items: center;
    gap: var(--s3);
    flex-wrap: wrap;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; overflow-wrap: anywhere; }

/* --- Dialogs ------------------------------------------------------------ */

.dialog {
    width: min(28rem, calc(100vw - 2rem));
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog h2 { margin-bottom: var(--s2); }

/* --- Print poster ------------------------------------------------------- */

.poster {
    max-width: 520px;
    margin: 0 auto;
    padding: var(--s6) var(--s5);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.poster img { width: min(340px, 78vw); margin: var(--s4) auto; background: #fff; padding: 12px; border-radius: var(--radius); }
.poster-title { font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.6rem); margin-bottom: var(--s1); }
.poster-date { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); }
.poster .join-code { font-size: 1.6rem; letter-spacing: 0.24em; }

@page { size: A5; margin: 12mm; }

@media print {
    :root {
        color-scheme: light;
        --surface: #fff; --bg: #fff; --text: #000; --text-muted: #444;
        --text-faint: #666; --border: #bbb;
    }
    body { background: #fff; color: #000; }
    .topbar, .tabbar, .actionbar, .dock, .selectbar, .no-print { display: none !important; }
    .shell-body { padding: 0; max-width: none; }
    .poster { border: 0; max-width: none; box-shadow: none; padding: 0; }
    .poster img { width: 62mm; }
    a { color: #000; text-decoration: none; }
}

/* --- Motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .tile-developed img { animation: none; }
    .tile-pending::after { display: none; }
}

/* --- Blazor plumbing ---------------------------------------------------- */

/* The reconnect overlay is rethemed in Components/Layout/ReconnectModal.razor.css. */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1001;
    padding: 0.8rem var(--s4) calc(0.8rem + var(--safe-b));
    background: light-dark(#26282c, #f0f0ee);
    color: light-dark(#fff, #16171a);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui a { color: inherit; margin-left: var(--s2); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; padding: 0 var(--s2); }
