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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: #2c3e50;
    color: white;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

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

.header-right .form-switch .form-check-label {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
}

.header-right .btn-outline-secondary {
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.8);
}

.header-right .btn-outline-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Panels */
.panels-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid #dee2e6;
    overflow: hidden;
}

.panel-books {
    width: 260px;
    flex-shrink: 0;
}

.panel-chapters {
    width: 280px;
    flex-shrink: 0;
}

.panel-content {
    flex: 1;
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
}

.panel-header h5 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: #495057;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Book List */
.book-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.book-item:hover {
    background: #f0f0f0;
}

.book-item.active {
    background: #e8f4fd;
    border-left: 3px solid #0d6efd;
}

.book-item-title {
    font-weight: 500;
    color: #212529;
    font-size: 0.9rem;
}

.book-item-meta {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 2px;
}

.book-item-stats {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 4px;
}

/* Chapter List */
.chapter-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 3px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapter-item:hover {
    background: #f0f0f0;
}

.chapter-item.active {
    background: #e8f4fd;
    border-left: 3px solid #0d6efd;
}

.chapter-item-title {
    font-size: 0.875rem;
    color: #212529;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-item.reviewed .chapter-item-title {
    color: #6c757d;
}

.chapter-item.reviewed::after {
    content: '';
}

.badge-reviewed {
    background: #28a745;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Content Panel */
.content-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #adb5bd;
}

.content-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.content-wrapper {
    padding: 1.5rem 2rem;
    max-width: 900px;
}

.content-wrapper h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.content-meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.markdown-body {
    font-size: 1rem;
    line-height: 1.7;
    color: #24292f;
}

.markdown-body pre {
    background: #f6f8fa;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
}

.markdown-body code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
}

.markdown-body blockquote {
    border-left: 4px solid #dfe2e5;
    padding-left: 1rem;
    color: #6a737d;
}

/* Edit Mode */
.edit-mode .content-view {
    display: none;
}

.edit-mode .content-edit {
    display: block;
}

.content-edit {
    display: none;
    padding: 1rem;
}

.content-edit textarea {
    width: 100%;
    min-height: 400px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    resize: vertical;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: flex-end;
}

/* Empty states */
.panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #adb5bd;
    text-align: center;
    padding: 2rem;
}

.panel-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Loading */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Toast */
.toast {
    background: #333;
    color: white;
    border-radius: 8px;
}

/* Modal */
.modal-header {
    background: #f8f9fa;
}

/* Responsive */
@media (max-width: 768px) {
    .panels-container {
        flex-direction: column;
    }

    .panel-books,
    .panel-chapters {
        width: 100%;
        max-height: 30vh;
    }

    .panel-content {
        flex: 1;
        min-height: 40vh;
    }
}
