/* Design tokens: keep aligned with DESIGN.md. */
:root {
    --color-player-background: #000000;
    --color-player-text: #fffaf0;
    --color-player-text-rgb: 255, 250, 240;
    --color-reddit-orange: #ff4500;
    --color-reddit-orange-rgb: 255, 69, 0;
    --color-youtube-red: #cb2027;
    --color-dark-panel: rgba(18, 18, 26, 0.95);
    --color-dark-panel-rgb: 18, 18, 26;
    --control-glass: rgba(var(--color-reddit-orange-rgb), 0.1);
    --control-glass-border: rgba(var(--color-reddit-orange-rgb), 0.2);
    --control-glass-glow: rgba(var(--color-reddit-orange-rgb), 0.15);
    --control-glass-hover: rgba(var(--color-reddit-orange-rgb), 0.18);
    --control-glass-hover-glow: rgba(var(--color-reddit-orange-rgb), 0.25);
    --text-muted: rgba(var(--color-player-text-rgb), 0.68);
    --text-subtle: rgba(var(--color-player-text-rgb), 0.6);
    --font-brand: 'Bebas Neue', cursive;
    --font-body: Roboto, sans-serif;
    --font-title: 'Barlow Condensed', sans-serif;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--color-player-background);
}

.wrapper {
    display: block;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ---- TOP BAR (branding) ---- */
.title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-player-text);
    font-family: var(--font-body);
    background: var(--color-player-background);
    height: 60px;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    box-sizing: border-box;
}

.header-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
    margin-top: 0;
    font-family: var(--font-brand);
    font-weight: normal;
    font-style: normal;
    font-size: 1.7em;
    letter-spacing: 5px;
    /* Match the play-controls pill width so the top badge reads as the same
       control-language element (see .controls-center.overlay-pill). */
    flex: 0 1 520px;
    max-width: min(94vw, 520px);
    min-width: 0;
}

