/*
 * Bildergalerie — quiet, photo first.
 *
 * Both themes are driven from one set of tokens. The light palette is the
 * bare :root declaration, so every colour has a value before any media query
 * runs; the dark palette then overrides only what actually changes.
 *
 * Which theme a visitor gets:
 *   - no data-theme on <html>   → follow the operating system,
 *   - data-theme="light"|"dark" → pin the page to that theme.
 *
 * Either way the palette stays low contrast, so nothing competes with the
 * photographs; only interactive elements get real brightness.
 */

:root {
    color-scheme: light;

    --bg: #f4f1ec;
    --surface-1: #ffffff;
    --surface-2: #faf8f5;
    --surface-3: #ece7e0;
    --border: rgba(28, 22, 14, 0.12);
    --border-strong: rgba(28, 22, 14, 0.26);
    /* The outline of a text field: 3:1 against the field and the panel, as
       WCAG 1.4.11 asks of a control's boundary; --border is for lines that
       only separate. */
    --border-field: rgba(28, 22, 14, 0.5);

    --text: #1c1815;
    --text-secondary: #5e574f;
    --text-muted: #736b61;

    /* The accent doubles as a link colour and as a button background, so it
       needs enough contrast against the page *and* a readable ink on top. */
    --accent: #825d2c;
    --accent-hover: #68471f;
    --accent-ink: #ffffff;
    --accent-soft: rgba(130, 93, 44, 0.1);
    --accent-border: rgba(130, 93, 44, 0.42);

    --danger: #c62a2f;
    --danger-soft: rgba(198, 42, 47, 0.09);
    --danger-border: rgba(198, 42, 47, 0.32);

    --success: #2f7a52;
    --success-soft: rgba(47, 122, 82, 0.1);
    --success-border: rgba(47, 122, 82, 0.35);

    --select: #2563eb;

    /* Backing for the sticky bars — --bg with the blur showing through. */
    --veil: rgba(244, 241, 236, 0.86);

    /* Thin strokes only read well on a dark ground; see the dark palette. */
    -webkit-font-smoothing: auto;

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

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-voice: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

    --shell: 1180px;
    /* Pages that are mostly photos: the gallery, favourites, collection. */
    --shell-wide: 1680px;
}

/*
 * Dark palette.
 *
 * The declarations are written out twice on purpose: plain CSS cannot share
 * one block between a media query and an attribute selector, and duplicating
 * twenty tokens beats maintaining a build step for it. Keep the two lists in
 * sync when adding a token.
 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0a0a0b;
        --surface-1: #131315;
        --surface-2: #17171a;
        --surface-3: #1e1e22;
        --border: rgba(255, 255, 255, 0.09);
        --border-strong: rgba(255, 255, 255, 0.18);
        --border-field: rgba(255, 255, 255, 0.38);

        --text: #f1efec;
        --text-secondary: #a5a19c;
        --text-muted: #8b857e;

        --accent: #d8b98d;
        --accent-hover: #e6cba5;
        --accent-ink: #241c10;
        --accent-soft: rgba(216, 185, 141, 0.14);
        --accent-border: rgba(216, 185, 141, 0.4);

        --danger: #e5484d;
        --danger-soft: rgba(229, 72, 77, 0.12);
        --danger-border: rgba(229, 72, 77, 0.38);

        --success: #4ea172;
        --success-soft: rgba(78, 161, 114, 0.1);
        --success-border: rgba(78, 161, 114, 0.4);

        --select: #3b82f6;

        --veil: rgba(10, 10, 11, 0.88);

        -webkit-font-smoothing: antialiased;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0a0a0b;
    --surface-1: #131315;
    --surface-2: #17171a;
    --surface-3: #1e1e22;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --border-field: rgba(255, 255, 255, 0.38);

    --text: #f1efec;
    --text-secondary: #a5a19c;
    --text-muted: #8b857e;

    --accent: #d8b98d;
    --accent-hover: #e6cba5;
    --accent-ink: #241c10;
    --accent-soft: rgba(216, 185, 141, 0.14);
    --accent-border: rgba(216, 185, 141, 0.4);

    --danger: #e5484d;
    --danger-soft: rgba(229, 72, 77, 0.12);
    --danger-border: rgba(229, 72, 77, 0.38);

    --success: #4ea172;
    --success-soft: rgba(78, 161, 114, 0.1);
    --success-border: rgba(78, 161, 114, 0.4);

    --select: #3b82f6;

    --veil: rgba(10, 10, 11, 0.88);

    -webkit-font-smoothing: antialiased;
}

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

/*
 * The browser's own [hidden] rule is a user-agent style, so *any* author
 * `display` on the same element wins over it and the element stays visible.
 * The category filter hides gallery cards by toggling `el.hidden`, and
 * .gallery-card sets `display: flex`, so this rule is what makes that work.
 * The !important is load-bearing: specificity alone cannot beat a normal
 * author declaration on the same element.
 */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

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

