/* Site layout (redesign). Loaded after Bootstrap 3, which page content still uses. */

:root {
    --c-bg: #F5F5F3;
    --c-surface: #FFFFFF;
    --c-ink: #1B1B1A;
    --c-ink-2: #45453F;
    --c-muted: #5E5E5A;
    --c-border: #E2E1DC;
    --c-border-strong: #C9C8C2;
    --c-hover: #EFEEEA;
    --c-badge: #F0EFEB;
    --c-accent: #B3261E;
    --c-accent-dark: #8C1D17;
    --c-accent-soft: #FBEAE8;
    --c-own: #1E6B43;
    --c-own-frame: #2F855A;
    --c-own-soft: #E7F2EC;
    --c-own-ink: #164F32;

    --font-ui: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: Literata, Georgia, serif;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;
    --tap: 44px;
    --sidebar-w: 288px;
    --page-max: 1600px;
    --page-pad: clamp(16px, 3vw, 32px);
    --header-h: 65px;
    --bottom-nav-h: 68px;
}

/* Base */

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

/* Column layout keeps the footer at the bottom of the window on short pages. */
body.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
}

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

.site a {
    color: var(--c-accent);
    text-decoration: none;
}

.site a:hover,
.site a:focus {
    color: var(--c-accent-dark);
    text-decoration: underline;
}

.site button,
.site input,
.site select,
.site textarea {
    font: inherit;
}

.site :focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
}

.site h1,
.site h2,
.site h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--c-ink);
}

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

.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--c-ink);
    color: #FFFFFF !important;
    font-weight: 600;
}

.skip-link:focus {
    top: 8px;
}

.icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Buttons */

.btn-ui {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: var(--tap);
    height: var(--tap);
    padding: 0 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-ink) !important;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
}

.btn-ui:hover {
    background: var(--c-hover);
}

.btn-ui[hidden] {
    display: none;
}

.btn-ui--primary {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: #FFFFFF !important;
    font-weight: 600;
}

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

.btn-ui--icon {
    padding: 0;
}

.btn-ui--ghost {
    border-color: transparent;
    background: transparent;
}

/* Header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
}

.site-header__bar {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 10px var(--page-pad);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.site-brand {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    text-decoration: none !important;
}

.site-brand img {
    display: block;
    height: 40px;
    width: auto;
}

.site-nav {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    height: var(--tap);
    padding: 0 14px;
    border-radius: var(--radius);
    color: var(--c-ink) !important;
    font-weight: 500;
    text-decoration: none !important;
    white-space: nowrap;
}

.site-nav__link:hover {
    background: var(--c-hover);
}

.site-nav__link[aria-current="page"] {
    background: var(--c-accent-soft);
    color: var(--c-accent-dark) !important;
    font-weight: 600;
}

.site-header__spacer {
    flex: 1 1 0;
}

.site-header__drawer-toggle,
.site-header__search-toggle {
    display: none;
}

.site-header__auth a[aria-current="page"] {
    background: var(--c-accent-soft);
    color: var(--c-accent-dark) !important;
    font-weight: 600;
}

.site-header__auth {
    display: flex;
    gap: 4px;
}

/* Search */

.site-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: clamp(200px, 26vw, 360px);
    height: var(--tap);
    margin: 0;
    padding: 0 4px 0 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
    color: var(--c-muted);
}

.site-search:focus-within {
    border-color: var(--c-border-strong);
    background: var(--c-surface);
}

.site-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--c-ink);
    font: inherit;
    font-size: 15px;
    outline: none;
}

.site-search__submit {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--c-ink-2);
    cursor: pointer;
}

.site-search__submit:hover {
    background: var(--c-hover);
}

/* Dropdown menus (details/summary) */

.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
}

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

.menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    min-width: 240px;
    padding: 6px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: 0 12px 32px rgba(20, 20, 18, 0.16);
}

.menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--c-ink) !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.menu__item:hover {
    background: var(--c-hover);
}

.menu__item .icon {
    color: var(--c-muted);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    border: 1px solid var(--c-border);
    border-radius: 50%;
    background: var(--c-bg);
    color: var(--c-ink);
    cursor: pointer;
}

.avatar:hover {
    background: var(--c-hover);
}

/* Admin bar: second header row, only for moderators */

.admin-bar {
    position: sticky;
    top: var(--header-h);
    z-index: 29;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
    font-size: 14px;
}

.admin-bar__inner {
    max-width: var(--page-max);
    min-height: 48px;
    margin: 0 auto;
    padding: 0 var(--page-pad);
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}

.admin-bar__label {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
    padding-right: 12px;
    color: var(--c-muted);
    font-size: 13px;
    font-weight: 500;
}

.admin-bar .icon {
    width: 16px;
    height: 16px;
}

.admin-bar__link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--c-ink-2) !important;
    font-weight: 500;
    text-decoration: none !important;
}

.admin-bar__link:hover {
    background: var(--c-hover);
}

.admin-bar__link[aria-current="page"] {
    background: var(--c-accent-soft);
    color: var(--c-accent-dark) !important;
    font-weight: 600;
}

/* Page body */

.site-body {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 24px var(--page-pad) 48px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.site-main {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.site-main__panel {
    padding: clamp(16px, 2.4vw, 28px);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

/* Bootstrap rows and fixed-width containers in legacy page content must not overflow the panel. */
.site-main__panel > .row {
    margin-left: 0;
    margin-right: 0;
}

.site-main__panel .container {
    width: auto;
    max-width: 100%;
}

.flash {
    padding: 12px 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    font-weight: 500;
}

.flash--success {
    border-color: var(--c-own-frame);
    background: var(--c-own-soft);
    color: var(--c-own-ink);
}

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

/* Sidebar / category tree */

.site-sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    overflow: hidden;
}

.site-sidebar__head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 12px 0 16px;
}

.site-sidebar__title {
    flex: 1 1 auto;
    margin: 0;
    font-family: var(--font-ui) !important;
    font-size: 15px;
    font-weight: 600;
    color: var(--c-ink-2) !important;
}

.site-sidebar__close {
    display: none;
}

.site-sidebar__filter {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--tap);
    margin: 10px 12px 8px;
    padding: 0 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
    color: var(--c-muted);
}

