:root {
    --tv-bg: #0b0d12;
    --tv-surface: #141821;
    --tv-surface-2: #1c2230;
    --tv-text: #f4f6fb;
    --tv-muted: #9aa3b5;
    --tv-accent: #e50914;
    --tv-focus: #ffffff;
    --tv-nav-w: 5.25rem;
    --tv-radius: 0.75rem;
    --tv-gap: 1.5rem;
    --tv-font: "Vazirmatn", Tahoma, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html.tv-html,
body.tv-body {
    margin: 0;
    min-height: 100%;
    background: var(--tv-bg);
    color: var(--tv-text);
    font-family: var(--tv-font);
    font-size: 22px;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.tv-shell {
    display: flex;
    min-height: 100vh;
}

.tv-nav {
    position: sticky;
    top: 0;
    width: var(--tv-nav-w);
    min-height: 100vh;
    padding: 1rem 0.45rem 1.25rem;
    background: linear-gradient(180deg, #10141d 0%, #0a0c10 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 40;
    flex-shrink: 0;
}

.tv-nav__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.35rem;
    border-radius: var(--tv-radius);
    margin-top: auto;
}

.tv-nav__brand img {
    width: 3.75rem;
    height: auto;
}

.tv-nav__list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.tv-nav__item,
.tv-nav__exit {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.35rem;
    padding: 0.65rem 0.35rem;
    border-radius: 0.85rem;
    color: var(--tv-muted);
    text-align: center;
}

.tv-nav__item i,
.tv-nav__exit i {
    font-size: 1.75rem;
    line-height: 1;
}

.tv-nav__item.is-active {
    color: var(--tv-text);
    background: rgba(229, 9, 20, 0.22);
    box-shadow: inset -3px 0 0 var(--tv-accent);
}

.tv-main {
    flex: 1;
    min-width: 0;
    padding: 0 0 3rem;
    outline: none;
}

.tv-hero {
    position: relative;
    min-height: 68vh;
    border-radius: 0;
    overflow: hidden;
    margin: 0;
    background: var(--tv-surface);
}

.tv-hero__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tv-hero__overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(270deg, rgba(5, 7, 12, 0.92) 0%, rgba(5, 7, 12, 0.55) 38%, rgba(5, 7, 12, 0.12) 72%, transparent 100%),
        linear-gradient(0deg, rgba(5, 7, 12, 0.95) 0%, rgba(5, 7, 12, 0.35) 42%, transparent 68%);
}

.tv-hero__content {
    position: relative;
    z-index: 2;
    max-width: 44rem;
    padding: 4.5rem 2.5rem 7rem;
    margin-inline-start: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    justify-content: flex-end;
    min-height: 68vh;
}

.tv-hero__title {
    margin: 0;
    font-size: clamp(2.5rem, 4.6vw, 4rem);
    font-weight: 800;
    line-height: 1.12;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.tv-hero__title-en {
    margin: 0.35rem 0 0;
    font-size: clamp(1.05rem, 1.8vw, 1.45rem);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.78);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}

.tv-hero__meta {
    margin: 0;
    color: #c9d1e0;
    font-size: 1.05rem;
    font-weight: 600;
}

.tv-hero__desc {
    margin: 0;
    color: #d5dbe8;
    font-size: 1.08rem;
    line-height: 1.7;
    max-width: 36rem;
}

.tv-hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
    margin-top: 0.5rem;
}

.tv-home-rails {
    position: relative;
    z-index: 3;
    margin-top: -5.5rem;
    padding: 0 1.75rem 1rem;
}

.tv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 3.25rem;
    padding: 0.7rem 1.6rem;
    border-radius: 0.7rem;
    border: 2px solid transparent;
    background: var(--tv-accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    font-family: inherit;
}