img {
    max-width: 100%;
    display: block;
}

h1, h2, h3 {
    font-family: var(--font-voice);
    font-weight: 500;
    letter-spacing: 0.01em;
    margin: 0;
}

h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

p { margin: 0 0 0.75rem; }

.shell {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
}

.shell--wide {
    max-width: var(--shell-wide);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 13px;
    line-height: 1;
    padding: 9px 15px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

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

.btn--ghost {
    background: transparent;
}

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

.btn--danger:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger);
}

.btn--block {
    width: 100%;
}

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn .icon {
    width: 16px;
    height: 16px;
}

/* --------------------------------------------------------------- app bar */

.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--veil);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.appbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: var(--appbar-min-height);
}

.appbar__brand {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-voice);
    font-size: 20px;
    letter-spacing: 0.02em;
}

/* The logo's size, shared with its preview on the admin logo page; the
   bar grows with it, keeping some air above and below. On a phone the
   logo leaves room for the menu button next to it.

   --appbar-default-height is the bar with its bottom border, as tall as
   it is unless its links wrap: what the page assumes until the appbar
   controller has measured the real height into --appbar-height. */
:root {
    --logo-height: 56px;
    --logo-max-width: 380px;
    --appbar-min-height: 76px;
    --appbar-default-height: calc(var(--appbar-min-height) + 1px);
}

@media (max-width: 640px) {
    :root {
        --logo-height: 44px;
        --logo-max-width: 240px;
        --appbar-min-height: 60px;
    }
}

.appbar__logo {
    display: block;
    height: var(--logo-height);
    width: auto;
    max-width: var(--logo-max-width);
    object-fit: contain;
}

/* With a dark variant, only one of the two shows: the light one by
   default, the dark one wherever the page is dark — following the
   operating system unless the theme switch pinned it. */
.appbar__logo--dark {
    display: none;
}

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

    :root:not([data-theme="light"]) .appbar__logo--dark {
        display: block;
    }
}

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

:root[data-theme="dark"] .appbar__logo--dark {
    display: block;
}

