:root {
    --primary: rgb(255, 75, 31);
    --secondary: rgb(31, 221, 255);
    --accent-soft: rgba(255, 75, 31, 0.18);
    --theme-bg-1: rgba(76, 43, 130, 0.82);
    --theme-bg-2: rgba(40, 116, 194, 0.68);
    --theme-bg-3: rgba(28, 37, 86, 0.65);
    --theme-bg-4: rgba(7, 10, 24, 0.98);
    --theme-surface-1: rgba(22, 26, 45, 0.78);
    --theme-surface-2: rgba(255, 255, 255, 0.08);
    --theme-surface-3: rgba(255, 255, 255, 0.14);
    --theme-border: rgba(255, 255, 255, 0.12);
    --theme-border-strong: rgba(255, 255, 255, 0.26);
    --theme-glow: rgba(255, 75, 31, 0.28);
    --theme-glow-soft: rgba(31, 221, 255, 0.16);
    --theme-shadow: rgba(0, 0, 0, 0.35);
    --theme-shadow-strong: rgba(0, 0, 0, 0.62);
    --theme-title: rgba(255, 255, 255, 0.98);
    --theme-text: rgba(242, 245, 255, 0.96);
    --theme-text-soft: rgba(223, 231, 255, 0.8);
    --theme-text-dim: rgba(200, 210, 235, 0.6);
    --theme-title-gradient-start: rgb(255, 255, 255);
    --theme-title-gradient-end: rgb(173, 223, 255);
    --theme-progress-track: rgba(255, 255, 255, 0.14);
    --theme-progress-fill: linear-gradient(90deg, rgb(255, 75, 31), rgb(31, 221, 255));
    --theme-player-overlay: linear-gradient(135deg, rgba(255, 75, 31, 0.14), rgba(31, 221, 255, 0.08) 45%, rgba(8, 10, 18, 0.24));
    --text: var(--theme-text);
    --dark-bg: #0b0f1a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --border: var(--theme-border);
    --font-body: 'Outfit', sans-serif;
    --font-display: 'Space Grotesk', 'Outfit', sans-serif;
    --nav-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

button:focus-visible,
input:focus-visible,
.book-card:focus-visible,
.history-card:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 3px;
}

html {
    color-scheme: dark;
}

body {
    color: var(--theme-text);
    min-height: 100vh;
    padding-bottom: 140px;
    overflow-x: hidden;
    position: relative;
    background:
        radial-gradient(circle at 14% 16%, var(--theme-bg-1) 0%, transparent 32%),
        radial-gradient(circle at 86% 18%, var(--theme-bg-2) 0%, transparent 28%),
        radial-gradient(circle at 50% 84%, var(--theme-bg-3) 0%, transparent 34%),
        linear-gradient(135deg, var(--theme-bg-4), var(--dark-bg) 42%, #04060c 100%);
    transition:
        background 0.9s ease,
        color 0.6s ease;
}

body.player-mode {
    padding-bottom: 260px;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -2;
}

body::before {
    background:
        radial-gradient(circle at 20% 30%, var(--theme-glow) 0%, transparent 30%),
        radial-gradient(circle at 78% 22%, var(--theme-glow-soft) 0%, transparent 26%),
        radial-gradient(circle at 52% 76%, rgba(255, 255, 255, 0.05) 0%, transparent 28%);
    filter: blur(28px);
    animation: ambientFloat 18s ease-in-out infinite alternate;
    opacity: 0.95;
}

body::after {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 110px 110px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), transparent 80%);
    opacity: 0.24;
}

@keyframes ambientFloat {
    0% {
        transform: translate3d(-2%, -1%, 0) scale(1);
    }
    100% {
        transform: translate3d(2%, 2%, 0) scale(1.06);
    }
}

.bg-gradient {
    display: none;
}

