/* LexiRead - Super Clean Apple-style EPUB Reader */

:root {
    /* Colors - Apple-inspired Dark Mode Default */
    --bg: #000000;
    --bg-secondary: #0f0f0f;
    --surface: #1c1c1e;
    --text: #ffffff;
    --text-secondary: #98989f;
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.12);
    --border: rgba(255, 255, 255, 0.1);
    --danger: #ff453a;
    --success: #30d158;
}

body.light-mode {
    --bg: #f2f2f7;
    --bg-secondary: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --text-secondary: #8e8e93;
    --accent: #007aff;
    --accent-soft: rgba(0, 122, 255, 0.12);
    --border: rgba(0, 0, 0, 0.1);
}

body.sepia-mode {
    --bg: #f4ecd8;
    --bg-secondary: #f8f1dd;
    --surface: #fff7e5;
    --text: #2c1f0a;
    --text-secondary: #8e826d;
    --accent: #b8860b;
    --accent-soft: rgba(184, 134, 11, 0.12);
    --border: rgba(44, 31, 10, 0.1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
    color: var(--text);
}

/* ============================================
   HALAMAN UTAMA (HOME SCREEN) NEW DESIGN
   ============================================ */
.home-screen {
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative; /* For dropdown positioning */
}

.integrated-header-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.integrated-header-button:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

/* Sync indicator animations */
@keyframes blink-red {
    0%, 100% { background-color: #ff453a; opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes pulse-blue {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.upload-only-state {
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-only-state svg {
    width: 24px;
    height: 24px;
}

.auth-toggle-btn {
    position: relative;
}

.user-initial {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.sync-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #30d158; /* Apple green */
    border: 2px solid var(--surface);
    display: none;
}

/* Dropdown menu styles */
.dropdown-menu {
    position: absolute;
    top: 60px;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    min-width: 160px;
    animation: fadeInUp 0.2s ease;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: var(--text);
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-item svg {
    width: 20px;
    height: 20px;
}

/* Hide old elements */
#home-user-bar,
.home-user-avatar,
.home-sync-indicator,
.upload-fab {
    display: none;
}

.home-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 36px;
    font-weight: 400;
    letter-spacing: -0.5px;
    color: var(--text);
}

.upload-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-fab svg {
    width: 24px;
    height: 24px;
}

.upload-fab:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.upload-fab:active {
    transform: scale(0.95);
}

.upload-section {
    display: none; /* Hide old upload section */
}

.books-section {
    flex: 1;
}

.section-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

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

.book-card {
    position: relative;
    background: transparent;
    border-radius: 0; /* No border radius */
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
    border: none;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.book-cover {
    aspect-ratio: 2/3;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.book-cover svg {
    width: 40%;
    height: 40%;
    opacity: 0.4;
}

.book-cover-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Tampilkan cover utuh tanpa terpotong */
    display: block;
}

.book-info {
    padding: 12px 0;
    background: transparent;
    flex-shrink: 0;
}

.book-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px; /* Lebih tebal agar terlihat */
    background: var(--border);
    z-index: 10; /* Pastikan di atas cover */
}

.book-progress-container .progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.book-info h3 {
    font-size: 15px;
    font-weight: 500;
    margin: 8px 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    color: var(--text);
}

.book-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 60px 20px;
    font-size: 16px;
}

/* Recent Books (untuk kompatibilitas) */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.recent-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border-radius: 12px; padding: 12px 16px;
    cursor: pointer; border: 1px solid var(--border);
}
.recent-item-title { font-weight: 600; }
.recent-item-progress { font-size: 12px; color: var(--text-secondary); }

/* ============================================
   READER SCREEN (FULL-SCREEN SUPER CLEAN)
   ============================================ */
.reader-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    overflow: hidden;
    width: 100vw;
    /* Use dynamic viewport height so Android nav bar doesn't cut off content */
    height: 100dvh;
    height: 100vh; /* fallback for browsers without dvh */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@supports (height: 100dvh) {
    .reader-screen {
        height: 100dvh;
    }
}

.epub-viewer {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    margin: 0;
    padding: 0;
}

.epub-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg); gap: 16px; z-index: 10;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Edge Navigation (Invisible but functional) */
.nav-edge {
    position: absolute;
    top: 0;
    width: 20%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.nav-edge-left { left: 0; }
.nav-edge-right { right: 0; }

/* Menu Trigger (Subtle tap areas) */
.menu-trigger {
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 100px;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
}

/* Reader Menu (Appears when triggered - Apple-style) */
.reader-menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    padding: calc(12px + env(safe-area-inset-top)) 16px 20px;
    z-index: 200;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: slideDown 0.3s cubic-bezier(0.2, 0.1, 0.1, 1);
    pointer-events: auto;
}

