:root {
    --bg: #141414;
    --surface: #1f1f1f;
    --surface-2: #292929;
    --text: #ffffff;
    --muted: #a9a9a9;
    --accent: #e50914;
    --accent-dark: #b20710;
    --border: rgba(255,255,255,.11);
    --shadow: 0 18px 50px rgba(0,0,0,.42);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; }

.site-header {
    position: sticky;
    z-index: 100;
    top: 0;
    background: rgba(20,20,20,.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(15px);
}
.header-inner, .page-shell, .site-footer {
    width: min(1500px, calc(100% - 32px));
    margin-inline: auto;
}
.header-inner { min-height: 68px; display: flex; align-items: center; }
.logo { font-size: clamp(1.1rem, 3vw, 1.55rem); font-weight: 900; letter-spacing: -.04em; }
.logo span { color: var(--accent); }
.page-shell { min-height: calc(100vh - 140px); padding-block: 36px 70px; }
.site-footer { padding: 28px 0; border-top: 1px solid var(--border); color: var(--muted); text-align: center; }

.catalog-hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.catalog-hero h1, .movie-info h1 { margin: 0; font-size: clamp(2rem, 5vw, 4.6rem); line-height: 1.02; letter-spacing: -.055em; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .76rem; font-weight: 900; letter-spacing: .18em; }
.result-count { color: var(--muted); white-space: nowrap; }

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(100px, .7fr)) minmax(180px, 1fr) minmax(190px, 1fr) minmax(190px, 1.1fr) auto auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 30px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.field { display: grid; gap: 7px; min-width: 0; }
.field-label { color: var(--muted); font-size: .78rem; font-weight: 700; }
input, select {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    background: #151515;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229,9,20,.16); }
.input-with-icon { position: relative; display: block; }
.input-with-icon svg { position: absolute; left: 12px; top: 50%; width: 19px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; }
.input-with-icon input { padding-left: 40px; }
input[type="range"] { height: 44px; padding: 0; accent-color: var(--accent); background: transparent; box-shadow: none; }
.button {
    display: inline-flex;
    min-height: 44px;
    padding: 0 18px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: background .2s, transform .2s;
}
.button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.button-secondary { background: var(--surface-2); border: 1px solid var(--border); }

.movie-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(14px, 2vw, 24px); }
.movie-card {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.movie-card:hover { z-index: 2; transform: scale(1.05); border-color: rgba(255,255,255,.25); box-shadow: var(--shadow); }
.poster { position: relative; overflow: hidden; aspect-ratio: 2 / 3; background: #333; isolation: isolate; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster::after { content: ""; position: absolute; inset: auto 0 0; height: 28%; background: linear-gradient(transparent, rgba(0,0,0,.5)); pointer-events: none; }
.poster-letter { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.82); font-size: clamp(4rem, 12vw, 8rem); font-weight: 950; text-shadow: 0 10px 40px rgba(0,0,0,.25); }
.rating-badge {
    position: absolute;
    z-index: 2;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    color: #fff;
    font-weight: 900;
    font-size: 1rem;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,.35);
    box-shadow: 0 4px 14px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.15);
    letter-spacing: .02em;
}
.card-body { padding: 14px; }
.card-body h2 { overflow: hidden; margin: 0 0 6px; font-size: 1rem; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.card-meta, .card-genre { margin: 0; color: var(--muted); font-size: .84rem; }
.card-genre { overflow: hidden; margin-top: 2px; white-space: nowrap; text-overflow: ellipsis; }

.gradient-0 { background: linear-gradient(145deg, #e50914, #3b0912, #13070c); }
.gradient-1 { background: linear-gradient(145deg, #6a11cb, #2575fc); }
.gradient-2 { background: linear-gradient(145deg, #f7971e, #ffd200, #7a2500); }
.gradient-3 { background: linear-gradient(145deg, #11998e, #38ef7d, #05352f); }
.gradient-4 { background: linear-gradient(145deg, #fc466b, #3f5efb); }
.gradient-5 { background: linear-gradient(145deg, #141e30, #243b55, #d34b35); }
.gradient-6 { background: linear-gradient(145deg, #833ab4, #fd1d1d, #fcb045); }
.gradient-7 { background: linear-gradient(145deg, #0f2027, #2c5364, #76b852); }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 38px; }
.pagination a, .pagination span { display: grid; min-width: 42px; height: 42px; padding: 0 11px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.pagination a:hover, .pagination a.active { background: var(--accent); border-color: var(--accent); }
#catalog-results { transition: opacity .15s; }
#catalog-results.is-loading { opacity: .45; pointer-events: none; }
.empty-state { padding: 70px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; text-align: center; }
.empty-state h1, .empty-state h2 { margin-top: 0; }

.back-link { display: inline-flex; margin-bottom: 25px; color: var(--muted); font-weight: 700; }
.back-link:hover { color: var(--text); }
.movie-detail { display: grid; grid-template-columns: minmax(240px, 380px) minmax(0, 1fr); gap: clamp(30px, 6vw, 90px); align-items: center; }
.detail-poster { width: 100%; border-radius: 18px; box-shadow: var(--shadow); }
.movie-info h1 { max-width: 1000px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 35px; }
.facts div { padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 4px 0 0; font-weight: 800; }
.facts .accent { color: var(--accent); font-size: 1.35rem; }
.player-section { margin-top: 60px; }
.player-section h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.video-frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

@media (max-width: 1250px) {
    .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .search-field { grid-column: span 2; }
    .movie-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .search-field, .rating-field { grid-column: span 2; }
    .movie-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .movie-detail { grid-template-columns: minmax(190px, 290px) 1fr; gap: 28px; }
}
@media (max-width: 650px) {
    .header-inner, .page-shell, .site-footer { width: min(100% - 22px, 1500px); }
    .page-shell { padding-top: 25px; }
    .catalog-hero { display: block; }
    .result-count { margin-top: 10px; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 13px; }
    .search-field, .rating-field { grid-column: 1 / -1; }
    .filter-submit, .button-secondary { width: 100%; }
    .movie-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
    .card-body { padding: 11px; }
    .rating-badge { min-width: 44px; height: 26px; font-size: .85rem; padding: 0 8px; }
    .movie-card:hover { transform: translateY(-3px); }
    .movie-detail { grid-template-columns: 1fr; }
    .detail-poster { width: min(80vw, 360px); margin-inline: auto; }
    .facts { grid-template-columns: 1fr 1fr; }
}
/* ===== VK Donut ===== */
.donut-badge {
    position: absolute;
    z-index: 2;
    top: 10px;
    left: 10px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    background: rgba(0,0,0,.72);
    color: #ffcc00;
    border: 1px solid rgba(255,204,0,.5);
    border-radius: 8px;
    backdrop-filter: blur(4px);
}
.donut-badge svg { width: 16px; height: 16px; }

.donut-overlay {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #0a0a0a;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    transition: transform .25s ease, box-shadow .25s ease;
}
.donut-overlay:hover { transform: translateY(-2px); box-shadow: 0 22px 60px rgba(0,0,0,.55); }
.donut-overlay-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(18px) brightness(.35) saturate(1.2);
    transform: scale(1.15);
    z-index: 0;
}
.donut-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0,0,0,.35), rgba(0,0,0,.85));
    z-index: 1;
}
.donut-overlay-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    padding: 24px;
    text-align: center;
    color: #fff;
}
.donut-icon {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    background: rgba(255,204,0,.16);
    color: #ffcc00;
    border: 2px solid rgba(255,204,0,.55);
    border-radius: 50%;
    margin-bottom: 4px;
}
.donut-icon svg { width: 30px; height: 30px; }
.donut-overlay-content h3 { margin: 0; font-size: clamp(1.05rem, 2.3vw, 1.6rem); }
.donut-overlay-content p { margin: 0; color: var(--muted); max-width: 480px; font-size: .95rem; }
.button-donut {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 22px;
    margin-top: 8px;
    background: linear-gradient(135deg, #ffcc00, #ff8800);
    color: #1a1a1a;
    font-weight: 800;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(255,170,0,.35);
    transition: transform .2s;
}
.donut-overlay:hover .button-donut { transform: scale(1.04); }