.glass-container {
    max-width: 1120px;
    margin: 20px auto;
    padding: 30px;
    position: relative;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
    padding: 18px 22px;
    border-radius: 26px;
    background: linear-gradient(180deg, var(--theme-surface-1), var(--theme-surface-2));
    border: 1px solid var(--theme-border);
    box-shadow:
        0 18px 50px var(--theme-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: all 0.35s ease;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    background: linear-gradient(120deg, var(--theme-title-gradient-start), var(--theme-title-gradient-end));
    -webkit-background-clip: text;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo span {
    font-family: inherit;
}

.search-box {
    background: linear-gradient(180deg, var(--theme-surface-2), rgba(255, 255, 255, 0.04));
    padding: 11px 20px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--theme-border);
    color: var(--theme-text-soft);
    transition: 0.3s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-box:focus-within {
    border-color: var(--theme-border-strong);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 24px var(--theme-glow-soft);
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--theme-text);
    outline: none;
    width: 150px;
}

.search-box input::placeholder {
    color: var(--theme-text-dim);
}

.glass-btn {
    background: linear-gradient(180deg, var(--theme-surface-2), rgba(255, 255, 255, 0.04));
    border: 1px solid var(--theme-border);
    color: var(--theme-text);
    width: 45px;
    height: 45px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s ease;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.glass-btn:hover {
    background: var(--theme-progress-fill);
    color: #08101a;
    box-shadow: 0 0 24px var(--theme-glow-soft);
}

#sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: linear-gradient(180deg, rgba(10, 12, 24, 0.96), rgba(18, 23, 41, 0.92));
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-right: 1px solid var(--theme-border);
    z-index: 2000;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 50px var(--theme-shadow-strong);
}

#sidebar.active {
    left: 0;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    z-index: 1999;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

#sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--theme-border);
}

.sidebar-header h3 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--theme-title);
    font-weight: 700;
}

#close-sidebar {
    background: transparent;
    border: none;
    color: var(--theme-text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.3s;
}

#close-sidebar:hover {
    color: var(--theme-text);
    transform: rotate(90deg);
}

.sidebar-nav {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-nav button {
    background: transparent;
    border: none;
    color: var(--theme-text-soft);
    text-align: left;
    padding: 15px;
    font-size: 1.03rem;
    border-radius: 14px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

.sidebar-nav button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--theme-title);
    padding-left: 20px;
}

.sidebar-nav button i {
    width: 25px;
    color: var(--secondary);
    text-align: center;
}

.divider {
    height: 1px;
    background: var(--theme-border);
    margin: 10px 0;
}

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

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.45rem, 2vw, 2rem);
    letter-spacing: -0.04em;
    color: var(--theme-title);
    margin-bottom: 18px;
    text-shadow: 0 10px 28px var(--theme-shadow);
}

.section-header-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section-subtitle {
    color: var(--theme-text-dim);
    line-height: 1.62;
    max-width: 58ch;
    margin-top: -6px;
}

.sync-status-banner,
.profile-sync-note {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid var(--theme-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--theme-text-soft);
    line-height: 1.5;
    font-size: 0.88rem;
}

.sync-status-banner[data-status="synced"],
.profile-sync-note[data-status="synced"] {
    border-color: rgba(119, 210, 140, 0.24);
    background: rgba(119, 210, 140, 0.08);
}

.sync-status-banner[data-status="pending"],
.profile-sync-note[data-status="pending"] {
    border-color: rgba(255, 211, 123, 0.28);
    background: rgba(255, 211, 123, 0.1);
}

.sync-status-banner[data-status="offline"],
.profile-sync-note[data-status="offline"] {
    border-color: rgba(31, 221, 255, 0.24);
    background: rgba(31, 221, 255, 0.1);
}

.loading-spinner {
    color: var(--secondary);
    font-size: 1.2rem;
    text-align: center;
    margin-top: 50px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

body.player-mode header {
    padding-bottom: 0;
    border-bottom: none;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    margin-bottom: 10px;
}

body.player-mode .search-box {
    display: none !important;
}

body.player-mode .logo {
    width: 100%;
    justify-content: center;
    margin-bottom: 0;
    font-size: 1.2rem;
    opacity: 0.9;
}

body.player-mode #menu-btn {
    display: none;
}

body.player-mode #back-btn {
    margin-top: -5px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 180px;
    }

    body.player-mode {
        padding-bottom: 330px;
    }

    .glass-container {
        padding: 0;
        width: 100%;
        margin: 0;
        max-width: 100%;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: linear-gradient(180deg, rgba(9, 12, 24, 0.92), rgba(18, 24, 43, 0.78));
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        padding: 15px 20px;
        margin-bottom: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 0 0 25px 25px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        flex-direction: row;
        gap: 15px;
        flex-wrap: wrap;
    }

    .logo {
        justify-content: flex-start;
        font-size: 1.4rem;
        flex-grow: 1;
    }

    .search-box {
        width: 100%;
        order: 3;
        background: rgba(255, 255, 255, 0.08);
        padding: 12px 20px;
    }

    .search-box input {
        width: 100%;
        font-size: 1rem;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        padding: 0 20px 100px 20px;
    }

    .section-title {
        padding-left: 20px;
        margin-bottom: 15px;
        font-size: 1.4rem;
    }

    .section-header-row,
    .section-subtitle {
        padding-left: 20px;
        padding-right: 20px;
    }

    .filter-container {
        padding-left: 20px;
        padding-right: 20px;
    }
}
