:root[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --accent: #3498db;
    --border: #e9ecef;
    --shadow: rgba(0,0,0,0.1);
    --menu-bg: rgba(255, 255, 255, 0.95);
}

:root[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #121212;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --accent: #61dafb;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --menu-bg: rgba(18, 18, 18, 0.95);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.8;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.menu-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 10px var(--shadow);
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background-color: var(--menu-bg);
    padding: 2rem;
    box-shadow: -5px 0 15px var(--shadow);
    transition: right 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.settings-panel.active {
    right: 0;
}

.settings-header {
    margin-bottom: 2rem;
    text-align: center;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

select {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    outline: none;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.8rem;
    border-radius: 8px;
    width: 100%;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.story-paragraph {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    line-height: 1.8;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.8s ease-out forwards;
    letter-spacing: 0.3px;
    white-space: pre-wrap;  /* Preserve whitespace and wrap text */
    font-family: inherit;   /* Use the same font as body */
    background: none;       /* Remove pre element's default background */
    border: none;          /* Remove pre element's default border */
    overflow-x: hidden;    /* Prevent horizontal scrolling */
    width: 100%;          /* Take full width of container */
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading-dots {
    display: flex;
    gap: 0.5rem;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 50%;
    animation: bounce 0.5s infinite alternate;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    to {
        transform: translateY(-8px);
    }
}

@media (max-width: 768px) {
    .story-container {
        padding: 1rem;
        padding-top: 4rem;
    }

    .story-paragraph {
        font-size: 1.1rem;
        line-height: 1.7;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
    }
}

/* Reading Progress Bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--border);
    z-index: 1002;
}

.progress {
    height: 100%;
    background-color: var(--accent);
    width: 0%;
    transition: width 0.1s;
}

/* Font size controls */
.font-size-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.font-size-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
}
/* Reading Time Indicator */
.reading-info {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background-color: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    box-shadow: 0 2px 10px var(--shadow);
    font-size: 0.9rem;
    color: var(--text-secondary);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.reading-info:hover {
    opacity: 1;
}

/* Text-to-Speech Controls */
.tts-controls {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}

.tts-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 10px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.tts-btn:hover {
    transform: scale(1.1);
}

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

/* Genre-specific themes */
.theme-group {
    display: none;
}

.theme-group.active {
    display: block;
}

/* Enhanced Settings Panel */
.settings-section {
    margin-top: 1rem;
    padding: 0.7rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow);
}

.appearance-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.font-family-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.font-size-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.font-size-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.font-size-btn:hover {
    background: var(--accent);
    color: var(--bg-secondary);
}

.theme-toggle {
    width: 100%;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--accent);
    color: var(--bg-secondary);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .reading-info {
        bottom: 4rem;
        right: 1rem;
        font-size: 0.8rem;
    }

    .appearance-controls {
        gap: 0.8rem;
    }

    .font-size-controls {
        justify-content: space-between;
    }

    .font-size-btn {
        flex: 1;
    }
}

/* Swipe Indicator */
.swipe-indicator {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow);
    display: none;
    animation: fadeInOut 2s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}
/* Add new styles for initial loading animation */
.initial-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
}

.initial-loading h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.quill-loading {
    width: 50px;
    height: 50px;
    margin-bottom: 1rem;
    background: var(--accent);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.78 15.84S18.64 13 19.61 12c3.07-3.07 4.24-6.29 2.83-7.7s-4.63-.24-7.7 2.83l-3.84 3.84M9.63 8.88S6.77 11.74 5.8 12.73c-3.07 3.07-4.24 6.29-2.83 7.7s4.63.24 7.7-2.83l3.84-3.84'/%3E%3C/svg%3E") center/contain no-repeat;
    animation: write 1s infinite;
}

@keyframes write {
    0% { transform: translateX(-15px) rotate(-45deg); }
    50% { transform: translateX(15px) rotate(-45deg); }
    100% { transform: translateX(-15px) rotate(-45deg); }
}
.app-logo {
    width: 4px;  /* Adjust size as needed */
    height: 4px;
    object-fit: contain;
    margin-right: 8px;
}

.app-name {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    z-index: 1001;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: transform 0.2s;
}

.app-name:hover {
    transform: translateY(-2px);
}

.app-icon {
    font-size: 1rem;
}

/* Add these styles */
.app-name, .reading-info, .tts-controls {
    transition: opacity 0.3s, visibility 0.3s;
}

.hide-ui .app-name,
.hide-ui .reading-info,
.hide-ui .tts-controls {
    opacity: 0;
    visibility: hidden;
}