:root {
    color-scheme: dark;
    --bg: #0c0f14;
    --panel: #151b23;
    --panel-2: #1d2631;
    --text: #edf2f7;
    --muted: #98a6b8;
    --line: #2b3543;
    --accent: #e7473c;
    --accent-2: #35b7a6;
    --focus: #f4c542;
}

* {
    box-sizing: border-box;
}

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

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

button,
input,
select,
textarea {
    font: inherit;
}

button,
.primary {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    min-height: 42px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
}

button:hover,
.primary:hover {
    filter: brightness(1.08);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f141b;
    color: var(--text);
    min-height: 42px;
    padding: 10px 12px;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 68px;
    padding: 0 clamp(18px, 4vw, 56px);
    background: rgba(12, 15, 20, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(18px);
}

.topbar.overlay {
    position: fixed;
    width: 100%;
}

.brand {
    font-weight: 900;
    letter-spacing: 0;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 18px;
    color: var(--muted);
}

.topbar nav a:hover {
    color: var(--text);
}

.page {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 34px clamp(16px, 4vw, 56px) 64px;
}

.library-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 28px;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(34px, 5vw, 72px);
    line-height: 0.95;
}

h2 {
    font-size: 22px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 9px;
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted,
small {
    color: var(--muted);
}

.search {
    display: flex;
    width: min(460px, 100%);
    gap: 10px;
}

.section {
    margin-top: 34px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
}

.tabs a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 14px;
    color: var(--muted);
}

.tabs a.active {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(231, 71, 60, 0.14);
}

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

.poster-card {
    display: grid;
    gap: 10px;
}

.poster,
.thumb {
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #232b36, #111820);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.poster {
    aspect-ratio: 2 / 3;
    border-radius: 8px;
}

.poster img,
.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poster span,
.thumb span {
    font-size: 54px;
    font-weight: 900;
    color: var(--accent-2);
}

.rail {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.wide-card {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 13px;
    align-items: center;
    min-height: 100px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.thumb {
    width: 74px;
    aspect-ratio: 2 / 3;
    border-radius: 6px;
}

progress {
    width: 100%;
    height: 8px;
    accent-color: var(--accent);
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-shell {
    width: min(420px, 100%);
}

.auth-panel,
.panel,
.editor-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-panel {
    padding: 28px;
}

.stack {
    display: grid;
    gap: 16px;
}

.compact {
    gap: 12px;
}

.alert,
.success,
.empty {
    border-radius: 8px;
    padding: 13px 14px;
    margin: 14px 0;
}

.alert {
    background: rgba(231, 71, 60, 0.16);
    border: 1px solid rgba(231, 71, 60, 0.45);
}

.success {
    background: rgba(53, 183, 166, 0.13);
    border: 1px solid rgba(53, 183, 166, 0.45);
}

.watch-body {
    background: #05070a;
}

.watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    min-height: 100vh;
}

.player-shell {
    display: grid;
    align-content: center;
    gap: 12px;
    padding: 84px 18px 18px;
}

video {
    width: 100%;
    max-height: calc(100vh - 160px);
    background: black;
    border-radius: 8px;
}

.player-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.player-tools label {
    width: auto;
    min-width: 130px;
}

.watch-info {
    padding: 92px 24px 24px;
    background: var(--panel);
    border-left: 1px solid var(--line);
    overflow: auto;
}

.watch-info h1 {
    font-size: 34px;
    line-height: 1.05;
}

.episode-list,
.simple-list,
.title-editor-list {
    display: grid;
    gap: 10px;
}

.episode-list a,
.simple-list > div {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: var(--panel-2);
    border: 1px solid transparent;
    border-radius: 8px;
}

.episode-list a.active {
    border-color: var(--accent);
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}

.panel {
    padding: 18px;
}

.editor-card {
    padding: 0;
}

.editor-card summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    padding: 16px;
}

.editor-card summary span {
    display: grid;
    gap: 4px;
}

.editor-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 16px 16px;
}

.editor-form .full,
.form-actions {
    grid-column: 1 / -1;
}

.inline-form,
.subtitle-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 0 16px 16px;
}

.subtitle-form {
    grid-template-columns: minmax(180px, 1fr) 82px minmax(110px, 140px) minmax(160px, 1fr) auto;
}

@media (max-width: 900px) {
    .library-head,
    .admin-grid,
    .watch-layout {
        grid-template-columns: 1fr;
    }

    .library-head {
        display: grid;
    }

    .watch-info {
        border-left: 0;
        padding-top: 24px;
    }

    .player-shell {
        min-height: auto;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: start;
        flex-direction: column;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .search,
    .inline-form,
    .subtitle-form,
    .editor-form {
        grid-template-columns: 1fr;
        display: grid;
    }

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

/* Modern UI pass */
:root {
    --bg: #080b10;
    --panel: #121821;
    --panel-2: #1a2430;
    --panel-3: #222d3a;
    --text: #f3f7fb;
    --muted: #9baabc;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #f24f45;
    --accent-2: #27c7a7;
    --warm: #f3b64d;
}

body {
    background:
        linear-gradient(180deg, rgba(39, 199, 167, 0.05), transparent 320px),
        var(--bg);
}

button,
.primary {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: var(--accent);
    box-shadow: 0 12px 30px rgba(242, 79, 69, 0.2);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
.primary:hover {
    transform: translateY(-1px);
    filter: none;
    border-color: rgba(255, 255, 255, 0.25);
}

input,
select,
textarea {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(8, 11, 16, 0.78);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(39, 199, 167, 0.75);
    box-shadow: 0 0 0 3px rgba(39, 199, 167, 0.14);
}

.topbar {
    min-height: 64px;
    background: rgba(8, 11, 16, 0.74);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar.overlay {
    background: rgba(8, 11, 16, 0.62);
}

.brand {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
}

.back-link {
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 999px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.05);
}

.page {
    padding-top: 44px;
}

.poster-card,
.wide-card,
.episode-list a,
.simple-list > div,
.editor-card,
.panel,
.auth-panel {
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18);
}

.poster-card {
    padding: 10px;
    border-radius: 12px;
    transition: transform 160ms ease, background 160ms ease;
}

.poster-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.04);
}

