:root {
    --bg-color: #0d0f12;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --gradient-glow: linear-gradient(135deg, rgba(99,102,241,0.2) 0%, rgba(217,70,239,0.2) 100%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    position: relative;
    line-height: 1.6;
}

.background-mesh {
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.15), transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(217, 70, 239, 0.1), transparent 30%);
    z-index: -1;
    animation: meshFlow 20s infinite alternate ease-in-out;
}

@keyframes meshFlow {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-10%, 10%); }
}

.hidden { display: none !important; }

/* BOTTOM SHEET MODALS (PageUnbound Edition) */
.bottom-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 85%;
    background: rgba(14, 16, 21, 0.85); /* Deep glass */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255,255,255,0.08);
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    z-index: 100;
    box-shadow: 0 -20px 50px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
    transform: translateY(0);
}
.bottom-sheet.hidden {
    transform: translateY(100%);
    display: flex !important; /* Keep display flex to allow transform animation before actual hide via JS */
    pointer-events: none;
    opacity: 0;
}
.bottom-sheet-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bottom-sheet-header h3 {
    color: #fff;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.btn-close-sheet {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    font-size: 1.4rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-close-sheet:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.bottom-sheet-body {
    flex: 1;
    overflow-y: auto;
}

/* Menu List (Timer) */
.menu-list .sheet-menu-item {
    width: 100%;
    padding: 1.2rem 1.5rem;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.8);
    text-align: left;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}
.menu-list .sheet-menu-item:hover, .menu-list .sheet-menu-item.active {
    background: linear-gradient(90deg, rgba(250, 166, 26, 0.05) 0%, transparent 100%);
    border-left: 3px solid var(--accent);
    color: #fff;
}
.menu-list .sheet-menu-item .checkmark {
    color: var(--accent);
    text-shadow: 0 0 12px rgba(250, 166, 26, 0.4);
    font-weight: bold;
}

/* Outline Buttons (Speed Presets) */
.speed-preset {
    padding: 0.8rem 1.2rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    text-align: center;
    transition: all 0.2s;
}
.speed-preset.active {
    background: rgba(250, 166, 26, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(250, 166, 26, 0.15);
}

.active { display: block; }

h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; }

.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 2rem; max-width: 1200px; margin: 0 auto;
}

.logo { font-size: 1.5rem; font-weight: 700; font-family: var(--font-heading); letter-spacing: -0.5px; }
.logo span { color: var(--accent); }

.lang-switch button {
    background: transparent; border: none; color: var(--text-secondary);
    font-size: 0.9rem; font-weight: 500; cursor: pointer; margin-left: 1rem;
    padding: 0.2rem 0; transition: all 0.3s ease;
}
.lang-switch button.active { color: var(--text-primary); border-bottom: 2px solid var(--accent); }

.container { max-width: 800px; margin: 2rem auto; padding: 0 1.5rem; }

