:root {
    --bg: #0d1220;
    --bg2: #141b2e;
    --bg3: #1c2540;
    --text: #e8ecf8;
    --muted: #8e9ab8;
    --accent: #4f8cff;
    --accent2: #35d0ba;
    --border: #263154;
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #fff; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 0;
    position: sticky;
    top: 0;
    background: rgba(14, 16, 20, .92);
    backdrop-filter: blur(10px);
    z-index: 50;
    border-bottom: 1px solid var(--border);
}
.logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.logo-tv {
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 15px;
}
.search-box { position: relative; flex: 1; max-width: 480px; margin-left: auto; }
.search-box input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 10px 14px;
    font-size: 15px;
    outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.search-results a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}
.search-results a:hover { background: var(--bg3); }
.search-results img { width: 30px; height: 30px; object-fit: contain; }

/* ---------- hero ---------- */
.hero { padding: 34px 0 18px; text-align: center; }
.hero h1 { font-size: 28px; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0; }

/* ---------- channel grid ---------- */
.channels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    padding: 18px 0 40px;
}
.card {
    display: flex;
    gap: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    transition: transform .12s ease, border-color .12s ease;
    /* не рендерим карточки за пределами экрана — критично для сетки из тысяч каналов */
    content-visibility: auto;
    contain-intrinsic-size: auto 90px;
}
.card:hover { transform: translateY(-2px); border-color: #3a4154; }
.card-logo img {
    width: 64px; height: 64px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 6px;
}
.card-body { min-width: 0; flex: 1; }
.card-name { font-weight: 700; margin-bottom: 4px; }
.card-now {
    display: flex; align-items: center; gap: 6px;
    color: var(--muted);
    font-size: 13px;
    min-height: 20px;
}
.now-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.now-live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    flex: none;
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}
.progress {
    margin-top: 8px;
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar { height: 100%; background: var(--accent); }

/* ---------- channel page ---------- */
.player-page {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 20px;
    padding: 20px 0;
}
@media (max-width: 900px) {
    .player-page { grid-template-columns: 1fr; }
}
.player-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }

.player-meta { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.ch-logo {
    width: 56px; height: 56px; object-fit: contain;
    background: #fff; border-radius: 12px; padding: 5px;
}
.ch-title { font-size: 22px; margin: 0; }
.ch-sub {
    font-size: 13px; color: var(--accent2);
    font-weight: 600; vertical-align: middle;
    margin-left: 6px;
}
.now-line { color: var(--muted); font-size: 14px; margin-top: 2px; }
.live-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 5px;
    padding: 1px 7px;
    margin-right: 4px;
    text-transform: uppercase;
}

.sources { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.src-label { color: var(--muted); font-size: 13px; width: 100%; }
.src-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
}
.src-btn:hover { border-color: #4a5164; }
.src-btn.active { border-color: var(--accent); background: rgba(232, 17, 45, .12); }
.src-ms { color: var(--muted); margin-left: 6px; font-size: 11px; }

/* ---------- schedule ---------- */
.schedule-col { min-width: 0; }
.day-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.day-tab {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--muted);
}
.day-tab.active { color: var(--text); border-color: var(--accent); background: rgba(232,17,45,.1); }

.programme-list {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    max-height: 720px;
    overflow-y: auto;
}
.prog {
    display: flex;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.prog:last-child { border-bottom: none; }
.prog-time { color: var(--muted); font-size: 13px; width: 78px; flex: none; padding-top: 2px; }
.prog-now { background: rgba(232, 17, 45, .06); }
.prog-now .prog-title { color: #fff; }
.prog-title { font-size: 14px; }
.prog-title-toggle { cursor: pointer; }
.prog-title-toggle:hover { color: var(--accent2); }
.prog-desc { margin-top: 4px; }
.prog-desc p { color: var(--muted); font-size: 13px; margin: 4px 0 2px; }
.prog-empty { padding: 24px; color: var(--muted); text-align: center; }

/* ---------- «смотрите также» ---------- */
.related { margin: 18px 0 6px; }
.related-title { font-size: 18px; margin: 0 0 12px; color: var(--text); }
.related-all { font-size: 13px; font-weight: 400; color: var(--accent); text-decoration: none; margin-left: 10px; }
.related-all:hover { text-decoration: underline; }

/* ---------- seo text ---------- */
.seo-text {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin: 10px 0 40px;
    color: var(--muted);
}
.seo-text h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.seo-text p { margin: 6px 0; }
.seo-now strong { color: var(--text); }

/* ---------- footer ---------- */
.footer {
    border-top: 1px solid var(--border);
    padding: 20px 0 30px;
    color: var(--muted);
    font-size: 13px;
}


/* ---------- категории: чипы ---------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 6px;
}
.chip {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.chip-n { opacity: .7; font-size: 11px; margin-left: 3px; }

/* ---------- хлебные крошки ---------- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent2); }
.breadcrumbs span[aria-current], .breadcrumbs span:last-child { color: var(--text); }

/* ---------- админ-статистика ---------- */
.admin-title { font-size: 24px; margin: 18px 0; }
.admin-h2 { font-size: 17px; margin: 26px 0 10px; }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}
.stat-grid.two { margin-bottom: 40px; }
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.stat-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--accent2); }
.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
    color: var(--muted);
}
.stat-row:last-child { border-bottom: none; }
.stat-row b { color: var(--text); font-weight: 600; white-space: nowrap; }
.stat-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13px;
}
.stat-table th, .stat-table td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.stat-table th { color: var(--muted); font-weight: 600; background: var(--bg3); }
.stat-table tr:last-child td { border-bottom: none; }
.stat-table .url { color: var(--muted); word-break: break-all; }
.stat-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 13px;
    max-height: 320px;
    overflow-y: auto;
}
.stat-list li { padding: 2px 0; }
