:root {
    color-scheme: dark;
    --bg: #080b18;
    --surface: #0f152b;
    --surface-raised: #172040;
    --border: #2a3c70;
    --text: #eef6ff;
    --muted: #8ea5cc;
    --accent: #38bdf8;
    --accent-violet: #8b5cf6;
    --accent-gold: #f59e0b;
    --accent-red: #f97316;
    --accent-soft: rgba(56, 189, 248, 0.16);
    --shadow: 0 16px 42px rgba(2, 4, 14, 0.65);
}

* {
    box-sizing: border-box;
}

body {
    position: relative;
    isolation: isolate;
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(ellipse at 12% 8%, rgba(56, 189, 248, 0.16), transparent 36rem),
        radial-gradient(ellipse at 88% 82%, rgba(139, 92, 246, 0.22), transparent 34rem),
        var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body::before,
body::after {
    position: fixed;
    z-index: -1;
    color: rgba(56, 189, 248, 0.16);
    font-family: "Segoe UI Symbol", serif;
    line-height: 1;
    pointer-events: none;
    text-shadow: 0 12px 32px rgba(56, 189, 248, 0.25);
    animation: nocturnal-wander 16s ease-in-out infinite;
}

body::before {
    top: 8vh;
    right: -0.05em;
    content: "☾";
    font-size: clamp(9rem, 19vw, 18rem);
}

body::after {
    bottom: 1vh;
    left: -0.04em;
    color: rgba(139, 92, 246, 0.18);
    content: "✦";
    font-size: clamp(8rem, 15vw, 14rem);
    animation-delay: -8s;
}

.view.active::before,
.view.active::after {
    position: fixed;
    z-index: -1;
    color: rgba(56, 189, 248, 0.22);
    font-family: "Segoe UI Symbol", serif;
    font-size: clamp(1.6rem, 2.8vw, 2.8rem);
    line-height: 1;
    pointer-events: none;
    animation: nocturnal-wander 13s ease-in-out infinite;
}

.view.active::before {
    top: 43vh;
    left: 8vw;
    content: "✦";
    text-shadow:
        15vw -32vh 0 rgba(56, 189, 248, 0.2),
        38vw -39vh 0 rgba(245, 158, 11, 0.18),
        57vw -27vh 0 rgba(56, 189, 248, 0.22),
        76vw -13vh 0 rgba(139, 92, 246, 0.2),
        67vw 4vh 0 rgba(56, 189, 248, 0.2),
        48vw 22vh 0 rgba(139, 92, 246, 0.18),
        26vw 38vh 0 rgba(56, 189, 248, 0.22),
        5vw 27vh 0 rgba(245, 158, 11, 0.16),
        82vw 32vh 0 rgba(56, 189, 248, 0.18);
}

.view.active::after {
    right: 7vw;
    bottom: 14vh;
    color: rgba(139, 92, 246, 0.22);
    content: "✧";
    text-shadow:
        -14vw 30vh 0 rgba(139, 92, 246, 0.2),
        -36vw 35vh 0 rgba(56, 189, 248, 0.2),
        -58vw 21vh 0 rgba(245, 158, 11, 0.16),
        -76vw 7vh 0 rgba(56, 189, 248, 0.22),
        -67vw -12vh 0 rgba(139, 92, 246, 0.18),
        -47vw -28vh 0 rgba(56, 189, 248, 0.2),
        -26vw -39vh 0 rgba(139, 92, 246, 0.18),
        -4vw -30vh 0 rgba(56, 189, 248, 0.22),
        -82vw -16vh 0 rgba(245, 158, 11, 0.16);
    animation-delay: -6s;
}

main::before,
main::after {
    position: fixed;
    z-index: -1;
    content: "🦇";
    font-size: clamp(3.8rem, 7.5vw, 6.5rem);
    opacity: 0.22;
    filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.55)) hue-rotate(225deg) saturate(1.8);
    pointer-events: none;
    animation: bat-glide 16s ease-in-out infinite;
}

main::before {
    top: 32vh;
    left: 1vw;
}

main::after {
    right: 1vw;
    bottom: 3vh;
    font-size: clamp(4.2rem, 8.5vw, 7.5rem);
    animation-delay: -8s;
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.topbar {
    position: sticky;
    z-index: 4;
    top: 0;
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px clamp(18px, 5vw, 72px);
    border-bottom: 1px solid rgba(56, 189, 248, 0.18);
    background: rgba(8, 11, 24, 0.88);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.home-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 15px;
    background: linear-gradient(145deg, var(--accent), var(--accent-violet));
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.28);
    color: #060913;
    font-weight: 900;
}