.tv-btn--ghost {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.tv-btn--icon {
    width: 3.25rem;
    min-width: 3.25rem;
    padding: 0;
    background: rgba(20, 24, 33, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
}

.tv-btn--icon i {
    font-size: 1.55rem;
}

.tv-row {
    margin-bottom: 1.6rem;
}

.tv-home-rails .tv-row:nth-child(n+2) {
    content-visibility: auto;
    contain-intrinsic-size: auto 18rem;
}

.tv-row__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.tv-row__title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    display: inline-block;
    padding: 0.25rem 0.35rem;
    border-radius: 0.4rem;
}

.tv-rail {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.75rem 0.25rem 1.35rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.tv-rail::-webkit-scrollbar {
    display: none;
}

.tv-card {
    flex: 0 0 17.5rem;
    scroll-snap-align: start;
    border-radius: 0.85rem;
    overflow: hidden;
    background: transparent;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.tv-card__poster {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: 0.85rem;
    overflow: hidden;
    background: linear-gradient(110deg, #1a2030 25%, #252d40 37%, #1a2030 63%);
    background-size: 200% 100%;
    animation: tvShimmer 1.4s ease-in-out infinite;
}

.tv-card__poster.is-loaded {
    animation: none;
    background: var(--tv-surface-2);
}

.tv-card__poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tv-card__poster img.is-loaded {
    opacity: 1;
}

@keyframes tvShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.tv-card__badge {
    position: absolute;
    top: 0.55rem;
    inset-inline-end: 0.55rem;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    z-index: 2;
}

.tv-card__overlay {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 1.6rem 0.85rem 0.75rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
    z-index: 2;
}

.tv-card__title {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

.tv-card__sub-title {
    margin: 0.2rem 0 0;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.tv-card__meta,
.tv-card__sub {
    display: none;
}

.tv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1.1rem;
    padding: 0 1.75rem;
}

.tv-grid .tv-card {
    flex: none;
    width: 100%;
}

.tv-page-title {
    margin: 0 0 1.25rem;
    padding: 1.5rem 1.75rem 0;
    font-size: 2rem;
    font-weight: 800;
}

.tv-search {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0 1.75rem;
}

.tv-search input {
    flex: 1;
    min-height: 3.5rem;
    border-radius: 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: var(--tv-surface);
    color: var(--tv-text);
    padding: 0 1.2rem;
    font-size: 1.15rem;
    font-family: inherit;
}

/* Virtual search keyboard panel */
.tv-search-panel {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(5, 7, 12, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.tv-search-panel[hidden] {
    display: none !important;
}

body.tv-search-open {
    overflow: hidden;
}

.tv-search-panel__inner {
    width: min(72rem, 100%);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.tv-search-panel__top {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tv-search-panel__query {
    flex: 1;
    min-height: 3.75rem;
    display: flex;
    align-items: center;
    padding: 0 1.35rem;
    border-radius: 0.85rem;
    background: var(--tv-surface);
    border: 2px solid rgba(255, 255, 255, 0.14);
    font-size: 1.35rem;
    font-weight: 700;
}

.tv-search-panel__query.is-empty {
    color: var(--tv-muted);
    font-weight: 500;
}

.tv-search-panel__form {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.tv-keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tv-keyboard__row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.tv-key {
    min-width: 3.15rem;
    min-height: 3.15rem;
    padding: 0.35rem 0.55rem;
    border-radius: 0.65rem;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: var(--tv-surface-2);
    color: var(--tv-text);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.tv-key--wide {
    min-width: 5.5rem;
}

.tv-key--space {
    min-width: 12rem;
}

.tv-key--search {
    min-width: 7.5rem;
    background: var(--tv-accent);
    border-color: transparent;
}

.tv-channel-group {
    margin-bottom: 2rem;
    padding: 0 1.75rem;
}

.tv-channel-group__title {
    margin: 0 0 1rem;
    font-size: 1.35rem;
}

.tv-channel {
    flex: 0 0 14rem;
    background: var(--tv-surface);
    border-radius: 0.9rem;
    overflow: hidden;
}

.tv-channel__thumb {
    aspect-ratio: 16 / 10;
    background: #000;
}

.tv-channel__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tv-channel__name {
    margin: 0;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.tv-unavailable {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1rem;
    max-width: 40rem;
    padding: 2rem;
}

.tv-unavailable__title {
    margin: 0;
    font-size: 2rem;
}

.tv-unavailable__text {
    margin: 0;
    color: var(--tv-muted);
    line-height: 1.7;
}

.tv-auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.tv-auth-card {
    width: min(34rem, 100%);
    background: rgba(20, 24, 33, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.25rem;
    padding: 2.25rem;
}

.tv-auth-card__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.tv-auth-card__logo img {
    height: 4rem;
}

.tv-auth-card h1 {
    margin: 0 0 1.5rem;
    text-align: center;
    font-size: 1.8rem;
}

.tv-field {
    margin-bottom: 1.1rem;
}

.tv-field label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--tv-muted);
    font-size: 0.95rem;
}

.tv-field input {
    width: 100%;
    min-height: 3.4rem;
    border-radius: 0.85rem;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: #0d1017;
    color: var(--tv-text);
    padding: 0 1rem;
    font-size: 1.1rem;
    font-family: inherit;
}

.tv-auth-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.tv-player-page {
    padding: 0;
}

.tv-player-wrap {
    position: relative;
    background: #000;
    border-radius: 1rem;
    overflow: hidden;
    min-height: 70vh;
}

.tv-player-wrap video,
.tv-player-wrap .plyr {
    width: 100%;
    height: 70vh;
}

.tv-player-meta {
    padding: 1.25rem 1.75rem 0;
}

.tv-player-meta h1 {
    margin: 0 0 0.5rem;
    font-size: 1.8rem;
}

.tv-player-meta p {
    margin: 0;
    color: var(--tv-muted);
}

.tv-episodes {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 1rem 1.75rem 0.5rem;
}

.tv-episode {
    flex: 0 0 12rem;
    padding: 1rem;
    border-radius: 0.85rem;
    background: var(--tv-surface);
    border: 2px solid transparent;
}

.tv-episode.is-current {
    border-color: var(--tv-accent);
}

.tv-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--tv-muted);
}

@media (max-width: 900px) {
    .tv-nav {
        width: 4.5rem;
    }

    .tv-home-rails {
        padding: 0 1rem 1rem;
        margin-top: -3.5rem;
    }

    .tv-hero__content {
        padding: 3rem 1.25rem 5rem;
    }

    .tv-card {
        flex-basis: 14rem;
    }
}

/* Watching badge on covers */
.watching-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 16px);
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(8, 10, 14, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
    user-select: none;
    z-index: 5;
}

.watching-badge__pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
    animation: watchingPulse 1.8s ease-out infinite;
}

.watching-badge__text {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watching-badge--cover,
.watching-badge--compact {
    position: absolute;
    bottom: 2.6rem;
    inset-inline-end: 10px;
}

@keyframes watchingPulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ESRA age rating on TV covers */
.esra-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.45rem;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    font-weight: 800;
    line-height: 1;
    color: #fff;
    text-align: center;
    pointer-events: none;
    user-select: none;
}

.esra-badge__age {
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.02em;
}

.esra-badge--0 {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
}

.esra-badge--6 {
    background: linear-gradient(180deg, #84cc16 0%, #65a30d 100%);
}

.esra-badge--12 {
    background: linear-gradient(180deg, #facc15 0%, #ca8a04 100%);
    color: #1a1a1a;
    border-color: rgba(0, 0, 0, 0.15);
}

.esra-badge--15 {
    background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
}

.esra-badge--18 {
    background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
}

.esra-badge--cover {
    position: absolute;
    top: 0.55rem;
    inset-inline-start: 0.55rem;
    z-index: 4;
}