.site-sidebar__filter input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--c-ink);
    font: inherit;
    font-size: 15px;
    outline: none;
}

.site-sidebar__scroll {
    flex: 1 1 auto;
    padding: 0 8px 12px;
}

.site-sidebar__empty {
    margin: 0;
    padding: 8px 12px;
    color: var(--c-muted);
    font-size: 14px;
}

.cat-tree,
.cat-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cat-tree ul {
    margin: 2px 0 6px 17px;
    padding-left: 8px;
    border-left: 1px solid var(--c-border);
}

.cat-tree__row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 8px 10px 8px 6px;
    border-radius: var(--radius-sm);
    color: var(--c-ink) !important;
    line-height: 1.3;
    text-decoration: none !important;
    cursor: pointer;
}

.cat-tree__row:hover {
    background: var(--c-hover);
}

.cat-tree__row--top {
    font-weight: 600;
}

.cat-tree__label {
    flex: 1 1 auto;
    min-width: 0;
}

.cat-tree__chevron {
    width: 18px;
    height: 18px;
    color: var(--c-muted);
}

.cat-tree--ready .cat-tree__chevron {
    transition: transform 0.15s ease;
}

.cat-tree__group.is-open > .cat-tree__row .cat-tree__chevron {
    transform: rotate(90deg);
}

/* Parent row: the chevron toggles the submenu, the name opens the category page. */
.cat-tree__row--parent {
    gap: 2px;
    padding: 0 10px 0 0;
    cursor: default;
}

.cat-tree__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
}

.cat-tree__toggle:hover {
    background: var(--c-badge);
    color: var(--c-ink);
}

.cat-tree__row--parent > .cat-tree__label {
    display: flex;
    align-items: center;
    align-self: stretch;
    padding: 8px 2px;
    color: inherit !important;
    text-decoration: none !important;
}

.cat-tree__row.is-current {
    background: var(--c-accent-soft);
    color: var(--c-accent-dark);
}

.cat-tree__row.is-current .cat-tree__toggle {
    color: var(--c-accent-dark);
}

.js .cat-tree__group:not(.is-open) > ul {
    display: none;
}

.cat-tree__leaf-icon {
    width: 18px;
    height: 18px;
    color: var(--c-muted);
}

/* Align top-level names with parent rows (36px toggle + 2px gap + 2px label padding). */
a.cat-tree__row--top {
    padding-left: 14px;
}

.cat-tree__count {
    flex: 0 0 auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--c-badge);
    color: var(--c-muted);
    font-size: 12px;
    font-weight: 600;
}

.cat-tree__link {
    padding-left: 10px;
}

.cat-tree__row[aria-current="page"] {
    background: var(--c-accent-soft);
    color: var(--c-accent-dark) !important;
    font-weight: 600;
}

.cat-tree__more {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--c-accent);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.cat-tree__more:hover {
    background: var(--c-hover);
}

.js .cat-tree--collapsible .cat-tree__extra {
    display: none;
}

.js .cat-tree--collapsible .is-expanded > .cat-tree__extra,
.cat-tree--filtering .cat-tree__extra {
    display: block !important;
}

html:not(.js) .cat-tree__more-row,
.cat-tree--filtering .cat-tree__more {
    display: none;
}

.cat-tree [hidden] {
    display: none !important;
}

.site-overlay {
    display: none;
}

/* Footer */

.site-footer {
    margin-top: 24px;
    background: var(--c-ink);
    color: #D6D5D0;
}

.site-footer__inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 28px var(--page-pad) 0;
}

.site-footer a:not(.btn-ui) {
    color: #E8E7E3;
}

.site-footer a:not(.btn-ui):hover {
    color: #FFFFFF;
}

.site-footer__about {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 560px;
    padding-bottom: 24px;
}

.site-footer__about p {
    margin: 0;
    color: #BDBCB6;
}

.site .site-footer__brand {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: #FFFFFF;
    text-decoration: none;
}

.site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    padding: 14px 0 18px;
    border-top: 1px solid #3A3A37;
    color: #A3A29C;
    font-size: 14px;
}

.site-footer__spacer {
    flex: 1 1 0;
}

.site-footer__counter img {
    display: block;
}

.site .site-footer__top {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tap);
    font-weight: 500;
    text-decoration: none;
}

.site-footer__top .icon {
    width: 16px;
    height: 16px;
}

/* Auth pages (login, password reset) */

.auth-page {
    display: flex;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 920px;
    display: flex;
    flex-wrap: wrap;
    border: 1px solid var(--c-border);
    border-radius: 18px;
    background: var(--c-surface);
    overflow: hidden;
}

.auth-card--single {
    max-width: 520px;
}

.auth-card__main {
    flex: 1 1 380px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: clamp(24px, 4vw, 44px);
}

.auth-card__head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.site .auth-card__title {
    margin: 0;
    font-size: clamp(28px, 3vw, 34px);
}

.site a.auth-card__back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tap);
    color: var(--c-ink);
    font-weight: 500;
    text-decoration: none;
}

.auth-card__aside {
    flex: 1 1 300px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: clamp(24px, 4vw, 44px);
    border-left: 1px solid var(--c-border);
    background: #F3F7F4;
}

.site .auth-card__aside-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.site a.auth-card__register {
    align-self: flex-start;
    border-color: #B9D8C6;
    color: var(--c-own-ink) !important;
    font-weight: 600;
}

