:root {
    --primary-color: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --accent-color: #d4af37;
    --accent-dark: #b8860b;
    --accent-light: #f4d03f;
    --bg-color: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-color: #1a1a1a;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg-color: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --text-color: #f5f5f5;
    --text-secondary: #9ca3af;
    --border-color: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px var(--shadow);
}

.header-left,
.header-right {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-center {
    flex: 1;
    text-align: center;
    padding: 0 0.5rem;
    min-width: 0;
}

.book-title {
    font-family: 'Crimson Pro', serif;
    font-size: 0.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    line-height: 1.2;
}



.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.icon-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Progress Bar */
.progress-container {
    position: sticky;
    top: 60px;
    z-index: 99;
    height: 3px;
    background: var(--border-color);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent-color), var(--accent-light));
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

/* Main Reading Area */
.reading-area {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-content {
    animation: fadeInUp 0.5s ease;
    min-height: 60vh;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-title {
    font-family: 'Crimson Pro', serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
}

.text-content {
    font-family: 'Crimson Pro', serif;
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-color);
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    word-wrap: break-word;
}

.text-content p {
    margin-bottom: 1.25rem;
}

.text-content p:last-child {
    margin-bottom: 0;
}

/* Page Info */
.page-info {
    position: sticky;
    bottom: 80px;
    text-align: center;
    padding: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

/* Navigation Controls */
.nav-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: 0 -2px 10px var(--shadow);
}

.nav-btn {
    flex: 1;
    max-width: 150px;
    height: 50px;
    border: 2px solid var(--accent-color);
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-color));
    color: #1a1a1a;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    font-weight: 700;
}

.nav-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
    background: linear-gradient(135deg, var(--accent-color), var(--accent-light));
}

.nav-btn:active:not(:disabled) {
    transform: translateY(0);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 350px;
    height: 100vh;
    background: var(--bg-color);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 20px var(--shadow-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.side-menu.active {
    left: 0;
}

.menu-content {
    padding: 1.5rem;
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.menu-header h2 {
    font-family: 'Crimson Pro', serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-color), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-section {
    margin-bottom: 2rem;
}

.menu-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.font-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 12px;
}

.font-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--accent-color);
    background: var(--bg-color);
    color: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.font-btn:hover {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-color));
    color: #1a1a1a;
    transform: scale(1.05);
}

.font-btn:active {
    transform: scale(0.95);
}

#fontSizeDisplay {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 60px;
    text-align: center;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chapter-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    color: var(--text-color);
}

.chapter-item:hover {
    border-color: var(--accent-color);
    background: rgba(212, 175, 55, 0.1);
    transform: translateX(5px);
}

.chapter-item.active {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-color));
    color: #1a1a1a;
    font-weight: 600;
    border-color: var(--accent-color);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Touch Feedback */
@media (hover: none) {

    .icon-btn:active,
    .nav-btn:active,
    .font-btn:active,
    .chapter-item:active {
        opacity: 0.7;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .book-title {
        font-size: 1rem;
    }

    .reading-area {
        padding: 1.5rem 1rem;
    }

    .chapter-title {
        font-size: 1.5rem;
    }

    .text-content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .nav-controls {
        padding: 0.75rem 1rem;
    }

    .nav-btn {
        height: 45px;
    }
}

@media (min-width: 768px) {
    .side-menu {
        width: 400px;
    }

    .reading-area {
        padding: 3rem 2rem;
    }
}

/* Font Size Classes */
.font-size-small .text-content {
    font-size: 0.9rem;
}

.font-size-normal .text-content {
    font-size: 1.125rem;
}

.font-size-large .text-content {
    font-size: 1.35rem;
}

.font-size-xlarge .text-content {
    font-size: 1.6rem;
}

/* Print Styles */
@media print {

    .app-header,
    .progress-container,
    .page-info,
    .nav-controls,
    .side-menu,
    .overlay {
        display: none !important;
    }

    .reading-area {
        padding: 0;
        max-width: 100%;
    }
}