:root {
    color-scheme: light dark;
    --bg: #f6f2ea;
    --bg-accent:
        radial-gradient(
            circle at top left,
            rgba(201, 153, 88, 0.28),
            transparent 36%
        ),
        linear-gradient(180deg, #f6f2ea 0%, #ece2d1 100%);
    --panel: rgba(255, 250, 243, 0.9);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --text: #1f1b18;
    --muted: #746a61;
    --line: rgba(87, 67, 47, 0.14);
    --brand: #aa5f22;
    --brand-strong: #8d4615;
    --danger: #be3c2f;
    --shadow: 0 18px 50px rgba(84, 53, 21, 0.12);
    --frame: #fefefe;
    --surface-gap: 1rem;
    --radius: 0.25vw;
    --radius-sm: var(--radius);
    --radius-md: var(--radius);
    --radius-lg: var(--radius);
    --radius-pill: 999px;
    --image-frame-overview: 5px;
    --image-frame-single: 20px;
    --photo-mat: transparent;
    --selected-surface: rgba(0, 0, 0, 0.045);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171718;
        --bg-accent:
            radial-gradient(
                circle at top left,
                rgba(203, 139, 73, 0.2),
                transparent 34%
            ),
            linear-gradient(180deg, #171718 0%, #0f1011 100%);
        --panel: rgba(35, 36, 39, 0.9);
        --panel-strong: rgba(24, 25, 28, 0.95);
        --text: #f6f3ee;
        --muted: #b4ab9f;
        --line: rgba(255, 255, 255, 0.1);
        --brand: #ee9b50;
        --brand-strong: #ffb26f;
        --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
        --frame: #ffffff;
        --photo-mat: rgba(255, 255, 255, 0.96);
        --selected-surface: rgba(255, 255, 255, 0.055);
    }
}

* {
    box-sizing: border-box !important;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background: var(--bg-accent);
    color: var(--text);
}

body {
    padding: 1.2rem;
}

a {
    color: inherit;
}

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

.icon {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
}

.shell {
    max-width: 1240px;
    margin: 0 auto;
}

.hero,
.panel,
.modal-panel,
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    height: 100%;
}

.hero {
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-flow: row;
    justify-content: space-between;
}

.brand img {
    width: auto;
    height: 8rem;
}

.content-header {
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    flex-flow: column;
}

.hero h1,
.hero h2,
.section-title {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: 0.02em;
}

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

.grid {
    display: grid;
    gap: 1rem;
}

.grid.admin {
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    align-items: start;
}

.panel {
    padding: 1rem;
}

.stack {
    display: grid;
    gap: 0.85rem;
}

.input,
.button,
.file-input-label {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    padding: 0.8rem 0.95rem;
}

.input {
    width: 100%;
    background: var(--panel-strong);
    color: var(--text);
}

.button,
.file-input-label {
    background: var(--brand);
    color: white;
    cursor: pointer;
    border: none;
    transition:
        transform 150ms ease,
        background 150ms ease,
        opacity 150ms ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
}

.button:hover,
.file-input-label:hover {
    background: var(--brand-strong);
    transform: translateY(-1px);
}

.button.secondary {
    background: var(--panel-strong);
    color: var(--text);
    border: 1px solid var(--line);
}

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

.button:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

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

.card-list {
    display: grid;
    gap: 0.85rem;
}

.album-card,
.media-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-strong);
    overflow: hidden;
}

.album-card button {
    width: 100%;
    background: none;
    color: inherit;
    border: none;
    text-align: left;
    padding: 1rem;
    cursor: pointer;
}

.album-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.45rem;
}

