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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Dark theme */
body.dark-mode {
    background: #1a202c;
    color: #e2e8f0;
}

body.dark-mode .header {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .header h1 {
    color: #e2e8f0;
}

body.dark-mode .header p {
    color: #a0aec0;
}

body.dark-mode .header-logo {
    filter: brightness(0) invert(1);
}

body.dark-mode .controls {
    background: #2d3748;
    border-color: #4a5568;
}

/* Sepia theme */
body.sepia-mode {
    background: #f0ece2;
    color: #8b4513;
}

body.sepia-mode .header {
    background: #f5f1e8;
    color: #8b4513;
    border-color: #d4af8c;
}

body.sepia-mode .controls {
    background: #f5f1e8;
    border-color: #d4af8c;
}

::selection {
    background: #007acc;
}

::-moz-selection {
    background: #007acc;
}

.header {
    background: white;
    border-bottom: 1px solid #ddd;
    padding: 1rem;
    text-align: center;
}

.header-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.header-logo {
    width: 32px;
    height: 32px;
    display: block;
}

.header h1 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header p {
    color: #666;
    font-size: 0.875rem;
    margin: 0;
}

.container {
    display: block;
    height: calc(100vh - 80px);
    padding-bottom: 0;
    position: relative;
}

.pdf-viewer {
    width: 100%;
    height: 100%;
    background: white;
    overflow-y: auto;
    overflow-x: auto;
    padding: 1rem;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.pdf-viewer.with-panel {
    height: 30%;
}

.ai-panel {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    height: 0;
    background: white;
    padding: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    z-index: 400;
}

.ai-panel.expanded {
    height: 70vh;
    padding: 1rem;
    overflow-y: auto;
}

/* Clean Bookmark Panel */
.bookmark-panel {
    position: fixed;
    top: 80px;
    right: -320px;
    width: 300px;
    height: calc(100vh - 140px);
    background: white;
    border-left: 1px solid #e2e8f0;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 500;
    transition: right 0.3s ease;
    overflow: hidden;
}

.bookmark-panel.open {
    right: 0;
}

.bookmark-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 2px solid #f1f5f9;
    background: #f8fafc;
}

.bookmark-panel-header h3 {
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.bookmark-search {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.bookmark-search input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.bookmark-search input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bookmark-list-container {
    padding: 0.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100% - 140px);
    scroll-behavior: smooth;
}

.bookmark-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Enhanced bookmark tree structure */
.bookmark-tree {
    padding: 0.5rem 0;
}

.bookmark-level {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bookmark-item {
    margin: 0;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f1f5f9;
}

.bookmark-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.bookmark-item:hover .bookmark-content {
    background: #f8fafc;
}

.bookmark-expand-indicator {
    font-size: 0.75rem;
    color: #6b7280;
    width: 12px;
    text-align: center;
    transition: transform 0.2s ease;
}

.bookmark-item.expanded .bookmark-expand-indicator {
    transform: rotate(0deg);
}

.bookmark-item.collapsed .bookmark-expand-indicator {
    transform: rotate(-90deg);
}

.bookmark-title {
    flex: 1;
    font-size: 0.9rem;
    color: #374151;
    font-weight: 500;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 180px;
}

.bookmark-page {
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
}

/* Clean level styling */
.level-0 {
    border-bottom: 2px solid #f1f5f9;
}

.level-0 .bookmark-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.level-1 .bookmark-title {
    font-weight: 500;
    color: #374151;
}

.level-2 .bookmark-title {
    font-weight: 400;
    color: #4b5563;
    font-size: 0.85rem;
}

.level-3 .bookmark-title {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.8rem;
}

.no-bookmarks {
    text-align: center;
    color: #6b7280;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.no-bookmarks-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.no-bookmarks p {
    font-style: italic;
    margin: 0;
    font-size: 0.9rem;
}

/* Mobile bookmark panel */
@media (max-width: 768px) {
    .bookmark-panel {
        top: 0;
        right: -100vw;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        z-index: 1000;
    }
    
    .bookmark-panel.open {
        right: 0;
    }
    
    .bookmark-panel-header {
        padding: 1.5rem 1rem;
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        color: white;
    }
    
    .bookmark-panel-header h3 {
        color: white;
        font-size: 1.2rem;
    }
    
    .bookmark-list-container {
        padding-bottom: 120px; /* Account for mobile controls */
    }
    
    .level-0 .bookmark-content {
        padding: 1.2rem;
        font-size: 1rem;
    }
    
    .level-1 .bookmark-content {
        padding: 1rem 1.5rem;
    }
    
    .level-2 .bookmark-content {
        padding: 0.9rem 2rem;
    }
}

/* Dark theme for bookmark panel */
body.dark-mode .bookmark-panel {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
}

body.dark-mode .bookmark-panel-header {
    background: #111827;
    border-color: #374151;
}

body.dark-mode .bookmark-panel-header h3 {
    color: #f3f4f6;
}

body.dark-mode .bookmark-search input {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

body.dark-mode .bookmark-item {
    border-color: #374151;
}

body.dark-mode .bookmark-item:hover {
    background: #374151;
}

body.dark-mode .bookmark-title {
    color: #e5e7eb;
}

body.dark-mode .level-0 {
    background: #111827;
}

/* Highlight Management Panel */
.highlight-panel {
    position: fixed;
    top: 80px;
    left: -320px;
    width: 300px;
    height: calc(100vh - 140px);
    background: white;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 500;
    transition: left 0.3s ease;
    overflow: hidden;
}

.highlight-panel.open {
    left: 0;
}

.highlight-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 2px solid #f1f5f9;
    background: #f8fafc;
}

.highlight-panel-header h3 {
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.highlight-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.highlight-action-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.highlight-action-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

.highlight-summary {
    padding: 0.75rem 1rem;
    background: #f0f9ff;
    border-bottom: 1px solid #e0f2fe;
}

.highlight-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #0369a1;
    font-weight: 500;
}

.highlight-list-container {
    padding: 0.5rem;
    overflow-y: auto;
    height: calc(100% - 160px);
}

.highlight-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.highlight-color-group {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

.highlight-color-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.color-title {
    flex: 1;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.clear-color-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.clear-color-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.highlight-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.highlight-item {
    padding: 0.75rem;
    border-bottom: 1px solid #f8fafc;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.highlight-item:hover {
    background: #f0f9ff;
}

.highlight-item:last-child {
    border-bottom: none;
}

.highlight-text {
    font-size: 0.9rem;
    color: #1f2937;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.highlight-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
}

.no-highlights {
    text-align: center;
    color: #6b7280;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.no-highlights-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.no-highlights p {
    font-style: italic;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    transition: opacity 0.4s ease;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f7fafc;
}

.ai-panel.expanded .ai-panel-header {
    opacity: 1;
}

.ai-panel-header h3 {
    color: #2d3748;
    font-size: 1.25rem;
    font-weight: 600;
}

.close-panel-btn {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
    color: white;
    border: none;
    border-radius: 12px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
}

.close-panel-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

.file-upload-area {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-width: 90%;
    text-align: center;
    z-index: 1001;
}

.file-upload-box {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 3px dashed #3182ce;
    border-radius: 24px;
    padding: 4rem 3rem;
    box-shadow: 0 20px 60px rgba(49, 130, 206, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.file-upload-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(49, 130, 206, 0.03) 0%, rgba(139, 92, 246, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-upload-box:hover {
    border-color: #2c5282;
    box-shadow: 0 32px 80px rgba(49, 130, 206, 0.25);
    transform: translateY(-4px) scale(1.02);
}

.file-upload-box:hover::before {
    opacity: 1;
}

.file-upload-box.dragover {
    border-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    transform: scale(1.03);
    box-shadow: 0 32px 80px rgba(16, 185, 129, 0.3);
}

.upload-icon {
    font-size: 4rem;
    color: #3182ce;
    margin-bottom: 1rem;
    display: block;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 1.5rem;
}

.file-input {
    display: none;
}

.upload-button {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

.upload-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(49, 130, 206, 0.4);
}

/* Hide upload area when PDF is loaded */
.pdf-loaded .file-upload-area {
    display: none;
}

#pdfContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* Seamless page flow with no gaps */
    min-height: min-content;
    padding: 0;
    box-sizing: border-box;
}

.pdf-page {
    border: none;
    margin-bottom: 0;
    position: relative;
    display: block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.pdf-page:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

/* Ensure proper mode display - override any conflicting styles */
body.easyreader-mode .pdf-original-page {
    display: none !important;
}

body.easyreader-mode .easyreader-page {
    display: block !important;
}

body.original-mode .easyreader-page {
    display: none !important;
}

body.original-mode .pdf-original-page {
    display: block !important;
}

/* Hybrid PDF pages - original look with selectable text */
.pdf-hybrid-page {
    background: white;
    margin-bottom: 0;
    border: none;
    position: relative;
    overflow: hidden;
}

.pdf-image-page {
    background: white;
    padding: 0;
    margin-bottom: 0;
    border: none;
}

/* Simple PDF text pages */
.pdf-text-page {
    background: white;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: var(--font-size);
    line-height: var(--line-height);
    padding: 1rem;
    margin-bottom: 0;
    border: none;
    border-bottom: 1px solid #eee;
}

.page-header {
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.simple-text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background: transparent;
    pointer-events: auto;
    overflow: hidden;
}

.overlay-text {
    position: absolute;
    top: 10%;
    left: 5%;
    right: 5%;
    bottom: 10%;
    color: transparent;
    font-size: var(--font-size);
    line-height: var(--line-height);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: text;
    cursor: text;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.overlay-text::selection {
    background: #007acc !important;
    color: white !important;
}

.overlay-text::-moz-selection {
    background: #007acc !important;
    color: white !important;
}

.precise-text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: transparent;
    pointer-events: auto;
}

.precise-text-overlay span {
    position: absolute;
    color: transparent;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    white-space: pre;
    line-height: 1;
    background: transparent;
}

.precise-text-overlay span::selection {
    background: #007acc !important;
    color: transparent !important;
}

.precise-text-overlay span::-moz-selection {
    background: #007acc !important;
    color: transparent !important;
}

/* OCR processing indicator */
.ocr-processing {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 123, 204, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 3;
    backdrop-filter: blur(10px);
}

/* Removed duplicate pdf-page styles - causing conflicts */

/* Removed Kindle/Ebook styling - now using Original PDF mode */

/* Simple table of contents - removed as not needed without Kindle mode */

/* PDF mode - original appearance */
.pdf-original-page {
    background: white;
    margin-bottom: 0;
    border: none;
    padding: 0;
}

.pdf-original-image {
    width: 100%;
    height: auto;
    display: block;
}

/* EasyReader mode - full width pages with no gaps */
.easyreader-page {
    background: #fdfcf8 !important;
    color: #2c2c2c;
    font-family: Georgia, 'Times New Roman', serif;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    position: relative;
    display: block;
    touch-action: manipulation;
    transform-origin: top center;
    /* Full width with no gaps */
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box;
}

.easyreader-page h2 {
    color: #1a1a1a;
    cursor: text;
    user-select: text;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    padding: 0.3em 0.5em;
    margin-left: -0.5em;
    margin-right: -0.5em;
    border-radius: 6px;
}

.easyreader-page h2:hover {
    background: rgba(255, 193, 7, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.25);
}

.easyreader-page p {
    color: #2c2c2c;
    cursor: text;
    user-select: text;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    padding: 0.2em 0.5em;
    margin-left: -0.5em;
    margin-right: -0.5em;
    border-radius: 4px;
}

.easyreader-page p:hover {
    background: rgba(255, 193, 7, 0.15);
    box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.3);
}

.easyreader-page ::selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
}

/* EasyReader text elements with enhanced appearance */
.easyreader-text-element {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    display: inline-block;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* Enhanced text appearance */
    border-radius: 2px;
    word-wrap: break-word;
    hyphens: auto;
}

.easyreader-text-element:hover {
    background: rgba(255, 193, 7, 0.15);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
    border-radius: 3px;
    z-index: 1000;
    transform: translateY(-1px);
}

.easyreader-text-element::selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
    text-shadow: none;
}

/* EasyReader text canvas with PDF structure */
.easyreader-text-canvas {
    position: relative;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    background: transparent;
}

/* Page canvas for all page types */
.pdf-page-canvas {
    position: relative;
    margin: 0 auto;
    background: transparent;
    overflow: hidden;
}

.easyreader-text-canvas .easyreader-text-element {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    transition: background-color 0.2s ease;
}

.easyreader-text-canvas .easyreader-text-element:hover {
    background: rgba(255, 193, 7, 0.15);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
}

.easyreader-text-canvas ::selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
}

/* Enhanced text blocks for better readability */
.easyreader-heading {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.easyreader-paragraph {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    transition: background-color 0.2s ease, transform 0.1s ease;
    text-align: left;
}

.easyreader-heading:hover {
    background: rgba(255, 193, 7, 0.12);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
    transform: translateY(-1px);
    border-radius: 4px;
}

.easyreader-paragraph:hover {
    background: rgba(255, 193, 7, 0.08);
    box-shadow: 0 1px 6px rgba(255, 193, 7, 0.15);
    border-radius: 3px;
}

.easyreader-heading::selection {
    background: rgba(255, 193, 7, 0.5);
    color: #1a1a1a;
}

.easyreader-paragraph::selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
}

/* Enhanced text blocks with improved typography */
.easyreader-text-block {
    font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
    text-rendering: geometricPrecision;
    font-variant-ligatures: common-ligatures;
}

.easyreader-quote {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-style: italic;
    color: #4a5568;
    background: rgba(113, 128, 150, 0.05);
    border-left: 3px solid #cbd5e0;
    padding-left: 12px;
    margin: 0.5em 0;
}

.easyreader-quote:hover {
    background: rgba(255, 193, 7, 0.06);
    border-left-color: #f59e0b;
    transform: translateX(2px);
}

/* Enhanced heading styles */
.easyreader-heading {
    font-weight: 600;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-bottom: 0.8em;
}

/* Enhanced paragraph styles */
.easyreader-paragraph {
    text-align: justify;
    text-indent: 1.5em;
    orphans: 2;
    widows: 2;
    hanging-punctuation: first last;
}

/* Improved hover effects for text blocks */
.easyreader-text-block:hover {
    z-index: 10;
}

.easyreader-heading:hover {
    background: rgba(255, 193, 7, 0.15);
    box-shadow: 0 3px 12px rgba(255, 193, 7, 0.25);
    transform: translateY(-2px);
    border-radius: 5px;
}

.easyreader-paragraph:hover {
    background: rgba(255, 193, 7, 0.08);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.18);
    transform: translateY(-1px);
}

/* Removed old EasyReader text layer styles - using simplified approach */

/* Removed old precise text styles - using clean EasyReader approach */

/* Selection styling for precise PDF text */
.pdf-precise-text-layer ::selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
    text-shadow: none;
}

.pdf-precise-text-layer ::-moz-selection {
    background: rgba(255, 193, 7, 0.4);
    color: #1a1a1a;
    text-shadow: none;
}

/* Structure reference background */
.pdf-structure-reference {
    opacity: 0.1;
    filter: grayscale(0.8) blur(0.5px);
    pointer-events: none;
}

/* Readability overlay */
.pdf-readability-overlay {
    background: rgba(255, 252, 248, 0.3) !important;
    backdrop-filter: blur(1px);
    pointer-events: none;
}

/* Original PDF mode - full width with no gaps */
.pdf-original-page {
    background: white;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    position: relative;
    display: block;
    touch-action: manipulation;
    transform-origin: top center;
    /* Full width with no gaps */
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box;
}

.pdf-original-image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.pdf-original-text-layer {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
}

.pdf-original-text {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    display: inline;
    background: transparent;
}

.pdf-original-text:hover {
    background: rgba(0, 123, 204, 0.1) !important;
    color: rgba(0, 123, 204, 0.8) !important;
}

/* Selection styling for original PDF text */
.pdf-original-text-layer ::selection {
    background: rgba(0, 123, 204, 0.3);
    color: #ffffff;
}

.pdf-original-text-layer ::-moz-selection {
    background: rgba(0, 123, 204, 0.3);
    color: #ffffff;
}

/* Mode-specific styling */
body.original-mode .pdf-original-page {
    display: block; /* Show original PDF in Original PDF mode */
}

body.original-mode .easyreader-page {
    display: none; /* Hide EasyReader in Original PDF mode */
}

body.easyreader-mode .pdf-original-page {
    display: none; /* Hide original PDF in EasyReader mode */
}

body.easyreader-mode .easyreader-page {
    display: block; /* Show EasyReader in EasyReader mode */
}

/* PDF text layer for selection - optimal approach */
.pdf-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
    mix-blend-mode: multiply;
}

.pdf-text-layer:hover {
    opacity: 0.05;
}

.pdf-text-layer span {
    position: absolute;
    color: rgba(0, 0, 0, 0.03);
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    background: transparent;
    font-weight: normal;
    mix-blend-mode: multiply;
}

.pdf-text-layer span::selection {
    background: #007acc !important;
    color: white !important;
    mix-blend-mode: normal;
    box-shadow: 0 0 0 2px #007acc !important;
}

.pdf-text-layer span::-moz-selection {
    background: #007acc !important;
    color: white !important;
    mix-blend-mode: normal;
    box-shadow: 0 0 0 2px #007acc !important;
}

/* Show text layer when selecting */
.pdf-text-layer:active,
.pdf-text-layer:focus-within {
    opacity: 0.1;
}

/* Removed ebook image styles - not needed without Kindle mode */

.page-title {
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.text-paragraph {
    margin-bottom: 2em;
    margin-top: 1em;
    text-align: left;
    line-height: var(--line-height);
    color: #333;
    cursor: text;
    user-select: text;
    padding: 0.5em 0;
}

.text-paragraph:first-of-type {
    margin-top: 1.5em;
}

.text-paragraph:last-of-type {
    margin-bottom: 2em;
}

.pdf-heading {
    font-size: calc(var(--font-size) * 1.3);
    font-weight: 700;
    color: #1a202c;
    margin: 2.5rem 0 1.5rem 0;
    line-height: 1.3;
    padding: 1rem 0 0.5rem 0;
}

.text-line {
    margin-bottom: 0.5em;
    line-height: var(--line-height);
    color: #333;
}

.pdf-native-image, .pdf-scanned-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Progressive loading placeholders */
.page-placeholder {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1rem;
    text-align: center;
    color: #6c757d;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.loading-spinner {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

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

.page-error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}

/* Removed simple-page styles - no longer needed */

/* Enhanced visual feedback animations */
@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

@keyframes selectionFeedback {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.drag-highlight.pulse {
    animation: highlightPulse 1s ease-out;
}

.selection-feedback {
    animation: selectionFeedback 0.3s ease-out;
}

/* AI button enhanced states */
.floating-ai-btn.has-selection {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.4);
}

.floating-ai-btn.processing {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    animation: processingPulse 1.5s ease-in-out infinite;
}

@keyframes processingPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 12px 40px rgba(245, 158, 11, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 16px 50px rgba(245, 158, 11, 0.6); }
}

/* Enhanced theme support for highlights */
body.dark-mode .drag-highlight {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.4) 0%, rgba(245, 158, 11, 0.5) 100%);
    color: #f3f4f6;
    box-shadow: 0 1px 3px rgba(251, 191, 36, 0.4);
}

