:root {
    --bg: #07111f;
    --bg-deep: #030914;
    --panel: rgba(10, 18, 35, 0.78);
    --panel-strong: rgba(9, 17, 32, 0.9);
    --panel-soft: rgba(255, 255, 255, 0.06);
    --line: rgba(151, 178, 255, 0.18);
    --line-strong: rgba(151, 178, 255, 0.3);
    --text: #f5f7ff;
    --muted: #9cabcb;
    --accent: #82a0ff;
    --accent-2: #7af0d2;
    --accent-3: #f3a8ff;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Inter", sans-serif;
    background:
        radial-gradient(
            circle at top left,
            rgba(130, 160, 255, 0.24),
            transparent 28%
        ),
        radial-gradient(
            circle at top right,
            rgba(122, 240, 210, 0.12),
            transparent 22%
        ),
        radial-gradient(
            circle at bottom center,
            rgba(243, 168, 255, 0.08),
            transparent 28%
        ),
        linear-gradient(145deg, var(--bg-deep) 0%, var(--bg) 38%, #0d1730 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.user-page,
.admin-page {
    width: min(1200px, calc(100% - 48px));
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    padding: 32px 36px 42px;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.04),
            rgba(255, 255, 255, 0.02)
        ),
        var(--panel);
    border: none;
    border-radius: 32px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}

.user-page::before,
.admin-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            circle at top,
            rgba(130, 160, 255, 0.12),
            transparent 35%
        ),
        linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 60%);
    pointer-events: none;
}

.user-header,
.admin-header,
.admin-list-header,
.viewer-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.user-header {
    justify-content: center;
    position: relative;
    margin-bottom: 56px;
    padding-top: 8px;
}

.user-header h1,
.admin-header h1 {
    margin: 0;
    font-size: clamp(2.5rem, 4vw, 4.3rem);
    font-weight: 700;
    letter-spacing: -0.05em;
    text-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.user-header h1 {
    background: linear-gradient(135deg, #ffffff 0%, #b8c9ff 45%, #92f2dc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.admin-header {
    margin-bottom: 28px;
    padding-top: 6px;
}

.admin-header p,
.admin-status,
.admin-book-meta,
.empty-state {
    color: var(--muted);
}

.admin-header p,
.admin-list-header h2,
.admin-status,
.admin-book-title,
.admin-book-meta,
.empty-state {
    margin: 0;
}

.admin-link,
.delete-button,
.close-button {
    border: 1px solid var(--line-strong);
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.12),
            rgba(255, 255, 255, 0.06)
        ),
        rgba(7, 15, 28, 0.75);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition:
        transform 160ms ease,
        box-shadow 160ms ease,
        border-color 160ms ease,
        background 160ms ease;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
}

.admin-link:hover,
.delete-button:hover,
.close-button:hover {
    transform: translateY(-2px);
    border-color: rgba(122, 240, 210, 0.38);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.26);
}

.books-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(142px, 142px));
    gap: 28px 24px;
    align-items: start;
}

.book-card {
    border: 1px solid transparent;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 14px 10px 12px;
    border-radius: 24px;
    transition:
        transform 180ms ease,
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease;
}

.book-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(130, 160, 255, 0.2);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
}

.book-icon {
    width: 90px;
    height: 116px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    display: block;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(
            180deg,
            rgba(130, 160, 255, 0.28),
            rgba(10, 18, 35, 0.82)
        ),
        linear-gradient(
            135deg,
            rgba(122, 240, 210, 0.16),
            rgba(243, 168, 255, 0.08)
        );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 18px 30px rgba(0, 0, 0, 0.25);
}

.book-icon::before {
    content: "PDF";
    position: absolute;
    left: 14px;
    bottom: 14px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(4, 8, 18, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.book-icon::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 28%),
        radial-gradient(
            circle at top right,
            rgba(255, 255, 255, 0.18),
            transparent 24%
        );
}

.book-title {
    max-width: 124px;
    text-align: center;
    line-height: 1.45;
    font-size: 0.97rem;
    font-weight: 500;
    word-break: break-word;
    color: #ecf1ff;
}

.upload-panel {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: end;
    margin: 30px 0 18px;
    max-width: 860px;
}

.pdf-selector,
.custom-title-field {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pdf-selector span,
.custom-title-field span {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e8eeff;
}

.pdf-selector input,
.custom-title-field input {
    border: 1px dashed rgba(130, 160, 255, 0.35);
    border-radius: 20px;
    padding: 16px;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.06),
            rgba(255, 255, 255, 0.03)
        ),
        rgba(9, 17, 32, 0.6);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    outline: none;
}

