/* Телепрограмма */
:root {
    --tv-bg: #141414;
    --tv-card: #1f1f1f;
    --tv-card-2: #2a2a2a;
    --tv-text: #fff;
    --tv-muted: #8c8c8c;
    --tv-line: #333;
    --tv-accent: #facc6d;
    --tv-accent-hover: #de984d;
    --tv-on-accent: #000;
}

.tv-section,
.tv-channel {
    color: var(--tv-text);
    background: var(--tv-bg);
    padding: 20px;
}

.tv-card {
    background: var(--tv-card);
    border: 1px solid var(--tv-line);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.tv-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.tv-card__logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.tv-card__name {
    color: var(--tv-text);
    font-size: 1.8rem;
    font-weight: 500;
    text-decoration: none;
}

.tv-card__list {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
}

.tv-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--tv-line);
}

.tv-line time {
    color: var(--tv-accent);
    font-weight: 600;
}

.tv-line__title {
    color: var(--tv-text);
}

.tv-card__more {
    color: var(--tv-muted);
    text-decoration: none;
    font-size: 1.4rem;
    margin-top: auto;
}

.tv-card__more:hover {
    color: var(--tv-accent);
}

.tv-grid__cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.tv-inline-player {
    max-width: 960px;
}

.tv-inline-video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.tv-inline-player__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
}

.tv-channel header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.tv-channel header p {
    margin: 0;
    color: #61706c;
}

.tv-channel section {
    margin-top: 24px;
}

.tv-channel__days {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.tv-channel__days a[aria-current="date"] {
    color: #147a64;
    font-weight: 700;
}

/* Rutube-style TV programme layout */
.tv-section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.tv-section__head h2 {
    margin: 0;
}

.tv-more,
.tv-card__more {
    color: #147a64;
    font-weight: 600;
    text-decoration: none;
}

.tv-more:hover,
.tv-card__more:hover {
    text-decoration: underline;
}

.tv-live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.tv-live-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.tv-live-card__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    background: #e8eeeb;
}

.tv-live-card__media img {
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
}

.tv-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: #e5173f;
}

.tv-live-card__body {
    display: grid;
    gap: 3px;
    padding: 10px 12px 4px;
    flex: 1;
}

.tv-live-card__channel {
    color: #222;
    font-weight: 700;
    text-decoration: none;
}

.tv-live-card__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.tv-live-card__time {
    color: #61706c;
}

.tv-live-card__actions {
    padding: 4px 12px 12px;
}

.tv-grid__title {
    margin: 0 0 14px;
    font-size: 28px;
}