/* Removed ebook selection styling - not needed without Kindle mode */

/* Dark theme for structure-preserved PDF mode */
body.dark-mode .pdf-structure-preserved {
    background: #1a202c !important;
    color: #e2e8f0;
}

body.dark-mode .pdf-precise-text-layer {
    color: #e2e8f0;
}

body.dark-mode .pdf-precise-text {
    color: #e2e8f0;
}

body.dark-mode .pdf-precise-text:hover {
    background: rgba(251, 191, 36, 0.15);
}

body.dark-mode .pdf-readability-overlay {
    background: rgba(26, 32, 44, 0.3) !important;
}

body.dark-mode .pdf-structure-reference {
    opacity: 0.05;
    filter: invert(1) grayscale(1) blur(1px);
}

body.dark-mode .pdf-precise-text-layer ::selection {
    background: rgba(251, 191, 36, 0.5);
    color: #f3f4f6;
}

body.dark-mode .pdf-precise-text-layer ::-moz-selection {
    background: rgba(251, 191, 36, 0.5);
    color: #f3f4f6;
}

/* Sepia theme for structure-preserved PDF mode */
body.sepia-mode .pdf-structure-preserved {
    background: #f5f1e8 !important;
    color: #8b4513;
}

body.sepia-mode .pdf-precise-text-layer {
    color: #8b4513;
}

