:root {
    --fw-radius: 8px;
    --fw-paper: #fbfaf7;
    --fw-ink: #17202a;
    --fw-muted: #667085;
    --fw-accent: #8b5e3c;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--bs-body-color);
}

img,
.img-fluid {
    max-width: 100%;
}

.icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hero-band {
    background:
        linear-gradient(90deg, rgba(255,255,255,.95), rgba(255,255,255,.72)),
        url("https://images.unsplash.com/photo-1516035069371-29a1b244cc32?auto=format&fit=crop&w=2200&q=80") center/cover;
}

[data-bs-theme="dark"] .hero-band {
    background:
        linear-gradient(90deg, rgba(16,18,20,.96), rgba(16,18,20,.72)),
        url("https://images.unsplash.com/photo-1516035069371-29a1b244cc32?auto=format&fit=crop&w=2200&q=80") center/cover;
}

.min-vh-75 {
    min-height: 75vh;
}

.hero-cover {
    aspect-ratio: 4 / 5;
    border-radius: var(--fw-radius);
    overflow: hidden;
    background: #111;
}

.hero-cover img,
.album-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-card {
    border-radius: var(--fw-radius);
    transition: transform .2s ease, box-shadow .2s ease;
}

.album-start {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

.unlock-page {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

.album-card-link {
    display: block;
    color: inherit;
    position: relative;
    height: 100%;
}

.album-count-badge {
    position: absolute;
    right: .75rem;
    bottom: .75rem;
    padding: .35rem .65rem;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: var(--fw-radius);
    background: rgba(0,0,0,.58);
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    backdrop-filter: blur(8px);
}

.album-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 1rem 2.5rem rgba(16,24,40,.12);
}

.album-card .card-img-top {
    aspect-ratio: 16 / 10;
}

.book-stage {
    min-height: calc(100dvh - 72px);
    background: linear-gradient(135deg, #f4f0ea, #ffffff 45%, #eef3f6);
}

[data-bs-theme="dark"] .book-stage {
    background: linear-gradient(135deg, #121416, #1d2227 45%, #101418);
}

.book-shell {
    position: relative;
    width: min(1180px, 100%);
    height: min(664px, calc(100dvh - 210px));
    overflow: hidden;
}

.book-spread {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    opacity: 0;
    transform: none;
    transition: opacity .22s ease;
    pointer-events: none;
}

.book-spread.active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.book-spread.turning-next {
    transform: none;
}

.book-spread.turning-prev {
    transform: none;
}

.book-page,
.book-cover-face,
.book-back-face {
    position: relative;
    overflow: hidden;
    background: #111;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow: inset 0 0 38px rgba(0,0,0,.05);
}

.book-page,
.book-page.single-image {
    grid-column: 1;
    border-radius: var(--fw-radius);
}

.book-page img,
.book-cover-face img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.book-cover {
    grid-template-columns: 1fr;
}

.book-cover-face,
.book-back-face {
    grid-column: 1 / -1;
    border-radius: var(--fw-radius);
}

.book-cover-text {
    position: absolute;
    inset: auto 2rem 2rem 2rem;
    color: #fff;
    text-shadow: 0 1rem 3rem rgba(0,0,0,.5);
}

.book-cover-text span,
.book-back-face span {
    display: block;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .8rem;
}

.book-cover-text strong {
    display: block;
    font-size: clamp(2rem, 6vw, 5rem);
    line-height: 1;
}

.book-back-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: var(--fw-muted);
}

.book-back-face i {
    font-size: 4rem;
    color: var(--fw-accent);
}

.book-shell.zoomed {
    max-width: none;
    width: min(1500px, 100%);
}

.book-progress {
    width: min(1180px, 100%);
}

.album-view {
    overflow: hidden;
}

.album-view .navbar,
.album-view footer {
    display: none;
}

.album-view .book-stage {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
}

.album-view .book-stage > .container-fluid {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: .5rem !important;
}

.album-view .book-topbar {
    position: fixed;
    top: max(.5rem, env(safe-area-inset-top));
    left: max(.5rem, env(safe-area-inset-left));
    right: max(.5rem, env(safe-area-inset-right));
    z-index: 20;
    margin: 0 !important;
    pointer-events: none;
}

.album-view .book-meta {
    display: none;
}

.album-view .book-overview-back,
.album-view .book-actions {
    pointer-events: auto;
    background: rgba(0,0,0,.48);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.album-view .book-overview-back,
.album-view .book-actions .btn {
    color: #fff;
    border-color: rgba(255,255,255,.18);
    background: transparent;
}

.album-view .book-shell {
    flex: 1 1 auto;
    width: 100%;
    height: calc(100svh - 1rem);
    max-height: calc(100svh - 1rem);
}

.album-view .book-shell.zoomed {
    width: 100%;
}

.album-view .book-progress {
    position: fixed;
    left: max(.75rem, env(safe-area-inset-left));
    right: max(.75rem, env(safe-area-inset-right));
    bottom: max(.5rem, env(safe-area-inset-bottom));
    z-index: 15;
    width: auto;
    max-width: 520px;
    opacity: .65;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f8f5f1, #eef3f6);
}

[data-bs-theme="dark"] .auth-body {
    background: linear-gradient(135deg, #121416, #1d2227 45%, #101418);
}

.auth-card {
    width: min(420px, calc(100vw - 2rem));
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--fw-radius);
    padding: 2rem;
    box-shadow: 0 1.25rem 4rem rgba(16,24,40,.12);
}

.admin-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--bs-body-bg);
}

.admin-sidebar .nav-link,
.admin-mobile-menu .nav-link {
    color: var(--bs-body-color);
    border-radius: var(--fw-radius);
}

.admin-sidebar .nav-link:hover,
.admin-mobile-menu .nav-link:hover {
    background: var(--bs-tertiary-bg);
}

.admin-logout-link {
    border: 0;
    background: transparent;
}

.metric-card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--fw-radius);
    padding: 1.25rem;
    background: var(--bs-body-bg);
}

