:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --border: #e5e5e5;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --sidebar-width: 280px;
    --header-height: 64px;
    --font-serif: 'Noto Serif SC', serif;
    --font-sans: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --accent: #a78bfa;
    --accent-hover: #c4b5fd;
    --border: #333333;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

#search {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.2s;
}

#search:focus {
    outline: none;
    border-color: var(--accent);
    width: 260px;
}

#theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

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

main {
    display: flex;
    margin-top: var(--header-height);
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    left: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 8px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: var(--border);
}

.book-list {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.book-item {
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.book-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.book-item.active {
    background: var(--accent);
    color: white;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: calc(100% - var(--sidebar-width));
}

.chapter-nav {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    display: none;
}

.chapter-nav.active {
    display: block;
}

#book-select {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-serif);
    cursor: pointer;
}

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

.chapter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chapter-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.chapter-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.chapter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.bible-text {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 2;
    color: var(--text-primary);
    min-height: 400px;
}

.bible-text:empty::after {
    content: '选择书卷开始阅读';
    color: var(--text-muted);
}

.bible-text .verse {
    display: block;
    clear: both;
    width: 100%;
    margin-bottom: 8px;
    overflow: hidden;
    box-sizing: border-box;
}

.bible-text .verse-num {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 8px;
    vertical-align: super;
}

.welcome {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 80px 0;
}

footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-left: var(--sidebar-width);
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .book-list {
        max-height: calc(50vh - 120px);
    }
    
    .content {
        margin-left: 0;
        max-width: 100%;
        padding: 16px;
    }
    
    main {
        flex-direction: column;
    }
    
    footer {
        margin-left: 0;
    }
    
    #search {
        width: 140px;
    }
    
    #search:focus {
        width: 180px;
    }
    
    /* Chapter nav hidden by default on mobile - only show when book selected */
    .chapter-nav {
        display: none;
    }
    
    .chapter-nav.active {
        display: block;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Search Results */
.search-results-header {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.bible-text .search-result {
    cursor: pointer;
    padding: 8px;
    margin: 4px 0;
    border-radius: 6px;
    background: var(--bg-secondary);
    transition: background 0.2s;
}

.bible-text .search-result:hover {
    background: var(--bg-tertiary);
}

.bible-text .verse-ref {
    display: block;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.bible-text .search-result mark {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] .bible-text .search-result mark {
    background: #854d0e;
    color: #fef08a;
}