body.sepia-mode .pdf-precise-text {
    color: #8b4513;
}

body.sepia-mode .pdf-precise-text:hover {
    background: rgba(180, 83, 9, 0.15);
}

body.sepia-mode .pdf-readability-overlay {
    background: rgba(245, 241, 232, 0.3) !important;
}

body.sepia-mode .pdf-structure-reference {
    opacity: 0.08;
    filter: sepia(0.8) grayscale(0.5) blur(0.5px);
}

body.sepia-mode .pdf-precise-text-layer ::selection {
    background: rgba(180, 83, 9, 0.4);
    color: #92400e;
}

body.sepia-mode .pdf-precise-text-layer ::-moz-selection {
    background: rgba(180, 83, 9, 0.4);
    color: #92400e;
}

/* Dark theme for EasyReader mode */
body.dark-mode .easyreader-page {
    background: #1a202c !important;
    color: #e2e8f0;
}

body.dark-mode .easyreader-page h2 {
    color: #f7fafc;
}

body.dark-mode .easyreader-page p {
    color: #e2e8f0;
}

body.dark-mode .easyreader-text-element {
    color: #e2e8f0;
}

body.dark-mode .easyreader-text-element:hover {
    background: rgba(251, 191, 36, 0.2);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4);
}

body.dark-mode .easyreader-page ::selection {
    background: rgba(251, 191, 36, 0.5);
    color: #1a202c;
}