.poster {
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 42px rgba(0, 0, 0, 0.24);
}

.wide-card {
    border-radius: 12px;
    background: rgba(18, 24, 33, 0.78);
}

.watch-body {
    background: #05070b;
    overflow: hidden;
}

.watch-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
    min-height: 100vh;
    background: #05070b;
}

.player-shell {
    align-content: center;
    min-height: 100vh;
    padding: 86px clamp(14px, 2.5vw, 34px) 28px;
}

.cinema-card {
    display: grid;
    gap: 18px;
    width: 100%;
}

.video-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.video-frame video {
    display: block;
    width: 100%;
    max-height: calc(100vh - 210px);
    min-height: min(56vw, 440px);
    background: #000;
    border-radius: 0;
    object-fit: contain;
}

.big-play {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 104px;
    height: 104px;
    min-height: 104px;
    padding: 0;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    background: rgba(242, 79, 69, 0.92);
    box-shadow: 0 22px 70px rgba(242, 79, 69, 0.35);
}

.video-frame.is-playing .big-play {
    opacity: 0;
    pointer-events: none;
}

.player-overlay {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    gap: 10px;
    padding: 72px 18px 16px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.86));
    opacity: 1;
    transition: opacity 180ms ease;
}

.video-frame.is-playing:not(:hover):not(:focus-within) .player-overlay {
    opacity: 0;
}

.seek {
    width: 100%;
    min-height: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    accent-color: var(--accent);
    cursor: pointer;
}

.control-row,
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-row {
    justify-content: space-between;
}

.control-group.right {
    justify-content: flex-end;
}

.icon-button,
.ghost-button {
    min-height: 38px;
    border-radius: 999px;
    box-shadow: none;
}

.icon-button {
    min-width: 76px;
}

.ghost-button {
    background: rgba(255, 255, 255, 0.1);
}

.timecode {
    min-width: 118px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.mini-control {
    display: grid;
    grid-template-columns: auto minmax(86px, 118px);
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.mini-control select {
    min-height: 36px;
    border-radius: 999px;
    padding: 7px 28px 7px 12px;
}

.now-playing {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    padding: 0 4px;
}

.now-playing h1 {
    font-size: clamp(28px, 4vw, 52px);
    line-height: 1;
}

.watch-info {
    height: 100vh;
    padding: 86px 18px 22px;
    background: linear-gradient(180deg, #151c25, #10161e);
    border-left: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: -22px 0 60px rgba(0, 0, 0, 0.22);
}

.side-title {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.side-poster {
    overflow: hidden;
    display: grid;
    place-items: center;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    background: linear-gradient(145deg, #263343, #121821);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.side-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-poster span {
    color: var(--accent-2);
    font-size: 38px;
    font-weight: 900;
}

.watch-info h1 {
    font-size: 28px;
}

.watch-info h2 {
    margin-top: 20px;
}

.episode-list {
    max-height: calc(100vh - 300px);
    overflow: auto;
    padding-right: 4px;
}

.episode-list a {
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 64px;
    padding: 12px 13px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.episode-list a span {
    grid-row: 1 / span 2;
    display: grid;
    place-items: center;
    min-width: 48px;
    min-height: 38px;
    border-radius: 10px;
    background: rgba(39, 199, 167, 0.11);
    color: var(--accent-2);
    font-weight: 900;
}

.episode-list a strong {
    font-size: 14px;
}

.episode-list a.active {
    border-color: rgba(242, 79, 69, 0.85);
    background: rgba(242, 79, 69, 0.12);
}

.episode-list a:hover {
    background: rgba(255, 255, 255, 0.09);
}

@media (max-width: 1080px) {
    .watch-body {
        overflow: auto;
    }

    .watch-layout {
        grid-template-columns: 1fr;
    }

    .player-shell {
        min-height: auto;
        padding-top: 96px;
    }

    .watch-info {
        height: auto;
        border-left: 0;
        box-shadow: none;
    }

    .episode-list {
        max-height: none;
    }
}

@media (max-width: 720px) {
    .video-frame.is-playing:not(:hover):not(:focus-within) .player-overlay {
        opacity: 1;
    }

    .control-row,
    .control-group {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .control-row {
        display: grid;
    }

    .mini-control {
        grid-template-columns: 1fr;
    }

    .now-playing {
        display: grid;
    }

    .video-frame video {
        min-height: 240px;
        max-height: 62vh;
    }
}
