:root[data-theme="dark"] {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --error: #ef4444;
    --success: #22c55e;
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f8f9fa;
    --border: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --error: #dc2626;
    --success: #16a34a;
}

:root[data-theme="slate"] {
    --bg: #0b1026;
    --surface: #15182c;
    --border: #262a4d;
    --text-primary: #e8e9f3;
    --text-secondary: #a9aed1;
    --accent: #7aa2f7;
    --accent-hover: #9db8ff;
    --error: #f87171;
    --success: #4ade80;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: background 0.2s, border-color 0.2s;
}

.header-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.logo {
    font-family: 'Merriweather', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.theme-toggle {
    padding: 0.375rem 0.625rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.home-btn {
    padding: 0.375rem 0.5rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.home-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

.select {
    padding: 0.375rem 0.625rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.select:hover:not(:disabled) {
    border-color: #3a3a3a;
}

.select:focus {
    outline: none;
    border-color: var(--accent);
}

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

.main {
    flex: 1;
    padding: 1.25rem 0;
}

.reader {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.selector-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.625rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: background 0.2s, border-color 0.2s;
}

.search-wrapper {
    display: flex;
    gap: 0.375rem;
    flex: 2;
    min-width: 100%;
}

.search-input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    transition: border-color 0.2s, background 0.2s;
}

.search-input:hover {
    border-color: #3a3a3a;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-btn {
    padding: 0.375rem 0.875rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.search-btn:hover {
    background: var(--accent-hover);
}

.book-select {
    flex: 2;
}

.chapter-select {
    flex: 1;
}

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

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 0.8125rem;
}

.result {
    animation: fadeIn 0.3s ease-in;
}

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

.result-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.result-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.result-actions {
    display: flex;
    align-items: center;
}

.passage-title {
    font-family: 'Merriweather', serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.translation-info {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.verses {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.verse {
    display: flex;
    gap: 0.75rem;
    line-height: 1.8;
}

.verse-number {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.75rem;
    min-width: 1.5rem;
    text-align: right;
    padding-top: 0.125rem;
    flex-shrink: 0;
}

.verse-text {
    font-family: 'Merriweather', serif;
    font-size: 0.9375rem;
    color: var(--text-primary);
    flex: 1;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.nav-btn {
    padding: 0.5rem 0.875rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    max-width: 120px;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.welcome {
    text-align: center;
    padding: 3rem 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.welcome h2 {
    font-family: 'Merriweather', serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.welcome p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer {
    padding: 1.25rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: border-color 0.2s;
}

#apiStatus {
    color: var(--success);
}

#apiStatus.offline {
    color: var(--error);
}

.menu-btn {
    display: none;
    padding: 0.375rem 0.5rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.menu-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: flex-start;
    justify-content: flex-end;
}

.mobile-menu.active {
    display: flex;
}

.mobile-menu-content {
    background: var(--surface);
    width: 280px;
    height: 100%;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-left: 1px solid var(--border);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-close {
    padding: 0.375rem 0.5rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    transition: all 0.2s;
    text-align: left;
}

.mobile-menu-item:hover {
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 768px) {
    .header-right {
        display: none;
    }
    .menu-btn {
        display: flex;
    }
    .header-content {
        justify-content: space-between;
    }
}

@media (min-width: 640px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .selector-bar {
        flex-direction: row;
        align-items: center;
        padding: 0.5rem;
    }
    
    .search-wrapper {
        min-width: auto;
        flex: 2;
    }
    
    .book-select {
        flex: 2;
        min-width: 180px;
    }
    
    .chapter-select {
        flex: 0 0 auto;
        min-width: 90px;
    }
    
    .passage-title {
        font-size: 1.75rem;
    }
    
    .verse-text {
        font-size: 1rem;
    }
}

@media (min-width: 1024px) {
    .search-wrapper {
        flex: 2.5;
    }
}

@media (max-width: 639px) {
    .logo {
        font-size: 1.125rem;
    }
    .header-right {
        gap: 0.25rem;
    }
    .theme-toggle, .home-btn {
        padding: 0.3125rem 0.4375rem;
    }
}
