:root {
    --bg-primary: #faf9f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f4f1;
    --text-primary: #3d3d3d;
    --text-secondary: #6b6b6b;
    --text-muted: #9a9a9a;
    --accent: #7c6f5b;
    --accent-hover: #5c5245;
    --accent-light: #e8e4dc;
    --verse-number: #a65d57;
    --border: #e5e2dc;
    --border-light: #f0ede8;
    --highlight: #fdf6e3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    --font-scale: 1;
    --visible-versions: 3;
}

[data-theme="dark"] {
    --bg-primary: #1a1a18;
    --bg-secondary: #232320;
    --bg-tertiary: #2d2d29;
    --text-primary: #d4d4d0;
    --text-secondary: #a8a8a4;
    --text-muted: #6b6b67;
    --accent: #b8a990;
    --accent-hover: #d4c4a8;
    --accent-light: #3d3a32;
    --verse-number: #c9897e;
    --border: #3a3a36;
    --border-light: #2d2d29;
    --highlight: #3a3526;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Progress button */
.progress-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    transition: background var(--transition-base), border-color var(--transition-base);
    z-index: 100;
}

.progress-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-base);
    transition: background var(--transition-base), border-color var(--transition-base);
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.theme-toggle .icon-moon {
    opacity: 1;
    transform: scale(1);
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: scale(0.5);
}

[data-theme="dark"] .theme-toggle .icon-moon {
    opacity: 0;
    transform: scale(0.5);
}

[data-theme="dark"] .theme-toggle .icon-sun {
    opacity: 1;
    transform: scale(1);
}

/* Scroll to top */
.scroll-top-btn {
    position: fixed;
    bottom: 20px;
    right: 15px;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    font-weight: bold;
    transition: all var(--transition-base);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
}

.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.scroll-top-btn:hover {
    transform: scale(1.05);
    background: var(--accent-hover);
    box-shadow: var(--shadow-lg);
}

/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Progress summary */
.progress-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.progress-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
}

.progress-card-title {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.progress-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Testament sections */
.testament-section {
    margin-bottom: 25px;
}

.testament-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    cursor: pointer;
}

.testament-header:hover {
    background: var(--accent-light);
}

.testament-title {
    font-weight: 600;
    color: var(--text-primary);
}

.testament-stats {
    display: flex;
    align-items: center;
    gap: 10px;
}

.testament-progress {
    font-size: 13px;
    color: var(--text-secondary);
}

.testament-percent {
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
}

/* Books grid */
.books-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 5px 0;
}

.books-grid.expanded {
    display: grid;
}

.book-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-light);
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.book-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.book-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-progress {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 8px;
}

/* Status colors */
.status-done {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
}

.status-done .book-progress {
    color: #4CAF50;
}

.status-progress {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.3);
}

.status-progress .book-progress {
    color: #F9A825;
}

.status-none {
    background: rgba(244, 67, 54, 0.1);
    border-color: rgba(244, 67, 54, 0.3);
}

.status-none .book-progress {
    color: #F44336;
}

.percent-done {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.percent-progress {
    background: rgba(255, 193, 7, 0.15);
    color: #F9A825;
}

.percent-none {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
}

/* Legend */
.legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 15px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.done {
    background: #4CAF50;
}

.legend-dot.progress {
    background: #F9A825;
}

.legend-dot.none {
    background: #F44336;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    background: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: var(--space-6);
    text-align: center;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.header h1 {
    font-size: var(--text-2xl);
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-2);
}

.header p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-5);
    margin-top: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.toolbar-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.version-checkboxes {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.version-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
}

.version-checkbox input {
    display: none;
}

.version-checkbox .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.version-checkbox .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.version-checkbox input:checked + .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.version-checkbox input:checked + .checkmark::after {
    opacity: 1;
    transform: scale(1);
}

.version-checkbox:hover .checkmark {
    border-color: var(--accent);
}

.version-checkbox .checkbox-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.font-size-control {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-1);
}

.font-size-control button {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.font-size-control button:hover:not(:disabled) {
    background: var(--accent-light);
}

.font-size-control button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.font-size-control span {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

.play-btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-left: var(--space-2);
    vertical-align: middle;
    color: var(--accent);
}

.play-btn-small:hover {
    color: var(--accent-hover);
    transform: scale(1.15);
}

.play-btn-small.playing {
    color: var(--verse-number);
}

.play-btn-small .play-icon {
    font-size: 16px;
    line-height: 1;
}

.chapter-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-4);
    margin-top: var(--space-5);
    flex-wrap: wrap;
}