.benefits {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.benefits__item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.benefits__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--c-own);
    color: #FFFFFF;
}

.benefits__icon .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.4;
}

.auth-form__forgotten {
    align-self: center;
    font-size: 14px;
    font-weight: 600;
}

.auth-alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid #E8B4AF;
    border-radius: var(--radius);
    background: var(--c-accent-soft);
    color: var(--c-accent-dark);
    font-size: 14px;
}

.field-input--large {
    min-height: 48px;
    font-size: 16px;
}

.field-input[aria-invalid="true"] {
    border-color: var(--c-accent);
}

.field-error {
    color: var(--c-accent-dark);
    font-size: 13px;
}

.password-field {
    position: relative;
}

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

.password-field__toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--c-ink-2);
    cursor: pointer;
}

.password-field__toggle[hidden] {
    display: none;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-field input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--c-accent);
}

.btn-ui--block {
    width: 100%;
    height: 50px;
    font-size: 16px;
}

@media (max-width: 639px) {
    .auth-card__aside {
        border-top: 1px solid var(--c-border);
        border-left: 0;
    }
}

/* Bottom nav (phones) */

.bottom-nav {
    display: none;
}

/* Tablet: categories move into a drawer */

@media (max-width: 1023px) {
    .site-header__drawer-toggle {
        display: inline-flex;
    }

    .site-nav {
        order: 10;
        flex-basis: 100%;
        margin: 0 -4px;
        overflow-x: auto;
    }

    .js .site-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 60;
        width: min(340px, 88vw);
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0s linear 0.2s;
    }

    .js .is-drawer-open .site-sidebar {
        transform: none;
        visibility: visible;
        transition: transform 0.2s ease;
    }

    .js .site-sidebar__head {
        padding: 10px 8px 10px 16px;
        border-bottom: 1px solid var(--c-border);
    }

    .js .site-sidebar__close {
        display: inline-flex;
    }

    /* The drawer is as tall as the screen, so only here the tree scrolls on its own. */
    .js .site-sidebar__scroll {
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .js .is-drawer-open .site-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(20, 20, 18, 0.45);
    }

    .js .is-drawer-open {
        overflow: hidden;
    }

    /* Without JS the sidebar stays in the page above the content. */
    html:not(.js) .site-body {
        flex-direction: column;
    }

    html:not(.js) .site-sidebar {
        width: 100%;
    }
}

/* Phone: system menu in the bottom bar, search behind an icon */

@media (max-width: 639px) {
    :root {
        --header-h: 65px;
    }

    .site-nav {
        display: none;
    }

    /* On phones the admin bar scrolls away with the page to keep the sticky header short. */
    .admin-bar {
        position: static;
    }

    .site-header__bar {
        gap: 8px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .site-brand img {
        height: 34px;
    }

    .js .site-header__search-toggle {
        display: inline-flex;
    }

    .js .site-search {
        display: none;
        order: 10;
        width: 100%;
    }

    .js .is-search-open .site-search {
        display: flex;
    }

    .site-search {
        order: 10;
        width: 100%;
    }

        .site-header__auth .btn-ui {
        padding: 0 10px;
    }

    .site-body {
        padding-top: 16px;
        padding-bottom: calc(var(--bottom-nav-h) + 24px);
    }

    .site-footer {
        padding-bottom: calc(var(--bottom-nav-h) + 16px);
    }

    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: flex;
        justify-content: space-around;
        padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--c-border);
        background: var(--c-surface);
    }

    .bottom-nav__item {
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 64px;
        height: 52px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--c-ink-2) !important;
        font: inherit;
        font-size: 12px;
        font-weight: 500;
        text-decoration: none !important;
        cursor: pointer;
    }

    .bottom-nav__item .icon {
        width: 22px;
        height: 22px;
    }

    .bottom-nav__item[aria-current="page"] {
        color: var(--c-accent) !important;
        font-weight: 600;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-sidebar,
    .cat-tree__chevron {
        transition: none !important;
    }
}

/* Focus ring on the field container, not on the bare input inside it. */
.site-search__input:focus-visible,
.site-sidebar__filter input:focus-visible {
    outline: none;
}

.site-search:focus-within,
.site-sidebar__filter:focus-within {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
}

/* Breadcrumbs */

.breadcrumb-nav ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--c-muted);
    font-size: 14px;
}

.breadcrumb-nav li + li::before {
    content: "/";
    margin-right: 6px;
    color: var(--c-border-strong);
}

.breadcrumb-nav a {
    color: var(--c-muted);
}

.breadcrumb-nav [aria-current="page"] {
    color: var(--c-ink);
    font-weight: 500;
}

/* Category header */

.cat-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: clamp(16px, 2.4vw, 28px);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

.cat-header__top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.cat-header__heading {
    flex: 1 1 260px;
    min-width: 0;
}

.site .cat-header__title {
    margin: 0;
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1.15;
}

.cat-header__description {
    max-width: 75ch;
}

.cat-header__description--editable {
    padding: 8px 10px;
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius);
}

.cat-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.cat-header__hint {
    color: var(--c-muted);
    font-size: 14px;
}

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

.rich-text > :last-child {
    margin-bottom: 0;
}

/* Collection progress */

.collection-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--c-own-soft);
    color: var(--c-own-ink);
}

.collection-progress__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.collection-progress__label .icon {
    width: 18px;
    height: 18px;
    stroke-width: 2.4;
}

.collection-progress__bar {
    flex: 1 1 200px;
    height: 10px;
    border-radius: 999px;
    background: var(--c-surface);
    box-shadow: inset 0 0 0 1px #B9D8C6;
    overflow: hidden;
}

.collection-progress__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--c-own);
}

