:root {
    color-scheme: dark;
    --bg: #0a0a0c;
    --bg-elevated: #141418;
    --bg-card: #1c1c22;
    --text: #f5f5f7;
    --text-muted: #98989d;
    --accent: #ffffff;
    --accent-hover: #e8e8ed;
    --error: #ff6b6b;
    --live: #e00;
    --border: #2c2c2e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --max-width: 1400px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a,
a:hover,
a:focus,
a:active,
a:visited {
    color: inherit;
    text-decoration: none;
}

.site-header {
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 12, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    width: 100%;
}

.fc-has-site-nav .site-header {
    z-index: 90;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-header nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

.site-header nav a:hover,
.site-header nav a.is-active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

main {
    padding: 1.25rem 1.5rem 3rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.page-watch main {
    max-width: none;
    padding: 0;
}

.panel { width: 100%; }

.login-panel { max-width: 420px; margin: 0 auto; }

.login-panel label {
    display: block;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-panel input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
}

.atv-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.atv-btn:hover {
    background: var(--bg-card);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text);
}

.hint, .status, .loading, .empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.empty-state { margin: 1rem 0; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.channel-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tab {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.tab:hover { border-color: rgba(255, 255, 255, 0.2); }

.tab.active {
    background: var(--text);
    color: #000;
    border-color: var(--text);
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex: 1 1 220px;
    max-width: 360px;
}

.search-form input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    min-width: 0;
}

.search-form .atv-btn {
    flex-shrink: 0;
}

/* ── Carousel rows ── */
.carousel-section {
    margin-bottom: 2.25rem;
}

.carousel-section__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
    padding: 0 0.15rem;
}

.carousel-section__title {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.carousel-section__link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.carousel-section__link:hover {
    color: var(--text);
}

.page-title {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    margin: 0 0 1.5rem;
    letter-spacing: -0.02em;
}

.page-back {
    margin: 0 0 1rem;
}

.carousel-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.875rem;
    overflow-x: auto;
    width: 100%;
    padding: 0.25rem 0.15rem 0.85rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.carousel-row::-webkit-scrollbar { height: 6px; }
.carousel-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ── Media cards ── */
.media-card {
    flex: 0 0 auto;
    width: 160px;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
}

.media-card:hover { transform: translateY(-4px); }

.media-card__poster {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.media-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-muted);
    background: linear-gradient(145deg, var(--bg-elevated), var(--bg-card));
}

.media-card--landscape .media-card__poster {
    aspect-ratio: 16 / 9;
}

.carousel-row--landscape .media-card.media-card--landscape {
    width: 280px;
}

.carousel-row--portrait .media-card:not(.media-card--landscape) {
    width: 160px;
}

.media-card__poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-card__badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.media-card__badge--live {
    background: var(--live);
}

.media-card__badge--upcoming {
    background: rgba(255, 159, 10, 0.92);
    color: #1a1200;
}

.media-card__badge--replay {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--text);
}

.media-card__badge--meta {
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.media-card__info {
    padding: 0.5rem 0.15rem 0;
}

.media-card__title {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card__meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .carousel-row--portrait .media-card:not(.media-card--landscape) {
        width: 180px;
    }
}

/* ── Show hero ── */
.show-hero {
    position: relative;
    min-height: 340px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    border-radius: var(--radius);
    margin: 0 0 2rem;
}

.show-hero__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
}

.show-hero__bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg) 0%, rgba(10, 10, 12, 0.65) 45%, rgba(10, 10, 12, 0.25) 100%);
}

.show-hero__content {
    position: relative;
    padding: 2rem 1.25rem;
    width: 100%;
}

.show-hero__back { margin: 0 0 0.75rem; }

.show-hero__title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.show-hero__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.tag {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    font-weight: 500;
}

.show-hero__desc {
    max-width: 640px;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.6;
}

/* ── Movie / title detail ── */
.title-detail {
    position: relative;
    margin-bottom: 2rem;
}

