/* ═══ YouTube Mobile App Player (YTM) ═══ */

.ytm-watch { background: #0f0f0f; min-height: 100dvh; }
.ytm-watch__info { padding: 12px 16px 24px; }
.ytm-watch__title {
    font-size: 16px; font-weight: 600; line-height: 1.35;
    color: #f1f1f1; margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ytm-watch__meta { font-size: 13px; color: #aaa; margin-bottom: 12px; }
.ytm-chips {
    display: flex; gap: 8px; flex-wrap: wrap; overflow-x: auto;
    padding-bottom: 4px;
}
.ytm-chip {
    flex-shrink: 0; padding: 8px 14px; border-radius: 999px;
    background: rgba(255,255,255,0.1); border: none;
    color: #f1f1f1; font-size: 13px; font-weight: 500; cursor: pointer;
}
.ytm-chip:hover { background: rgba(255,255,255,0.16); }
.ytm-chip:disabled { opacity: 0.35; pointer-events: none; }
.ytm-chip--gold { background: rgba(212,175,55,0.2); color: var(--gold, #d4af37); }

/* Action bar — gaya YouTube app */
.ytm-action-bar {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 2px 0 14px;
    margin-bottom: 2px;
    scrollbar-width: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ytm-action-bar::-webkit-scrollbar { display: none; }
.ytm-action-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 72px;
    padding: 6px 8px 10px;
    background: none;
    border: none;
    border-radius: 10px;
    color: #f1f1f1;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.ytm-action-btn__icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    transition: background 0.15s, color 0.15s;
}
.ytm-action-btn svg {
    width: 20px; height: 20px; fill: currentColor;
}
.ytm-action-btn:active .ytm-action-btn__icon { background: rgba(255,255,255,0.18); }
.ytm-action-btn:disabled { opacity: 0.35; pointer-events: none; }
.ytm-action-btn:disabled .ytm-action-btn__icon { background: rgba(255,255,255,0.05); }
.ytm-action-btn.active { color: var(--gold, #d4af37); }
.ytm-action-btn.active .ytm-action-btn__icon { background: rgba(212,175,55,0.2); }

/* Player shell = YTM mode */
.ytm-player {
    position: absolute; inset: 0;
    background: #000; overflow: visible;
}
.ytm-player .yt-player__media {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
}

/* Auto aspect — vertical fills width like YT app */
.player-stage--ytm { width: 100%; margin: 0 auto; background: #000; }
.player-wrap--vertical {
    width: 100%;
    max-width: 100%;
    aspect-ratio: var(--video-ar, 9 / 16);
    max-height: min(calc(100vw * 16 / 9), 78vh);
}
.player-wrap--horizontal {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: min(calc(100vw * 9 / 16), 56vw);
}
@media (orientation: landscape) and (max-height: 500px) {
    .player-wrap--vertical,
    .player-wrap--horizontal {
        max-height: 100vh;
        aspect-ratio: unset;
        height: 100vh;
    }
}

/* Hide desktop resize in YTM */
.ytm-watch .yt-stage-resize { display: none; }
.ytm-watch .yt-stage-ratio { display: none; }

/* Thin progress bar (always visible like YT app) */
.ytm-progress {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 12;
    height: 3px; padding: 0;
}
.ytm-progress__track {
    position: relative; height: 100%; background: rgba(255,255,255,0.25);
}
.ytm-progress__track:hover,
.yt-player--show-controls .ytm-progress { height: 5px; }
.ytm-progress__buffer,
.ytm-progress__played {
    position: absolute; top: 0; left: 0; height: 100%;
}
.ytm-progress__buffer { background: rgba(255,255,255,0.35); width: 0; }
.ytm-progress__played { background: #ff0000; width: 0; z-index: 1; }
.ytm-progress__seek {
    position: absolute; inset: -10px 0; width: 100%; height: calc(100% + 20px);
    opacity: 0; cursor: pointer; z-index: 2; margin: 0;
}

/* Tap overlay */
.ytm-overlay {
    position: absolute; inset: 0; z-index: 8;
    pointer-events: none;
    opacity: 0; transition: opacity 0.2s;
}
.yt-player--show-controls .ytm-overlay,
.yt-player--paused .ytm-overlay { opacity: 1; pointer-events: auto; }
.ytm-overlay__scrim {
    position: absolute; inset: 0;
    background: linear-gradient(to bottom,
        rgba(0,0,0,0.55) 0%, transparent 22%,
        transparent 55%, rgba(0,0,0,0.65) 100%);
    pointer-events: none;
}
.ytm-overlay__ui {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    justify-content: space-between;
    padding: 8px 8px 14px;
    pointer-events: none;
}
.ytm-overlay__ui > * { pointer-events: auto; }

/* Top bar */
.ytm-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 4px 0;
}
.ytm-top__right { display: flex; align-items: center; gap: 2px; }
.ytm-icon-btn {
    width: 40px; height: 40px; padding: 8px;
    background: none; border: none; border-radius: 50%;
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ytm-icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.ytm-icon-btn:active { background: rgba(255,255,255,0.12); }
.ytm-icon-btn.active { color: var(--gold, #d4af37); background: rgba(212,175,55,0.15); }
.ytm-autoplay {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 8px; border-radius: 4px;
    background: rgba(255,255,255,0.15); border: none;
    color: #fff; font-size: 11px; cursor: pointer;
}
.ytm-autoplay.active { background: rgba(255,255,255,0.28); }

/* Center controls */
.ytm-center {
    display: flex; align-items: center; justify-content: center;
    gap: 28px; flex: 1;
    pointer-events: none;
}
.ytm-center-btn {
    width: 48px; height: 48px; padding: 0;
    background: none; border: none; color: #fff;
    cursor: pointer; pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.85;
}
.ytm-center-btn svg { width: 36px; height: 36px; fill: currentColor; }
.ytm-center-btn--lg {
    width: 64px; height: 64px;
    background: rgba(0,0,0,0.35); border-radius: 50%;
}
.ytm-center-btn--lg svg { width: 44px; height: 44px; }
.ytm-center-btn:disabled { opacity: 0.25; pointer-events: none; }
.ytm-center-btn--seek { font-size: 13px; font-weight: 700; flex-direction: column; gap: 2px; }
.ytm-center-btn--seek span { font-size: 10px; }

/* Bottom row portrait */
.ytm-bottom {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 4px;
    gap: 8px;
}
.ytm-bottom__actions {
    display: flex; align-items: center; gap: 2px;
}
.ytm-time-pill {
    font-size: 12px; color: #fff; font-variant-numeric: tabular-nums;
    background: rgba(0,0,0,0.55); padding: 4px 10px; border-radius: 4px;
}

/* Captions YTM style */
.ytm-player .yt-captions {
    bottom: 20px; font-size: 16px;
    background: rgba(0,0,0,0.65); padding: 6px 12px;
    text-shadow: none;
}
.yt-player--show-controls .yt-captions { bottom: 28px; }

/* Landscape / fullscreen immersive */
.player-stage:fullscreen,
.ytm-player--landscape {
    width: 100vw; height: 100vh;
}
.player-stage:fullscreen .player-wrap,
.ytm-player--landscape .player-wrap {
    width: 100%; height: 100%; max-height: none;
    aspect-ratio: unset !important;
}
.ytm-landscape-bar {
    display: none;
    position: absolute; bottom: 48px; left: 0; right: 0;
    justify-content: center; gap: 20px; padding: 0 16px;
}
.ytm-player--landscape .ytm-landscape-bar,
.player-stage:fullscreen .ytm-landscape-bar { display: flex; }
.ytm-player--landscape .ytm-center-btn--seek,
.player-stage:fullscreen .ytm-center-btn--seek { display: flex; }

/* Bottom sheet — premium settings panel */
.ytm-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
}
.ytm-sheet-backdrop:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.ytm-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 501;
    max-height: 86vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 22px 22px 0 0;
    background: linear-gradient(180deg, #24242c 0%, #16161c 48%, #101014 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 -1px 0 rgba(212, 175, 55, 0.12),
        0 -24px 64px rgba(0, 0, 0, 0.55);
    transform: translateY(105%);
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
}
.ytm-sheet:not(.hidden) {
    transform: translateY(0);
    pointer-events: auto;
}
.ytm-sheet.hidden {
    transform: translateY(105%);
}

.ytm-sheet__handle {
    width: 40px;
    height: 4px;
    border-radius: 99px;
    margin: 10px auto 4px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.22);
}

/* Header */
.ytm-sheet__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 14px;
    flex-shrink: 0;
}
.ytm-sheet__head h3 {
    flex: 1;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #f5f5f7;
    letter-spacing: -0.02em;
    text-align: center;
}
.ytm-sheet__head--main {
    flex-direction: column;
    align-items: center;
    padding: 4px 20px 10px;
    border-bottom: none;
}
.ytm-sheet__head--main h3 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}
.ytm-sheet__sub {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
}
.ytm-sheet__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #f1f1f1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.ytm-sheet__close:hover,
.ytm-sheet__close:active {
    background: rgba(255, 255, 255, 0.14);
}
.ytm-sheet__close svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}
.ytm-sheet__head-spacer {
    width: 40px;
    flex-shrink: 0;
}

/* Body & groups */
.ytm-sheet__body {
    overflow-y: auto;
    padding: 0 0 calc(20px + env(safe-area-inset-bottom, 0px));
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.ytm-sheet__body--options {
    padding-top: 4px;
}
.ytm-sheet-group {
    margin-bottom: 18px;
}
.ytm-sheet-group:last-child {
    margin-bottom: 8px;
}
.ytm-sheet-section__label {
    padding: 0 22px 8px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.38);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Card container */
.ytm-sheet-card {
    margin: 0 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    overflow: hidden;
}
.ytm-sheet-card + .ytm-sheet-card,
.ytm-cc-mute-row {
    margin-top: 12px;
}
.ytm-sheet-card > .ytm-sheet-row:not(:last-child),
.ytm-sheet-card > button.ytm-sheet-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ytm-sheet-card > .ytm-sheet-option:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Rows */
.ytm-sheet-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 12px 16px;
    background: none;
    border: none;
    color: #f3f3f5;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.ytm-sheet-row:hover,
.ytm-sheet-row:active {
    background: rgba(255, 255, 255, 0.05);
}
.ytm-sheet-row.hidden {
    display: none;
}
.ytm-sheet-row--static {
    cursor: default;
}
.ytm-sheet-row--static:hover,
.ytm-sheet-row--static:active {
    background: none;
}

/* Icon badges */
.ytm-sheet-row__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
}
.ytm-sheet-row__icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
.ytm-sheet-row__icon--pip {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(37, 99, 235, 0.2));
}
.ytm-sheet-row__icon--mini {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(124, 58, 237, 0.2));
}
.ytm-sheet-row__icon--fullscreen {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.35), rgba(22, 163, 74, 0.2));
}
.ytm-sheet-row__icon--theater {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.35), rgba(234, 88, 12, 0.2));
}
.ytm-sheet-row__icon--quality {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.35), rgba(8, 145, 178, 0.2));
}
.ytm-sheet-row__icon--speed {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(219, 39, 119, 0.2));
}
.ytm-sheet-row__icon--audio {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.35), rgba(220, 38, 38, 0.2));
}
.ytm-sheet-row__icon--cc {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.35), rgba(13, 148, 136, 0.2));
}
.ytm-sheet-row__icon--more {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.35), rgba(100, 116, 139, 0.2));
}
.ytm-sheet-row__icon--sleep {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(79, 70, 229, 0.2));
}
.ytm-sheet-row__icon--default {
    background: rgba(255, 255, 255, 0.1);
}