.collection-progress__missing {
    font-size: 14px;
    font-weight: 600;
}

/* Toolbar: ownership filter, sorting */

.cat-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.cat-toolbar__spacer {
    flex: 1 1 0;
}

.segmented {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: #EAE9E5;
}

.segmented__option {
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--c-ink-2);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

a.segmented__option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-ink-2) !important;
    text-decoration: none !important;
}

.segmented__option[aria-current="true"],
.segmented__option[aria-pressed="true"] {
    background: var(--c-surface);
    color: var(--c-ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.sort-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.sort-form__label {
    margin: 0;
    color: var(--c-muted);
    font-size: 14px;
    font-weight: 400;
}

.sort-form__select {
    height: var(--tap);
    padding: 0 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-ink);
    font: inherit;
    font-size: 15px;
}

/* Item grid */

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    /* Vertical spacing comes from the card margin: a row gap would also split the subgrid rows. */
    gap: 0 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.item-grid__empty {
    margin: 0;
    padding: 40px 16px;
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    color: var(--c-muted);
    text-align: center;
}

/* Each card spans three grid rows (photo, ownership band, text) through subgrid, so in a row of cards the
   photo area takes the tallest photo, the text area the longest title, and the bands line up.
   The card and its link must not have containment: a contained element cannot be a subgrid. */
.item-card {
    position: relative;
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    margin-bottom: 20px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    overflow: hidden;
}

.item-card[hidden] {
    display: none;
}

.item-card--owned {
    border-color: var(--c-own-frame);
}

.item-card--missing {
    border-style: dashed;
    border-color: var(--c-border-strong);
    background: var(--c-bg);
}

.item-card__link {
    display: grid;
    grid-row: 1 / -1;
    grid-template-rows: subgrid;
    color: var(--c-ink) !important;
    text-decoration: none !important;
}

/* The whole photo is shown; shorter photos are centred. */
.item-card__frame {
    position: relative;
    container-type: inline-size;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    background: #CFCFCB;
}

.item-card__image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200cqw;
    object-fit: contain;
}

.item-card--missing .item-card__image {
    filter: grayscale(1);
    opacity: 0.55;
}

.item-card--missing .item-card__link:hover .item-card__image,
.item-card--missing .item-card__link:focus-visible .item-card__image {
    filter: none;
    opacity: 1;
}

.item-card__no-image {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ECEBE7;
    color: var(--c-muted);
    font-size: 13px;
}

.item-card__no-image .icon {
    width: 28px;
    height: 28px;
    stroke-width: 1.6;
}

.item-card__band {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    font-size: 14px;
}

.item-card__band--owned {
    background: var(--c-own);
    color: #FFFFFF;
    font-weight: 700;
}

.item-card__band--owned .icon {
    width: 16px;
    height: 16px;
    stroke-width: 3;
}

.item-card__band--missing {
    border-top: 1px solid var(--c-border);
    background: rgba(255, 255, 255, 0.94);
    color: var(--c-ink-2);
    font-weight: 600;
}

.item-card__body {
    grid-row: 3;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px 12px;
}

.item-card__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.item-card__link:hover .item-card__title {
    color: var(--c-accent);
}

.item-card__year {
    color: var(--c-muted);
    font-size: 13px;
}

/* 44px hit area around a 32px visible circle. */
.item-card__toggle {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.item-card__toggle::before {
    content: "";
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
}

.item-card--owned .item-card__toggle::before {
    border: 0;
    background: var(--c-own);
    box-shadow: 0 0 0 2px var(--c-surface);
}

.item-card__toggle .icon {
    position: relative;
    width: 17px;
    height: 17px;
    color: var(--c-ink);
    stroke-width: 2.4;
}

.item-card--owned .item-card__toggle .icon {
    color: #FFFFFF;
    stroke-width: 3;
}

@media (max-width: 639px) {
    .item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 12px;
    }

    .item-card {
        margin-bottom: 16px;
    }

    .item-card__band {
        height: 30px;
        padding: 0 10px;
        font-size: 13px;
    }

    .cat-toolbar .segmented {
        flex: 1 1 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cat-toolbar .segmented--sort {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.category-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Shared form fields and text */

.field-input {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-ink);
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
}

textarea.field-input {
    resize: vertical;
}

.muted {
    margin: 0;
    color: var(--c-muted);
}

/* Item detail */

.item-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px;
}

.item-gallery {
    flex: 1 1 420px;
    min-width: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-gallery__main {
    position: relative;
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    max-height: 680px;
    border-radius: 16px;
    background: #CFCFCB;
    overflow: hidden;
}

.item-gallery__main img {
    display: block;
    max-width: 100%;
    max-height: 680px;
    object-fit: contain;
}

.item-gallery__zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--c-ink);
}

.item-gallery__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 320px;
    border-radius: 16px;
    background: #ECEBE7;
    color: var(--c-muted);
}

.item-gallery__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.item-gallery__thumb {
    width: 72px;
    height: 72px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: #CFCFCB;
    overflow: hidden;
    cursor: pointer;
}

.item-gallery__thumb[aria-pressed="true"] {
    border-color: var(--c-ink);
}

.item-gallery__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-info {
    flex: 1 1 360px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-info__head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.site a.item-info__category {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--c-accent-soft);
    color: var(--c-accent-dark);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.site .item-info__title {
    margin: 0;
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1.15;
}

.item-info__meta {
    margin: 0;
    color: var(--c-muted);
}

.item-info__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Ownership box */

.ownership-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border: 2px solid var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

.ownership-box--owned {
    border-color: var(--c-own-frame);
    background: var(--c-own-soft);
}

.ownership-box__status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ownership-box__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--c-own);
    color: #FFFFFF;
}

.ownership-box__check .icon {
    width: 16px;
    height: 16px;
    stroke-width: 3;
}