.title-detail__backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    opacity: 0.18;
    z-index: 0;
    border-radius: var(--radius);
    pointer-events: none;
}

.title-detail__hero {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.title-detail__poster {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    aspect-ratio: 2 / 3;
    background: var(--surface);
}

.title-detail__poster img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.title-detail__body {
    min-width: 0;
    padding-top: 0.25rem;
}

.title-detail__brand {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.title-detail__title {
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.title-detail__tagline {
    margin: 0 0 0.75rem;
    color: var(--text-muted);
    font-size: 1rem;
    font-style: italic;
}

.title-detail__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.title-detail__desc {
    max-width: 720px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.65;
    margin: 0 0 1.25rem;
}

.title-detail__actions {
    margin: 0;
}

.atv-btn--primary {
    background: var(--text);
    color: #000;
    border-color: var(--text);
}

.atv-btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #000;
}

.cast-section {
    position: relative;
    z-index: 1;
    margin-top: 2rem;
}

.cast-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}

.cast-row {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scroll-snap-type: x mandatory;
}

.cast-card {
    flex: 0 0 auto;
    width: 110px;
    scroll-snap-align: start;
    text-align: center;
}

.cast-card__photo {
    width: 88px;
    height: 88px;
    margin: 0 auto 0.5rem;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface);
}

.cast-card__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cast-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
}

.cast-card__name {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
}

.cast-card__role {
    margin: 0.2rem 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
}

@media (max-width: 640px) {
    .title-detail__hero {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 1rem;
    }
}

/* ── Season sections ── */
.season-section { margin-bottom: 2rem; }

.season-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.season-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.season-section.is-collapsed .episode-row { display: none; }

.episode-card {
    flex: 0 0 auto;
    width: 280px;
    scroll-snap-align: start;
}

.episode-card .media-card { width: 100%; }

.episode-card .media-card__title { font-size: 0.82rem; }

/* ── Search results grid ── */
.search-results__group { margin-bottom: 2rem; }

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.25rem;
}

.search-grid .media-card { width: 100%; }

/* ── Shelf “See all” grid ── */
.shelf-grid {
    display: grid;
    gap: 1.25rem 1rem;
}

.shelf-grid--portrait {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.shelf-grid--landscape {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.shelf-grid .media-card {
    width: 100%;
}

@media (min-width: 768px) {
    .shelf-grid--portrait {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

/* ── Player ── */
.player-shell {
    background: #000;
}

.player-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.player-topbar .atv-btn {
    flex-shrink: 0;
}

.player-topbar__title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-panel { position: relative; }

#player {
    width: 100%;
    aspect-ratio: 16 / 9;
}

.player-info {
    padding: 1.5rem 1.5rem 2.5rem;
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1.25rem;
    align-items: start;
    background: var(--bg);
}

.player-info--standalone {
    display: block;
    padding: 1rem 1.5rem 2rem;
}

.player-info__thumb {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
}

.player-info__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info__body { min-width: 0; }

.player-info__title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    margin: 0 0 0.35rem;
    letter-spacing: -0.02em;
}

.player-info__subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 0.75rem;
}

.player-info__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.player-info__desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
    margin: 0 0 1rem;
    max-width: 72ch;
}

.player-info__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.error-box {
    padding: 0.75rem 1rem;
    margin: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: rgba(255, 107, 107, 0.15);
    color: var(--error);
}

.live-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 5;
    background: var(--live);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.feed-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.feed-picker > span {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.feed-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: all 0.15s;
}

.feed-link:hover { color: var(--text); }

.feed-link.active {
    color: #000;
    background: var(--text);
    border-color: var(--text);
}

@media (max-width: 640px) {
    .player-info {
        grid-template-columns: 1fr;
    }

    .player-info__thumb {
        max-width: 200px;
    }

    .search-form {
        margin-left: 0;
        max-width: none;
        width: 100%;
    }

    main {
        padding: 1rem 1rem 2.5rem;
    }
}