.album-card.active {
    outline: 2px solid rgba(170, 95, 34, 0.35);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: var(--radius-lg);
    padding: 1rem 1.7rem;
    background: rgba(170, 95, 34, 0.12);
    color: var(--brand);
    font-size: 0.9rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.toolbar-group {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
}

.gallery {
    display: grid;
    gap: 1rem;
}

.gallery.grid-view {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

.gallery.list-view {
    grid-template-columns: 1fr;
}

.media-card {
    position: relative;
}

.media-card.selectable {
    transition:
        box-shadow 150ms ease,
        border-color 150ms ease,
        background 150ms ease;
}

.media-card.selectable:hover {
    box-shadow: var(--shadow);
}

.media-card.is-selected {
    border-color: rgba(170, 95, 34, 0.65);
    box-shadow:
        0 0 0 2px rgba(170, 95, 34, 0.18),
        var(--shadow);
    background: color-mix(
        in srgb,
        var(--panel-strong) 88%,
        var(--selected-surface)
    );
}

.media-thumb-wrap {
    position: relative;
    background: rgba(0, 0, 0, 0.05);
    display: grid;
    place-items: center;
    padding: 0.9rem 0.9rem 1rem;
    overflow: hidden;
}

.media-thumb-frame {
    width: auto;
    height: 100%;
    border-radius: var(--radius-md);
    background: var(--photo-mat);
    padding: 0;
    border: var(--image-frame-overview) solid var(--photo-mat);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.media-thumb,
.single-media img,
.single-media video {
    border-radius: var(--radius-sm);
    display: block;
}

.media-thumb {
    width: 100%;
    height: 100%;
}

.media-thumb-placeholder {
    width: 100%;
    height: 100%;
}

.media-thumb-cover {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.gallery .orientation-portrait {
    aspect-ratio: 9 / 16;
}

.gallery .orientation-landscape {
    aspect-ratio: 16 / 9;
}

.gallery .orientation-square {
    aspect-ratio: 1 / 1;
}

.gallery.list-view .media-thumb {
    max-height: 100%;
}

.media-card-body {
    padding: 1rem;
    display: grid;
    gap: 0.6rem;
    min-width: 0;
    overflow: hidden;
}

.media-select-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.media-select-hit {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
}

.media-select-name {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    min-width: 0;
}

.media-select-name strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.select-chip {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    min-width: 7.8rem;
    justify-content: center;
}

.select-chip.active {
    background: rgba(170, 95, 34, 0.12);
    border-color: rgba(170, 95, 34, 0.4);
    color: var(--brand);
}

.select-chip-icon {
    display: inline-flex;
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 150ms ease;
}

.select-chip.active .select-chip-icon {
    opacity: 1;
    width: 1.05rem;
}

.select-chip.active .select-chip-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.media-card-open {
    cursor: pointer;
}

.media-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.92rem;
    min-width: 0;
    overflow: hidden;
}

.media-meta span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.login-wrap {
    min-height: calc(100vh - 2.4rem);
    display: grid;
    place-items: center;
}

.login-card {
    width: min(460px, 100%);
    padding: 1.35rem;
}

.notice,
.error {
    padding: 0.8rem 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
}

.notice {
    background: rgba(170, 95, 34, 0.08);
}

.error {
    background: rgba(190, 60, 47, 0.14);
}

.link-box {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    border: 1px dashed var(--line);
    padding: 0.8rem;
    border-radius: var(--radius-md);
}

.queue-bar {
    height: 10px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.queue-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--brand), #f3b37a);
}

.hidden {
    display: none !important;
}

.sr-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.desktop-toggle {
    display: flex;
    gap: 0.4rem;
}

.desktop-only {
    display: inline-flex;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 10, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 30;
}

.modal.open {
    display: flex;
}

.modal-panel {
    width: min(1100px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1rem;
}

.single-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.single-media {
    display: grid;
    place-items: center;
    height: 72vh;
    min-height: 72vh;
    background: rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    padding: 1rem;
    overflow: hidden;
}

.single-media .media-thumb-frame {
    width: fit-content;
    height: fit-content;
    max-width: min(100%, 92vw);
    max-height: calc(72vh - 2rem);
    padding: 0;
    border: var(--image-frame-single) solid var(--photo-mat);
    justify-self: center;
    align-self: center;
    background: var(--photo-mat);
    display: inline-grid;
}

.single-media img,
.single-media video {
    max-width: 100%;
    max-height: 72vh;
}

.single-sidebar {
    display: grid;
    gap: 1rem;
}

.single-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.single-counter {
    min-width: 5.5rem;
    justify-content: center;
}

.single-view-media {
    display: block;
    border-radius: var(--radius-sm);
    width: auto;
    height: auto;
    max-width: min(100%, calc(92vw - (2 * var(--image-frame-single))));
    max-height: calc(72vh - 2rem - (2 * var(--image-frame-single)));
    object-fit: contain;
}

.orientation-landscape .single-view-media,
.orientation-square .single-view-media {
    width: auto;
    height: auto;
    max-width: min(100%, calc(92vw - (2 * var(--image-frame-single))));
    max-height: calc(72vh - 2rem - (2 * var(--image-frame-single)));
}

.orientation-portrait .single-view-media {
    width: auto;
    height: auto;
    max-width: min(100%, calc(92vw - (2 * var(--image-frame-single))));
    max-height: calc(72vh - 2rem - (2 * var(--image-frame-single)));
}

.single-actions {
    justify-content: center;
    flex-wrap: nowrap;
}

.badge {
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 2;
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.65rem;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
}

.media-card:hover .badge,
.media-card:focus-within .badge {
    opacity: 1;
}

.badge .icon {
    width: 0.95rem;
    height: 0.95rem;
}

.badge-label {
    display: none;
}

.media-card:hover .badge-label,
.media-card:focus-within .badge-label {
    display: inline;
}

.icon-only {
    padding-inline: 0.85rem;
}

.icon-only span {
    display: none;
}

.media-thumb-placeholder {
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.08);
    color: var(--muted);
}

.media-thumb-placeholder .icon {
    width: 2rem;
    height: 2rem;
}

.actions .button.icon-only {
    min-width: 2.9rem;
}

.actions .button.icon-only .icon + .icon {
    width: 0.85rem;
    height: 0.85rem;
    opacity: 0.72;
    margin-left: -0.15rem;
}

.gallery.grid-view .media-card {
    width: max(calc(var(--preview-width, 220px) + 3.4rem), 260px);
    flex: 0 0 max(calc(var(--preview-width, 220px) + 3.4rem), 260px);
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 430px;
    max-height: 430px;
}

.gallery.grid-view .media-thumb-wrap {
    width: 100%;
    height: 220px;
}

.gallery.grid-view .media-thumb-frame {
    max-width: calc(100% - 8px);
    justify-self: center;
}

.media-card-main {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 0;
    height: 100%;
}

.gallery.grid-view .media-card-main {
    min-height: 210px;
}

.gallery.grid-view .media-card-body {
    align-content: end;
    grid-template-rows: auto auto;
}

.gallery.list-view .media-card {
    display: grid;
    grid-template-columns: minmax(210px, var(--preview-width, 220px)) minmax(
            0,
            1fr
        );
    grid-template-rows: 1fr;
    align-items: start;
    min-height: 220px;
}

.gallery.list-view .media-thumb-wrap {
    width: 100%;
    height: 100%;
}

.gallery.list-view .media-card-main {
    height: 100%;
    min-height: 100%;
    justify-content: space-between;
}

.gallery.list-view .media-card-body {
    grid-template-rows: auto auto;
    align-content: start;
    padding-bottom: 0.5rem;
}

.gallery.list-view .media-thumb-frame {
    width: 100%;
    height: 100%;
}

.gallery.grid-view .media-card .media-select-name,
.gallery.list-view .media-card .media-select-name,
.gallery.grid-view .media-card .media-select-hit,
.gallery.list-view .media-card .media-select-hit {
    min-width: 0;
    overflow: hidden;
}

.media-actions {
    padding: 0 1rem 1rem;
    justify-content: stretch;
    flex-wrap: nowrap;
    overflow: visible;
    gap: 0.55rem;
    margin-top: auto;
}

.gallery.list-view .media-actions {
    padding: 0 1rem 1rem;
}

.media-actions .button,
.media-actions a.button {
    flex: 1 1 0;
}

.download-feedback {
    display: grid;
    gap: 0.4rem;
    min-width: min(24rem, 100%);
}

.download-progress {
    height: 6px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.download-progress > span {
    display: block;
    width: 36%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--brand-strong));
    transform: translateX(-120%);
}

.download-feedback.is-busy .download-progress > span {
    animation: loading-slide 1.25s ease-in-out infinite;
}

.button.is-loading {
    opacity: 0.72;
}

@keyframes loading-slide {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(320%);
    }
}

#download-status.is-busy {
    animation: pulse-status 1.2s ease-in-out infinite;
}

.button.is-loading {
    opacity: 0.72;
}

@keyframes pulse-status {
    0% {
        opacity: 0.65;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.65;
    }
}

.empty-state {
    padding: 2rem;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}

@media (max-width: 980px) {
    .grid.admin,
    .single-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    body {
        padding: 0.8rem;
    }

    .gallery.list-view .media-card {
        grid-template-columns: 1fr;
    }

    .single-media {
        height: 64vh;
        min-height: 64vh;
    }

    .desktop-only {
        display: none;
    }

    .media-thumb-wrap {
        min-height: 220px;
    }
}