.ownership-box__label {
    margin: 0;
    color: var(--c-ink-2);
    font-size: 18px;
    font-weight: 700;
}

.ownership-box--owned .ownership-box__label {
    color: var(--c-own-ink);
}

.ownership-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ownership-list__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 4px 4px 4px 12px;
    border-radius: var(--radius);
    background: var(--c-surface);
}

.ownership-list__quantity {
    font-weight: 700;
}

.ownership-list__note {
    flex: 1 1 140px;
    min-width: 0;
    color: var(--c-ink-2);
}

.ownership-box__edit {
    align-self: flex-start;
}

.ownership-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
}

.ownership-form > .auth-alert {
    flex: 1 1 100%;
}

.ownership-form .stack-form__field {
    gap: 4px;
}

.ownership-form__field--quantity {
    flex: 0 0 110px;
}

.ownership-form__field--note {
    flex: 1 1 180px;
}

/* The button lines up with the inputs under their labels. */
.ownership-form > .btn-ui {
    height: 48px;
    margin-top: 25px;
}

/* Dialogs (dialog.modal); .modal--sheet becomes a bottom sheet on phones. */

.modal {
    width: min(560px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: var(--c-surface);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    color: var(--c-ink);
    font-size: 15px;
    line-height: 1.5;
}

.modal::backdrop {
    background: rgba(20, 20, 18, 0.55);
}

.modal__form {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 32px);
    margin: 0;
}

.modal__handle {
    display: none;
}

.modal__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px 0 24px;
}

.modal__title {
    flex: 1 1 auto;
    margin: 0;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

.modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-ink-2);
    cursor: pointer;
}

.modal__close:hover {
    background: var(--c-hover);
}

.modal__body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 14px 24px 4px;
    overflow-y: auto;
}

.modal__foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px 24px;
}

.modal__foot .btn-ui {
    height: 48px;
    padding: 0 18px;
}

.modal .auth-alert[hidden] {
    display: none;
}

@media (max-width: 639px) {
    .modal--sheet {
        width: 100%;
        max-height: calc(100dvh - 24px);
        margin: auto 0 0;
        border-radius: 20px 20px 0 0;
    }

    .modal--sheet .modal__form {
        max-height: calc(100dvh - 24px);
    }

    .modal--sheet .modal__handle {
        display: block;
        align-self: center;
        width: 40px;
        height: 5px;
        margin-top: 8px;
        border-radius: 999px;
        background: var(--c-border-strong);
    }

    .modal--sheet .modal__foot {
        padding-bottom: 28px;
    }

    .modal--sheet .modal__foot .btn-ui {
        flex: 1 1 0;
    }
}

.btn-ui--own {
    border-color: var(--c-own);
    background: var(--c-own);
    color: #FFFFFF !important;
    font-weight: 600;
}

.btn-ui--own:hover {
    border-color: var(--c-own-ink);
    background: var(--c-own-ink);
}

.btn-ui--own .icon {
    stroke-width: 2.8;
}

/* Collection dialog */

.collection-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    border-radius: 12px;
    background: var(--c-bg);
}

.collection-item__image {
    flex: 0 0 auto;
    width: 56px;
    height: 75px;
    border-radius: var(--radius-sm);
    background: #8E8E8A;
    object-fit: cover;
}

.collection-item__image[hidden] {
    display: none;
}

.collection-item__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.collection-item__title {
    font-weight: 600;
    line-height: 1.35;
}

.collection-item__meta {
    color: var(--c-muted);
    font-size: 13px;
}

.collection-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.collection-entries__label {
    font-size: 14px;
    font-weight: 600;
}

.collection-entries__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.collection-entries__list:empty {
    display: none;
}

.collection-entry {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 10px;
    padding: 10px;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    background: var(--c-surface);
}

.collection-entry__quantity {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 4px;
}

.collection-entry__quantity .field-error {
    max-width: 124px;
}

.site .collection-entry__note {
    flex: 1 1 160px;
    min-width: 0;
    height: 46px;
    font-size: 16px;
}

.collection-entry__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-accent);
    cursor: pointer;
}

.collection-entry__remove:hover {
    background: var(--c-accent-soft);
}

.collection-entry__remove[hidden] {
    display: none;
}

.collection-entries__empty {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--c-accent-soft);
    color: var(--c-accent-dark);
    font-size: 14px;
}

.collection-entries__add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--tap);
    border: 1px dashed var(--c-border-strong);
    border-radius: 12px;
    background: transparent;
    color: var(--c-ink-2);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.collection-entries__add:hover {
    background: var(--c-hover);
}

.collection-entries__add .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    overflow: hidden;
}

.stepper:has(.stepper__input[aria-invalid="true"]) {
    border-color: var(--c-accent);
}

.stepper__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: var(--tap);
    padding: 0;
    border: 0;
    background: var(--c-surface);
    color: var(--c-ink);
    cursor: pointer;
}

.stepper__button:hover:not(:disabled) {
    background: var(--c-hover);
}

.stepper__button:disabled {
    color: #A3A29C;
    cursor: default;
}

.stepper__button .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.stepper__input {
    width: 44px;
    height: var(--tap);
    padding: 0;
    border: 0;
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-ink);
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}

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

/* Tabs */

.item-tabs {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    overflow: hidden;
}

.item-tabs__list {
    display: flex;
    gap: 2px;
    padding: 6px;
    border-bottom: 1px solid var(--c-border);
    overflow-x: auto;
}

.item-tabs__tab {
    flex: 0 0 auto;
    height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--c-ink-2);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.item-tabs__tab:hover {
    background: var(--c-hover);
}

.item-tabs__tab[aria-selected="true"] {
    background: var(--c-ink);
    color: #FFFFFF;
    font-weight: 600;
}