/* Sepia theme for EasyReader mode */
body.sepia-mode .easyreader-page {
    background: #f5f1e8 !important;
    color: #8b4513;
}

body.sepia-mode .easyreader-page h2 {
    color: #654321;
}

body.sepia-mode .easyreader-page p {
    color: #8b4513;
}

body.sepia-mode .easyreader-text-element {
    color: #8b4513;
}

body.sepia-mode .easyreader-text-element:hover {
    background: rgba(180, 83, 9, 0.15);
    box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.3);
}

body.sepia-mode .easyreader-page ::selection {
    background: rgba(180, 83, 9, 0.4);
    color: #f5f1e8;
}

/* Scanned PDF pages - full width with no gaps */
.pdf-scanned-page {
    background: #fdfcf8 !important;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    position: relative;
    display: block;
    touch-action: manipulation;
    transform-origin: top center;
    /* Full width with no gaps */
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box;
}

/* Dark theme for scanned pages */
body.dark-mode .pdf-scanned-page {
    background: #1a202c !important;
}

/* Sepia theme for scanned pages */
body.sepia-mode .pdf-scanned-page {
    background: #f5f1e8 !important;
}

/* Dark theme for original PDF mode */
body.dark-mode .pdf-original-page {
    background: #1a202c;
}

body.dark-mode .pdf-original-image {
    filter: invert(0.9) hue-rotate(180deg);
}

