:root {
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --muted: #666;
    --accent: #4a6cf7;
    --accent-hover: #3a56d4;
    --border: #e0e0e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3em;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}

nav a {
    margin-left: 20px;
    color: var(--muted);
    text-decoration: none;
}

nav a:hover { color: var(--accent); }

main { padding: 30px 20px; min-height: calc(100vh - 200px); }

/* ===== Каталог ===== */
.catalog-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 30px;
}

.filters {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    align-self: start;
    position: sticky;
    top: 80px;
}

.filters h3 { margin-top: 0; }

.filters label {
    display: block;
    margin: 14px 0 6px;
    font-size: 0.9em;
    color: var(--muted);
}

.filters select,
.filters input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95em;
    background: #fff;
}

.filters .checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95em;
    margin: 10px 0;
}

.btn-outline {
    margin-top: 20px;
    width: 100%;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}

.btn-outline:hover { background: var(--bg); }

.search-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.search-row input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1em;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.results-count { color: var(--muted); white-space: nowrap; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card-thumb {
    width: 100%;
    height: 280px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.no-thumb { color: #ccc; font-size: 3em; }

.card-body {
    padding: 12px 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-weight: 600;
    margin: 0 0 4px;
    font-size: 0.95em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-composer {
    color: var(--muted);
    font-size: 0.85em;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto;
    font-size: 0.75em;
}

.badge {
    background: #eef2ff;
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.badge.official { background: #fff4e5; color: #d97706; }
.badge.mp3 { background: #e8f5e9; color: #2e7d32; }

.loading { text-align: center; padding: 40px; color: var(--muted); }

/* ===== Пагинация ===== */
.pagination {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}

.pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Карточка ноты ===== */
.note-detail {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}

/* ===== PDF-просмотрщик ===== */
.note-viewer {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    height: calc(100vh - 140px);
    min-height: 700px;
    position: sticky;
    top: 80px;
}

.pdf-viewer-wrap {
    background: #ffffff;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0 8px;
}

.pdf-page-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    border-radius: 2px;
}

/* Мини-панель над PDF */
.viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.btn-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85em;
    cursor: pointer;
}

.btn-toolbar:hover {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--accent);
}

.note-sidebar {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.note-sidebar h1 {
    font-size: 1.3em;
    margin: 0 0 8px;
    line-height: 1.3;
}

.note-sidebar .composer {
    color: var(--muted);
    margin-bottom: 20px;
    font-size: 0.95em;
}

.note-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    display: inline-block;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    border: 0;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
}

.btn:hover { background: var(--accent-hover); }
.btn-outline {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); color: var(--accent); }

.note-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 0.9em;
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.note-meta dt { color: var(--muted); }
.note-meta dd { margin: 0; font-weight: 500; }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.tag {
    background: #eef2ff;
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
}

.note-description {
    font-size: 0.9em;
    color: var(--muted);
    margin-top: 16px;
    line-height: 1.5;
}

.similar {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.similar h3 { font-size: 1em; margin: 0 0 10px; }

.similar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.similar li {
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.similar a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9em;
}

.similar a:hover { color: var(--accent); }
.similar small { color: var(--muted); font-size: 0.8em; white-space: nowrap; }

/* ===== Статистика ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    margin: 0 0 12px;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9em;
}

.stat-card .big {
    font-size: 2.2em;
    font-weight: 700;
    color: var(--accent);
}

.stat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}

.stat-list li:last-child { border-bottom: 0; }
.stat-list strong { color: var(--accent); }

footer {
    text-align: center;
    color: var(--muted);
    padding: 30px 0;
    font-size: 0.9em;
}

@media (max-width: 900px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .filters { position: static; }
    .note-detail { grid-template-columns: 1fr; }
    .note-viewer {
        position: static;
        height: 70vh;
        min-height: 500px;
    }
}

/* ===== Панель управления PDF ===== */
.viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}

.btn-toolbar:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-toolbar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-toolbar:active:not(:disabled) {
    transform: translateY(1px);
}

.zoom-value {
    min-width: 55px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text);
    padding: 0 4px;
}