.item-tabs__panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px 20px;
}

.item-tabs__panel[hidden] {
    display: none;
}

/* Without JS every panel is shown, one under another. */
html:not(.js) .item-tabs__panel[hidden] {
    display: flex;
}

html:not(.js) .item-tabs__list {
    display: none;
}

.item-props {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 10px 20px;
    margin: 0;
}

.item-props:empty {
    display: none;
}

.item-props dt {
    color: var(--c-muted);
    font-size: 14px;
    font-weight: 400;
}

.item-props dd {
    margin: 0;
}

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

.discussion {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.discussion__entry {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--c-border);
}

.discussion__meta {
    margin: 0 0 4px;
    font-size: 14px;
}

.discussion__meta time {
    margin-left: 6px;
    color: var(--c-muted);
}

.discussion__text {
    margin: 0;
    white-space: pre-line;
}

.discussion-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
}

@media (max-width: 639px) {
    .item-gallery__main,
    .item-gallery__empty {
        min-height: 240px;
    }

    .item-props {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }

    .item-props dd + dt {
        margin-top: 10px;
    }
}

/* Stacked forms */

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}

.stack-form__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stack-form__field label {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.stack-form__hint {
    color: var(--c-muted);
    font-size: 13px;
}

.stack-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--c-border);
}

.form-errors {
    margin: 0;
    padding: 10px 14px 10px 30px;
    border: 1px solid var(--c-accent);
    border-radius: var(--radius);
    background: var(--c-accent-soft);
    color: var(--c-accent-dark);
}

/* Category management */

.admin-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-page__head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.site .admin-page__title {
    margin: 0;
    font-size: clamp(26px, 3vw, 34px);
}

.admin-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px;
}

.admin-panel {
    min-width: 0;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

.admin-panel--tree {
    flex: 999 1 520px;
    overflow: hidden;
}

.admin-panel--form {
    flex: 1 1 340px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
}

.admin-panel__head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--c-border);
}

.site .admin-panel__title {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 18px;
}

.site .admin-panel__title--display {
    font-family: var(--font-display);
    font-size: 24px;
}

.admin-panel__hint {
    margin: 0;
    color: var(--c-muted);
    font-size: 13px;
}

.admin-tree-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-tree-search {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--tap);
    padding: 0 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
    color: var(--c-muted);
}

.admin-tree-search:focus-within {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
}

.admin-tree-search input:focus-visible {
    outline: none;
}

.admin-tree-search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--c-ink);
    font: inherit;
    font-size: 15px;
    outline: none;
}

/* jsTree, default theme: taller rows for touch, site colours. */
.admin-tree {
    padding: 8px;
    font-family: var(--font-ui);
    font-size: 15px;
}

.admin-tree .jstree-node {
    min-height: 40px;
    line-height: 40px;
}

.admin-tree .jstree-anchor,
.admin-tree .jstree-wholerow {
    height: 40px;
    line-height: 40px;
}

.admin-tree .jstree-anchor {
    color: var(--c-ink) !important;
    text-decoration: none !important;
}

.admin-tree > .jstree-container-ul > .jstree-node > .jstree-anchor {
    font-weight: 600;
}

.admin-tree .jstree-ocl,
.admin-tree .jstree-ocl:empty {
    position: relative;
    width: 28px;
    height: 40px;
    line-height: 40px;
    background: none !important;
}

.admin-tree .jstree-open > .jstree-ocl::before,
.admin-tree .jstree-closed > .jstree-ocl::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--c-muted);
    border-bottom: 2px solid var(--c-muted);
    transform: translate(-70%, -50%) rotate(-45deg);
}

.admin-tree .jstree-open > .jstree-ocl::before {
    transform: translate(-50%, -70%) rotate(45deg);
}

.admin-tree .jstree-children {
    margin-left: 13px;
    border-left: 1px solid var(--c-border);
}

.admin-tree .jstree-node {
    margin-left: 0;
}

.admin-tree .jstree-children > .jstree-node {
    margin-left: 12px;
}

.admin-tree .jstree-container-ul {
    margin-left: 0;
    border-left: 0;
}

.admin-tree .jstree-container-ul > .jstree-node {
    margin-left: 0;
}

.admin-tree .jstree-ocl {
    vertical-align: top;
}

.admin-tree.jstree-default .jstree-wholerow-hovered {
    background: var(--c-hover);
}

.admin-tree.jstree-default .jstree-wholerow-clicked {
    background: var(--c-accent-soft);
}

.admin-tree .jstree-search {
    color: var(--c-accent-dark) !important;
    font-style: normal;
}

/* Unsaved changes bar */

.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
}

.save-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 16px;
}

.save-bar__dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c-own);
}

.save-bar--dirty .save-bar__dot {
    background: var(--c-accent);
}

.save-bar__text {
    flex: 1 1 220px;
    color: var(--c-ink-2);
}

.save-bar--dirty .save-bar__text {
    color: var(--c-ink);
    font-weight: 600;
}

.save-bar--error .save-bar__text {
    color: var(--c-accent-dark);
    font-weight: 600;
}

@media (max-width: 639px) {
    .save-bar {
        bottom: var(--bottom-nav-h);
    }
}

.admin-tree.jstree-default .jstree-clicked {
    background: transparent;
    box-shadow: none;
}

.admin-tree .jstree-node {
    position: relative;
}

/* Row buttons at the end of a row: add a subcategory, edit, and delete (only categories that can be deleted). */
.admin-tree__actions {
    position: absolute;
    top: 0;
    right: 4px;
    z-index: 1;
    display: flex;
    width: 120px;
}

.admin-tree__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
}

.admin-tree__action:hover,
.admin-tree__action:focus-visible {
    background: var(--c-hover);
    color: var(--c-ink);
}