.title-reddit {
    color: var(--color-reddit-orange);
    text-shadow: 0 0 14px rgba(var(--color-reddit-orange-rgb), 0.65), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.title-viewer {
    color: var(--color-player-text);
    text-shadow: 0 0 10px rgba(var(--color-player-text-rgb), 0.25), 0 1px 2px rgba(0, 0, 0, 0.5);
}

.title-badge {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 6px 18px;
    margin-top: 0;
    background: var(--control-glass);
    border: 1px solid var(--control-glass-border);
    border-radius: 24px;
    box-shadow: 0 4px 15px var(--control-glass-glow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Wordmark on the left, picker(s) on the right. Leaves room on the right for
   additional pickers (e.g. a time-period selector) alongside the subreddit. */
.title-badge-stack {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 1 1 auto;
    min-width: 0;
}

.title-text {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    flex: 0 0 auto;
}

.subreddit-dropdown-wrap {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
}

.subreddit-select {
    background: transparent;
    color: rgba(var(--color-player-text-rgb), 0.9);
    border: none;
    border-radius: 0;
    padding: 0 2px;
    font-family: var(--font-body);
    font-size: 14px;
    max-width: 220px;
    width: 100%;
    text-align: right;
    text-align-last: right;
    cursor: pointer;
}

.subreddit-select:hover,
.subreddit-select:focus {
    color: var(--color-player-text);
}

/* ---- TOP BAR RIGHT (QR remote trigger) ---- */
.header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

/* ---- SETTINGS DROPDOWN ----
   .settings-section now lives inside the play-controls pill (left group) as
   the positioning anchor for the dropdown. */
.settings-section {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.settings-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: rgba(var(--color-player-text-rgb), 0.85);
    font-family: var(--font-brand);
    font-size: 16px;
    letter-spacing: 3px;
    font-weight: normal;
    padding: 4px 14px 6px;
    border-radius: 40px;
    background: var(--control-glass);
    border: 1px solid var(--control-glass-border);
    box-shadow: 0 4px 15px var(--control-glass-glow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.settings-trigger:hover {
    color: var(--color-player-text);
    background: var(--control-glass-hover);
    box-shadow: 0 4px 20px var(--control-glass-hover-glow);
}

.settings-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(var(--color-dark-panel-rgb), 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 10px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 50;
    flex-direction: column;
    gap: 4px;
}

.menu-open .settings-dropdown {
    display: flex;
}

/* ---- VIDEO ---- */
.video-container {
    position: relative;
    height: calc(100% - 120px);
    width: 100%;
    display: flex;
    margin-top: 60px;
}

.click-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: pointer;
}

.video {
    flex-grow: 1;
}

.video iframe {
    display: block;
    border: none;
    pointer-events: none;
}

@media (orientation: landscape) and (max-height: 600px) and (hover: none) {
    .video-container {
        height: 100dvh;
        margin-top: 0;
    }

    .video,
    .video iframe {
        width: 100%;
        height: 100%;
    }

    .title-container,
    .controls-container {
        background: transparent;
    }

    .thread-name {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    }
}

/* ---- BOTTOM BAR (thread title) ---- */
.controls-container {
    --overlay-pill-gap: 16px;
    --thumbnail-strip-height: 56px;
    --youtube-pill-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-player-background);
    height: 60px;
    padding: 0 20px;
    box-sizing: border-box;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

.overlay-stack {
    position: fixed;
    left: 50%;
    bottom: 94px;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--overlay-pill-gap);
    pointer-events: none;
}

.overlay-stack .overlay-pill {
    position: static;
    transform: none;
    pointer-events: auto;
}

/* ---- THREAD NAME (in bottom bar) ---- */
.thread-name {
    font-family: var(--font-title);
    color: var(--color-player-text);
    font-size: 1.4rem;
    font-weight: 300;
    font-style: normal;
    letter-spacing: 0.4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    max-width: 100%;
    cursor: pointer;
}

.thread-name:hover {
    text-decoration: underline;
}

/* ---- OVERLAY PILL (shared style for video overlay controls) ---- */
.overlay-pill {
    position: fixed;
    bottom: 98px;
    transform: translateY(50%);
    z-index: 15;
    background: var(--control-glass);
    border: 1px solid var(--control-glass-border);
    border-radius: 24px;
    box-shadow: 0 4px 15px var(--control-glass-glow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--color-player-text);
}

/* Play controls — center pill (speed | nav | fullscreen) */
.controls-center.overlay-pill {
    width: min(94vw, 520px);
    box-sizing: border-box;
    padding: 0 18px;
    min-height: 50px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
}

.thumbnail-carousel.overlay-pill {
    padding: 6px 6px;
    min-height: var(--thumbnail-strip-height);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 24px;
    max-width: min(94vw, 520px);
}

.thumbnail-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    flex: 1 1 auto;
    min-width: 0;
}

.thumbnail-strip::-webkit-scrollbar {
    display: none;
}

.thumbnail-chevron {
    flex: 0 0 auto;
    width: 30px;
    height: 44px;
    background: transparent;
    border: 0;
    padding: 0;
    color: rgba(255, 250, 240, 0.7);
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.thumbnail-chevron svg {
    display: block;
}

.thumbnail-chevron:hover {
    color: var(--color-player-text);
    background: rgba(255, 255, 255, 0.08);
}

.thumbnail-sentinel {
    flex: 0 0 1px;
    align-self: stretch;
    visibility: hidden;
}

body.tv-mode .thumbnail-chevron {
    display: none;
}

.thumbnail-item {
    position: relative;
    flex: 0 0 auto;
    scroll-snap-align: center;
    width: 78px;
    height: 44px;
    border: 1px solid rgba(255, 250, 240, 0.25);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 0;
    margin: 0;
    overflow: visible;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.thumbnail-image-frame {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    display: block;
}

.thumbnail-item:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 250, 240, 0.65);
}

.thumbnail-item.current {
    border-color: var(--color-reddit-orange);
    box-shadow: 0 0 0 1px rgba(var(--color-reddit-orange-rgb), 0.4);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.thumbnail-tooltip {
    position: fixed;
    width: 240px;
    max-width: calc(100vw - 16px);
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(var(--color-dark-panel-rgb), 0.94);
    border: 1px solid rgba(var(--color-reddit-orange-rgb), 0.38);
    color: var(--color-player-text);
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55), 0 0 16px var(--control-glass-hover);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(2px);
    transition: opacity 0.14s ease, visibility 0.14s ease, transform 0.14s ease;
    z-index: 120;
}

.thumbnail-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.thumbnail-item.thumbnail-unavailable {
    border-style: dashed;
    background: rgba(255, 255, 255, 0.04);
}

.thumbnail-item.thumbnail-unavailable::after {
    content: "No preview";
    font-family: var(--font-body);
    font-size: 11px;
    color: rgba(var(--color-player-text-rgb), 0.78);
    letter-spacing: 0.2px;
}

/* Removed controls-right section since fullscreen moved to header */

/* ---- PROGRESS BAR / SCRUBBER ---- */
.scrubber-container {
    position: fixed;
    bottom: 50px;
    left: 20px;
    width: calc(100% - 40px);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 20;
    transition: opacity 1s ease;
}

.progress-bar {
    -webkit-appearance: none;
    appearance: none;
    flex-grow: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.1s ease;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-youtube-red);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.progress-bar::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.progress-bar::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-youtube-red);
    cursor: pointer;
    border: none;
    transition: transform 0.1s ease;
}