.ytm-sheet-row__label {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}
.ytm-sheet-row__value {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.08);
    margin-right: 2px;
}
.ytm-sheet-row__chev {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.45;
}
.ytm-sheet-row__chev svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    color: rgba(255, 255, 255, 0.6);
}

/* Toggle switch */
.ytm-sheet-toggle {
    width: 48px;
    height: 28px;
    border-radius: 99px;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.22s ease;
}
.ytm-sheet-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e8e8ea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1), background 0.22s;
}
.ytm-sheet-toggle.active {
    background: linear-gradient(135deg, #e8c547, #d4af37);
}
.ytm-sheet-toggle.active::after {
    transform: translateX(20px);
    background: #fff;
}

/* Option list (sub-menus) */
.ytm-sheet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 52px;
    padding: 14px 18px;
    background: none;
    border: none;
    color: #ececf0;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ytm-sheet-option:hover,
.ytm-sheet-option:active {
    background: rgba(255, 255, 255, 0.05);
}
.ytm-sheet-option.active {
    color: var(--gold, #e8c547);
    font-weight: 600;
}
.ytm-sheet-option.active::after {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gold, #d4af37);
    flex-shrink: 0;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 14px no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.ytm-sheet-divider {
    height: 1px;
    margin: 8px 22px;
    background: rgba(255, 255, 255, 0.06);
}

/* CC section */
.ytm-cc-section__label {
    padding: 14px 22px 8px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.38);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.ytm-cc-empty {
    padding: 12px 22px 20px;
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.42);
    line-height: 1.45;
}

/* Hide legacy desktop bar in YTM */
.ytm-player .yt-player__controls,
.ytm-player .yt-player__big-play,
.ytm-player .yt-player__title { display: none !important; }

.ytm-player .yt-mini-drag {
    display: none;
    position: absolute; top: 0; left: 0; right: 0; z-index: 20;
    height: 28px; cursor: grab; align-items: center; justify-content: center;
}
.ytm-player .yt-mini-drag:not(.hidden) { display: flex; }
.player-stage--mini .ytm-overlay { opacity: 0 !important; pointer-events: none !important; }

/* Loader */
.ytm-player .yt-player__loader { z-index: 15; }
