:root {
    color-scheme: dark;
    --bg: #101820;
    --panel: rgba(255, 255, 255, 0.08);
    --panel-strong: rgba(255, 255, 255, 0.14);
    --text: #f6f2e8;
    --muted: #b8c4c9;
    --accent: #efc34a;
    --accent-strong: #f1724f;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(239, 195, 74, 0.18), transparent 34rem),
        linear-gradient(135deg, #101820 0%, #18343a 52%, #402d2c 100%);
}

button {
    font: inherit;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

button *,
.action-button,
.quality-button,
.zoom-indicator {
    user-select: none;
    -webkit-user-select: none;
}

.app-shell {
    width: min(1180px, calc(100% - 28px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 7vw, 4.8rem);
    line-height: 0.95;
}

.counter {
    min-width: 96px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(16, 24, 32, 0.5);
    color: var(--muted);
    text-align: center;
    box-shadow: var(--shadow);
}

.counter span:first-child {
    color: var(--text);
    font-weight: 800;
}

.album-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
}

.album-tab {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(16, 24, 32, 0.5);
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.album-tab:hover {
    color: var(--text);
    background: var(--panel-strong);
}

.album-tab.is-active {
    border-color: rgba(239, 195, 74, 0.65);
    color: #101820;
    background: var(--accent);
}

.gallery {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    align-items: center;
    gap: 16px;
}

.stage {
    min-width: 0;
    margin: 0;
    display: grid;
    gap: 14px;
}

.photo-opener {
    width: 100%;
    height: min(68vh, 680px);
    min-height: 320px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    background: rgba(0, 0, 0, 0.24);
    box-shadow: var(--shadow);
}

.photo-opener img,
.lightbox__viewport img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

figcaption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
}

figcaption > div:first-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

figcaption span {
    color: var(--text);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.action-button {
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.92rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.action-button--accent {
    border-color: rgba(239, 195, 74, 0.45);
    background: rgba(239, 195, 74, 0.18);
}

.action-button.is-disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.nav-button,
.icon-button,
.lightbox__nav {
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-button {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    font-size: 3rem;
    line-height: 1;
    display: grid;
    place-items: center;
}

.nav-button,
.nav-button *,
.lightbox__nav,
.lightbox__nav * {
    -webkit-user-drag: none;
}

.nav-button:hover,
.icon-button:hover,
.lightbox__nav:hover,
.thumb:hover,
.action-button:hover {
    background: var(--panel-strong);
}

.thumb-strip {
    overflow: hidden;
}

.thumb-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scroll-snap-type: x proximity;
}

.thumb {
    flex: 0 0 86px;
    width: 86px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
    cursor: pointer;
    scroll-snap-align: center;
}

.thumb.is-active {
    border-color: var(--accent);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.empty-state {
    align-self: center;
    max-width: 620px;
    margin: auto;
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(16, 24, 32, 0.58);
    box-shadow: var(--shadow);
    text-align: center;
}

.debug-box,
.status-box {
    padding: 14px 16px;
    border: 1px solid rgba(239, 195, 74, 0.42);
    border-radius: 8px;
    background: rgba(16, 24, 32, 0.72);
    color: var(--muted);
}

.debug-box h2 {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 1rem;
}

.debug-box p,
.debug-box ul,
.status-box p {
    margin: 4px 0;
}

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

.empty-mark {
    width: 92px;
    height: 92px;
    margin: 0 auto 22px;
    border: 3px solid var(--accent);
    border-radius: 24px 8px 24px 8px;
    position: relative;
}

.empty-mark::before,
.empty-mark::after {
    content: "";
    position: absolute;
}

.empty-mark::before {
    width: 18px;
    height: 18px;
    top: 18px;
    right: 18px;
    border-radius: 50%;
    background: var(--accent);
}

.empty-mark::after {
    left: 14px;
    right: 14px;
    bottom: 16px;
    height: 30px;
    background: linear-gradient(135deg, transparent 47%, var(--accent-strong) 48% 62%, transparent 63%),
        linear-gradient(45deg, transparent 42%, var(--accent) 43% 62%, transparent 63%);
}

.empty-state h2 {
    margin-bottom: 10px;
    font-size: clamp(1.7rem, 5vw, 3rem);
}

.empty-state p {
    color: var(--muted);
}

.formats {
    margin-bottom: 0;
    font-size: 0.92rem;
}

.lightbox {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(5, 8, 10, 0.94);
    color: var(--text);
}

.lightbox::backdrop {
    background: rgba(0, 0, 0, 0.76);
}

.lightbox[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.lightbox__bar {
    min-height: 66px;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(16, 24, 32, 0.78);
}

.lightbox__bar > div:first-child {
    min-width: 0;
}

.lightbox__bar strong,
.lightbox__bar small {
    display: block;
    overflow-wrap: anywhere;
}

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

.lightbox__tools {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
}

.quality-button {
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid rgba(239, 195, 74, 0.45);
    border-radius: 8px;
    color: var(--text);
    background:
        linear-gradient(90deg, rgba(239, 195, 74, 0.34) var(--progress, 0%), transparent var(--progress, 0%)),
        rgba(239, 195, 74, 0.16);
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 900;
    white-space: nowrap;
}

.quality-button:hover {
    background:
        linear-gradient(90deg, rgba(239, 195, 74, 0.38) var(--progress, 0%), transparent var(--progress, 0%)),
        rgba(239, 195, 74, 0.24);
}

.quality-button:disabled {
    cursor: default;
    opacity: 0.64;
}

.quality-button.is-loading {
    opacity: 1;
}

.icon-button--small-text {
    font-size: 0.8rem;
    font-weight: 900;
}

.zoom-indicator {
    min-width: 52px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
    text-align: center;
}

.lightbox__viewport {
    min-height: 0;
    padding: 10px 74px 24px;
    overflow: hidden;
    cursor: zoom-in;
    touch-action: none;
    user-select: none;
}

.lightbox__viewport.is-zoomed {
    cursor: grab;
}

.lightbox__viewport.is-dragging {
    cursor: grabbing;
}

.lightbox__viewport img {
    transform-origin: center center;
    will-change: transform;
    -webkit-user-drag: none;
}

.lightbox__viewport img.is-zoomed {
    cursor: inherit;
}

.lightbox__nav {
    position: fixed;
    top: 50%;
    z-index: 2;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    font-size: 2.8rem;
    line-height: 1;
}

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

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

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 18px, 1180px);
        padding: 14px 0;
        gap: 12px;
    }

    .topbar {
        align-items: flex-end;
    }

    .counter {
        min-width: 78px;
        padding: 8px 10px;
    }

    .album-tabs {
        margin-inline: -2px;
    }

    .gallery {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .nav-button {
        position: fixed;
        top: 50%;
        z-index: 3;
        width: 48px;
        height: 48px;
        background: rgba(16, 24, 32, 0.68);
        backdrop-filter: blur(12px);
    }

    .nav-button--prev {
        left: 12px;
    }

    .nav-button--next {
        right: 12px;
    }

    .photo-opener {
        height: 62vh;
        min-height: 260px;
    }

    figcaption {
        display: grid;
        gap: 4px;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .action-button {
        padding-inline: 8px;
        text-align: center;
        white-space: normal;
    }

    .thumb {
        flex-basis: 72px;
        width: 72px;
        height: 56px;
    }

    .empty-state {
        padding: 24px 18px;
    }

    .lightbox__bar {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .lightbox__tools {
        margin-left: auto;
        gap: 6px;
    }

    .icon-button {
        width: 40px;
        height: 40px;
    }

    .quality-button {
        min-height: 40px;
        max-width: 100%;
        padding-inline: 9px;
        white-space: normal;
    }

    .zoom-indicator {
        min-width: 48px;
    }

    .lightbox__viewport {
        padding: 8px 0 18px;
    }

    .lightbox__nav {
        top: auto;
        bottom: 18px;
        background: rgba(16, 24, 32, 0.72);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .photo-opener img,
    .thumb,
    .action-button,
    .nav-button,
    .icon-button,
    .quality-button,
    .album-tab,
    .lightbox__nav {
        transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
    }

    .photo-opener:hover img {
        transform: scale(1.012);
    }

    .nav-button:active,
    .icon-button:active,
    .lightbox__nav:active {
        transform: scale(0.96);
    }
}