.metric-card span {
    display: block;
    color: var(--bs-secondary-color);
}

.metric-card strong {
    font-size: 2rem;
}

.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .75rem;
}

.album-sort-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .75rem;
}

.image-sort-item {
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--fw-radius);
    background: var(--bs-body-bg);
    cursor: grab;
    transition: opacity .15s ease, transform .15s ease, border-color .15s ease;
}

.image-sort-item:active {
    cursor: grabbing;
}

.image-sort-item.is-dragging {
    opacity: .45;
    transform: scale(.98);
    border-color: var(--bs-primary);
}

.image-sort-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.image-sort-controls {
    display: grid;
    gap: .5rem;
    padding: .65rem;
}

.image-delete-check {
    color: var(--bs-danger-text-emphasis);
}

.image-sort-controls .btn-group {
    width: 100%;
}

.image-sort-controls .btn {
    flex: 1 1 0;
}

.cover-option {
    position: relative;
    cursor: pointer;
}

.cover-option input {
    position: absolute;
    inset: .5rem auto auto .5rem;
    z-index: 2;
}

.cover-option img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--fw-radius);
    border: 2px solid transparent;
}

.cover-option input:checked + img {
    border-color: var(--bs-primary);
}

@media (max-width: 991.98px) {
    .admin-sidebar {
        display: none !important;
        width: 0;
        flex-basis: 0;
    }

    .admin-shell > .d-flex > .flex-grow-1 {
        min-width: 0;
        width: 100%;
    }

    .admin-shell header {
        padding: .85rem 1rem !important;
    }

    .admin-shell main {
        padding: 1rem !important;
    }

    .book-shell {
        width: min(100%, 620px);
        height: calc(100dvh - 190px);
    }

    .book-spread {
        grid-template-columns: 1fr;
    }

    .book-page,
    .book-page.single-image {
        grid-column: 1;
        border-radius: var(--fw-radius);
    }

}

@media (max-width: 767.98px) {
    .album-view .book-progress {
        display: none;
    }
}

@media (max-width: 991.98px) and (orientation: landscape) {
    .album-view .book-stage {
        height: 100dvh;
        min-height: 100dvh;
        background: #000;
    }

    .album-view .book-stage > .container-fluid {
        padding: 0 !important;
    }

    .album-view .book-shell {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
    }

    .album-view .book-page,
    .album-view .book-back-face {
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .album-view .book-topbar {
        top: max(.35rem, env(safe-area-inset-top));
        left: max(.35rem, env(safe-area-inset-left));
        right: max(.35rem, env(safe-area-inset-right));
    }

    .album-view .book-overview-back,
    .album-view .book-actions {
        opacity: .42;
        transition: opacity .15s ease;
    }

    .album-view .book-overview-back:is(:hover, :focus-visible),
    .album-view .book-actions:is(:hover, :focus-within) {
        opacity: 1;
    }

    .album-view .book-progress {
        display: none;
    }
}