.brand-mark {
    display: block;
    width: 88px;
    height: 88px;
    flex: 0 0 88px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 5px 14px rgba(56, 189, 248, 0.35));
    transition: transform 220ms ease, filter 220ms ease;
}

.brand:hover .brand-mark {
    transform: rotate(-5deg) scale(1.05);
    filter: drop-shadow(0 6px 18px rgba(139, 92, 246, 0.55));
}

.brand-accent {
    display: inline-block;
    margin-left: 3px;
    padding: 1px 6px 2px;
    border-radius: 6px;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.35);
    color: #080b18;
    font-size: 0.78em;
    font-weight: 900;
    line-height: 1.15;
    vertical-align: 0.08em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-button,
.icon-button,
.back-button,
.primary-button {
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: var(--muted);
    font-weight: 650;
    transition: background 220ms ease, border-color 220ms ease, color 220ms ease,
        box-shadow 220ms ease, transform 220ms ease;
}

.nav-button:hover,
.icon-button:hover,
.back-button:hover {
    border-color: var(--border);
    background: var(--surface-raised);
    color: var(--text);
}

.nav-button.active {
    border-color: rgba(56, 189, 248, 0.42);
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: 0 5px 18px rgba(56, 189, 248, 0.16);
}

.icon-button {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 5px 15px rgba(2, 4, 14, 0.35);
}

.settings-button {
    display: grid;
    width: 48px;
    min-width: 48px;
    place-items: center;
    padding: 6px;
}

.settings-bat {
    display: block;
    width: 28px;
    height: 24px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.45));
}

.settings-button:hover .settings-bat,
.settings-button:focus-visible .settings-bat {
    animation: settings-bat-spin 750ms ease-out;
}

.settings-button.is-spinning .settings-bat {
    animation: settings-bat-spin-click 750ms ease-out;
}

main {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 36px clamp(18px, 5vw, 72px) 64px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: view-arrive 480ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hero {
    max-width: 900px;
    margin: clamp(32px, 7vh, 84px) auto;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(32px, 5vw, 54px);
    line-height: 1.08;
}

h1::after {
    display: inline-block;
    margin-left: 0.18em;
    color: var(--accent);
    content: "☾";
    font-size: 0.48em;
    text-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
    vertical-align: 0.28em;
}

#homeView .home-title-row {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.8vw, 16px);
}

#homeView .home-title-row h1 {
    margin-bottom: 12px;
}

.home-title-logo {
    position: relative;
    display: block;
    width: clamp(86px, 11vw, 132px);
    aspect-ratio: 1;
    flex: 0 0 auto;
    overflow: hidden;
}

.home-title-logo img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    max-width: none;
    object-fit: contain;
    transform: translate(-50%, -50%);
}

.hero-copy,
.settings-copy {
    max-width: 680px;
    color: var(--muted);
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 36px;
}

.home-card {
    position: relative;
    overflow: hidden;
    display: flex;
    min-height: 220px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background:
        radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.22), transparent 48%),
        linear-gradient(145deg, #131b36, #0c1124);
    box-shadow: var(--shadow);
    color: var(--text);
    text-align: left;
    transition: border-color 240ms ease, transform 240ms ease, box-shadow 240ms ease,
        background 240ms ease;
}

.home-card:hover,
.home-card:focus-visible {
    transform: translateY(-5px);
    border-color: var(--accent);
    background:
        radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.34), transparent 52%),
        linear-gradient(145deg, #182346, #111834);
    box-shadow: 0 20px 44px rgba(2, 4, 14, 0.8), 0 0 24px rgba(56, 189, 248, 0.16);
}

.home-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 23px;
    font-weight: 750;
}

.home-card-title img {
    display: block;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    object-fit: contain;
}