.tv-days {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tv-days a {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 18px;
    color: #222;
    background: #e8eeeb;
    text-decoration: none;
    white-space: nowrap;
}

.tv-days a[aria-current="date"] {
    color: #fff;
    background: #147a64;
}

.tv-grid__cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.tv-card {
    display: flex;
    flex-direction: column;
    padding: 14px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.tv-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.tv-card__logo {
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: #e8eeeb;
}

.tv-card__logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tv-card__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: #222;
    font-weight: 700;
    text-overflow: ellipsis;
    text-decoration: none;
    white-space: nowrap;
}

.tv-card__head .tv-player-open {
    padding: 6px 10px;
    font-size: 13px;
}

.tv-card__list {
    flex: 1;
    max-height: 340px;
    margin: 0 0 10px;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.tv-line {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-top: 1px solid #eef1ef;
}

.tv-line time {
    flex: 0 0 44px;
    color: #61706c;
    font-variant-numeric: tabular-nums;
}

.tv-line--past {
    opacity: .55;
}

.tv-line--current {
    font-weight: 700;
}

.tv-line--current time {
    color: #e5173f;
}

.tv-line--empty {
    color: #61706c;
}

@media (max-width: 640px) {
    .tv-live-grid,
    .tv-grid__cards {
        grid-template-columns: 1fr;
    }
}


@media (max-width: 640px) {
    .tv-grid__row {
        display: block;
    }
    .tv-grid__channel {
        width: auto;
        margin-bottom: 10px;
    }
    .tv-grid__programmes {
        grid-template-columns: 1fr;
    }
    .tv-player-modal {
        padding: 8px;
    }
}


/* ===== Dark theme (prokino-gold): переопределения цветов и вёрстки ===== */
.tv-section,
.tv-channel {
    --tv-text: var(--prokino-light, #fff);
    --tv-muted: var(--prokino-grey, #8c8c8c);
    --tv-line: rgba(255, 255, 255, .1);
    --tv-card: #1e1e1e;
    --tv-card-2: #262626;
    --tv-accent: var(--prokino-gold, #facc6d);
    --tv-accent-hover: var(--prokino-gold-hover, #de984d);
    --tv-on-accent: #141414;
    color: var(--tv-text);
    font-family: var(--prokino-font, inherit);
}

.tv-section {
    margin-bottom: 32px;
}

.tv-section h1,
.tv-section h2,
.tv-channel h1,
.tv-channel h2,
.tv-grid__title {
    color: var(--tv-text);
}

.tv-now__list,
.tv-grid__rows,
.tv-programme-list {
    border-top-color: var(--tv-line);
}

.tv-now__item,
.tv-grid__row {
    border-bottom-color: var(--tv-line);
}

.tv-now__item > img {
    background: var(--tv-card-2);
}

.tv-now__copy small,
.tv-programme time,
.tv-programme span,
.tv-live-card__time,
.tv-line time,
.tv-line--empty,
.tv-channel header p {
    color: var(--tv-muted);
}

.tv-now__progress {
    background: var(--tv-line);
}

.tv-now__progress span {
    background: var(--tv-accent);
}

.tv-programme {
    border-left-color: var(--tv-accent);
    background: var(--tv-card);
}

.tv-more,
.tv-card__more,
.tv-grid__head a[aria-current="date"],
.tv-channel__days a[aria-current="date"] {
    color: var(--tv-accent);
}

.tv-more:hover,
.tv-card__more:hover {
    color: var(--tv-accent-hover);
}

.tv-card__more {
    margin-top: auto;
    align-self: flex-start;
}

.tv-channel__days a {
    color: var(--tv-text);
}

/* Кнопки */
.tv-player-open {
    color: var(--tv-on-accent);
    font-weight: 600;
    background: var(--tv-accent);
    transition: background .2s ease;
}

.tv-player-open:hover {
    background: var(--tv-accent-hover);
}

.tv-player-close {
    color: #fff;
    background: #3a3a3a;
}

.tv-player-close:hover {
    background: #4a4a4a;
}

.tv-quality {
    color: var(--tv-text);
    border: 1px solid var(--tv-line);
    border-radius: 3px;
    padding: 6px 8px;
    background: var(--tv-card-2);
}

/* Дни недели */
.tv-days {
    scrollbar-width: thin;
}

.tv-days a {
    color: var(--tv-text);
    background: var(--tv-card-2);
    transition: background .2s ease, color .2s ease;
}

.tv-days a:hover {
    background: #333;
}

.tv-days a[aria-current="date"] {
    color: var(--tv-on-accent);
    font-weight: 700;
    background: var(--tv-accent);
}

/* Карточки «Прямые эфиры» */
.tv-live-card,
.tv-card {
    border: 1px solid var(--tv-line);
    background: var(--tv-card);
    box-shadow: none;
}

.tv-live-card {
    transition: transform .2s ease, border-color .2s ease;
}

.tv-live-card:hover,
.tv-card:hover {
    border-color: rgba(250, 204, 109, .45);
}

.tv-live-card__media,
.tv-card__logo {
    background: var(--tv-card-2);
}

.tv-live-card__channel,
.tv-card__name {
    color: var(--tv-text);
}

.tv-live-card__channel:hover,
.tv-card__name:hover {
    color: var(--tv-accent);
}

/* Сетка каналов */
.tv-grid__cards {
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

.tv-card {
    /* страница содержит сотни каналов: не рендерим карточки вне экрана */
    content-visibility: auto;
    contain-intrinsic-size: auto 420px;
}

.tv-card__logo img {
    max-width: 80%;
    max-height: 80%;
}

.tv-card__list {
    scrollbar-width: thin;
    scrollbar-color: #4a4a4a transparent;
}

.tv-line {
    border-top-color: var(--tv-line);
}

.tv-line__title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.tv-line--current {
    color: var(--tv-accent);
}

.tv-line--current time {
    color: var(--tv-accent);
}

.tv-badge {
    background: #e5173f;
}

/* ===== Превью канала по наведению на постер ===== */
.tv-live-card__media {
    overflow: hidden;
}

.tv-live-card__preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.tv-live-card__media--playing .tv-live-card__preview {
    opacity: 1;
}

.tv-live-card__media[data-preview] {
    cursor: pointer;
}

.tv-live-card__media .tv-badge {
    z-index: 1;
}

/* ===== Плеер: модальное окно и встроенный плеер ===== */
.tv-player-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .85);
}

.tv-player-modal[hidden] {
    display: none;
}

.tv-player-modal__panel {
    width: min(1100px, 100%);
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.tv-player-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    color: #fff;
    background: var(--tv-card, #1e1e1e);
}

.tv-player-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.tv-player-video,
.tv-embed-frame {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
}

.tv-inline-player {
    position: relative;
    max-width: none;
}

.tv-inline-video,
.tv-inline-player .tv-embed-frame {
    border-radius: 16px;
}

.tv-inline-player__error {
    margin: 8px 0 0;
    color: #ff6b6b;
}

.tv-player-open {
    padding: 8px 14px;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

/* ===== Страница канала в стиле Rutube: плеер слева, телепрограмма справа ===== */
.tv-channel__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
}

.tv-channel__main {
    min-width: 0;
}

.tv-channel__title {
    margin: 18px 0 12px;
    font-size: 28px;
    line-height: 1.2;
}

.tv-channel__info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.tv-channel__info img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    background: var(--tv-card-2);
}

.tv-channel__info p {
    margin: 2px 0 0;
}

.tv-channel__side {
    display: flex;
    flex-direction: column;
    max-height: 760px;
    padding: 16px;
    border-radius: 16px;
    background: var(--tv-card);
}

.tv-channel__tabs {
    margin-bottom: 14px;
}

.tv-channel__tabs span {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 12px;
    color: #000;
    font-weight: 600;
    background: #fff;
}

.tv-channel__days {
    flex: 0 0 auto;
    gap: 4px;
    margin-bottom: 10px;
    overflow-x: auto;
    border-bottom: 1px solid var(--tv-line);
    flex-wrap: nowrap;
}

.tv-channel__days a {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.tv-channel__days a[aria-current="date"] {
    border-bottom-color: var(--tv-text);
    color: var(--tv-text);
}

.tv-channel__schedule {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.tv-channel__schedule .tv-programme-list {
    border: 0;
}

.tv-programme {
    display: flex;
    gap: 14px;
    padding: 10px 12px;
    border-left: 0;
    border-radius: 10px;
    background: transparent;
}

.tv-programme time {
    flex: 0 0 48px;
    font-variant-numeric: tabular-nums;
}

.tv-programme__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tv-programme__body strong {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.tv-programme__body span {
    font-size: 12px;
}

.tv-programme--past {
    opacity: .55;
}

.tv-programme--current {
    background: #262d3b;
}

.tv-programme--current time {
    color: var(--tv-accent);
}

.tv-channel__news {
    margin-top: 32px;
}

.tv-channel__news article {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--tv-line);
}

.tv-channel__news a {
    color: var(--tv-text);
}

@media (max-width: 980px) {
    .tv-channel__layout {
        grid-template-columns: 1fr;
    }
    .tv-channel__side {
        max-height: 520px;
    }
}

/* Категории (как «Все прямые эфиры / Новости / Спорт» на Rutube) */
.tv-groups {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tv-groups a {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 18px;
    color: var(--tv-text);
    background: var(--tv-card-2);
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s ease, color .2s ease;
}

.tv-groups a:hover {
    background: #333;
}

.tv-groups a[aria-current="true"] {
    color: var(--tv-on-accent);
    font-weight: 700;
    background: var(--tv-accent);
}

.tv-grid__empty {
    color: var(--tv-muted);
}

.tv-card__list {
    max-height: none;
    overflow: visible;
}

@media (max-width: 640px) {
    .tv-section__head {
        flex-wrap: wrap;
    }
    .tv-days a {
        padding: 7px 14px;
    }
}