.menu-btn {
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
}

body.light-mode .reader-menu,
body.sepia-mode .reader-menu {
    background: linear-gradient(to bottom, rgba(255,255,255,0.92), transparent);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.menu-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    flex-shrink: 0;
}

.menu-btn:hover { transform: scale(1.05); }
.menu-btn:active { transform: scale(0.95); }
.menu-btn.locked { color: var(--accent); background: var(--accent-soft); }
.menu-btn svg { width: 22px; height: 22px; }

.book-info {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.book-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-name {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.progress-percent {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

@media (max-width: 600px) {
    .reader-menu {
        top: auto;
        bottom: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
        padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px));
        animation: slideUpMenu 0.3s cubic-bezier(0.2, 0.1, 0.1, 1);
        display: flex;
        flex-direction: column-reverse;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    
    body.light-mode .reader-menu,
    body.sepia-mode .reader-menu {
        background: linear-gradient(to top, rgba(255,255,255,0.95), transparent);
        border-top: 1px solid rgba(0,0,0,0.05);
    }
    
    .menu-header {
        margin-bottom: 0;
        margin-top: 16px;
    }
}

@keyframes slideUpMenu {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SETTINGS PANEL APPLE-STYLE
   ============================================ */
/* Unified Modal Backdrop Containers */
.modal-backdrop-container,
.settings-panel,
.vocab-panel,
.translation-panel,
.toc-sidebar,
.search-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 250; /* Ensure high priority */
    display: none;
    align-items: flex-end; /* Mobile bottom sheet default */
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.panel-content {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.panel-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-close:hover {
    background: var(--border);
    color: var(--text);
    transform: scale(1.05);
}

.panel-close svg {
    width: 18px;
    height: 18px;
}

.panel-scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* Mobile bottom sheet */
@media (max-width: 768px) {
    .panel-content {
        border-radius: 24px 24px 0 0;
        max-height: 85vh;
        animation: slideUp 0.3s cubic-bezier(0.2, 0, 0.2, 1);
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    .vocab-panel .panel-content {
        height: 80vh;
        max-height: 80vh;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

.vocab-panel .panel-scroll-content {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Desktop side drawer */
@media (min-width: 769px) {
    .modal-backdrop-container,
    .settings-panel,
    .vocab-panel,
    .translation-panel,
    .toc-sidebar,
    .search-panel {
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        pointer-events: none;
    }

    .panel-content {
        pointer-events: auto; /* Re-enable pointer events for the card */
        position: fixed;
        width: 380px;
        top: 20px;
        bottom: 20px;
        border-radius: 20px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        background: rgba(28, 28, 30, 0.85); /* Slightly transparent surface */
    }
    
    body.light-mode .panel-content {
        background: rgba(255, 255, 255, 0.9);
    }
    
    body.sepia-mode .panel-content {
        background: rgba(253, 246, 227, 0.9);
    }

    /* Position left for TOC, right for others */
    .toc-sidebar .panel-content {
        left: 20px;
        animation: slideInLeft 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    }

    .vocab-panel .panel-content,
    .translation-panel .panel-content,
    .search-panel .panel-content,
    .settings-panel .panel-content {
        right: 20px;
        animation: slideInRight 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    }
}

@keyframes slideInLeft {
    from { transform: translateX(-110%); }
    to { transform: translateX(0); }
}

@keyframes slideInRight {
    from { transform: translateX(110%); }
    to { transform: translateX(0); }
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.theme-options {
    display: flex;
    gap: 12px;
}

.theme-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

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

.theme-preview {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.theme-preview.dark { background: #1c1c1e; }
.theme-preview.light { background: #f2f2f7; }
.theme-preview.sepia { background: #f4ecd8; }

.font-size-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 14px;
}

.size-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--surface);
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

#font-size-value {
    font-size: 17px;
    font-weight: 600;
}

.settings-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 15px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-group select:focus {
    border-color: var(--accent);
}

.btn-danger {
    width: 100%;
    padding: 14px;
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 16px;
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.15);
}

.btn-danger:active {
    transform: scale(0.98);
}

.btn-danger {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,69,58,0.1);
    color: var(--danger);
    border: 1px solid rgba(255,69,58,0.2);
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
}
.btn-danger:hover { background: rgba(255,69,58,0.18); }

/* ─── Google Drive Sync UI ─────────────────────────────────────── */
.drive-sync-group {
    border: 1px solid rgba(66, 133, 244, 0.2);
    border-radius: 14px;
    padding: 16px;
    background: rgba(66, 133, 244, 0.05);
}

.drive-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0 12px;
    line-height: 1.5;
}

.drive-user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

.drive-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(66,133,244,0.4);
}

.drive-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.drive-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drive-user-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drive-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.drive-dot {
    font-size: 14px;
    line-height: 1;
}

.drive-status-text { flex: 1; }

.btn-drive-connect, .btn-drive-sync, .btn-drive-disconnect {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.btn-drive-connect {
    background: linear-gradient(135deg, #4285F4, #34A853);
    color: white;
}
.btn-drive-connect:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-drive-connect:active { transform: scale(0.98); }

.btn-drive-sync {
    background: rgba(52, 168, 83, 0.12);
    color: #34A853;
    border: 1px solid rgba(52, 168, 83, 0.25);
}
.btn-drive-sync:hover { background: rgba(52, 168, 83, 0.2); }

.btn-drive-disconnect {
    background: rgba(255, 69, 58, 0.08);
    color: var(--danger);
    border: 1px solid rgba(255, 69, 58, 0.2);
}
.btn-drive-disconnect:hover { background: rgba(255, 69, 58, 0.15); }



select, input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
}

/* ============================================
   SEMUA KELAS CSS LAMA UNTUK KOMPATIBILITAS
   ============================================ */

/* Sidebar Inner Section & Utilities */
.sidebar-section { padding:16px; border-top:1px solid var(--border); }
.toc-nav { padding:8px; }
.toc-item { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 10px 12px; 
    border-radius: 8px; 
    color: var(--text-secondary); 
    cursor: pointer; 
    text-decoration: none; 
    transition: all 0.15s; 
}
.toc-item:hover { background: var(--accent-soft); color: var(--accent); }
.toc-item.active { 
    color: var(--accent); 
    background: var(--accent-soft); 
    font-weight: 500;
}
.toc-item.active::after {
    content: '📍 Posisi Anda';
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-left: 12px;
    white-space: nowrap;
}
.toc-item.depth-1 { padding-left:24px; }
.toc-item.depth-2 { padding-left:36px; }
.icon-btn { width:36px; height:36px; display:flex; align-items:center; justify-content:center; border-radius:10px; background: transparent; border:none; color: var(--text-secondary); cursor:pointer; }
.icon-btn.small { width:28px; height:28px; }
.icon-btn:hover { background: var(--bg-secondary); color: var(--text); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

/* Search Elements */
.search-input-wrap { flex:1; display:flex; align-items:center; gap:8px; background: var(--bg-secondary); padding:8px 12px; border-radius:10px; }
.search-input-wrap input { background:transparent; border:none; outline:none; flex:1; padding:0; color: var(--text); }
.search-results { flex:1; overflow-y:auto; padding:8px; }
.search-result-item { padding:10px 12px; border-radius:8px; cursor:pointer; font-size:14px; border-bottom:1px solid var(--border); }
.search-result-item:hover { background: var(--accent-soft); }
.search-result-item .result-chapter { font-size:12px; color: var(--text-secondary); margin-bottom:4px; }

/* Translation Elements */
.panel-api { padding:12px 16px; border-bottom:1px solid var(--border); }
.translation-content { flex:1; overflow-y:auto; padding:16px; }
.translation-hint { display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%; gap:12px; color: var(--text-secondary); text-align:center; }
.panel-stats { padding:10px 16px; border-top:1px solid var(--border); font-size:12px; color: var(--text-secondary); display:flex; justify-content:space-between; }
.btn-small { padding:6px 12px; background: var(--accent); color:white; border:none; border-radius:8px; font-weight:600; cursor:pointer; }
.lang-selector select { width:auto; }

/* Translation Popup */
.translation-popup {
    position: fixed; max-width:480px; min-width:300px;
    background: var(--surface); border:1px solid var(--border);
    border-radius:20px; box-shadow:0 12px 28px rgba(0,0,0,0.3);
    z-index:200; overflow:hidden; animation:popupIn 0.18s ease;
}
@keyframes popupIn { from { opacity:0; transform: translateY(10px) scale(0.98); } to { opacity:1; transform:none; } }
.popup-header { background: var(--bg-secondary); padding:10px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.popup-lang-badge { font-size:12px; font-weight:700; color: var(--accent); background: var(--accent-soft); padding:4px 12px; border-radius:20px; }
.popup-actions { display:flex; gap:4px; }
.popup-btn { width:32px; height:32px; border-radius:10px; border:none; background:transparent; cursor:pointer; }
.popup-btn:hover { background: var(--surface); }
.popup-original, .popup-translated { padding:14px 16px; line-height:1.6; }
.popup-original { background: var(--bg-secondary); color: var(--text-secondary); font-style:italic; max-height:180px; overflow-y:auto; }
.popup-translated { max-height:220px; overflow-y:auto; }
.popup-divider { display:flex; justify-content:center; padding:6px; background: var(--bg); }
.translating-indicator { display:flex; align-items:center; gap:8px; color: var(--text-secondary); }
.dot-pulse { width:12px; height:12px; border-radius:50%; background: var(--accent); animation:pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* Vocab Panel */
.vocab-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vocab-tabs { 
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--border);
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.vocab-tabs::-webkit-scrollbar { display: none; }
.vocab-tab-btn { 
    padding: 10px 4px; 
    border: none; 
    background: transparent; 
    color: var(--text-secondary); 
    cursor: pointer; 
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}
.vocab-tab-btn .tab-icon { font-size: 18px; }
.vocab-tab-btn .tab-label { font-size: 10px; }
.vocab-tab-btn.active { 
    color: var(--accent); 
    border-bottom-color: var(--accent); 
    background: transparent;
}
.vocab-miner { 
    padding: 12px 16px; 
    border-bottom:1px solid var(--border); 
}
.btn-miner { 
    width:100%; 
    padding: 12px 14px; 
    background: var(--accent); 
    color: white; 
    border: none; 
    border-radius: 16px; 
    font-weight:700; 
    cursor:pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-miner:hover { 
    transform: scale(1.01); 
    filter: brightness(1.05);
}
.btn-miner:active {
    transform: scale(0.98);
}
.vocab-content { 
    flex: 1; 
    overflow-y: auto; 
    padding: 0;  /* no padding — inner containers handle their own padding */
    display: flex;
    flex-direction: column;
    min-height: 0;
}
/* My Dictionary container */
.my-dictionary-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.my-dictionary-container .dict-controls {
    flex-shrink: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.my-dictionary-container .dict-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}
/* empty state shared */
.empty-state-dict {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}
.empty-state-dict .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.vocab-card, .saved-translation-card { 
    background: var(--bg-secondary); 
    padding: 16px; 
    border-radius: 16px; 
    margin-bottom: 16px; 
    border-left:4px solid var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.vocab-word { 
    font-weight:800; 
    color: var(--accent); 
    font-size:18px;
}
.vocab-translation { 
    margin: 6px 0; 
    font-size:16px;
}
.vocab-context { 
    font-size:13px; 
    color: var(--text-secondary); 
    font-style:italic; 
    margin-top: 10px; 
    padding-top: 10px; 
    border-top: 1px dashed var(--border);
}
.vocab-actions { 
    display:flex; 
    gap: 10px; 
    justify-content:flex-end; 
    margin-top: 12px;
}
.vocab-review { 
    background: var(--accent-soft); 
    color: var(--accent); 
    border:none; 
    padding: 8px 12px; 
    border-radius: 10px; 
    cursor:pointer; 
    font-size:13px;
    font-weight:600;
}
.vocab-delete, .delete-translation { 
    background: rgba(255,69,58,0.1); 
    color: var(--danger); 
    border: none; 
    padding: 8px 12px; 
    border-radius: 10px; 
    cursor:pointer; 
    font-size:13px;
    font-weight:600;
}
.saved-translation-card .original { font-size:13px; color: var(--text-secondary); font-style:italic; }
.saved-translation-card .translated { margin:6px 0; }
.saved-translation-card .meta { font-size:12px; color: var(--text-secondary); margin-bottom:8px; }

/* Responsive Design */
@media (max-width: 1024px) {
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    .home-screen { padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
    .home-title { font-size: 28px; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .book-info { padding: 12px 0; }
    .reader-menu { padding: calc(10px + env(safe-area-inset-top)) 12px 16px; }
    .menu-header { gap: 8px; }
    .menu-btn { width: 40px; height: 40px; border-radius: 10px; }
    .menu-btn svg { width: 20px; height: 20px; }
    .book-title { font-size: 13px; }
    .chapter-name { font-size: 11px; }
}

@media (max-width: 480px) {
    .home-title { font-size: 24px; }
    .books-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .book-cover { aspect-ratio: 3/4; }
    .upload-fab { width: 48px; height: 48px; }
    .menu-header { gap: 6px; }
    .menu-btn { width: 38px; height: 38px; border-radius: 8px; }
    .menu-btn svg { width: 18px; height: 18px; }
    .vocab-tabs { padding: 0; }
    .vocab-tab-btn { padding: 8px 2px; }
    .vocab-tab-btn .tab-icon { font-size: 16px; }
    .vocab-tab-btn .tab-label { font-size: 9px; }
    .btn-miner { padding: 10px; font-size: 13px; }
    .progress-slider { height: 4px; }
    .progress-slider::-webkit-slider-thumb { width: 18px; height: 18px; }
}

@media (min-width: 1280px) {
    .home-screen { padding: calc(32px + env(safe-area-inset-top)) 48px calc(32px + env(safe-area-inset-bottom)); }
    .home-title { font-size: 36px; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
    .reader-menu { padding: calc(20px + env(safe-area-inset-top)) 24px 24px; }
}

@media (min-width: 1600px) {
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px; }
    .home-screen { padding: calc(40px + env(safe-area-inset-top)) 80px calc(40px + env(safe-area-inset-bottom)); }
}

/* Bilingual Mode: Clean, precise, with subtle spacing */
.lexi-bilingual-block {
    margin: 0.5em 0; /* Small top/bottom margin for separation */
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    display: block;
    clear: both; /* Prevent floating */
}

.lexi-bilingual-block::before {
    display: none !important;
}

/* No extra styles on child elements */
.lexi-bilingual-block > * {
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    background: transparent;
    border: none;
}

.lexi-paragraph-clickable { cursor:pointer; padding:2px; border-radius:4px; transition:background 0.15s; }
.lexi-paragraph-clickable:hover { background: var(--accent-soft); outline:1px solid var(--accent); }
.lexi-paragraph-clickable.lexi-translating { background: var(--accent-soft); }

/* Toast */
.toast {
    position: fixed; bottom: 30px; left:50%; transform: translateX(-50%);
    background: var(--surface); padding:12px 24px; border-radius:100px;
    font-size:14px; font-weight:500; box-shadow:0 4px 20px rgba(0,0,0,0.3);
    z-index:1000; opacity:0; transition:opacity 0.2s; pointer-events:none;
}
.toast.show { opacity:1; }

/* Scrollbar */
::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius:4px; }

/* ============================================
   AUTO-HIDE & LOCK UI
   ============================================ */
.reader-menu {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.reader-menu.hidden {
    opacity:0;
    transform: translateY(-30px);
    pointer-events:none;
}

/* Responsive */
/* Standardized responsive panels handle sizes natively now */
@media (max-width: 768px) {
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .translation-popup { max-width: calc(100vw - 32px); left:16px !important; right:16px !important; top:auto !important; bottom:20px !important; }
}

/* ============================================
   WORD & PHRASE MINER POPUPS
   ============================================ */
.dict-popup {
    position: fixed;
    /* Mobile default: bottom sheet */
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    top: auto;
    width: auto;
    max-width: none;
    background: var(--surface); border:1px solid var(--border);
    border-radius: 20px; box-shadow: 0 -4px 32px rgba(0,0,0,0.3);
    z-index: 400; overflow: hidden; animation: popupIn 0.2s ease;
    display: flex; flex-direction: column;
}
@media (min-width: 600px) {
    .dict-popup {
        /* Desktop: near cursor, constrained width */
        position: fixed;
        left: auto;
        right: auto;
        bottom: auto;
        width: auto;
        min-width: 320px;
        max-width: 400px;
    }
}
.dict-popup-header {
    background: var(--bg-secondary); padding:12px 16px; 
    border-bottom:1px solid var(--border); display:flex; 
    align-items:center; justify-content:space-between;
}
.dict-popup-title {
    font-size:14px; font-weight:700; color:var(--accent);
}
.dict-popup-body {
    padding: 16px; max-height: 280px; overflow-y: auto;
    font-size: 15px; line-height: 1.6;
}
.dict-term {
    font-size: 20px; font-weight: 700; color: var(--text);
    margin-bottom: 4px;
}
.dict-phonetic {
    font-size: 13px; color: var(--text-secondary); margin-bottom: 12px;
}
.dict-definition-title {
    font-weight: 600; font-size: 13px; color: var(--text-secondary);
    text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px;
}
.dict-definition {
    background: var(--bg-secondary); border-radius: 12px;
    padding: 12px; border-left: 3px solid var(--accent);
    margin-bottom: 12px; font-size: 14px;
}
.dict-context-box {
    margin-top: 12px; padding: 10px; font-size: 13px;
    color: var(--text-secondary); border: 1px dashed var(--border);
    border-radius: 8px; background: rgba(255,255,255,0.01);
}
.dict-popup-footer {
    padding: 12px 16px; background: var(--bg-secondary);
    border-top: 1px solid var(--border); display: flex; gap: 8px;
}
.dict-btn-primary {
    flex: 1; padding: 10px; background: var(--accent);
    color: white; border: none; border-radius: 10px;
    font-weight: 600; cursor: pointer; transition: background 0.2s;
    font-size: 14px;
}
.dict-btn-secondary {
    padding: 10px 16px; background: var(--surface);
    color: var(--text); border: 1px solid var(--border); border-radius: 10px;
    font-weight: 600; cursor: pointer; transition: background 0.2s;
    font-size: 14px;
}

/* ============================================
   MY DICTIONARY UI
   ============================================ */
.dict-controls {
    /* NOTE: Inside .my-dictionary-container, .dict-controls is sticky top */
    display: flex; flex-direction: column; gap: 12px;
    /* padding and border handled by .my-dictionary-container .dict-controls rule */
}
.dict-search-row {
    display: flex; gap: 8px;
}
.dict-search-input-wrap {
    flex: 1; display: flex; align-items: center; gap: 8px;
    background: var(--bg-secondary); padding: 8px 12px; border-radius: 12px;
    border: 1px solid var(--border);
}
.dict-search-input-wrap input {
    background: transparent; border: none; outline: none;
    color: var(--text); flex: 1; font-size: 14px;
}
.dict-select {
    padding: 8px 12px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); font-size: 13px; outline: none; cursor: pointer;
}
.dict-list {
    display: flex; flex-direction: column; gap: 12px;
}
.dict-card {
    background: var(--bg-secondary); padding: 16px;
    border-radius: 16px; border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    display: flex; flex-direction: column; gap: 6px;
    position: relative; transition: border-color 0.2s;
}
.dict-card:hover {
    border-color: var(--accent);
}
.dict-card-header {
    display: flex; justify-content: space-between; align-items: center;
}
.dict-card-term {
    font-size: 16px; font-weight: 700; color: var(--text);
}
.dict-card-type-badge {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 2px 6px; border-radius: 4px; letter-spacing: 0.5px;
}
.dict-card-type-badge.word {
    background: var(--accent-soft); color: var(--accent);
}
.dict-card-type-badge.phrase {
    background: rgba(48, 209, 88, 0.12); color: var(--success);
}
.dict-card-definition {
    font-size: 14px; color: var(--text); line-height: 1.5;
}
.dict-card-context {
    font-size: 12px; color: var(--text-secondary); font-style: italic;
    background: var(--surface); padding: 8px; border-radius: 8px;
    margin-top: 4px;
}
.dict-card-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: var(--text-secondary); margin-top: 6px;
    border-top: 1px dashed var(--border); padding-top: 6px;
}
.dict-card-tags {
    display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px;
}
.dict-card-tag {
    font-size: 10px; background: var(--surface); border: 1px solid var(--border);
    padding: 2px 6px; border-radius: 100px; color: var(--text-secondary);
}
.dict-card-actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px;
}
.dict-btn-icon {
    border: none; background: transparent; color: var(--text-secondary);
    cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 12px;
    font-weight: 600; display: flex; align-items: center; gap: 4px;
    transition: all 0.2s;
}
.dict-btn-icon:hover {
    background: var(--surface); color: var(--text);
}
.dict-btn-icon.delete:hover {
    background: rgba(255, 69, 58, 0.1); color: var(--danger);
}

/* ============================================
   FLASH CARDS
   ============================================ */
.flashcards-container {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}
.flashcards-screen {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; flex: 1; min-height: 380px; padding: 8px;
}
.flashcard-perspective {
    perspective: 1000px; width: 100%; max-width: 320px;
    height: 220px; margin: 16px auto;
}
.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d; cursor: pointer;
}
.flashcard-inner.flipped {
    transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: 20px; border: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 20px; box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.flashcard-front {
    background: var(--bg-secondary); color: var(--text);
}
.flashcard-back {
    background: var(--surface); color: var(--text);
    transform: rotateY(180deg);
}
.flashcard-badge {
    position: absolute; top: 12px; right: 16px; font-size: 9px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 6px; border-radius: 4px; background: var(--border);
    color: var(--text-secondary);
}
.flashcard-content-term {
    font-size: 22px; font-weight: 700; text-align: center;
    color: var(--accent); margin-bottom: 8px; word-break: break-word;
}
.flashcard-content-def {
    font-size: 14px; text-align: center; line-height: 1.5;
    word-break: break-word; overflow-y: auto; max-height: 120px;
}
.flashcard-hint {
    font-size: 11px; color: var(--text-secondary); margin-top: 12px;
}
.flashcard-buttons {
    display: flex; gap: 12px; width: 100%; max-width: 320px;
    margin-top: 12px;
}
.flashcard-btn {
    flex: 1; padding: 12px; border: none; border-radius: 12px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: transform 0.1s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.flashcard-btn:active { transform: scale(0.97); }
.flashcard-btn-wrong {
    background: rgba(255, 69, 58, 0.12); color: var(--danger);
    border: 1px solid rgba(255, 69, 58, 0.2);
}
.flashcard-btn-correct {
    background: rgba(48, 209, 88, 0.12); color: var(--success);
    border: 1px solid rgba(48, 209, 88, 0.2);
}
.flashcard-progress-bar {
    width: 100%; max-width: 320px; height: 4px; background: var(--border);
    border-radius: 2px; margin-top: 16px; overflow: hidden;
}
.flashcard-progress-fill {
    height: 100%; background: var(--accent); width: 0%;
    transition: width 0.3s ease;
}
.flashcard-stats {
    font-size: 12px; color: var(--text-secondary); margin-top: 8px;
}
.flashcard-quiz-finished {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; gap: 12px; padding: 24px;
}

/* ============================================
   BILINGUAL SCREEN — Ultra Clean (matches main reader)
   ============================================ */
.bilingual-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    color: var(--text);
    z-index: 105;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
}

.bilingual-content {
    flex: 1;
    overflow-y: auto;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
    line-height: 1.8;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Bilingual paragraph pair */
.bilingual-p-wrapper {
    margin-bottom: 28px;
}
.orig-p {
    font-size: 1.05em;
    margin: 0 0 5px 0;
    color: var(--text);
}
.trans-p {
    font-size: 0.93em;
    color: var(--text-secondary);
    margin: 0;
    font-style: italic;
}
.trans-p.clickable { cursor: pointer; }
.trans-missing {
    color: var(--accent);
    text-decoration: underline;
    font-style: normal;
    font-size: 0.88em;
}

.bilingual-header-wrapper { margin: 32px 0 16px; }
.bilingual-header-wrapper h1,
.bilingual-header-wrapper h2,
.bilingual-header-wrapper h3,
.bilingual-header-wrapper h4,
.bilingual-header-wrapper h5,
.bilingual-header-wrapper h6 { margin: 0 0 4px 0; }
.trans-header {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-style: italic;
}

.bilingual-loading, .bilingual-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-secondary);
    text-align: center;
    gap: 12px;
}

/* Center menu trigger area (invisible) */
.bilingual-menu-trigger {
    position: fixed;
    top: 0;
    left: 20%;
    right: 20%;
    height: 100px;
    z-index: 110;
    cursor: pointer;
    opacity: 0;
}

/* Floating minimal menu */
.bilingual-float-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    animation: slideDown 0.25s cubic-bezier(0.2,0.1,0.1,1);
    pointer-events: auto;
}
.bilingual-float-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.82), transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
body.light-mode .bilingual-float-inner,
body.sepia-mode .bilingual-float-inner {
    background: linear-gradient(to bottom, rgba(255,255,255,0.92), transparent);
}
.bilingual-float-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: transform 0.1s;
}
.bilingual-float-btn svg { width: 20px; height: 20px; }
.bilingual-float-btn:active { transform: scale(0.95); }
.bilingual-float-chapter {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bilingual-float-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.bilingual-float-themes {
    display: flex;
    gap: 5px;
    background: var(--surface);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.bilingual-theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.12);
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s;
}
.bilingual-theme-dot:hover { transform: scale(1.15); }
.theme-light-dot { background: #ffffff; }
.theme-sepia-dot { background: #f4ecd8; }
.theme-dark-dot  { background: #111318; }

/* Chapter nav row in floating menu */
.bilingual-float-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}
body.light-mode .bilingual-float-nav,
body.sepia-mode .bilingual-float-nav {
    background: linear-gradient(to bottom, rgba(255,255,255,0.7), transparent);
}
.bilingual-nav-arrow {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.bilingual-nav-arrow svg { width: 18px; height: 18px; }
.bilingual-nav-arrow:disabled { opacity: 0.35; cursor: not-allowed; }
.bilingual-nav-arrow-right { flex-direction: row-reverse; }
.bilingual-float-progress {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   HOME — Login Card & Sync Indicator
   ============================================ */
.home-login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px 20px;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: fadeInUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-align: center;
}

.login-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.login-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.home-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.2);
    margin-top: 8px;
}

.home-login-btn:hover { opacity: 0.92; box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3); }
.home-login-btn:active { transform: scale(0.97); }
.home-login-btn svg { width: 20px; height: 20px; }

/* Minimal Auth Toggle Button */
.auth-toggle-btn, .add-book-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
}

.auth-toggle-btn:hover, .add-book-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.auth-toggle-btn svg, .add-book-btn svg {
    width: 22px;
    height: 22px;
}

/* Auth Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.auth-modal-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.auth-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.auth-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.auth-modal-close:hover {
    background: var(--bg-secondary);
}

/* Forgot Password */
.forgot-password-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    margin-top: 8px;
    text-align: center;
    font-family: inherit;
}

.forgot-password-btn:hover {
    text-decoration: underline;
}

/* Logout Section */
.logout-section {
    text-align: center;
    padding: 12px 0;
}

.user-email {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    word-break: break-all;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 12px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
}
.auth-tab-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.auth-tab-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Auth Form */
.auth-form {
    width: 100%;
    margin-top: 8px;
}
.auth-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 15px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}
.auth-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.auth-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: inherit;
}
.auth-btn.primary {
    background: var(--accent);
    color: #fff;
}
.auth-btn.primary:hover { opacity: 0.92; }
.auth-btn.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.auth-btn.secondary:hover { background: var(--bg-secondary); }
.auth-message {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}
.auth-message.error { color: var(--danger); }
.auth-message.success { color: var(--success); }

/* User info bar (when logged in) */
.home-user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    margin-bottom: 12px;
}
.home-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: none;
}
.home-user-info { flex: 1; }
.home-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.home-user-email {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Sync indicator dot */
.home-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: default;
    transition: opacity 0.3s;
}
.home-sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    flex-shrink: 0;
}
.home-sync-indicator.syncing .home-sync-dot {
    background: var(--accent);
    animation: pulse 1s infinite;
}
.home-sync-indicator.synced .home-sync-dot {
    background: var(--success);
}
.home-sync-indicator.error .home-sync-dot {
    background: var(--danger);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Centered Translation Progress Modal */
.translation-progress-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.translation-progress-content {
    background: var(--surface);
    color: var(--text);
    width: 90%;
    max-width: 400px;
    padding: 28px 24px;
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    text-align: center;
    border: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}




details[open] summary .details-arrow {
    transform: rotate(180deg);
}
summary::-webkit-details-marker {
    display: none;
}