.home-card-copy {
    max-width: 360px;
    color: var(--muted);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.section-heading h1 {
    margin: 0;
    font-size: clamp(30px, 4vw, 42px);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select,
.settings-dialog input[type="url"],
.settings-dialog select {
    min-height: 48px;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 4px 14px rgba(2, 4, 14, 0.35);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.toolbar input:focus,
.toolbar select:focus,
.settings-dialog input[type="url"]:focus,
.settings-dialog select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
    outline: none;
}

.toolbar input {
    flex: 1 1 250px;
}

.toolbar select {
    min-width: 155px;
}

.movie-toolbar select {
    min-width: 145px;
}

.result-count {
    margin-left: auto;
    color: var(--muted);
}

.tv-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
    gap: 22px;
    align-items: start;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.channel-card {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: 0 4px 14px rgba(2, 4, 14, 0.3);
    transition: border-color 200ms ease, background 200ms ease, transform 200ms ease,
        box-shadow 200ms ease;
}

.channel-card:hover,
.channel-card:focus-visible,
.channel-card.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
    transform: translateY(-2px);
}

.channel-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 10px;
    background: #172040;
    object-fit: contain;
}

.channel-card-details {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.channel-card-name {
    display: -webkit-box;
    overflow: hidden;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.channel-card-country {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-player-panel {
    position: sticky;
    top: 96px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #060812;
    box-shadow: 0 18px 42px rgba(2, 4, 14, 0.72);
}

.player-title {
    display: flex;
    min-height: 54px;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(100deg, #131b36, #0d1326);
    color: var(--text);
    font-weight: 700;
}

.live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-gold);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.75);
}

#tvPlayer {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #04060d;
}

.player-message {
    margin: 0;
    padding: 12px 16px;
    background: #0c1124;
    color: var(--muted);
    font-size: 13px;
}

.catalog-status {
    min-height: 24px;
    margin: 4px 0 12px;
    color: var(--muted);
}

.catalog-status.error {
    color: var(--accent-red);
}

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 18px;
}

.movie-card {
    overflow: hidden;
    padding: 0;
    border: 1px solid rgba(42, 60, 112, 0.8);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: 0 8px 24px rgba(2, 4, 14, 0.45);
    transition: border-color 220ms ease, transform 220ms ease, box-shadow 220ms ease;
}

.movie-card:hover,
.movie-card:focus-visible {
    transform: translateY(-5px) scale(1.015);
    border-color: var(--accent);
    box-shadow: 0 14px 32px rgba(2, 4, 14, 0.75), 0 0 0 3px var(--accent-soft);
}

.movie-poster {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    background: #141c38;
    object-fit: cover;
}

.movie-info {
    padding: 12px;
}