.progress-bar:hover {
    height: 6px;
}

/* ---- CURRENT TIME & VIDEO LENGTH ---- */
.current-time,
.video-length {
    font-family: var(--font-body);
    color: var(--color-player-text);
    font-weight: 300;
    font-size: 13px;
    white-space: nowrap;
    width: 45px;
    font-variant-numeric: tabular-nums;
}

.current-time {
    text-align: left;
}

.video-length {
    text-align: right;
}


.controls-center {
    color: var(--color-player-text);
}

.controls-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    justify-self: center;
    grid-column: 2;
}

.controls-nav > div {
    cursor: pointer;
    user-select: none;
    padding: 5px;
    transition: transform 0.1s ease, opacity 0.2s ease;
}

.controls-nav > div:hover {
    opacity: 0.8;
}

.controls-nav > div:active {
    transform: scale(0.95);
}

/* Left group (YouTube + Settings) and Right group (Speed + Fullscreen)
   sit in the outer 1fr columns of the controls-center grid. */
.controls-left {
    grid-column: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls-right-group {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Borderless transparent icon buttons inside the play pill */
.controls-center .pill-icon-btn,
.controls-center .playback-rate-indicator,
.controls-center .fullscreen-btn {
    background-color: transparent;
    background-image: none;
    border: 0;
    outline: 0;
    box-shadow: none;
    padding: 4px 6px;
    color: rgba(var(--color-player-text-rgb), 0.85);
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, transform 0.1s ease;
}

.controls-center .playback-rate-indicator {
    font-family: var(--font-brand);
    font-size: 22px;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    /* Optical alignment: nudge down so the glyph center matches the adjacent
       icon center. */
    position: relative;
    top: 1.5px;
}

.controls-center .pill-icon-btn svg,
.controls-center .fullscreen-btn svg {
    display: block;
}

.controls-center .pill-icon-btn:hover,
.controls-center .pill-icon-btn:focus,
.controls-center .pill-icon-btn:focus-visible,
.controls-center .playback-rate-indicator:hover,
.controls-center .playback-rate-indicator:focus,
.controls-center .playback-rate-indicator:focus-visible,
.controls-center .fullscreen-btn:hover,
.controls-center .fullscreen-btn:focus,
.controls-center .fullscreen-btn:focus-visible {
    color: var(--color-player-text);
    background-color: transparent;
    box-shadow: none;
    outline: none;
    transform: scale(1.1);
}

.controls-center .pill-icon-btn:active,
.controls-center .playback-rate-indicator:active,
.controls-center .fullscreen-btn:active {
    background-color: transparent;
    box-shadow: none;
    transform: scale(0.95);
}

#last-updated {
    font-family: Roboto, sans-serif;
    font-size: 11px;
    color: rgba(255, 250, 240, 0.6);
    white-space: nowrap;
}

.previous-video {
    cursor: pointer;
    padding: 8px 4px;
}

.next-video {
    cursor: pointer;
    padding: 8px 4px;
}

/* ---- SETTINGS DROPDOWN ITEMS ---- */
.generate-youtube-playlist,
.privacy-policy {
    text-align: center;
    cursor: pointer;
    background: transparent;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-player-text);
    font-family: Roboto, sans-serif;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.generate-youtube-playlist:hover,
.generate-youtube-playlist.keyboard-focus,
.privacy-policy:hover,
.privacy-policy.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.filter-politics {
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    background: transparent;
}

.filter-subreddit {
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    background: transparent;
}

.filter-subreddit:hover,
.filter-subreddit.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.filter-politics:hover,
.filter-politics.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.filter-sort {
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    background: transparent;
}

.filter-sort:hover,
.filter-sort.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.filter-captions {
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
    background: transparent;
}

.filter-captions:hover,
.filter-captions.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.clear-history {
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    background: transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.keyboard-shortcuts {
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    background: transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.clear-history:hover,
.clear-history.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.keyboard-shortcuts:hover,
.keyboard-shortcuts.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

.phone-remote {
    display: none;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px 6px;
    margin: 2px 0;
    font-family: Roboto, sans-serif;
    font-size: 13px;
    color: var(--color-player-text);
    background: transparent;
    white-space: nowrap;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.phone-remote:hover,
.phone-remote.keyboard-focus {
    background: rgba(255, 255, 255, 0.1);
}

/* ---- SETTINGS INFO ---- */
.settings-info {
    padding: 4px 6px;
    font-family: Roboto, sans-serif;
    font-size: 11px;
    color: rgba(255, 250, 240, 0.6);
    text-align: center;
}

/* ---- UI DIMMING ---- */
.title-container,
.controls-container,
.overlay-pill {
    transition: opacity 1s ease;
}

.ui-controls-dimmed,
.ui-controls-dimmed .click-layer {
    cursor: none;
}

.ui-controls-dimmed .title-container,
.ui-controls-dimmed .overlay-pill,
.ui-controls-dimmed .scrubber-container {
    opacity: 0;
    pointer-events: none;
}

.ui-controls-force-hidden .title-container,
.ui-controls-force-hidden .overlay-pill,
.ui-controls-force-hidden .scrubber-container {
    transition: none !important;
    opacity: 0;
    pointer-events: none;
}

.ui-thread-dimmed .controls-container {
    opacity: 0;
    pointer-events: none;
}

.shortcut-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.shortcut-overlay.hidden {
    display: none;
}

.shortcut-overlay-panel {
    position: relative;
    width: min(620px, 100%);
    max-height: min(78vh, 640px);
    overflow-y: auto;
    background: rgba(18, 18, 26, 0.95);
    border: 1px solid rgba(255, 69, 0, 0.4);
    border-radius: 14px;
    box-shadow: 0 14px 46px rgba(0, 0, 0, 0.65), 0 0 28px rgba(255, 69, 0, 0.18);
    padding: 22px 24px 18px;
    color: var(--color-player-text);
    font-family: Roboto, sans-serif;
}

.shortcut-overlay-panel h2 {
    margin: 0 0 14px;
    font-family: 'Bebas Neue', cursive;
    font-size: 28px;
    letter-spacing: 1.5px;
    color: var(--color-reddit-orange);
}

.shortcut-overlay-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 250, 240, 0.35);
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-player-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.shortcut-overlay-close:hover {
    background: rgba(255, 69, 0, 0.2);
    border-color: rgba(255, 69, 0, 0.6);
}

.shortcut-grid {
    display: grid;
    grid-template-columns: minmax(170px, 0.95fr) minmax(0, 1.25fr);
    row-gap: 10px;
    column-gap: 14px;
    align-items: center;
}

.shortcut-key {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    color: rgba(255, 250, 240, 0.92);
    font-size: 14px;
}

.shortcut-key span {
    color: rgba(255, 250, 240, 0.58);
}

.shortcut-key kbd {
    font-family: Roboto, sans-serif;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 250, 240, 0.24);
    border-bottom-color: rgba(255, 250, 240, 0.45);
    border-radius: 6px;
    padding: 3px 7px;
    line-height: 1.3;
    min-width: 20px;
    text-align: center;
    box-sizing: border-box;
}

.shortcut-desc {
    font-size: 14px;
    color: rgba(255, 250, 240, 0.9);
}

.shortcut-overlay-hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: rgba(255, 250, 240, 0.7);
}

.shortcut-overlay-hint kbd {
    font-family: Roboto, sans-serif;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 250, 240, 0.24);
    border-bottom-color: rgba(255, 250, 240, 0.45);
    border-radius: 5px;
    padding: 2px 6px;
}