body.dark-mode .pdf-original-text:hover {
    background: rgba(96, 165, 250, 0.2) !important;
    color: rgba(96, 165, 250, 0.9) !important;
}

body.dark-mode .pdf-original-text-layer ::selection {
    background: rgba(96, 165, 250, 0.4);
    color: #f3f4f6;
}

body.dark-mode .pdf-original-text-layer ::-moz-selection {
    background: rgba(96, 165, 250, 0.4);
    color: #f3f4f6;
}

/* Sepia theme for original PDF mode */
body.sepia-mode .pdf-original-page {
    background: #f5f1e8;
}

body.sepia-mode .pdf-original-image {
    filter: sepia(0.6) contrast(1.1) brightness(1.1);
}

body.sepia-mode .pdf-original-text:hover {
    background: rgba(180, 83, 9, 0.15) !important;
    color: rgba(180, 83, 9, 0.9) !important;
}

body.sepia-mode .pdf-original-text-layer ::selection {
    background: rgba(180, 83, 9, 0.4);
    color: #f5f1e8;
}

body.sepia-mode .pdf-original-text-layer ::-moz-selection {
    background: rgba(180, 83, 9, 0.4);
    color: #f5f1e8;
}

body.sepia-mode .drag-highlight {
    background: linear-gradient(135deg, rgba(180, 83, 9, 0.3) 0%, rgba(146, 64, 14, 0.4) 100%);
    color: #92400e;
    box-shadow: 0 1px 3px rgba(180, 83, 9, 0.3);
}

/* Removed leftover ebook selection styling */

/* Long press visual feedback */
.long-press-indicator {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: longPressRotate 0.5s linear infinite;
    z-index: 1002;
    pointer-events: none;
}

@keyframes longPressRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Selection count indicator */
.selection-count {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1003;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
}

.selection-count.show {
    opacity: 1;
    transform: translateY(0);
}