.movie-title {
    display: -webkit-box;
    overflow: hidden;
    min-height: 44px;
    margin: 0 0 6px;
    font-weight: 750;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.movie-meta,
.movie-languages {
    color: var(--muted);
    font-size: 12px;
}

.movie-languages {
    margin-top: 5px;
    color: var(--accent);
    font-weight: 700;
}

.movie-overview {
    display: -webkit-box;
    overflow: hidden;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.movie-genres {
    margin-top: 8px;
    color: var(--accent-gold);
    font-size: 11px;
    font-weight: 750;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 28px;
    color: var(--muted);
}

.back-button {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.movie-dialog,
.settings-dialog {
    width: min(1000px, calc(100vw - 28px));
    max-width: none;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(145deg, #131b36, #0a0e1f);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(2, 4, 14, 0.85);
}

.movie-dialog {
    display: flex;
    flex-direction: column;
    height: min(760px, calc(100dvh - 28px));
}

.movie-dialog:not([open]) {
    display: none;
}

.movie-dialog[open] {
    display: flex;
}

.movie-dialog::backdrop,
.settings-dialog::backdrop {
    background: rgba(4, 6, 15, 0.78);
    backdrop-filter: blur(8px);
}

.dialog-header {
    display: flex;
    flex: 0 0 auto;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dialog-header h2,
.settings-dialog h2 {
    margin: 0;
}

.movie-header-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.movie-player-shell {
    position: relative;
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
    border-radius: 12px;
    background: #04060d;
}

#seriesControls[hidden] {
    display: none;
}

.series-controls:not([hidden]) {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: minmax(130px, 0.8fr) minmax(200px, 1.2fr);
    align-items: end;
    gap: 12px;
    padding: 4px 0 14px;
}

.series-field {
    display: grid;
    min-width: 0;
    gap: 5px;
    color: var(--text);
    font-size: 13px;
    font-weight: 750;
}

.series-field select,
.series-field input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.series-episode-field {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) auto;
    align-items: end;
    gap: 8px;
}

.series-episode-buttons {
    display: flex;
    gap: 6px;
}

.series-episode-buttons .back-button {
    min-width: 42px;
    padding-inline: 10px;
    font-size: 18px;
    line-height: 1;
}

.series-status {
    grid-column: 1 / -1;
    min-height: 1.3em;
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.welcome-dialog {
    position: relative;
    width: min(580px, calc(100vw - 28px));
    max-width: none;
    max-height: calc(100dvh - 28px);
    overflow: auto;
    padding: clamp(22px, 5vw, 38px);
    border: 1px solid var(--border);
    border-radius: 28px;
    background:
        radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.22), transparent 48%),
        linear-gradient(145deg, #131b36, #0a0e1f);
    color: var(--text);
    text-align: center;
    box-shadow: 0 24px 70px rgba(2, 4, 14, 0.85);
}

.welcome-dialog::before,
.welcome-dialog::after {
    position: absolute;
    z-index: 0;
    color: rgba(56, 189, 248, 0.24);
    font-family: "Segoe UI Symbol", serif;
    font-size: clamp(1.8rem, 4.5vw, 2.8rem);
    line-height: 1;
    pointer-events: none;
    animation: popup-star-drift 8s ease-in-out infinite;
}

.welcome-dialog::before {
    top: 8%;
    left: 7%;
    content: "✦";
    text-shadow:
        72px 22px 0 rgba(139, 92, 246, 0.2),
        22px 150px 0 rgba(56, 189, 248, 0.18),
        110px 300px 0 rgba(245, 158, 11, 0.18);
}

.welcome-dialog::after {
    right: 7%;
    bottom: 8%;
    color: rgba(139, 92, 246, 0.24);
    content: "☾";
    text-shadow:
        -72px -22px 0 rgba(56, 189, 248, 0.18),
        -22px -150px 0 rgba(139, 92, 246, 0.2),
        -110px -300px 0 rgba(56, 189, 248, 0.18);
    animation-delay: -4s;
}

.welcome-dialog[open] {
    animation: welcome-appear 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.welcome-dialog::backdrop {
    background: rgba(4, 6, 15, 0.82);
    backdrop-filter: blur(9px);
}

.welcome-content {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 16px;
}

.welcome-content .eyebrow,
.welcome-content h2 {
    margin: 0;
}

.welcome-content h2 {
    font-size: clamp(25px, 5vw, 36px);
    line-height: 1.15;
}

.welcome-video-ad {
    position: relative;
    width: min(100%, 480px);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 20px;
    background: #060913;
    box-shadow: 0 12px 32px rgba(2, 4, 14, 0.7);
}

.welcome-ad-prompt {
    max-width: 42ch;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

#welcomeAdVideo,
#welcomeAdContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#welcomeAdVideo {
    object-fit: contain;
}

.welcome-ad-status {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.welcome-audio-hint {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.welcome-dialog .primary-button {
    min-width: 210px;
}

#movieFrame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: inherit;
    background: #04060d;
}

.movie-description-overlay {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    height: 50%;
    flex-direction: column;
    gap: 8px;
    padding: 12px clamp(14px, 3vw, 26px) 18px;
    color: #fff;
    background: linear-gradient(
        to top,
        rgba(8, 11, 24, 0.97) 0%,
        rgba(19, 27, 54, 0.9) 68%,
        rgba(19, 27, 54, 0) 100%
    );
    text-shadow: 0 1px 6px rgba(2, 4, 14, 0.85);
    transition: transform 320ms ease, opacity 320ms ease,
        visibility 0s linear 320ms;
}

.movie-description-overlay.is-lowered {
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.movie-overlay-lower {
    display: inline-flex;
    min-height: 34px;
    flex: 0 0 auto;
    align-items: center;
    align-self: flex-end;
    gap: 7px;
    padding: 6px 11px;
    border: 1px solid rgba(56, 189, 248, 0.55);
    border-radius: 999px;
    background: rgba(8, 11, 24, 0.65);
    color: var(--accent);
    font: inherit;
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
    text-shadow: inherit;
}

.movie-overlay-lower:hover,
.movie-overlay-lower:focus-visible {
    background: rgba(56, 189, 248, 0.2);
    color: #fff;
}

.movie-overlay-copy {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 2px 3px 4px 0;
    overscroll-behavior: contain;
}

.movie-overlay-copy h3 {
    margin: 0 0 6px;
    font-size: clamp(17px, 2.2vw, 24px);
    line-height: 1.2;
}

.movie-overlay-copy p {
    margin: 0;
    font-size: clamp(13px, 1.45vw, 16px);
    line-height: 1.5;
    white-space: pre-line;
}

.settings-dialog {
    width: min(520px, calc(100vw - 28px));
}

.settings-dialog form {
    display: grid;
    gap: 14px;
}

.settings-dialog input[type="url"],
.settings-dialog select {
    width: 100%;
}

.field-label,
.checkbox-label {
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--muted);
}

.checkbox-label input {
    margin-top: 4px;
    accent-color: var(--accent);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-violet));
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.25);
    color: #060913;
    font-weight: 750;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(56, 189, 248, 0.36);
}

.back-button:disabled,
.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
    box-shadow: none;
}

.toast {
    position: fixed;
    z-index: 8;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 12px 16px;
    transform: translateY(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #131b36;
    color: var(--text);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

@keyframes nocturnal-wander {
    0%,
    100% {
        transform: translate3d(0, 0, 0) rotate(-14deg) scale(0.95);
    }

    25% {
        transform: translate3d(34px, -42px, 0) rotate(10deg) scale(1.04);
    }

    55% {
        transform: translate3d(-18px, -68px, 0) rotate(22deg) scale(1.08);
    }

    80% {
        transform: translate3d(-42px, -22px, 0) rotate(-6deg) scale(0.98);
    }
}

@keyframes popup-star-drift {
    0%,
    100% {
        transform: translate3d(0, 0, 0) rotate(-12deg);
    }

    50% {
        transform: translate3d(8px, -12px, 0) rotate(12deg);
    }
}

@keyframes bat-glide {
    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-14px) rotate(3deg);
    }
}

@keyframes view-arrive {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes welcome-appear {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes settings-bat-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes settings-bat-spin-click {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 850px) {
    .tv-layout {
        grid-template-columns: 1fr;
    }

    .tv-player-panel {
        position: static;
        grid-row: 1;
    }
}

@media (max-width: 960px) {
    .topbar {
        flex-wrap: wrap;
        gap: 10px 20px;
    }

    .main-nav {
        order: 3;
        flex: 1 0 100%;
        justify-content: center;
    }

    .brand-mark {
        width: 68px;
        height: 68px;
        flex-basis: 68px;
    }

    main {
        padding-top: 28px;
    }
}

@media (max-width: 620px) {
    .topbar {
        gap: 8px 12px;
        padding: 8px 12px;
    }

    .brand {
        gap: 7px;
        font-size: 19px;
    }

    .brand-mark {
        width: 54px;
        height: 54px;
        flex-basis: 54px;
    }

    .topbar > .icon-button {
        min-height: 38px;
        padding: 7px 11px;
    }

    .main-nav {
        gap: 5px;
    }

    .nav-button,
    .icon-button,
    .back-button,
    .primary-button {
        min-height: 40px;
        padding: 8px 12px;
        border-radius: 12px;
    }

    main {
        padding: 20px 14px 40px;
    }

    .hero {
        margin: 24px auto 36px;
    }

    h1 {
        font-size: clamp(29px, 8vw, 42px);
    }

    .section-heading {
        gap: 12px;
        margin-bottom: 16px;
    }

    .section-heading h1 {
        font-size: clamp(26px, 7vw, 36px);
    }

    .section-heading .back-button {
        flex: 0 0 auto;
    }

    .home-actions {
        gap: 14px;
        margin-top: 24px;
        grid-template-columns: 1fr;
    }

    .home-card {
        min-height: 170px;
        padding: 20px;
        border-radius: 18px;
    }

    .home-card-title {
        font-size: 20px;
    }

    .toolbar {
        gap: 9px;
    }

    .toolbar input,
    .toolbar select {
        min-width: 0;
        min-height: 44px;
    }

    .toolbar input {
        flex-basis: 100%;
    }

    .toolbar select {
        flex: 1 1 calc(50% - 9px);
        width: 100%;
    }

    .result-count {
        margin-left: 0;
    }

    .tv-layout {
        gap: 16px;
    }

    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 175px), 1fr));
        gap: 9px;
    }

    .channel-card {
        gap: 9px;
        padding: 9px;
    }

    .channel-logo {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 145px), 1fr));
        gap: 10px;
    }

    .movie-info {
        padding: 9px;
    }

    .movie-title {
        min-height: 40px;
        font-size: 14px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 10px;
    }

    .movie-dialog,
    .settings-dialog,
    .welcome-dialog {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        padding: 14px;
        border-radius: 20px;
    }

    .movie-dialog {
        height: calc(100dvh - 20px);
    }

    .dialog-header {
        min-height: 56px;
    }

    .movie-header-actions {
        gap: 5px;
    }

    .movie-header-actions .icon-button {
        padding-inline: 9px;
        font-size: 12px;
    }

    .series-controls:not([hidden]) {
        grid-template-columns: 1fr;
        gap: 9px;
        padding-bottom: 10px;
    }

    .movie-description-overlay {
        gap: 5px;
        padding: 8px 12px 12px;
    }

    .movie-overlay-lower {
        min-height: 30px;
        padding: 5px 9px;
    }

    .series-episode-field {
        grid-template-columns: minmax(90px, 1fr) auto;
    }

    .series-status {
        grid-column: auto;
    }

    .welcome-content {
        gap: 12px;
    }

    .welcome-content h2 {
        font-size: clamp(23px, 6vw, 30px);
    }

    .welcome-dialog::before,
    .welcome-dialog::after {
        font-size: 1.8rem;
    }

    .welcome-dialog::before {
        text-shadow:
            55px 20px 0 rgba(139, 92, 246, 0.2),
            20px 120px 0 rgba(56, 189, 248, 0.18);
    }

    .welcome-dialog::after {
        text-shadow:
            -55px -20px 0 rgba(56, 189, 248, 0.18),
            -20px -120px 0 rgba(139, 92, 246, 0.2);
    }

    .welcome-dialog .primary-button {
        width: 100%;
        min-width: 0;
    }

    .view.active::before {
        top: 36vh;
        left: 4vw;
        font-size: 1.8rem;
    }

    .view.active::after {
        right: 4vw;
        bottom: 17vh;
        font-size: 1.8rem;
    }

    main::before {
        top: 30vh;
        left: -0.5rem;
        font-size: 4.5rem;
    }

    main::after {
        right: -0.5rem;
        bottom: 2vh;
        font-size: 5rem;
    }
}

