/* ==========================================================================
   E-BOOK READER: MODERN GLASSMORPHIC DESIGN SYSTEM
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
    /* Obsidian Dark Theme (Default) */
    --bg-main: #0a0e17;
    --bg-surface: #131b2e;
    --bg-surface-elevated: #1a243d;
    --bg-glass: rgba(19, 27, 46, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --reader-bg: #0f1422;
    --reader-text: #e2e8f0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-reader: 'Lora', Georgia, serif;
    --font-size-reader: 18px;
    --line-height-reader: 1.65;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Warm Sepia Theme */
[data-theme="sepia"] {
    --bg-main: #f5ece0;
    --bg-surface: #ede0cf;
    --bg-surface-elevated: #e4d3bd;
    --bg-glass: rgba(237, 224, 207, 0.85);
    --border-subtle: rgba(90, 60, 30, 0.12);
    --border-active: rgba(180, 83, 9, 0.5);
    --text-primary: #2d1d0e;
    --text-secondary: #6b533f;
    --text-muted: #8d7560;
    --accent: #b45309;
    --accent-hover: #92400e;
    --accent-gradient: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    --accent-glow: rgba(180, 83, 9, 0.2);
    --reader-bg: #f9f3e9;
    --reader-text: #332211;
    --shadow-sm: 0 2px 8px rgba(90, 60, 30, 0.08);
    --shadow-md: 0 8px 24px rgba(90, 60, 30, 0.12);
}

/* Clean Light Theme */
[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-active: rgba(37, 99, 235, 0.5);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --accent-glow: rgba(37, 99, 235, 0.18);
    --reader-bg: #ffffff;
    --reader-text: #1e293b;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* OLED Midnight Theme */
[data-theme="oled"] {
    --bg-main: #000000;
    --bg-surface: #0a0a0a;
    --bg-surface-elevated: #141414;
    --bg-glass: rgba(10, 10, 10, 0.85);
    --border-subtle: rgba(255, 255, 255, 0.12);
    --border-active: rgba(245, 158, 11, 0.5);
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --accent-glow: rgba(245, 158, 11, 0.2);
    --reader-bg: #000000;
    --reader-text: #d4d4d4;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.8);
}

/* Nord Arctic Theme */
[data-theme="nord"] {
    --bg-main: #242933;
    --bg-surface: #2e3440;
    --bg-surface-elevated: #3b4252;
    --bg-glass: rgba(46, 52, 64, 0.85);
    --border-subtle: rgba(216, 222, 233, 0.1);
    --border-active: rgba(136, 192, 208, 0.5);
    --text-primary: #eceff4;
    --text-secondary: #d8dee9;
    --text-muted: #88c0d0;
    --accent: #88c0d0;
    --accent-hover: #81a1c1;
    --accent-gradient: linear-gradient(135deg, #88c0d0 0%, #5e81ac 100%);
    --accent-glow: rgba(136, 192, 208, 0.25);
    --reader-bg: #2e3440;
    --reader-text: #eceff4;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Container */
#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ==========================================================================
   VIEW 1: LIBRARY / WELCOME SCREEN
   ========================================================================== */
#library-view {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at 50% 10%, var(--bg-surface-elevated) 0%, var(--bg-main) 70%);
    transition: opacity var(--transition-smooth), transform var(--transition-smooth), visibility 0s;
}

#library-view.hidden {
    opacity: 0;
    transform: scale(0.98);
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-smooth), transform var(--transition-smooth), visibility 0s 250ms;
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 48px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.library-content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 48px 24px 72px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Hero Section */
.hero-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.hero-title {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.hero-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 580px;
    line-height: 1.5;
}

/* Drop Zone */
.dropzone-container {
    width: 100%;
}

.dropzone {
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 48px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: var(--bg-surface-elevated);
    box-shadow: 0 12px 40px var(--accent-glow);
    transform: translateY(-2px);
}

.dropzone-icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-smooth);
}

.dropzone:hover .dropzone-icon-wrap {
    transform: scale(1.08);
}

.dropzone-text h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.dropzone-text p {
    font-size: 14px;
    color: var(--text-secondary);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(1px);
}

.format-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 6px;
}

.format-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
}

/* Sample Books Shelf */
.section-title-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.book-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    gap: 16px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.book-card-cover {
    width: 68px;
    height: 96px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.book-card-cover svg {
    width: 32px;
    height: 32px;
}

.book-card-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}

.book-card-format {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
}

.book-card-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card-author {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card-cta {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   VIEW 2: READER CANVAS
   ========================================================================== */
#reader-view {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    background-color: var(--reader-bg);
    color: var(--reader-text);
    overflow: hidden;
}

/* Header Bar */
.reader-header {
    position: relative;
    height: 60px;
    flex-shrink: 0;
    z-index: 40;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: margin-top var(--transition-smooth), opacity var(--transition-smooth);
}

.reader-header.autohide {
    margin-top: -60px;
    opacity: 0;
    pointer-events: none;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 16px;
    min-width: 0;
}

.book-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
}