/* Dark theme for pages */
body.dark-mode .pdf-text-page {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .pdf-image-page {
    background: #2d3748;
    border-color: #4a5568;
}

body.dark-mode .pdf-image {
    filter: invert(0.9) hue-rotate(180deg);
}

/* Sepia theme for pages */
body.sepia-mode .pdf-text-page {
    background: #f5f1e8;
    color: #8b4513;
    border-color: #d4af8c;
}

body.sepia-mode .pdf-image-page {
    background: #f5f1e8;
    border-color: #d4af8c;
}

body.sepia-mode .pdf-image {
    filter: sepia(0.6) contrast(1.1) brightness(1.1);
}

.pdf-image-page {
    background: white;
    padding: 0;
    margin-bottom: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pdf-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Simple typography that looks like original PDF */
.pdf-paragraph {
    font-size: var(--font-size);
    line-height: var(--line-height);
    margin-bottom: 1em;
    color: #333;
    text-align: left;
}

.pdf-title, .pdf-chapter, .pdf-heading, .pdf-subheading, .pdf-section {
    font-size: var(--font-size);
    font-weight: bold;
    color: #333;
    margin: 1em 0 0.5em 0;
    line-height: var(--line-height);
}

.pdf-list-item, .pdf-bullet-item {
    font-size: var(--font-size);
    line-height: var(--line-height);
    margin-bottom: 0.5em;
    color: #333;
}

.pdf-list-item {
    display: list-item;
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin-bottom: 0.5em;
    line-height: var(--user-line-height);
}

.pdf-bullet-item {
    display: list-item;
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 0.5em;
    line-height: var(--user-line-height);
}

.page-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-number {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
    margin: 0;
}

.page-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.text-overlay {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: rgba(49, 130, 206, 0.9);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.overlay-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.overlay-content p {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.3;
    line-height: 1.0;
    pointer-events: auto;
    user-select: text;
    /* Mobile text selection optimizations */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    touch-action: manipulation;
}

.textLayer > span {
    position: absolute;
    white-space: pre;
    color: transparent;
    cursor: text;
}

.textLayer > span::selection {
    background: #3182ce !important;
}

.textLayer > span::-moz-selection {
    background: #3182ce !important;
}

.textLayer ::selection {
    background: #3182ce !important;
}

.textLayer ::-moz-selection {
    background: #3182ce !important;
}

.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: nowrap;
}

.controls span {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.tool-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border: 1px solid #ddd;
}

.tool-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 0.375rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(49, 130, 206, 0.1);
    transform: translateY(-1px);
}

.tool-btn.active {
    background: #007acc;
    color: white;
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 36px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: #e0e0e0;
}

.toggle-btn.active {
    background: #007acc;
    color: white;
}

.color-themes, .reading-modes, .scroll-controls, .view-options {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.color-themes label, .reading-modes label, .scroll-controls label {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.875rem;
}

.mode-selector {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 0.75rem;
    cursor: pointer;
}

.mode-selector:hover {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.mode-selector:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Floating AI Button */
.floating-ai-btn {
    position: fixed;
    bottom: 80px;
    right: 2rem;
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 12px 40px rgba(49, 130, 206, 0.4);
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: all;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.floating-ai-btn.show {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: all;
}

.floating-ai-btn:hover {
    background: linear-gradient(135deg, #2c5282 0%, #2a4365 100%);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 20px 60px rgba(49, 130, 206, 0.6);
}

.floating-ai-btn:active {
    transform: scale(0.95) rotate(0deg);
}

.floating-ai-btn.loading {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1) rotate(0deg); box-shadow: 0 8px 32px rgba(237, 137, 54, 0.4); }
    50% { transform: scale(1.1) rotate(5deg); box-shadow: 0 12px 40px rgba(237, 137, 54, 0.6); }
    100% { transform: scale(1) rotate(0deg); box-shadow: 0 8px 32px rgba(237, 137, 54, 0.4); }
}

.ai-content {
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ai-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3182ce 0%, #8b5cf6 50%, #06b6d4 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-content:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.ai-content:hover::before {
    opacity: 1;
}

.selected-text {
    background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
    padding: 1rem;
    border-left: 4px solid #667eea;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    font-style: italic;
    color: #2d3748;
    font-weight: 500;
}

.selected-text strong {
    color: #667eea;
    font-weight: 600;
}

.explanation {
    line-height: 1.7;
    color: #2d3748;
    font-size: 0.95rem;
}

.explanation h1, .explanation h2, .explanation h3 {
    color: #2d3748;
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.explanation h1 { font-size: 1.25rem; }
.explanation h2 { font-size: 1.125rem; }
.explanation h3 { font-size: 1rem; }

.explanation strong {
    color: #667eea;
    font-weight: 600;
}

.explanation em {
    color: #4a5568;
    font-style: italic;
}

.explanation ul, .explanation ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.explanation li {
    margin: 0.5rem 0;
    color: #2d3748;
}

.explanation p {
    margin: 0.75rem 0;
}

.explanation code {
    background: #edf2f7;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    color: #667eea;
}

.explanation blockquote {
    border-left: 4px solid #667eea;
    margin: 1rem 0;
    padding: 1rem 1.5rem;
    background: #f7fafc;
    border-radius: 8px;
    color: #4a5568;
}

/* More Information Button */
.more-info-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}

.more-info-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.more-info-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.more-info-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.more-info-content {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
}

/* Permanent highlights for all text types */
.pdf-highlight {
    background: #ffeb3b !important;
    padding: 1px 2px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pdf-highlight:hover {
    background: #fdd835 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Enhanced highlights for all colors */
.easyreader-text-element.pdf-highlight {
    border-radius: 3px;
    padding: 1px 2px;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Yellow highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="yellow"] {
    background: linear-gradient(135deg, #ffeb3b 0%, #fdd835 100%) !important;
    box-shadow: 0 1px 3px rgba(255, 235, 59, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="yellow"]:hover {
    background: linear-gradient(135deg, #fdd835 0%, #f9a825 100%) !important;
    box-shadow: 0 2px 6px rgba(255, 235, 59, 0.6);
    transform: translateY(-1px);
}

/* Green highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="green"] {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%) !important;
    box-shadow: 0 1px 3px rgba(74, 222, 128, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="green"]:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
    box-shadow: 0 2px 6px rgba(74, 222, 128, 0.6);
    transform: translateY(-1px);
}

/* Blue highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="blue"] {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%) !important;
    box-shadow: 0 1px 3px rgba(96, 165, 250, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="blue"]:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    box-shadow: 0 2px 6px rgba(96, 165, 250, 0.6);
    transform: translateY(-1px);
}

/* Pink highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="pink"] {
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%) !important;
    box-shadow: 0 1px 3px rgba(244, 114, 182, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="pink"]:hover {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
    box-shadow: 0 2px 6px rgba(244, 114, 182, 0.6);
    transform: translateY(-1px);
}

/* Orange highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="orange"] {
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%) !important;
    box-shadow: 0 1px 3px rgba(251, 146, 60, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="orange"]:hover {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
    box-shadow: 0 2px 6px rgba(251, 146, 60, 0.6);
    transform: translateY(-1px);
}

/* Purple highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="purple"] {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%) !important;
    box-shadow: 0 1px 3px rgba(167, 139, 250, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="purple"]:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    box-shadow: 0 2px 6px rgba(167, 139, 250, 0.6);
    transform: translateY(-1px);
}

/* Red highlights */
.easyreader-text-element.pdf-highlight[data-highlight-color="red"] {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.4);
}

.easyreader-text-element.pdf-highlight[data-highlight-color="red"]:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.6);
    transform: translateY(-1px);
}

.loading {
    color: #718096;
    font-style: italic;
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { opacity: 0.5; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.5; }
}

.error {
    color: #e53e3e;
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid #e53e3e;
    font-weight: 500;
}

/* Reading Modes */
body.dark-mode {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: #e2e8f0;
}

body.dark-mode .header {
    background: rgba(26, 32, 44, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .header h1 {
    color: #e2e8f0;
}

body.dark-mode .header p {
    color: #a0aec0;
}

body.dark-mode .pdf-viewer {
    background: #2d3748;
    color: #e2e8f0;
}

body.dark-mode .ai-panel {
    background: #2d3748;
    color: #e2e8f0;
    border-top: 2px solid #4a5568;
}

body.dark-mode .controls {
    background: rgba(74, 85, 104, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
}

body.dark-mode .pdf-page {
    background: #1a202c;
    border-color: #4a5568;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.dark-mode .pdf-page canvas {
    filter: invert(0.85) contrast(1.1) brightness(1.1);
    border-radius: 8px;
}

body.dark-mode.read-mode .pdf-page {
    background: #1a202c;
}

body.dark-mode.read-mode .pdf-page canvas {
    filter: invert(0.85) contrast(1.1) brightness(1.1);
    border-radius: 0;
}

body.dark-mode ::selection {
    background: #4299e1 !important;
}

body.sepia-mode {
    background: linear-gradient(135deg, #f7f3e9 0%, #ede0d3 100%);
}

body.sepia-mode .pdf-viewer {
    background: #f5f1e8;
    color: #8b4513;
}

body.sepia-mode .ai-panel {
    background: #f5f1e8;
    color: #8b4513;
    border-top: 2px solid #d4af8c;
}

body.sepia-mode .controls {
    background: rgba(245, 241, 232, 0.95);
    border-top: 1px solid rgba(139, 69, 19, 0.2);
    backdrop-filter: blur(15px);
}

body.sepia-mode .pdf-page {
    background: #f4f1e8;
    border-color: #d4af8c;
    box-shadow: 0 4px 16px rgba(139, 69, 19, 0.15);
    position: relative;
}

body.sepia-mode .pdf-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 222, 179, 0.4);
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

body.sepia-mode .pdf-page canvas {
    background: #f5f1e8;
}

body.sepia-mode .textLayer {
    z-index: 2;
    position: relative;
}

body.sepia-mode.read-mode .pdf-page::after {
    background: rgba(245, 222, 179, 0.5);
    mix-blend-mode: multiply;
}

body.sepia-mode ::selection {
    background: #d2691e !important;
}


/* Read Mode - Seamless continuous reading */
body.read-mode #pdfContainer {
    gap: 0;
}

body.read-mode .pdf-page {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
    background: white;
}

body.read-mode .pdf-page canvas {
    display: block;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

body.read-mode .pdf-viewer {
    background: white;
}

body.read-mode .textLayer {
    background: transparent;
}

/* Scroll modes */
.pdf-viewer.scroll-smooth {
    scroll-behavior: smooth;
}

.pdf-viewer.scroll-instant {
    scroll-behavior: auto;
}

.pdf-viewer.scroll-page {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
}

.pdf-viewer.scroll-page .pdf-page {
    scroll-snap-align: start;
}

body.read-mode .pdf-viewer.scroll-page {
    scroll-snap-type: none;
}

body.read-mode .pdf-viewer.scroll-page .pdf-page {
    scroll-snap-align: none;
}

/* Enhanced drag selection highlighting */
.drag-highlight {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.3) 0%, rgba(255, 235, 59, 0.4) 100%);
    border-radius: 3px;
    padding: 0 2px;
    box-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.drag-highlight::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 235, 59, 0.2) 100%);
    border-radius: 5px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.drag-highlight:hover::before {
    opacity: 1;
}

.drag-highlight.active {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.5) 0%, rgba(255, 235, 59, 0.6) 100%);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
    transform: translateY(-1px);
}

/* Mobile selection feedback */
.selection-handles {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

.selection-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #007acc;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3);
    pointer-events: auto;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: all 0.2s ease;
}

.selection-handle:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
}

.selection-handle.start {
    background: #10b981;
    border-color: white;
}

.selection-handle.end {
    background: #f59e0b;
    border-color: white;
}

/* Selection tooltip */
.selection-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1001;
    transform: translateX(-50%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.selection-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Mobile styling for original PDF mode */
@media (max-width: 768px) {
    .pdf-original-page {
        border-radius: 6px !important;
        margin: 0 auto 0.5rem auto !important;
        max-width: calc(100vw - 20px) !important;
        width: auto !important;
    }
    
    .pdf-original-text {
        min-font-size: 10px;
        text-rendering: optimizeLegibility;
    }
}
    
    /* Structure-preserved PDF mobile adjustments */
    .pdf-structure-preserved {
        border-radius: 6px !important;
        margin: 0 auto 0.5rem auto !important;
        /* Ensure proper mobile viewport fitting */
        max-width: calc(100vw - 20px) !important;
        width: auto !important;
        /* Mobile scaling handled by JavaScript transform */
    }
    
    .pdf-precise-text {
        /* Ensure text is readable on mobile */
        min-font-size: 10px;
        text-rendering: optimizeLegibility;
    }
    
    .pdf-readability-overlay {
        background: rgba(255, 252, 248, 0.3) !important;
    }
    
    /* Dark mode mobile adjustments */
    body.dark-mode .pdf-readability-overlay {
        background: rgba(26, 32, 44, 0.3) !important;
    }
    
    /* Sepia mode mobile adjustments */
    body.sepia-mode .pdf-readability-overlay {
        background: rgba(245, 241, 232, 0.3) !important;
    }
    
    /* EasyReader mobile responsiveness with content-based height */
    .easyreader-page {
        width: 100%;
        max-width: calc(100vw - 20px);
        margin: 0 auto 0.5rem auto;
        border-radius: 6px;
        /* Allow content to determine height */
        height: auto;
        min-height: 200px;
        /* Mobile-specific padding adjustments */
        padding-top: 20px;
        padding-bottom: 20px;
    }
    
    .easyreader-text-element {
        /* Enhanced mobile text appearance */
        min-font-size: 12px;
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        /* Better mobile spacing */
        padding: 2px 3px;
        line-height: 1.6;
        word-wrap: break-word;
    }
    
    /* Mobile theme adjustments */
    body.dark-mode .easyreader-page {
        background: #1a202c !important;
    }
    
    body.dark-mode .easyreader-text-element {
        color: #e2e8f0 !important;
    }
    
    body.sepia-mode .easyreader-page {
        background: #f5f1e8 !important;
    }
    
    body.sepia-mode .easyreader-text-element {
        color: #8b4513 !important;
    }
}

/* Mobile-optimized layout */
@media (max-width: 768px) {
    .container {
        display: block;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        background: white;
        padding-bottom: 80px;
        overflow-x: hidden;
        position: relative;
        /* Better content flow for dynamic heights */
        overflow-y: visible;
    }

    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    .pdf-viewer {
        width: 100%;
        height: auto;
        min-height: calc(100vh - 160px);
        margin: 0;
        padding: 0;
        border-radius: 0;
        overflow-y: auto;
        background: #f8fafc;
    }

    .pdf-viewer.with-panel {
        height: 60vh;
    }

    .ai-panel.expanded {
        height: 65vh;
        padding: 0.75rem;
    }

    .pdf-viewer.with-panel {
        height: 35vh;
    }

    .controls {
        flex-direction: row;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 0.5rem;
        border-radius: 0;
        border: none;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        box-shadow: none;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .controls-group {
        width: 100%;
        gap: 0.5rem;
        justify-content: space-around;
        align-items: center;
    }

    .tool-controls {
        gap: 0.25rem;
        padding: 0.25rem;
    }

    /* Hide labels on mobile */
    .color-themes label, 
    .reading-modes label, 
    .scroll-controls label,
    .view-options label {
        display: none;
    }

    .color-themes, .reading-modes, .scroll-controls, .view-options {
        min-width: 0;
        gap: 0;
        flex: 1;
    }

    .controls span {
        font-size: 0.7rem;
        padding: 0.5rem;
        background: rgba(49, 130, 206, 0.1);
        border-radius: 6px;
        margin: 0;
        width: 100%;
        text-align: center;
    }

    .mode-selector {
        font-size: 0.7rem;
        padding: 0.3rem 0.4rem;
        min-width: 60px;
    }

    .tool-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.8rem;
        padding: 0.2rem;
    }

    .file-upload-area {
        width: 85%;
        max-width: 300px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 1001;
    }

    .file-upload-box {
        padding: 2.5rem 1.5rem;
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(49, 130, 206, 0.2);
        border-width: 2px;
    }

    .upload-icon {
        font-size: 3.5rem;
        margin-bottom: 1.5rem;
    }

    .upload-text {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }

    .upload-subtitle {
        font-size: 0.9rem;
        margin-bottom: 2rem;
    }

    .upload-button {
        padding: 1rem 2rem;
        font-size: 1rem;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(49, 130, 206, 0.4);
    }

    .floating-ai-btn {
        width: 56px;
        height: 56px;
        bottom: 80px;
        right: 1rem;
        font-size: 24px;
    }
}

/* Modal System Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show .modal-container {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    color: #1a202c;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.modal-content {
    padding: 1.5rem 2rem;
    max-height: 60vh;
    overflow-y: auto;
    color: #374151;
    line-height: 1.6;
}

.modal-content h4 {
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

.modal-content p {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
}

.modal-content .tool-example {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: monospace;
    font-size: 0.9rem;
}

.modal-content .feature-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.modal-content .feature-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-content .feature-list li:last-child {
    border-bottom: none;
}

.modal-content .feature-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* Selection option buttons */
.theme-options, .mode-options, .fitmode-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.theme-option, .mode-option, .fitmode-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.theme-option:hover, .mode-option:hover, .fitmode-option:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.theme-option.active, .mode-option.active, .fitmode-option.active {
    border-color: #3b82f6;
    background: #dbeafe;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.theme-icon, .mode-icon, .fitmode-icon {
    font-size: 1.5rem;
    width: 32px;
    text-align: center;
}

.theme-name, .mode-name, .fitmode-name {
    font-weight: 600;
    color: #1f2937;
}

.mode-desc, .fitmode-desc {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Dark theme for option buttons */
body.dark-mode .theme-option, 
body.dark-mode .mode-option, 
body.dark-mode .fitmode-option {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

body.dark-mode .theme-option:hover,
body.dark-mode .mode-option:hover,
body.dark-mode .fitmode-option:hover {
    background: #4b5563;
    border-color: #60a5fa;
}

body.dark-mode .theme-name, 
body.dark-mode .mode-name, 
body.dark-mode .fitmode-name {
    color: #f3f4f6;
}

/* Sepia theme for option buttons */
body.sepia-mode .theme-option,
body.sepia-mode .mode-option,
body.sepia-mode .fitmode-option {
    background: #ede0d3;
    border-color: #d4af8c;
    color: #8b4513;
}

body.sepia-mode .theme-option:hover,
body.sepia-mode .mode-option:hover,
body.sepia-mode .fitmode-option:hover {
    background: #f5f1e8;
    border-color: #92400e;
}

/* Highlight color picker */
.highlight-colors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem 0;
}

.highlight-color-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.highlight-color-option:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.highlight-color-option.active {
    border-color: #3b82f6;
    background: #dbeafe;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-icon {
    font-size: 1.2rem;
}

.color-name {
    font-weight: 500;
    color: #1f2937;
}

.highlight-instructions {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.highlight-instructions h4 {
    margin: 0 0 0.5rem 0;
    color: #0369a1;
}

.highlight-instructions ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.2rem;
}

.highlight-instructions li {
    margin: 0.25rem 0;
    color: #0c4a6e;
}

/* Dark theme for highlight picker */
body.dark-mode .highlight-color-option {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

body.dark-mode .highlight-color-option:hover {
    background: #4b5563;
    border-color: #60a5fa;
}

body.dark-mode .color-name {
    color: #f3f4f6;
}

body.dark-mode .highlight-instructions {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

/* Enhanced highlight colors for different themes */
body.dark-mode .easyreader-text-element.pdf-highlight {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.sepia-mode .easyreader-text-element.pdf-highlight {
    box-shadow: 0 1px 3px rgba(139, 69, 19, 0.2);
}

.modal-footer {
    padding: 1rem 2rem 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid #f1f5f9;
}

.modal-action-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Dark theme for modals */
body.dark-mode .modal-container {
    background: #1f2937;
    color: #f3f4f6;
}

body.dark-mode .modal-title {
    color: #f3f4f6;
}

body.dark-mode .modal-header {
    border-color: #374151;
}

body.dark-mode .modal-content {
    color: #d1d5db;
}

body.dark-mode .modal-content h4 {
    color: #f3f4f6;
}

body.dark-mode .modal-content .tool-example {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-mode .modal-footer {
    border-color: #374151;
}

/* Sepia theme for modals */
body.sepia-mode .modal-container {
    background: #f5f1e8;
    color: #8b4513;
}

body.sepia-mode .modal-title {
    color: #654321;
}

body.sepia-mode .modal-header {
    border-color: #d4af8c;
}

body.sepia-mode .modal-content {
    color: #8b4513;
}

body.sepia-mode .modal-content h4 {
    color: #654321;
}

body.sepia-mode .modal-content .tool-example {
    background: #ede0d3;
    border-color: #d4af8c;
    color: #8b4513;
}

body.sepia-mode .modal-footer {
    border-color: #d4af8c;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .mode-selector, .close-panel-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .floating-ai-btn {
        width: 60px;
        height: 60px;
    }

    .ai-content {
        padding: 1.25rem;
    }
    
    .modal-container {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-close-btn, .modal-action-btn {
        min-height: 44px;
        min-width: 44px;
    }
}