.appbar__nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.navlink {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

/* Signing out is a form; it takes part in the nav's flex layout as if the
   button were one of the links. */
.appbar__form {
    display: contents;
}

button.navlink {
    background: transparent;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.navlink:hover,
.navlink.is-active {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

.navlink .icon {
    width: 16px;
    height: 16px;
}

/*
 * The menu button and the links behind it, on a narrow screen (see
 * appbar_controller.js; keep the width in step with NARROW there). Only
 * with the script there to open it ("has-menu"); without, the links wrap
 * as on a wide screen. The panel lies over the page instead of pushing it
 * down, so the bar keeps its height.
 */
.appbar__toggle {
    display: none;
}

@media (max-width: 900px) {
    .appbar.has-menu .appbar__toggle {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: var(--radius-pill);
        border: 1px solid var(--border);
        background: transparent;
        color: var(--text);
        cursor: pointer;
    }

    .appbar.has-menu .appbar__toggle-icon {
        grid-area: 1 / 1;
        width: 20px;
        height: 20px;
    }

    .appbar__toggle-icon--close,
    .appbar.has-menu.is-open .appbar__toggle-icon--open {
        display: none;
    }

    .appbar.has-menu.is-open .appbar__toggle-icon--close {
        display: block;
    }

    .appbar.has-menu .appbar__nav {
        display: none;
        position: absolute;
        inset: 100% 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        max-height: calc(100svh - var(--appbar-height, var(--appbar-default-height)));
        overflow-y: auto;
        padding: 10px clamp(16px, 4vw, 32px) 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    }

    .appbar.has-menu.is-open .appbar__nav {
        display: flex;
    }

    .appbar.has-menu .appbar__nav .navlink {
        justify-content: flex-start;
        padding: 12px 14px;
        font-size: 15px;
        border-radius: var(--radius);
    }

    .appbar.has-menu .appbar__nav .icon {
        width: 18px;
        height: 18px;
    }

    /* Laid out like the links, with its text. */
    .appbar.has-menu .appbar__nav .theme-toggle {
        display: flex;
        justify-content: flex-start;
        gap: 7px;
        width: auto;
        height: auto;
        padding: 12px 14px;
        border-radius: var(--radius);
        font: inherit;
        font-size: 15px;
    }

    .appbar.has-menu .appbar__nav .theme-toggle__text {
        display: inline;
    }
}

/* ---------------------------------------------------------- theme switch */

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

/* Even, like the circle, for a whole-pixel inset — see .tile__toggle .icon. */
.theme-toggle .icon {
    width: 16px;
    height: 16px;
}

/*
 * Which of the three icons is visible is derived from the same data-theme
 * attribute the palette reads, rather than from JavaScript. That way the
 * button is already showing the right state on the very first paint, when
 * the inline head script has set the attribute but Stimulus has not started.
 *
 * No attribute means "automatisch", which is the default shown here.
 */
.theme-toggle__icon {
    display: none;
}

.theme-toggle__icon--auto,
:root[data-theme="light"] .theme-toggle__icon--light,
:root[data-theme="dark"] .theme-toggle__icon--dark {
    display: block;
}

:root[data-theme="light"] .theme-toggle__icon--auto,
:root[data-theme="dark"] .theme-toggle__icon--auto {
    display: none;
}

/* Its text, in the menu on a narrow screen: the mode is picked the same way. */
.theme-toggle__text,
.theme-toggle__mode {
    display: none;
}

.theme-toggle__mode--auto,
:root[data-theme="light"] .theme-toggle__mode--light,
:root[data-theme="dark"] .theme-toggle__mode--dark {
    display: inline;
}

:root[data-theme="light"] .theme-toggle__mode--auto,
:root[data-theme="dark"] .theme-toggle__mode--auto {
    display: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-sans);
}

/*
 * Flex centring centres the line box, not the digits: their ink sat about a
 * pixel low, as the font's ascent and descent are not symmetric. Trimming the
 * text to its cap height — which digits share — makes the box the ink, so the
 * padding alone places it. The trim does not reach the anonymous item of a
 * flex box, hence the plain inline-block. Browsers without text-box keep the
 * flex centring above.
 */
@supports (text-box: trim-both cap alphabetic) {
    .badge {
        display: inline-block;
        box-sizing: border-box;
        min-width: 19px;
        height: auto;
        padding-block: calc((19px - 1cap) / 2);
        line-height: 1;
        text-align: center;
        text-box: trim-both cap alphabetic;
    }
}

/* ---------------------------------------------------------------- layout */

.page {
    padding: clamp(28px, 5vw, 52px) 0 80px;
}

/* A gallery opening with its cover across the whole screen: edge to edge,
   and as tall as the screen below the app bar. The bar is
   --appbar-default-height tall, more where its links wrap; the appbar
   controller keeps --appbar-height at its actual height. The hero takes back the page's top
   padding, so it starts right under the bar. */
.hero {
    position: relative;
    display: grid;
    place-items: center;
    height: calc(100svh - var(--appbar-height, var(--appbar-default-height)));
    min-height: 360px;
    margin-top: calc(-1 * clamp(28px, 5vw, 52px));
    margin-bottom: clamp(24px, 4vw, 40px);
    overflow: hidden;
    background: #0a0a0b;
    color: #fff;
    text-align: center;
}

.hero__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Darker towards the edges and the bottom, so white text stays readable
   on a bright photo without dimming the middle of the picture much. */
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.42) 100%),
        linear-gradient(to bottom, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
}

.hero__text {
    position: relative;
    z-index: 1;
    max-width: min(90vw, 760px);
    padding: 0 clamp(16px, 4vw, 32px);
    text-shadow: 0 1px 18px rgba(0, 0, 0, 0.45);
}

.hero__title {
    font-size: clamp(36px, 6vw, 68px);
    line-height: 1.05;
    color: #fff;
}

.hero__date {
    margin: 14px 0 0;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.86);
}