.chapter-nav select {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chapter-nav select:hover {
    border-color: var(--accent);
}

.chapter-nav select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.chapter-controls {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.chapter-nav button {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.chapter-nav button:hover:not(:disabled) {
    background: var(--accent-light);
    border-color: var(--accent);
}

.chapter-nav button:disabled {
    opacity: 0.5;
    color: var(--text-muted);
    cursor: not-allowed;
}

.chapter-nav button .btn-icon {
    display: none;
    font-size: var(--text-lg);
}

.error {
    text-align: center;
    padding: var(--space-10);
    color: var(--verse-number);
    font-size: var(--text-lg);
}

.grid-header {
    display: grid;
    background: var(--bg-tertiary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

.grid-header-cell {
    padding: var(--space-4) var(--space-5);
    text-align: center;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.grid-header-cell:last-child {
    border-right: none;
}

.grid-header-cell .header-title {
    flex: 1;
}

.grid-header-cell.hidden,
.verse-text.hidden {
    display: none;
}

.verse-row {
    display: grid;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.verse-row:nth-child(even) {
    background: var(--bg-tertiary);
}

.verse-row:hover {
    background: var(--highlight);
}

.verse-num {
    padding: var(--space-5) var(--space-4);
    text-align: center;
    font-weight: 700;
    color: var(--verse-number);
    font-size: var(--text-sm);
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.verse-text {
    padding: var(--space-5);
    line-height: 1.9;
    font-size: calc(var(--text-base) * var(--font-scale));
    border-right: 1px solid var(--border-light);
    font-family: 'Georgia', 'Times New Roman', serif;
}

.verse-text:last-child {
    border-right: none;
}

.verse-text.speaking,
.verse-text-mobile.speaking {
    background: var(--highlight);
    box-shadow: inset 3px 0 0 var(--verse-number);
}

.mobile-view {
    display: none;
}

.footer {
    margin-top: auto;
    padding: var(--space-6);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.footer-note {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Mobile styles */
@media (max-width: 768px) {
    .progress-btn {
        top: 10px;
        left: 10px;
        width: 38px;
        height: 38px;
        font-size: 10px;
    }
    
    .theme-toggle {
        top: 10px;
        right: 10px;
        width: 38px;
        height: 38px;
        font-size: var(--text-sm);
    }
    
    .scroll-top-btn {
        bottom: 15px;
        right: 10px;
        width: 38px;
        height: 38px;
    }
    
    .header {
        padding: var(--space-4);
        padding-top: var(--space-4);
    }
    
    .header h1 {
        font-size: var(--text-xl);
    }
    
    .toolbar {
        gap: var(--space-3);
        padding: var(--space-2) 0;
    }
    
    .version-checkboxes {
        order: 1;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .toolbar-label {
        width: 100%;
        text-align: center;
        margin-bottom: var(--space-1);
    }
    
    .font-size-control {
        order: 2;
    }
    
    .chapter-nav {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .chapter-nav select {
        width: 100%;
    }
    
    .chapter-controls {
        display: flex;
        gap: var(--space-3);
        width: 100%;
    }
    
    .chapter-controls button {
        flex: 0 0 48px;
        height: 48px;
        padding: var(--space-3);
        justify-content: center;
    }
    
    .chapter-controls select {
        flex: 1;
    }
    
    .chapter-controls button .btn-text {
        display: none;
    }
    
    .chapter-controls button .btn-icon {
        display: inline;
        font-size: var(--text-xl);
    }
    
    .desktop-view {
        display: none;
    }
    
    .mobile-view {
        display: block;
        flex: 1;
    }
    
    .version-indicator {
        font-size: var(--text-base);
        font-weight: 600;
        padding: var(--space-3) var(--space-4);
        background: var(--accent);
        color: white;
        text-align: center;
        position: sticky;
        top: 0;
        z-index: 60;
        letter-spacing: 0.05em;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-3);
    }
    
    .indicator-text {
        flex: 1;
    }
    
    .play-btn-indicator {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: none;
        border-radius: var(--radius-full);
        cursor: pointer;
        transition: all var(--transition-fast);
        color: white;
    }
    
    .play-btn-indicator:hover {
        transform: scale(1.1);
    }
    
    .play-btn-indicator.playing {
        color: #ffcccc;
    }
    
    .play-btn-indicator .play-icon {
        font-size: 18px;
    }
    
    .verses-container {
        display: flex;
    }
    
    .verse-numbers-column {
        flex: 0 0 44px;
        background: var(--bg-tertiary);
        border-right: 2px solid var(--border);
    }
    
    .verse-num-mobile {
        padding: var(--space-4) var(--space-2);
        text-align: center;
        font-weight: 700;
        color: var(--verse-number);
        font-size: var(--text-sm);
        border-bottom: 1px solid var(--border-light);
        transition: background var(--transition-fast);
    }
    
    .verse-num-mobile.highlight {
        background: var(--highlight);
    }
    
    .versions-scroll-area {
        flex: 1;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    .versions-track {
        display: flex;
    }
    
    .version-column {
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }
    
    .version-column.hidden {
        display: none;
    }
    
    .verse-text-mobile {
        padding: var(--space-4) var(--space-5);
        line-height: 1.8;
        font-size: calc(var(--text-base) * var(--font-scale));
        border-bottom: 1px solid var(--border-light);
        font-family: 'Georgia', 'Times New Roman', serif;
        transition: background var(--transition-fast);
    }
    
    .verse-text-mobile.highlight {
        background: var(--highlight);
    }
    
    .swipe-hint {
        position: fixed;
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--bg-secondary);
        color: var(--text-primary);
        padding: var(--space-3) var(--space-6);
        border-radius: var(--radius-full);
        font-size: var(--text-sm);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
        border: 1px solid var(--border);
        animation: fadeOut 3s forwards;
        white-space: nowrap;
    }
    
    @keyframes fadeOut {
        0%, 70% { opacity: 1; }
        100% { opacity: 0; pointer-events: none; }
    }
    
    .footer {
        padding: var(--space-4);
    }
    
    .progress-summary {
        grid-template-columns: 1fr;
    }
    
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .legend {
        flex-wrap: wrap;
        gap: 12px;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: var(--accent-light);
    color: var(--accent);
}