:root {
    --watch-player-max-h: 50dvh;
}

@media (max-width: 900px) {
    :root {
        --watch-player-max-h: 40dvh;
    }
}

/* Tam ekran izleme sayfası */
.watch-page {
    overflow: hidden;
    height: 100dvh;
    background: var(--bg-primary);
}

.watch-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 100vw;
    overflow: hidden;
}

.watch-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: rgba(10, 10, 15, 0.96);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 10;
}

.watch-back {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s;
}

.watch-back:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.watch-header-text {
    min-width: 0;
    flex: 1;
}

.watch-title {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.watch-episode-label {
    font-size: 12px;
    color: var(--text-muted);
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watch-main {
    flex: 1 1 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    min-height: 0;
    overflow: hidden;
}

.watch-player-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #000;
}

.watch-source-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(10, 10, 15, 0.96);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.watch-source-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.watch-source-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.watch-source-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.player-source-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.player-source-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.player-source-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

/* Varsayılan: kendi player — tam genişlik */
.watch-player-wrap {
    flex: 1 1 auto;
    position: relative;
    width: 100%;
    min-height: 220px;
    max-height: calc(100dvh - 220px);
    background: #000;
    overflow: hidden;
}

.watch-player-wrap #artplayerContainer {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
}

.player-embed-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

.player-embed-frame {
    position: absolute;
    inset: 0;
    border: 0;
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}

.player-embed-wrap--vimeo .player-embed-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Vimeo / embed: dikey oran, ortalanmış */
.watch-player-wrap.watch-player-wrap--embed {
    flex: 0 0 auto;
    width: min(100%, calc((100dvh - 220px) * 9 / 16));
    aspect-ratio: 9 / 16;
    max-height: calc(100dvh - 220px);
    margin-inline: auto;
}

.watch-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    position: relative;
    z-index: 6;
    background: var(--bg-secondary);
}

.watch-toolbar .player-embed-fs-btn {
    margin-left: auto;
}

.watch-player-wrap.watch-player-wrap--fs {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    aspect-ratio: unset !important;
    margin: 0 !important;
}

body.watch-embed-fs-active {
    overflow: hidden;
}

body.watch-embed-fs-active .watch-toolbar .player-embed-fs-btn {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
    z-index: 10000;
}

.watch-actions {
    flex-shrink: 0;
    padding: 12px 16px 16px !important;
    background: var(--bg-secondary);
}

.watch-actions .player-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.watch-actions .player-action-btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
}

.watch-episode-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100% !important;
    height: 100%;
    overflow: hidden;
    border-left: 1px solid var(--border-color);
}

.watch-episode-panel .player-sidebar-header {
    flex-shrink: 0;
}

.watch-episode-panel .episode-list-vertical {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.watch-ep-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.watch-page .player-sidebar-header {
    padding: 14px 16px;
}

/* player.css modal kurallarının watch sayfasına karışmasını engelle */
.watch-page .watch-player-wrap.artplayer-wrap {
    min-height: 220px;
}

@media (max-width: 900px) {
    html:has(body.watch-page),
    body.watch-page {
        overflow: hidden !important;
        height: 100dvh;
        width: 100%;
        /* position:fixed iOS'ta iç scroll'u kilitler — sadece yükseklik sınırla */
        overscroll-behavior: none;
    }

    .watch-page .watch-player-wrap.artplayer-wrap:not(.watch-player-wrap--embed):not(.watch-player-wrap--fs) {
        height: var(--watch-player-max-h, 42dvh) !important;
        max-height: var(--watch-player-max-h, 42dvh) !important;
        min-height: min(180px, 34dvh) !important;
    }

    .watch-page {
        overflow: hidden;
        height: 100dvh;
        min-height: 0;
    }

    .watch-app {
        height: 100dvh;
        min-height: 0;
        max-height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .watch-header {
        flex-shrink: 0;
    }

    .watch-main {
        display: flex;
        flex-direction: column;
        flex: 1 1 0;
        min-height: 0;
        overflow: hidden;
    }

    .watch-player-column {
        position: relative;
        top: auto;
        z-index: 1;
        flex: 0 0 auto;
        min-height: 0;
        overflow: hidden;
        box-shadow: none;
    }

    /* Player sabit yükseklik — kalan alan bölüm listesine */
    .watch-player-wrap:not(.watch-player-wrap--embed):not(.watch-player-wrap--fs) {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        height: var(--watch-player-max-h, 42dvh);
        max-height: var(--watch-player-max-h, 42dvh);
        min-height: min(180px, 34dvh);
        aspect-ratio: unset;
        margin-inline: 0;
        transition: none;
    }

    .watch-player-wrap.watch-player-wrap--embed:not(.watch-player-wrap--fs) {
        flex: 0 0 auto;
        width: min(100%, calc(var(--watch-player-max-h, 42dvh) * 9 / 16));
        aspect-ratio: 9 / 16;
        max-height: var(--watch-player-max-h, 42dvh);
        margin-inline: auto;
        transition: none;
    }

    body.watch-player-compact .watch-actions {
        padding-top: 8px !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }

    body.watch-player-compact .watch-actions .player-action-btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    .watch-toolbar {
        flex-shrink: 0;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .watch-toolbar .player-ep-counter {
        order: 0;
        width: 100%;
        text-align: center;
        margin-bottom: 2px;
    }

    .watch-toolbar #btnPrevEp {
        order: 1;
        flex: 1;
        min-width: 0;
    }

    .watch-toolbar .player-embed-fs-btn {
        order: 2;
        flex: 1;
        min-width: 0;
        justify-content: center;
        margin-left: 0;
    }

    .watch-toolbar #btnNextEp {
        order: 3;
        flex: 1;
        min-width: 0;
    }

    .watch-toolbar .player-nav-btn {
        padding: 10px 12px;
        font-size: 12px;
        justify-content: center;
    }

    .watch-actions {
        flex-shrink: 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }

    .watch-episode-panel {
        flex: 1 1 0;
        min-height: 0;
        max-height: none !important;
        height: auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-bottom: 0;
        position: relative;
        z-index: 2;
        touch-action: pan-y;
    }

    .watch-episode-panel .player-sidebar-header {
        flex-shrink: 0;
    }

    /* iOS: flex column içinde scroll için block + sabit yükseklik (JS ile de ayarlanır) */
    .watch-episode-panel .episode-list-vertical {
        flex: 1 1 0;
        min-height: 0;
        max-height: none;
        display: block;
        overflow-y: scroll !important;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        padding: 10px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .watch-episode-panel .episode-list-vertical .episode-btn {
        display: flex;
        margin-bottom: 6px;
    }

    .watch-episode-panel .episode-list-vertical .episode-btn:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .watch-header {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .watch-title {
        font-size: 14px;
    }

    .watch-episode-panel {
        min-height: 0;
    }

    .watch-toolbar .player-nav-btn span {
        display: inline;
    }
}
