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

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --accent: #e74c3c;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 25px 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo i {
    font-size: 2.2rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-stats {
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-section {
    margin: 30px 0;
}

.search-box {
    display: flex;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.search-box:focus-within {
    box-shadow: 0 4px 25px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.search-icon {
    align-self: center;
    color: var(--text-light);
    padding: 0 12px;
}

.search-box input {
    flex: 1;
    border: none;
    padding: 14px;
    font-size: 1rem;
    outline: none;
    background: transparent;
    min-width: 200px;
}

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

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--secondary);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid #ddd;
}

.btn-secondary:hover:not(:disabled) {
    background: #e0e0e0;
}

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

.search-info {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-light);
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 8px;
}

.search-tips {
    display: flex;
    align-items: center;
    gap: 6px;
}

.results-section {
    margin: 30px 0;
    min-height: 400px;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ===== КАРТОЧКА КНИГИ С ОБЛОЖКОЙ ===== */
.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border-left: 4px solid var(--secondary);
    display: flex;
    gap: 16px;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    border-left-color: var(--accent);
}

/* Обложка */
.book-cover {
    flex-shrink: 0;
    width: 100px;
    height: 150px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.3s ease;
}

.book-card:hover .book-cover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Заглушка для книг без обложки */
.no-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #e8e8e8;
    color: #aaa;
    font-size: 2.5rem;
}

/* Информация о книге */
.book-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.book-card .author {
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.book-card .title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card .series {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.book-card .meta {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 12px;
    opacity: 0.7;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.book-card .meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.book-card .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.book-card .actions button {
    flex: 1;
    min-width: 60px;
    padding: 6px 10px;
    font-size: 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    white-space: nowrap;
}

.book-card .actions .download-btn {
    background: var(--secondary);
    color: white;
}

.book-card .actions .download-btn:hover {
    background: #2980b9;
    transform: scale(1.02);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-light);
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.loading i {
    font-size: 2.5rem;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
    display: block;
    color: var(--secondary);
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}

footer {
    background: var(--primary);
    color: white;
    padding: 25px 0;
    margin-top: 40px;
    text-align: center;
}

footer .footer-legal {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 8px;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.3rem;
    }
    .logo i {
        font-size: 1.6rem;
    }
    .books-grid {
        grid-template-columns: 1fr;
    }
    .search-box {
        flex-direction: column;
        padding: 12px;
    }
    .search-box input {
        width: 100%;
        padding: 12px;
    }
    .search-info {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    .pagination {
        flex-wrap: wrap;
        gap: 10px;
    }
    .book-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .book-cover {
        width: 120px;
        height: 180px;
    }
    .book-info {
        width: 100%;
    }
}

/* ===== ТЁМНАЯ ТЕМА ===== */
.btn-theme {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.3rem;
    padding: 8px 16px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.btn-theme:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(15deg);
    border-color: rgba(255, 255, 255, 0.5);
}

body.dark-theme {
    background-color: #1a1a2e;
    --bg: #1a1a2e;
    --card-bg: #16213e;
    --text: #e0e0e0;
    --text-light: #a0a0b0;
    --shadow: 0 4px 15px rgba(0,0,0,0.4);
}

body.dark-theme .book-card {
    background: #16213e !important;
    border-left-color: #4a9eff;
}

body.dark-theme .book-cover {
    background: #2a3a5e;
}

body.dark-theme .no-cover {
    background: #2a3a5e;
    color: #5a7a9e;
}

body.dark-theme .search-box {
    background: #16213e;
    border: 1px solid #2a3a5e;
}

body.dark-theme .search-box input {
    color: #e0e0e0;
}

body.dark-theme .search-box input::placeholder {
    color: #7a7a8a;
}

body.dark-theme .welcome-state h2 {
    color: #e0e0e0 !important;
}

body.dark-theme .welcome-state p {
    color: #a0a0b0 !important;
}

body.dark-theme .welcome-state span {
    background: #2a3a5e !important;
    color: #e0e0e0 !important;
}

body.dark-theme footer {
    background: #0d0d1a;
}

body.dark-theme .btn-secondary {
    background: #2a3a5e;
    color: #e0e0e0;
    border-color: #3a4a6e;
}

body.dark-theme .search-info,
body.dark-theme .page-info,
body.dark-theme .empty-state,
body.dark-theme .loading {
    color: #a0a0b0;
}

body.dark-theme .book-card .meta,
body.dark-theme .book-card .series {
    color: #7a7a8a;
}

body.dark-theme .book-card .actions {
    border-top-color: #2a3a5e;
}

/* Кнопка "Читать" */
.book-card .actions .read-btn {
    background: #27ae60;
    color: white;
}

.book-card .actions .read-btn:hover {
    background: #1e8449;
}

body.dark-theme .book-card .actions .read-btn {
    background: #2ecc71;
}

body.dark-theme .book-card .actions .read-btn:hover {
    background: #27ae60;
}

.btn-clear {
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 1.2rem;
    padding: 0 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: 0.3s;
}

.btn-clear:hover {
    color: #e74c3c;
}

.book-card .actions .download-epub-btn {
    background: #8e44ad;
    color: white;
}

.book-card .actions .download-epub-btn:hover {
    background: #6c3483;
    transform: scale(1.02);
}

body.dark-theme .book-card .actions .download-epub-btn {
    background: #9b59b6;
}

body.dark-theme .book-card .actions .download-epub-btn:hover {
    background: #7d3c98;
}

/* ===== АВТОДОПОЛНЕНИЕ ===== */
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f0f4f8;
}

.suggestion-item .suggestion-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.suggestion-item .suggestion-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text, #2c3e50);
}

.suggestion-item .suggestion-type {
    font-size: 0.7rem;
    color: var(--text-light, #7f8c8d);
    background: var(--bg, #f5f6fa);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Тёмная тема */
body.dark-theme .suggestion-item {
    border-bottom-color: #2a3a5e;
}

body.dark-theme .suggestion-item:hover {
    background: #2a3a5e;
}

body.dark-theme .suggestion-item .suggestion-text {
    color: #e0e0e0;
}

body.dark-theme .suggestion-item .suggestion-type {
    color: #a0a0b0;
    background: #1a1a2e;
}

body.dark-theme #suggestionsList {
    background: #16213e;
    border-color: #2a3a5e;
}