.hero__description {
    max-width: 56ch;
    margin: 12px auto 0;
    font-size: 15px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.86);
}

.page__head {
    text-align: center;
    padding-bottom: clamp(24px, 4vw, 40px);
}

.page__head .subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 8px 0 0;
}

.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 0;
}

.meta-facts {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
}

.meta-facts span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.meta-facts .icon {
    width: 15px;
    height: 15px;
}

.toolbar {
    position: sticky;
    /* Right under the app bar, overlapping its 1px border; the bar grows
       where its links wrap, see the appbar controller. */
    top: calc(var(--appbar-height, var(--appbar-default-height)) - 1px);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    background: var(--veil);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.toolbar__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* On a narrow screen the labelled buttons no longer fit beside each other,
   and a second row would make the sticky toolbar take a good part of the
   screen. The buttons keep their icons; the labels stay for screen
   readers. */
@media (max-width: 640px) {
    /* 16px icon, 9px all round and the border: a 36px circle. */
    .toolbar__actions .btn {
        padding: 9px;
    }

    .toolbar__actions .btn__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

.pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pills::-webkit-scrollbar { display: none; }

.pill {
    font-size: 13px;
    padding: 7px 13px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

.pill:hover { color: var(--text); }

.pill.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}

/* ------------------------------------------------------------ flash notes */

.flashes {
    display: grid;
    gap: 8px;
    padding-top: 16px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

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

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

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

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

.gallery-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    overflow: hidden;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.gallery-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    color: inherit;
}

.gallery-card__cover {
    aspect-ratio: 4 / 3;
    background: var(--surface-3);
    position: relative;
    overflow: hidden;
}

.gallery-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-card__empty {
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--text-muted);
}

.gallery-card__body {
    padding: 14px 16px 16px;
}

.gallery-card__title {
    font-family: var(--font-voice);
    font-size: 19px;
    margin: 0;
}

.gallery-card__meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/*
 * Marks, for administrators, why a gallery is not out for its customers
 * (gallery/_status.html.twig). It sits on photos too, so its colours are
 * the same in both themes.
 */
.status-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge--draft {
    background: #f2c14e;
    color: #2b2006;
}

.status-badge--expired,
.status-badge--unassigned {
    background: #3b3a3f;
    color: #f1efec;
}

.status-badge--password {
    background: #d8e6f5;
    color: #13283f;
}

.gallery-card__cover .status-badges {
    position: absolute;
    inset: 10px 10px auto 10px;
    z-index: 1;
}

.gallery-card__cover .status-badge {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.tag {
    display: inline-block;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* -------------------------------------------------------------- sections */

/*
 * One gallery renders each of its sub-galleries as a section. A gallery with
 * only one section hides the heading entirely, so it reads like an ungrouped
 * gallery rather than a list of one. The pills hide sections rather than
 * remove them, so only a visible section before it earns the gap.
 */
.section:not([hidden]) ~ .section {
    margin-top: 34px;
}

.section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.section__head h2 {
    font-size: 19px;
}

.section__count {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --------------------------------------------------------------- masonry */

.masonry {
    --masonry-gap: 6px;
    columns: 4;
    column-gap: var(--masonry-gap);
    margin-top: 20px;
}

@media (max-width: 1280px) { .masonry { columns: 3; } }
@media (max-width: 900px) { .masonry { columns: 2; } }
@media (max-width: 560px) { .masonry { columns: 1; } }

.tile {
    position: relative;
    break-inside: avoid;
    /* A <figure>: without this, the browser's own 40px on either side. */
    margin: 0 0 var(--masonry-gap);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.tile__button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.tile img {
    width: 100%;
    height: auto;
    display: block;
    background: var(--surface-3);
}

.tile__actions {
    /*
     * These controls sit on top of a photograph, so they keep the dark glass
     * treatment in both themes — their backdrop is the image, never the page.
     * The two state colours are pinned to values that stay legible on it.
     */
    --danger: #ff5f63;
    --select: #3b82f6;

    position: absolute;
    inset: 8px 8px auto auto;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tile:hover .tile__actions,
.tile:focus-within .tile__actions,
.tile.is-marked .tile__actions {
    opacity: 1;
}

.tile__toggle {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(12, 12, 14, 0.72);
    backdrop-filter: blur(6px);
    color: #fff;
    cursor: pointer;
    padding: 0;
}

/*
 * Even, like the 30px circle, so the inset is a whole 7px. With an odd size
 * the circle and the icon are snapped to the pixel grid separately — tiles
 * sit at fractional positions in the fluid columns — and the icon lands a
 * pixel off centre.
 */
.tile__toggle .icon {
    width: 16px;
    height: 16px;
}

.tile__toggle[aria-pressed="true"] .tile__icon-off,
.tile__toggle:not([aria-pressed="true"]) .tile__icon-on {
    display: none;
}

.tile__toggle[aria-pressed="true"][data-kind="bookmark"] {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 60%, transparent);
}

.tile__toggle[aria-pressed="true"][data-kind="bookmark"] .icon {
    fill: var(--danger);
}

.tile__toggle[aria-pressed="true"][data-kind="cart"] {
    background: var(--select);
    border-color: var(--select);
}

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

.lightbox {
    /*
     * The full screen viewer stays dark in both themes: at this size the
     * backdrop for a photograph should be black, not a bright page.
     * Re-declaring the tokens here means the controls inside it — including
     * the plain .btn — follow along without any extra rules.
     */
    --surface-2: #1c1c1f;
    --surface-3: #26262a;
    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.28);
    --text: #f1efec;
    --text-secondary: #a5a19c;
    --accent: #d8b98d;
    --accent-hover: #e6cba5;
    --accent-ink: #241c10;

    /* A <dialog>: none of the browser's own frame, margin and size limits. */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--text);
    background: rgba(6, 6, 7, 0.97);
    display: none;
    flex-direction: column;
}

.lightbox::backdrop {
    background: transparent;
}

.lightbox[open] {
    display: flex;
}

.lightbox__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.lightbox__stage {
    flex: 1;
    /* Sideways swipes are the viewer's (paging); scrolling up and down and
       zooming with two fingers stay the browser's. */
    touch-action: pan-y pinch-zoom;
    position: relative;
    /* The neighbours wait just out of view, either side. */
    overflow: hidden;
    user-select: none;
    display: grid;
    /*
     * An explicit, shrinkable track gives the cell a definite size. With the
     * implicit auto row the cell grows to fit the photo, so the image's
     * max-height: 100% has nothing to resolve against and tall photos spill
     * out past the footer.
     */
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    padding: 0 18px;
    min-height: 0;
}

/*
 * The slides share the stage's one cell; each sits one width (and a gap)
 * further along, and all of them move by --drag, which lightbox_controller.js
 * sets while a finger drags them and to slide in the next photo.
 */
.lightbox__slide {
    --slot: 0;
    --slide-gap: 36px;
    grid-area: 1 / 1;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    transform: translateX(calc(var(--slot) * (100% + var(--slide-gap)) + var(--drag, 0px)));
    transition: transform 280ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.lightbox__slide--before { --slot: -1; }
.lightbox__slide--after { --slot: 1; }

.lightbox__stage.is-dragging .lightbox__slide {
    transition: none;
}

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

.lightbox__stage img {
    -webkit-user-drag: none;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.lightbox__nav {
    position: absolute;
    /* Above the slides, which their transform lifts into layers of their own. */
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: rgba(24, 24, 27, 0.85);
    color: var(--text);
    cursor: pointer;
    padding: 0;
}

.lightbox__nav--prev { left: 14px; }
.lightbox__nav--next { right: 14px; }

.lightbox__footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 18px 24px;
}

/* Same state colours as the tile toggles, so a marked photo reads the same. */
.lightbox__toggle[aria-pressed="true"][data-kind="bookmark"] {
    --bookmark: #ff5f63;
    color: var(--bookmark);
    border-color: color-mix(in srgb, var(--bookmark) 60%, transparent);
}

.lightbox__toggle[aria-pressed="true"][data-kind="bookmark"] .icon {
    fill: var(--bookmark);
}

.lightbox__toggle[aria-pressed="true"][data-kind="cart"] {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

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

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    padding: clamp(20px, 4vw, 30px);
}

.panel--narrow {
    max-width: 440px;
    margin: 0 auto;
}

/* The watermark page, with its previews (admin/watermark.html.twig). */
.panel--watermark {
    max-width: 640px;
}

.watermark-range-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.watermark-range-label output {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.watermark-samples {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px;
}

.watermark-sample {
    margin: 0;
}

.watermark-sample canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Upright, it would tower over the others at the full column width. */
.watermark-sample:last-child canvas {
    width: 66%;
}

.watermark-sample figcaption {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.panel__title {
    font-family: var(--font-voice);
    font-size: 24px;
    margin-bottom: 6px;
}

.panel__lead {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
}

.field {
    display: block;
    margin-bottom: 14px;
}

/* The logo as it shows in the app bar, on the app bar's colour in either
   scheme. */
.logo-preview {
    display: flex;
    align-items: center;
    min-height: var(--appbar-min-height);
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.logo-preview img {
    height: var(--logo-height);
    width: auto;
    max-width: var(--logo-max-width);
    object-fit: contain;
}

.field > label,
.field-label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-field);
    border-radius: var(--radius);
    padding: 11px 13px;
}

.input:focus,
input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* A tile's photo button fills the tile, which clips whatever reaches past
   its rounded corners, the ring of the button included. The ring goes
   around the tile instead. */
.tile__button:focus-visible {
    outline: none;
}

.tile:has(> .tile__button:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.input--code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 17px;
    letter-spacing: 0.16em;
    text-align: center;
    text-transform: uppercase;
}

/* A password field with its show/hide button (password_visibility_controller.js). */
.password-field {
    position: relative;
    display: block;
}

.password-field input {
    padding-right: 92px;
}

.password-field__toggle {
    position: absolute;
    inset: 50% 6px auto auto;
    transform: translateY(-50%);
    padding: 5px 10px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.password-field__toggle:hover,
.password-field__toggle:focus-visible {
    color: var(--text);
    background: var(--surface-2);
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin: 0 0 14px;
}

.form-help {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 6px;
}

/* A link within a sentence ("Passwort vergessen?", "Hier einlösen") has to
   look like one: links are otherwise drawn as plain text (see "a" above),
   which suits the navigation and the cards, not a running sentence. */
.form-help a,
.panel__lead a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.form-help a:hover,
.panel__lead a:hover {
    color: var(--accent-hover);
}

/* ----------------------------------------------------------- code tokens */

.token-list {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.token {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.token__code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 16px;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.token__meta {
    font-size: 12px;
    color: var(--text-muted);
}

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

.empty {
    text-align: center;
    padding: clamp(40px, 8vw, 80px) 20px;
    color: var(--text-secondary);
}

.empty .icon {
    width: 30px;
    height: 30px;
    color: var(--text-muted);
    margin: 0 auto 14px;
}

/* ------------------------------------------------------------------ misc */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}

.stat {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 16px;
}

.stat__value {
    font-family: var(--font-voice);
    font-size: 30px;
    line-height: 1.1;
}

.stat__label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 22px 0 40px;
    font-size: 12px;
    color: var(--text-muted);
}

.site-footer__links {
    gap: 18px;
}

/* --------------------------------------------------------- legal texts */

/* The imprint and the privacy policy: a column of text, short enough lines
   to read. */
.legal {
    max-width: 68ch;
    margin: 0 auto;
    padding-top: clamp(24px, 4vw, 40px);
}

/*
 * HTML from the backend's text editor (Trix). It writes each paragraph as
 * a <div>, with <br> for a line break within it, and offers all six levels
 * of heading. Even its <h1> ranks below the page's own title here.
 */
.prose {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.prose > div,
.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre {
    margin: 0 0 1em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    margin: 1.8em 0 0.6em;
    line-height: 1.3;
    color: var(--text);
}

/* h1 to h3 in the display face, like the site's own headings; h4 to h6
   as small labels in the text face. */
.prose h1 { font-size: 22px; }
.prose h2 { font-size: 19px; }
.prose h3 { font-size: 17px; }

.prose h4,
.prose h5,
.prose h6 {
    font-weight: 600;
}

.prose h4 { font-size: 15px; }

.prose h5,
.prose h6 {
    margin-top: 1.4em;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.prose h6 { color: var(--text-secondary); }

.prose > :first-child { margin-top: 0; }

.prose strong { color: var(--text); }

.prose a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose ul,
.prose ol { padding-left: 1.4em; }

.prose blockquote {
    padding-left: 14px;
    border-left: 2px solid var(--border-strong);
}

.prose pre {
    white-space: pre-wrap;
    font: inherit;
}

.icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cluster--end { justify-content: flex-end; }
.stack { display: grid; gap: 14px; }