.book-header-meta {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
}

/* Icon Buttons */
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}

.btn-icon:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.btn-icon.active {
    background: var(--border-active);
    color: var(--accent);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Reader Main View Container */
.reader-canvas-wrap {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
}

foliate-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Page Navigation Click Zones */
.nav-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10%;
    min-width: 60px;
    max-width: 120px;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    cursor: pointer;
    transition: opacity var(--transition-smooth), background var(--transition-fast);
}

.nav-zone:hover {
    opacity: 1;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent);
}

.nav-zone-right {
    right: 0;
}
.nav-zone-right:hover {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.08), transparent);
}

.nav-arrow-indicator {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transform: scale(0.9);
    transition: transform var(--transition-fast);
}

.nav-zone:hover .nav-arrow-indicator {
    transform: scale(1);
}

/* Bottom Navigation Bar */
.reader-footer {
    position: relative;
    height: 56px;
    flex-shrink: 0;
    z-index: 40;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    transition: margin-bottom var(--transition-smooth), opacity var(--transition-smooth);
}

.reader-footer.autohide {
    margin-bottom: -56px;
    opacity: 0;
    pointer-events: none;
}

.slider-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

#progress-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-surface-elevated);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    transition: background var(--transition-fast);
}

#progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

#progress-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.progress-info {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
    font-feature-settings: "tnum";
}

/* ==========================================================================
   SLIDE-OUT SIDEBAR DRAWER (Table of Contents & Info)
   ========================================================================== */
#sidebar-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 360px;
    max-width: 85vw;
    z-index: 60;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition-smooth);
}

#sidebar-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface-elevated);
    padding: 4px;
    border-radius: var(--radius-md);
    margin: 12px 20px;
}

.drawer-tab {
    flex: 1;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    transition: all var(--transition-fast);
}

.drawer-tab.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 20px;
}

/* TOC Tree view styling */
.toc-list, .toc-list ol {
    list-style: none;
    padding-left: 12px;
}
.toc-list > ol {
    padding-left: 0;
}
.toc-item {
    margin: 2px 0;
}
.toc-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition-fast);
}
.toc-link:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}
.toc-link[aria-current="page"], .toc-link.active {
    background: var(--border-active);
    color: var(--accent);
    font-weight: 600;
}

/* Sidebar Dimming Backdrop */
#backdrop-overlay {
    position: absolute;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

#backdrop-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   FLYOUT SETTINGS MODAL (Appearance, Fonts, Themes)
   ========================================================================== */
#settings-flyout {
    position: absolute;
    top: 68px;
    right: 20px;
    width: 320px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 70;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    transform: translateY(-8px) scale(0.97);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

#settings-flyout.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Theme selector pills */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.theme-pill {
    height: 36px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.theme-pill:hover {
    transform: scale(1.05);
}

.theme-pill.active {
    border-color: var(--accent);
}

.pill-obsidian { background: #0f172a; color: #f8fafc; }
.pill-sepia { background: #f5ece0; color: #3d2c1d; }
.pill-light { background: #ffffff; color: #0f172a; border: 1px solid rgba(0,0,0,0.1); }
.pill-oled { background: #000000; color: #e5e5e5; }
.pill-nord { background: #2e3440; color: #eceff4; }

/* Font Family buttons */
.font-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.font-btn {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    transition: all var(--transition-fast);
}

.font-btn:hover {
    color: var(--text-primary);
}

.font-btn.active {
    background: var(--border-active);
    color: var(--accent);
    border-color: var(--accent);
}

/* Stepper Controls */
.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.stepper-btn {
    width: 44px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

.stepper-btn:hover {
    background: var(--border-subtle);
    color: var(--text-primary);
}

.stepper-value {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}

/* TTS Player Floating Bar */
#tts-bar {
    position: absolute;
    bottom: 68px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

#tts-bar.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.tts-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* Toast Notifications */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 10px;
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .library-header {
        padding: 16px 20px;
    }
    .hero-title {
        font-size: 28px;
    }
    .library-content {
        padding: 24px 16px 48px;
    }
    #settings-flyout {
        right: 10px;
        width: 300px;
    }
    .book-header-title {
        max-width: 200px;
    }
}

/* ==========================================================================
   CUSTOM CONTEXT MENU (Right-Click Export Options)
   ========================================================================== */
#context-menu {
    position: fixed;
    z-index: 200;
    width: 260px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
    backdrop-filter: blur(20px);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.94);
    transform-origin: top left;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

#context-menu.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.context-menu-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-align: left;
    transition: background var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}

.context-menu-item:hover {
    background: var(--bg-surface-elevated);
    transform: translateX(2px);
}

.menu-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-item-icon.pdf-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.menu-item-icon.rtf-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.menu-item-icon.md-icon {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.menu-item-icon.txt-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.menu-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.menu-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.menu-item-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.context-menu-scope {
    padding: 6px 10px 4px;
}

.scope-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.scope-label input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