@media (max-width: 380px) {
    .brand {
        font-size: 17px;
    }

    .brand-mark {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }

    .topbar > .icon-button {
        padding-inline: 8px;
        font-size: 13px;
    }

    .nav-button {
        padding-inline: 10px;
        font-size: 14px;
    }

    .movie-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .movie-header-actions .icon-button {
        padding-inline: 7px;
        font-size: 11px;
    }

    .channel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .topbar {
        position: relative;
        gap: 6px 14px;
        padding-block: 6px;
    }

    .brand-mark {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }

    .main-nav {
        flex: 0 1 auto;
        order: initial;
        margin-left: auto;
    }

    main {
        padding-top: 16px;
    }

    .hero {
        margin-block: 16px 28px;
    }

    .welcome-dialog {
        width: min(760px, calc(100vw - 24px));
        padding: 14px 20px;
    }

    .welcome-content {
        gap: 9px;
    }

    .series-controls:not([hidden]) {
        grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1.2fr);
    }
}

/* ===================================================================
   Lecture en cours : on rend tout le budget de composition a la video.
   Sur les navigateurs TV (GPU faible, pas de surcouche de composition
   genereuse), les calques animes en permanence + les deux flous plein
   ecran saturent le thread de rendu. Le player tiers n'arrive alors plus
   a alimenter ses buffers MSE -> micro-coupures et "chargement" toutes
   les quelques secondes. On gele tout pendant la lecture.
   =================================================================== */
html.film-playing body::before,
html.film-playing body::after,
html.film-playing main::before,
html.film-playing main::after,
html.film-playing .view.active::before,
html.film-playing .view.active::after,
html.film-playing .welcome-dialog::before,
html.film-playing .welcome-dialog::after {
    display: none;
}

html.film-playing .topbar,
html.film-playing .movie-dialog::backdrop {
    backdrop-filter: none;
}

html.film-playing .movie-dialog::backdrop {
    background: #04060d;
}

html.film-playing .movie-grid,
html.film-playing .channel-grid {
    display: none;
}

html.film-playing .view.active {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after,
    main::before,
    main::after,
    .view.active::before,
    .view.active::after,
    .welcome-dialog::before,
    .welcome-dialog::after,
    .settings-bat {
        animation: none;
    }

    .view.active {
        animation: none;
    }
}