.custom-title-field input::placeholder {
    color: var(--muted);
}

.admin-status,
.empty-state {
    position: relative;
    z-index: 1;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(12px);
}

.admin-list-header {
    position: relative;
    z-index: 1;
    margin: 26px 0 14px;
}

.admin-list-header h2 {
    font-size: 1.2rem;
    color: #edf2ff;
}

.admin-books-list {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.admin-book-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.06),
            rgba(255, 255, 255, 0.03)
        ),
        rgba(9, 17, 32, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
}

.admin-book-title {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
    color: #f5f7ff;
}

body.viewer-open {
    overflow: hidden;
}

.viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background:
        radial-gradient(
            circle at top left,
            rgba(130, 160, 255, 0.16),
            transparent 30%
        ),
        linear-gradient(145deg, #020711 0%, #07111f 55%, #0a1428 100%);
}

.viewer-shell {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: rgba(3, 9, 20, 0.94);
}

.viewer-topbar,
.viewer-bottombar {
    position: relative;
    z-index: 2;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
        rgba(5, 12, 26, 0.88);
    border: none;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(18px);
}

.viewer-topbar {
    padding: max(14px, env(safe-area-inset-top)) clamp(14px, 3vw, 30px) 14px;
}

.viewer-heading {
    min-width: 0;
}

.viewer-topbar h2 {
    margin: 0;
    max-width: min(72vw, 820px);
    overflow: hidden;
    color: #f5f7ff;
    font-size: clamp(1rem, 2vw, 1.35rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-progress {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: clamp(0.82rem, 1.7vw, 0.96rem);
}

.viewer-bottombar {
    padding: 12px clamp(12px, 3vw, 30px) max(12px, env(safe-area-inset-bottom));
}

.viewer-actions {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    gap: clamp(8px, 2vw, 16px);
    width: min(920px, 100%);
    margin: 0 auto;
}

.viewer-close-button {
    flex: 0 0 auto;
}

.page-button:first-child {
    justify-self: end;
}

.page-button:last-child {
    justify-self: start;
}

.zoom-controls {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 12px 28px rgba(0, 0, 0, 0.18);
}

.zoom-button {
    min-width: 44px;
    padding-inline: 14px;
}

.zoom-label {
    min-width: 58px;
    text-align: center;
    font-size: 0.92rem;
    font-weight: 600;
    color: #dce6ff;
}

.close-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.close-button:disabled:hover {
    transform: none;
    border-color: var(--line-strong);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.pdf-viewer-wrap {
    width: 100%;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: clamp(12px, 2.6vw, 34px);
    background:
        radial-gradient(
            circle at top,
            rgba(130, 160, 255, 0.08),
            transparent 34%
        ),
        rgba(1, 5, 12, 0.38);
    scroll-behavior: smooth;
}

.pdf-canvas {
    display: block;
    margin: 0 auto;
    border-radius: clamp(8px, 1.6vw, 14px);
    background: #ffffff;
    box-shadow: 0 20px 58px rgba(0, 0, 0, 0.46);
}

.hidden {
    display: none !important;
}

@media (max-width: 700px) {
    .user-page,
    .admin-page {
        width: calc(100% - 20px);
        margin: 10px auto;
        min-height: calc(100vh - 20px);
        padding: 22px 16px 30px;
        border-radius: 24px;
    }

    .user-header,
    .admin-header,
    .admin-book-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-header {
        justify-content: flex-start;
        padding-top: 48px;
        margin-bottom: 38px;
    }

    .upload-panel {
        grid-template-columns: 1fr;
    }

    .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(104px, 104px));
        gap: 20px 16px;
    }

    .book-icon {
        width: 76px;
        height: 98px;
        border-radius: 18px;
    }

    .viewer-topbar {
        gap: 10px;
        padding-inline: 12px;
    }

    .viewer-topbar h2 {
        max-width: 58vw;
    }

    .viewer-close-button {
        padding: 9px 12px;
    }

    .viewer-bottombar {
        padding-inline: 10px;
    }

    .viewer-actions {
        grid-template-columns: 1fr auto 1fr;
        width: 100%;
        gap: 6px;
    }

    .page-button {
        width: 100%;
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    .zoom-controls {
        gap: 4px;
        padding: 4px;
    }

    .zoom-button {
        min-width: 38px;
        padding-inline: 10px;
    }

    .zoom-label {
        min-width: 48px;
        font-size: 0.82rem;
    }

    .pdf-viewer-wrap {
        padding: 12px 8px;
    }
}
