:root {
    color-scheme: light;
    --bg: #eef8fc;
    --ink: #123044;
    --muted: #557083;
    --line: #c7e4ef;
    --panel: #ffffff;
    --accent: #1597c9;
    --accent-dark: #0b6f96;
    --gold: #c99a2e;
    --gold-soft: #fff6dc;
    --danger: #9f2d2d;
    --shadow: 0 18px 42px rgba(18, 48, 68, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(238, 248, 252, 0.92) 42%, #eef8fc 100%),
        radial-gradient(circle at 14% 0%, rgba(21, 151, 201, 0.18), transparent 34%),
        radial-gradient(circle at 86% 8%, rgba(201, 154, 46, 0.18), transparent 30%);
}

button,
input {
    font: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 56px;
}

.gallery-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 34px;
    border: 1px solid rgba(199, 228, 239, 0.95);
    border-top: 5px solid var(--gold);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
}

h1 {
    margin: 0;
    max-width: 820px;
    color: var(--ink);
    font-size: clamp(1.8rem, 3.4vw, 3rem);
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.08;
}

.gallery-header p {
    max-width: 620px;
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.65;
}

.counter {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 116px;
    min-height: 94px;
    border: 1px solid rgba(201, 154, 46, 0.45);
    background: linear-gradient(180deg, #fff 0%, var(--gold-soft) 100%);
    color: var(--ink);
    box-shadow: 0 10px 26px rgba(18, 48, 68, 0.08);
}

.counter strong {
    color: var(--accent-dark);
    font-size: 2rem;
    line-height: 1;
}

.counter span {
    color: var(--gold);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.notice {
    margin-top: 28px;
    padding: 24px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.notice h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.notice p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.notice code {
    color: var(--ink);
    font-size: 0.95em;
}

.notice-error {
    border-color: rgba(159, 45, 45, 0.45);
}

.notice-error h2 {
    color: var(--danger);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0;
}

.toolbar label {
    font-weight: 800;
}

.toolbar input {
    width: min(420px, 100%);
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
    padding: 0 14px;
    outline-color: var(--accent);
}

.folder-overviews[hidden],
.folder-tools[hidden] {
    display: none;
}

.folder-overviews {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.folder-preview {
    min-width: 0;
    padding: 12px;
    border: 1px solid rgba(199, 228, 239, 0.96);
    border-top: 4px solid var(--gold);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 14px 32px rgba(18, 48, 68, 0.1);
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.folder-preview:hover {
    border-color: rgba(21, 151, 201, 0.55);
    box-shadow: 0 18px 38px rgba(18, 48, 68, 0.14);
    transform: translateY(-2px);
}

.folder-tools {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 24px 0;
}

.folder-tools .toolbar {
    margin: 0;
}

.folder-back,
.folder-open {
    min-height: 38px;
    border: 1px solid var(--accent);
    background: linear-gradient(180deg, #20aee3 0%, var(--accent) 100%);
    color: #fff;
    padding: 0 12px;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(21, 151, 201, 0.22);
}

.folder-back {
    min-height: 44px;
    padding: 0 16px;
    font-size: 1rem;
}

.folder-back:hover,
.folder-open:hover,
.folder-back:focus-visible,
.folder-open:focus-visible {
    border-color: var(--gold);
    background: linear-gradient(180deg, #d8ac45 0%, var(--gold) 100%);
    color: #102638;
}

.folder-section {
    margin-top: 32px;
}

.folder-section[hidden] {
    display: none;
}

.folder-header {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(199, 228, 239, 0.88);
}

.folder-header div {
    min-width: 0;
}

.folder-header h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 850;
    line-height: 1.2;
}

.folder-header span {
    flex: 0 0 auto;
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.folder-carousel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(199, 228, 239, 0.9);
    background: #d9f1fa;
}

.carousel-photo {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.carousel-photo img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
    -webkit-user-drag: none;
    pointer-events: none;
    transition: filter 180ms ease;
}

.carousel-photo:hover img,
.carousel-photo:focus-visible img {
    filter: saturate(1.08);
}

.carousel-control-prev,
.carousel-control-next {
    width: 34px;
    opacity: 0.9;
}

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

.photo-card {
    min-width: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 10px 24px rgba(18, 48, 68, 0.08);
}

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

.photo-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    overflow: hidden;
}

.photo-button img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
    -webkit-user-drag: none;
    pointer-events: none;
    transition: transform 180ms ease, filter 180ms ease;
}

.photo-button:hover img,
.photo-button:focus-visible img {
    filter: saturate(1.08);
    transform: scale(1.035);
}

.lightbox {
    width: min(1100px, calc(100vw - 28px));
    border: 0;
    padding: 0;
    background: transparent;
    overflow: visible;
}

.lightbox::backdrop {
    background: rgba(9, 37, 56, 0.84);
}

.lightbox figure {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    min-height: min(78vh, 720px);
    background: #082638;
    color: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.lightbox img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
    background: #082638;
    -webkit-user-drag: none;
    pointer-events: none;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    display: grid;
    place-items: center;
    border: 0;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    cursor: pointer;
}

.lightbox-close {
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 42px;
    height: 42px;
    font-size: 1.8rem;
}

.lightbox-nav {
    top: 50%;
    width: 46px;
    height: 58px;
    transform: translateY(-50%);
    font-size: 2.8rem;
}

.lightbox-prev {
    left: 12px;
}

.lightbox-next {
    right: 12px;
}

@media (max-width: 1080px) {
    .folder-overviews {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .folder-overviews {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 22px, 1180px);
        padding-top: 18px;
    }

    .gallery-header,
    .folder-tools,
    .toolbar,
    .folder-header {
        align-items: stretch;
        flex-direction: column;
    }

    .folder-header {
        gap: 6px;
    }

    .folder-preview {
        padding: 12px;
    }

    .folder-overviews {
        grid-template-columns: 1fr;
    }

    .folder-tools {
        gap: 12px;
    }

    .toolbar input {
        width: 100%;
    }

    .carousel-photo img {
        aspect-ratio: 4 / 3;
    }

    .counter {
        align-self: start;
        min-width: 94px;
        min-height: 76px;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .lightbox-close {
        top: 8px;
        right: 8px;
    }

    .lightbox-prev {
        left: 0;
    }

    .lightbox-next {
        right: 0;
    }
}

@media print {
    body {
        visibility: hidden;
    }
}