.qr-overlay-panel {
    width: min(360px, 100%);
    text-align: center;
}

.qr-code-wrap {
    margin: 6px auto 12px;
    width: 280px;
    height: 280px;
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code-wrap canvas,
.qr-code-wrap img,
.qr-code-wrap svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-overlay-url {
    margin: 0 0 4px;
    font-size: 12px;
    color: rgba(255, 250, 240, 0.78);
    word-break: break-all;
    font-family: Roboto, sans-serif;
}

.qr-diagnostics-link {
    min-height: 32px;
    margin: 8px auto 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 69, 0, 0.5);
    border-radius: 8px;
    padding: 0 12px;
    background: rgba(255, 69, 0, 0.12);
    color: #ffb299;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.qr-diagnostics-link:hover {
    background: rgba(255, 69, 0, 0.22);
    color: var(--color-player-text);
}

.qr-connected-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    animation: qr-connected-in 0.3s ease;
}

.qr-connected-state p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: #4ade80;
}

@keyframes qr-connected-in {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

/* ---- MOBILE OVERRIDES ---- */
@media (max-width: 600px) {
    .controls-container {
        --overlay-pill-gap: 14px;
        --thumbnail-strip-height: 48px;
        --youtube-pill-height: 34px;
    }

    .title-container {
        padding: 0 10px;
    }

    .controls-center.overlay-pill {
        padding: 0 10px;
        min-height: 42px;
        gap: 6px;
    }

    .controls-left {
        gap: 8px;
    }

    .controls-right-group {
        gap: 8px;
    }

    .controls-nav {
        gap: 14px;
    }

    .controls-nav > div {
        padding: 3px;
    }

    .controls-nav svg {
        width: 24px;
        height: 24px;
    }

    .controls-center .playback-rate-indicator {
        font-size: 19px;
        min-width: 38px;
        padding: 3px 4px;
    }

    .controls-center .pill-icon-btn,
    .controls-center .fullscreen-btn {
        padding: 3px 4px;
    }

    .controls-center .pill-icon-btn svg,
    .controls-center .fullscreen-btn svg {
        width: 20px;
        height: 20px;
    }

    .settings-dropdown {
        left: 0;
        transform: none;
    }

    .thread-name {
        font-size: 1.1rem;
    }

    .filter-politics {
        font-size: 12px;
    }

    .filter-subreddit {
        font-size: 12px;
    }

    .filter-sort {
        font-size: 12px;
    }

    .filter-captions {
        font-size: 12px;
    }

    .clear-history {
        font-size: 12px;
    }

    .keyboard-shortcuts {
        font-size: 12px;
    }

    .qr-trigger {
        display: none;
    }

    .phone-remote {
        display: flex;
        font-size: 12px;
    }

    .subreddit-select {
        max-width: 140px;
        font-size: 10px;
        padding: 0;
        text-align: center;
        text-align-last: center;
    }

    /* Narrow phones keep the compact stacked badge (wordmark over picker);
       the wide side-by-side pill is a desktop-only layout. */
    .title-badge {
        flex-direction: column;
        width: auto;
        padding: 4px 12px;
        box-sizing: border-box;
    }

    .title-badge-stack {
        flex-direction: column;
        gap: 4px;
    }

    .subreddit-dropdown-wrap {
        justify-content: center;
    }

    /* Merged header: title pill centered between the header-left/right slots. */
    .title-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        justify-content: initial;
        gap: 0;
    }

    .header-left,
    .title,
    .header-right {
        flex: 0 0 auto;
    }

    .header-left {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        margin-right: 0;
    }

    .title {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        margin-top: 0;
        font-size: 1.6em;
        letter-spacing: 4px;
    }

    .header-right {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        align-self: center;
    }

    .overlay-stack {
        bottom: 90px;
    }

    .thumbnail-carousel.overlay-pill {
        gap: 4px;
        padding: 6px 4px;
    }

    .thumbnail-strip {
        gap: 6px;
    }

    .thumbnail-item {
        width: 60px;
        height: 36px;
    }

    .shortcut-overlay-panel {
        padding: 18px 16px 14px;
    }

    .shortcut-overlay-panel h2 {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .shortcut-grid {
        grid-template-columns: 1fr;
        row-gap: 6px;
    }

    .shortcut-desc {
        margin-bottom: 6px;
    }
}

@media (max-width: 360px) {
    #fullscreen-btn {
        display: none !important;
    }
}