.admin-tree__action--delete:hover,
.admin-tree__action--delete:focus-visible {
    background: var(--c-accent-soft);
    color: var(--c-accent);
}

.admin-tree__action .icon {
    width: 18px;
    height: 18px;
}

/* Long names end with an ellipsis before the row buttons. */
.admin-tree .jstree-anchor {
    max-width: calc(100% - 160px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

/* Category form: beside the tree, a bottom sheet on phones. */

.site .category-form-panel {
    position: static;
    width: auto;
    max-width: none;
    margin: 0;
    color: var(--c-ink);
}

.category-form-panel:not([open]) {
    display: none;
}

.category-form-panel__handle {
    display: none;
}

.category-form-panel__head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.category-form-panel__head > div {
    flex: 1 1 auto;
    min-width: 0;
}

.category-form-panel__eyebrow {
    margin: 0;
    color: var(--c-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.category-form-panel__close {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-ink-2);
    cursor: pointer;
}

/* CKEditor sets its own border and padding on the editable element. */
.site .category-form__editor.ck-editor__editable_inline {
    min-height: 120px;
    padding: 2px 12px;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
}

.site .category-form__editor.ck-editor__editable_inline.ck-focused {
    border-color: var(--c-ink-2);
    box-shadow: none;
}

.stack-form__spacer {
    flex: 1 1 0;
}

.site .btn-ui--danger {
    color: var(--c-accent) !important;
    font-weight: 600;
}

.btn-ui--danger:hover {
    background: var(--c-accent-soft);
}

@media (max-width: 639px) {
    .site .category-form-panel:modal {
        position: fixed;
        inset: auto 0 0;
        width: 100%;
        max-height: calc(100dvh - 24px);
        padding: 0 20px 22px;
        overflow-y: auto;
        border: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
    }

    .category-form-panel::backdrop {
        background: rgba(20, 20, 18, 0.5);
    }

    .category-form-panel__handle {
        display: block;
        width: 40px;
        height: 5px;
        margin: 8px auto 4px;
        border-radius: 999px;
        background: var(--c-border-strong);
    }

    .category-form-panel__close {
        display: inline-flex;
    }
}

.admin-page__head--actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.item-grid__loading {
    margin: 0;
    padding: 16px;
    color: var(--c-muted);
    text-align: center;
}

.item-grid__loading[hidden] {
    display: none;
}

/* The cell is the per-card snippet wrapper; the card inside is the grid item. */
.item-grid__cell {
    display: contents;
}

/* Home page (Novinky) */

.home-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.home-intro,
.home-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: clamp(18px, 2.6vw, 32px);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

.home-intro {
    border-top: 4px solid var(--c-accent);
}

.site .home-intro__title {
    margin: 0;
    font-size: clamp(30px, 3.6vw, 44px);
    line-height: 1.1;
}

.home-intro__text {
    max-width: 68ch;
    margin: 0;
    color: var(--c-ink-2);
    font-size: 17px;
    line-height: 1.6;
}

.home-intro__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.home-section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 16px;
}

.site .home-section__title {
    margin: 0;
    font-size: clamp(22px, 2.4vw, 28px);
}

.site a.home-section__more {
    font-weight: 600;
}

.news-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.news-list__entry {
    display: grid;
    grid-template-columns: 9em minmax(0, 1fr);
    gap: 4px 20px;
    padding: 14px 0;
    border-top: 1px solid var(--c-border);
}

.news-list__entry:first-child {
    border-top: 0;
    padding-top: 0;
}

.news-list__date {
    color: var(--c-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
}

.news-list__text {
    max-width: 75ch;
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 639px) {
    .news-list__entry {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Month headings between cards (Nově přidané položky) */

.site .item-grid__month {
    grid-column: 1 / -1;
    margin: 8px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--c-border);
    font-size: 20px;
}

.stack-form__group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    margin: 0;
    padding: 16px 0 0;
    border: 0;
    border-top: 1px solid var(--c-border);
}

/* Floated, the legend is laid out as ordinary content instead of being drawn into the fieldset border. */
.site .stack-form__legend {
    float: left;
    width: 100%;
    margin: 0 0 -8px;
    padding: 0;
    border: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--c-ink);
}

.field-input:disabled {
    background: var(--c-bg);
    color: var(--c-muted);
}

.search-empty__title {
    margin: 0 0 6px;
    color: var(--c-ink);
    font-size: 17px;
    font-weight: 600;
}

/* Item admin forms (create, edit, assign) */

.admin-panel--padded {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: clamp(16px, 2.4vw, 24px);
}

.admin-panel__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
}

.item-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}

.item-form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px 20px;
}

.item-form__wide {
    grid-column: 1 / -1;
}

.item-form__grid--dimensions {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.item-form__inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.item-form__inline .stack-form__field {
    flex: 1 1 260px;
}

.item-form__inline > .btn-ui {
    margin-top: 27px;
    min-height: 48px;
}

.item-form__actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
}

.item-form__actions .btn-ui {
    min-height: 48px;
    padding: 0 24px;
}

.upload-field {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 120px;
    margin: 0;
    padding: 20px;
    border: 2px dashed var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-bg);
    color: var(--c-ink-2);
    font-weight: 500;
    text-align: center;
    cursor: pointer;
}

.upload-field:hover,
.upload-field:focus-within {
    border-color: var(--c-accent);
    color: var(--c-accent-dark);
}

.upload-field .icon {
    width: 28px;
    height: 28px;
}

/* The native file input stays focusable but invisible; the whole field is its label. */
.upload-field__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.admin-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-list__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 8px 0;
    border-top: 1px solid var(--c-border);
}

.admin-list__row:first-child {
    border-top: 0;
}

.admin-list__text {
    flex: 1 1 240px;
    min-width: 0;
}