.glass-panel {
    background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: 24px; padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.card-animation { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

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

/* Shared text styles */
.glass-panel h1 { font-size: 2.3rem; margin-bottom: 1rem; background: linear-gradient(to right, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.glass-panel p { color: var(--text-secondary); margin-bottom: 2rem; font-size: 1.1rem; }

/* Upload Area */
.upload-area {
    border: 2px dashed rgba(255,255,255,0.2); border-radius: 16px; padding: 2.5rem 1.5rem; text-align: center;
    cursor: pointer; transition: all 0.3s ease; background: rgba(0,0,0,0.2);
}
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); background: rgba(99, 102, 241, 0.05); }
.upload-icon { font-size: 3rem; margin-bottom: 1rem; filter: drop-shadow(0 0 10px rgba(255,255,255,0.2)); }
.upload-area h3 { margin-bottom: 0.5rem; font-size:1.5rem;}

/* Progress */
#upload-progress { margin-top: 2rem; }
.status-text { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.5rem; text-align: center; }
.progress-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width 0.3s ease; }
.processing-note { font-size: 0.8rem; color: #f59e0b; text-align: center; margin-top: 1rem; }

/* Library System */
.library-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem;
}
.book-card {
    background: rgba(0,0,0,0.2); border: 1px solid var(--glass-border); border-radius: 12px;
    padding: 1.5rem; text-align: left; cursor: pointer; transition: transform 0.2s, background 0.2s;
}
.book-card:hover { transform: translateY(-5px); background: rgba(0,0,0,0.4); border-color: var(--accent); }
.book-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: #fff; }
.book-card p { font-size: 0.8rem; margin:0; color: var(--text-secondary); }
.book-progress { width: 100%; height: 4px; background: rgba(255,255,255,0.1); margin-top: 1rem; border-radius: 2px;}
.book-progress-fill { height: 100%; background: var(--accent); border-radius: 2px;}


/* Player Section */
.player-header { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; margin-top: 1rem; }
.book-cover-mock {
    width: 80px; height: 110px; background: linear-gradient(135deg, #4f46e5, #9333ea);
    border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.btn-ghost {
    background: transparent; border: none; color: var(--text-secondary); cursor: pointer;
    font-size: 0.9rem; display: inline-flex; align-items: center; transition: color 0.2s; margin-bottom: 1rem;
}
.btn-ghost:hover { color: #fff; }

.voice-selector { margin-bottom: 2rem; }
.voice-selector label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.voice-selector select { width: 100%; padding: 0.8rem 1rem; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); border-radius: 8px; color: #fff; font-family: inherit; outline: none; appearance: none; }
.voice-selector select:focus { border-color: var(--accent); }

.audio-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-bottom: 2rem; }

.btn-primary {
    background: var(--accent); color: #fff; border: none; padding: 1rem 2rem; border-radius: 50px;
    font-family: var(--font-heading); font-size: 1.1rem; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(99,102,241,0.4);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-2px); }
.btn-primary:disabled { background: #475569; cursor: not-allowed; box-shadow: none; opacity: 0.7; }

.btn-secondary {
    background: rgba(255,255,255,0.1); color: #fff; border: 1px solid var(--glass-border); padding: 0.8rem;
    border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); }

.text-content-wrapper { background: rgba(0,0,0,0.2); border-radius: 12px; padding: 1.5rem; max-height: 250px; overflow-y: auto; border: 1px solid var(--glass-border); }
.text-content { font-size: 1.1rem; color: #cbd5e1; white-space: pre-wrap; line-height: 1.8; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.skeleton-line {
    height: 16px; background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%; animation: skeleton 1.5s infinite; border-radius: 4px; margin-bottom: 12px; width: 100%;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Base header navigation styles */
.auth-group { display: flex; align-items: center; gap: 1rem; }
.auth-user-group { display: flex; align-items: center; gap: 1rem; color: rgba(255,255,255,0.8); }
.lang-group { display: flex; align-items: center; }

.mobile-menu-btn { display: none; background: transparent; border: none; font-size: 2rem; color: #fff; cursor: pointer; }
.mobile-header-nav { display: flex; align-items: center; gap: 1.5rem; }

@media(max-width: 768px) { 
    .glass-panel { padding: 1.5rem; }
    .mobile-menu-btn { display: block; }
    .mobile-header-nav {
        display: none;
        position: absolute;
        top: 75px;
        left: 0;
        width: 100%;
        background: rgba(20,20,30,0.98);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 2rem;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        z-index: 1000;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        align-items: center;
        gap: 1.5rem;
    }
    .mobile-header-nav.open {
        display: flex;
    }
    .auth-group, .auth-user-group {
        flex-direction: column;
        gap: 1.2rem;
    }
    .app-header {
        padding: 1rem 1.5rem;
    }
    .logo span {
        font-size: 1.2rem !important;
    }
    .logo img { height: 40px !important; }
}