@media (min-width: 601px) {
    .thread-name {
        font-size: 1.6rem;
    }
}

/* ---- PWA STANDALONE SAFE AREAS ---- */
@media (display-mode: standalone) {
    .title-container {
        padding-top: env(safe-area-inset-top);
        padding-left: calc(20px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
        height: calc(60px + env(safe-area-inset-top));
    }

    .video-container {
        margin-top: calc(60px + env(safe-area-inset-top));
        height: calc(100% - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .controls-container {
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: calc(20px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
        height: calc(60px + env(safe-area-inset-bottom));
    }

    .scrubber-container {
        bottom: calc(50px + env(safe-area-inset-bottom));
        left: calc(20px + env(safe-area-inset-left));
        width: calc(100% - 40px - env(safe-area-inset-left) - env(safe-area-inset-right));
    }

    .overlay-stack {
        bottom: calc(94px + env(safe-area-inset-bottom));
    }
}

@media (display-mode: standalone) and (orientation: portrait) and (max-width: 600px) {
    .title-container {
        padding-left: calc(10px + env(safe-area-inset-left));
        padding-right: calc(10px + env(safe-area-inset-right));
    }

    .title {
        min-width: 0;
        width: 100%;
    }

    .title-badge {
        max-width: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
    }
}

/* ---- LANDSCAPE MOBILE STANDALONE — edge-to-edge video ---- */
@media (display-mode: standalone) and (orientation: landscape) and (max-height: 600px) and (hover: none) {
    .video-container {
        height: 100dvh;
        margin-top: 0;
    }

    .video,
    .video iframe {
        width: 100vw;
        height: 100dvh;
    }

    .title-container {
        background: transparent;
        height: auto;
        padding-top: env(safe-area-inset-top);
    }

    .controls-container {
        background: transparent;
        height: auto;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .thread-name {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    }

    .scrubber-container {
        bottom: calc(10px + env(safe-area-inset-bottom));
        left: calc(20px + env(safe-area-inset-left));
        width: calc(100% - 40px - env(safe-area-inset-left) - env(safe-area-inset-right));
    }

    .overlay-stack {
        bottom: calc(50px + env(safe-area-inset-bottom));
    }
}
