/* Shared top-control palette. Layout and SVG paths stay unchanged. */
.phase-play .player-top-capsule {
    --capsule-surface: rgba(18, 18, 24, .50);
    --capsule-surface-shadow: inset 0 0 0 1px rgba(255,255,255,.10), 0 2px 5px rgba(0,0,0,.12);
    --capsule-border: rgba(255, 255, 255, .10);
    --capsule-shadow: rgba(0, 0, 0, .16);
    --capsule-button: rgba(255, 255, 255, .10);
    --capsule-button-border: rgba(255, 255, 255, .10);
    --capsule-icon: #ffffff;
    --capsule-text: #ffffff;
    --capsule-hover: rgba(255, 255, 255, .16);
    --capsule-on: rgba(255, 255, 255, .22);
    --capsule-on-border: rgba(255, 255, 255, .28);
    --capsule-on-icon: #ffffff;
    --capsule-dot: #ffffff;
    --capsule-focus: #dfe4ed;
    position: absolute;
    top: 10px;
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    /* Navigation must remain reachable while the course-opening veil is up. */
    z-index: 100;
    height: 52px;
    box-sizing: border-box;
    padding: 4px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 140px;
    column-gap: 14px;
    align-items: center;
    /* Invisible layout wrapper only; individual controls keep their surfaces. */
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    cursor: default;
}

/* Inner controls never participate in legacy absolute/safe-area positioning. */
.phase-play .video-container .player-top-capsule .m-top-btn {
    position: relative;
    inset: auto !important;
    z-index: auto;
    display: flex;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0;
    border: .75px solid transparent;
    border-radius: 22px;
    color: var(--capsule-icon);
    background: var(--capsule-surface) !important;
    box-shadow: var(--capsule-surface-shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.phase-play .player-top-capsule .m-btn-back::before { content: none; }
.phase-play .player-top-capsule .m-top-btn svg {
    width: 31px;
    height: 31px;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
    pointer-events: none;
}
.phase-play .player-top-capsule .m-btn-back svg { stroke-width: 2; }
.phase-play .player-top-capsule .m-top-actions {
    position: static;
    inset: auto !important;
    z-index: auto;
    display: grid;
    grid-template-columns: repeat(3, 44px);
    gap: 4px;
    width: 140px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.phase-play .player-top-capsule .burned-mask-toggle { grid-column: 1; grid-row: 1; }
.phase-play .player-top-capsule .m-btn-caption-cycle { grid-column: 2; grid-row: 1; }
.phase-play .player-top-capsule .m-btn-share { grid-column: 3; grid-row: 1; }
.phase-play .player-top-capsule .m-top-btn[hidden] { display: none !important; }
.phase-play .player-top-capsule .m-top-actions[data-pending] {
    visibility: hidden;
    pointer-events: none;
}

/* Read-only progress shares the white foreground of the navigation icons. */
.phase-play .player-top-capsule .m-top-status {
    position: static;
    inset: auto !important;
    transform: none;
    z-index: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    text-align: left;
    cursor: default;
    pointer-events: auto;
}
.phase-play .player-top-capsule .m-top-status-line {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--capsule-text);
    text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.phase-play .player-top-capsule #mTopStatusRepeat { display: none !important; }

@media (hover: hover) and (pointer: fine) {
    .phase-play .video-container .player-top-capsule .m-top-btn:hover:not(:disabled) {
        background: var(--capsule-surface) !important;
    }
}
.phase-play .video-container .player-top-capsule .m-top-btn:active {
    color: var(--capsule-on-icon);
    background: var(--capsule-surface) !important;
    transform: none;
}
/* Stronger than hover/active, including sticky hover on touch browsers. */
.phase-play .video-container .player-top-capsule .m-top-btn[aria-pressed="true"] {
    color: var(--capsule-on-icon);
    background: var(--capsule-on) !important;
    border-color: var(--capsule-on-border);
    box-shadow: 0 2px 5px var(--capsule-shadow);
}
.phase-play .player-top-capsule .m-btn-caption-cycle::after {
    width: 3.2px;
    height: 3.2px;
    bottom: 4px;
    background: var(--capsule-dot);
}
.phase-play .player-top-capsule .m-btn-caption-cycle[aria-pressed="true"] svg {
    transform: translateY(-1.5px);
}
.phase-play .video-container .player-top-capsule .m-top-btn:focus-visible {
    outline: 2px solid var(--capsule-focus);
    outline-offset: 2px;
}

/* Keep the existing dark mask mark from burned-subtitle-mask.css. */
.phase-play .player-top-capsule .burned-mask-toggle::before {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
    background-size: 22px 22px;
    pointer-events: none;
}

/* Right-side tools share the same smoke-black surface as the back button.
   Keep the original grid and 44px hit areas, with one surface for this group. */
.phase-play .video-container .player-top-capsule .m-top-actions {
    --capsule-icon: #ffffff;
    --capsule-on-icon: #ffffff;
    position: relative;
    inset: auto !important;
    isolation: isolate;
}
.phase-play .player-top-capsule .m-top-actions::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 22px;
    background: var(--capsule-surface);
    box-shadow: var(--capsule-surface-shadow);
    pointer-events: none;
}
/* Shrink only the shared paint, not the slots: a hidden mask/share creates
   neither an empty capsule cell nor a shift in the remaining button positions. */
.phase-play .player-top-capsule .m-top-actions:not(:has(.burned-mask-toggle:not([hidden])))::before { left: 48px; }
.phase-play .player-top-capsule .m-top-actions:not(:has(.m-btn-share:not([hidden])))::before { right: 48px; }
.phase-play .video-container .player-top-capsule .m-top-actions .m-top-btn,
.phase-play .video-container .player-top-capsule .m-top-actions .m-top-btn:is(:hover, :active, :disabled, [aria-pressed="true"]) {
    background: transparent !important;
    box-shadow: none;
    border-color: transparent;
}
/* On/off feedback is an outline and the existing state dot, never a filled tile. */
.phase-play .video-container .player-top-capsule .m-top-actions .m-top-btn[aria-pressed="true"] {
    border-color: rgba(255,255,255,.50);
}
.phase-play .player-top-capsule .m-top-actions .burned-mask-toggle::before {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
    background-size: 31px 31px;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
.phase-play.css-fullscreen .player-top-capsule,
:fullscreen .player-top-capsule,
:-webkit-full-screen .player-top-capsule {
    top: max(40px, calc(env(safe-area-inset-top) + 8px));
}
/* Use measured video bounds on desktop, but never squeeze controls together
   for a narrow portrait clip. Mobile/landscape touch stays container-anchored. */
@media (min-width: 1025px) and (pointer: fine) {
    .phase-play .video-container .player-top-capsule {
        top: calc(var(--rs-media-top, 0px) + 8px);
        left: max(8px, min(calc(var(--rs-media-left, 0px) + 8px), calc((100% - 288px) / 2)));
        right: max(8px, min(calc(var(--rs-media-right, 0px) + 8px), calc((100% - 288px) / 2)));
    }
}
@media (max-width: 350px) {
    .phase-play .player-top-capsule { column-gap: 8px; }
    .phase-play .player-top-capsule .m-top-status-line { font-size: 16px; }
}
.phase-play.sentence-editing-mode .player-top-capsule { display: none !important; }
@media (prefers-reduced-motion: reduce) {
    .phase-play .player-top-capsule .m-top-btn,
    .phase-play .player-top-capsule .m-btn-caption-cycle::after { transition: none; }
}