.site .admin-list__danger {
    color: var(--c-accent) !important;
}

.image-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.image-list__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
}

/* Same frame for every photo, whatever its proportions; the photo is centred in it. */
.image-list__item img {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: #CFCFCB;
}

.assign-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
}

.assign-preview__image {
    flex: 0 0 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    border-radius: var(--radius);
    background: #CFCFCB;
    overflow: hidden;
}

.assign-preview__image img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
}

.assign-preview__info {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assign-preview__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

@media (max-width: 639px) {
    .item-form__inline > .btn-ui {
        width: 100%;
        margin-top: 0;
    }

    .item-form__actions {
        bottom: var(--bottom-nav-h);
    }

    .item-form__actions .btn-ui {
        width: 100%;
    }
}

/* Marking photos and categories for removal on the edit form */

.mark-toggle {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    margin: 0;
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--c-accent);
    font-weight: 600;
    cursor: pointer;
}

.mark-toggle:hover {
    background: var(--c-accent-soft);
}

.mark-toggle:focus-within {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
}

.mark-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mark-toggle__on,
.is-marked .mark-toggle__off {
    display: none;
}

.is-marked .mark-toggle__on {
    display: inline;
    color: var(--c-ink);
}

.admin-list__row.is-marked .admin-list__text {
    color: var(--c-muted);
    text-decoration: line-through;
}

/* The first photo cannot move earlier, the last one later. */
.image-list__item:first-child [data-image-move="-1"],
.image-list__item:last-child [data-image-move="1"] {
    visibility: hidden;
}

.image-list__preview {
    display: block;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
}

.image-preview {
    max-width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: #1B1B1A;
    overflow: hidden;
}

.image-preview::backdrop {
    background: rgba(20, 20, 18, 0.8);
}

.image-preview__image {
    display: block;
    max-width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    object-fit: contain;
}

.image-preview__nav {
    position: absolute;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--c-ink);
    transform: translateY(-50%);
    cursor: pointer;
}

.image-preview__nav[hidden],
.image-preview__counter[hidden] {
    display: none;
}

.image-preview__nav--prev {
    left: 10px;
}

.image-preview__nav--next {
    right: 10px;
}

.image-preview__counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(27, 27, 26, 0.75);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 600;
    transform: translateX(-50%);
}

.image-preview__close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--c-ink);
    cursor: pointer;
}

.image-list__item.is-marked img {
    opacity: 0.3;
}

.image-list__item.is-marked {
    border-color: var(--c-accent);
    border-style: dashed;
}

.image-list__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.image-list__item:first-child::before {
    content: "Hlavní";
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 1;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--c-ink);
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 600;
}

.item-form__actions {
    align-items: center;
    gap: 12px;
}

.item-form__note {
    flex: 1 1 auto;
    color: var(--c-accent-dark);
    font-weight: 600;
}

.item-form__note[hidden] {
    display: none;
}

.btn-ui--dark {
    border-color: var(--c-ink);
    background: var(--c-ink);
    color: #FFFFFF !important;
    font-weight: 600;
}

.btn-ui--dark:hover {
    background: #000000;
}

/* 4xx pages */

.not-found {
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: center;
    gap: 32px 56px;
    padding: clamp(24px, 4vw, 56px);
    border: 1px solid var(--c-border);
    border-radius: 18px;
    background: var(--c-surface);
}

.not-found__content {
    flex: 999 1 420px;
    min-width: 0;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.not-found__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--c-muted);
    font-size: 14px;
    font-weight: 600;
}

.not-found__code {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--c-badge);
    color: var(--c-ink);
}

.site .not-found__title {
    margin: 0;
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.1;
}

.not-found__text {
    max-width: 560px;
    margin: 0;
    color: var(--c-ink-2);
    font-size: 17px;
}

.not-found__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.not-found__art {
    flex: 1 1 220px;
    display: flex;
    justify-content: center;
}

.not-found__card {
    width: 240px;
    display: flex;
    flex-direction: column;
    border: 2px dashed var(--c-border-strong);
    border-radius: 16px;
    background: var(--c-bg);
    box-shadow: 0 18px 40px rgba(27, 27, 26, 0.1);
    overflow: hidden;
    transform: rotate(-3deg);
}

.not-found__card-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 4;
    background: #ECEBE7;
}

.not-found__card-media svg {
    width: 132px;
    height: 172px;
}

.not-found__card-band {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border-top: 1px solid var(--c-border);
    background: rgba(255, 255, 255, 0.94);
    color: var(--c-ink-2);
    font-size: 14px;
    font-weight: 600;
}

.not-found__card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px 14px;
}

.not-found__card-title {
    font-weight: 600;
}

.not-found__card-meta {
    color: var(--c-muted);
    font-size: 13px;
}

/* Standalone search field (404) */

.search-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.search-panel__label {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.search-panel__row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-panel__field {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 14px;
    border: 1px solid var(--c-border-strong);
    border-radius: 12px;
    background: var(--c-surface);
    color: var(--c-muted);
}

.search-panel__field:focus-within {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
}

.search-panel__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 46px;
    border: 0;
    background: transparent;
    color: var(--c-ink);
    font: inherit;
    font-size: 16px;
    outline: none;
}

.search-panel__submit {
    height: 50px;
    padding: 0 22px;
    font-size: 16px;
}

@media (max-width: 639px) {
    .not-found__card {
        width: 150px;
    }

    .not-found__card-media {
        aspect-ratio: auto;
        height: 150px;
    }

    .not-found__card-media svg {
        width: 84px;
        height: 110px;
    }

    .not-found__card-band {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
    }

    .not-found__card-body {
        display: none;
    }

    .not-found__actions .btn-ui,
    .search-panel__submit {
        flex: 1 1 100%;
    }
}
