/* ============================================
   RedditListen — Dark Premium Design System
   ============================================ */

:root {
    --bg: #000000;
    --surface: #09090b;
    --surface2: #121214;
    --surface3: #18181b;
    --border: #1f1f22;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --accent: #ff4500;
    --accent-glow: rgba(255, 69, 0, 0.15);
    --accent2: #ff5722;
    --green: #10b981;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --yellow: #f59e0b;
    --cyan: #06b6d4;
    --radius: 24px;
    --radius-sm: 14px;
    --radius-xs: 8px;
}

/* Voice color palette */
.voice-0 {
    --voice-color: #FF4500;
}

.voice-1 {
    --voice-color: #60a5fa;
}

.voice-2 {
    --voice-color: #4ade80;
}

.voice-3 {
    --voice-color: #f472b6;
}

.voice-4 {
    --voice-color: #fbbf24;
}

.voice-5 {
    --voice-color: #a78bfa;
}

.voice-6 {
    --voice-color: #22d3ee;
}

.voice-7 {
    --voice-color: #fb923c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #2a2a2e #0a0a0b;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: #0a0a0b;
}

*::-webkit-scrollbar-thumb {
    background: #2a2a2e;
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background: #3a3a3e;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: row;
}

#main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px;
    /* Space for mini player */
}

/* ---- SIDEBAR ---- */
#sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#btn-sidebar-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.2s;
}

#btn-sidebar-close:hover {
    color: var(--text);
}

.sidebar-section {
    padding: 16px 20px;
    flex-shrink: 0;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.sidebar-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.sidebar-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.sidebar-list li:hover {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-list li.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.btn-remove-sub {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-remove-sub:hover {
    color: var(--accent);
}

.sidebar-add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.sidebar-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setting-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.number-stepper {
    display: flex;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 2px;
}

.stepper-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.stepper-btn:hover {
    background: var(--surface3);
}

.stepper-val {
    width: 32px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.mobile-only {
    display: none !important;
}

/* ---- MINI PLAYER ---- */
#mini-player {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(180, 30, 60, 0.55), rgba(120, 20, 120, 0.45));
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border: 1px solid rgba(220, 50, 90, 0.25);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(180, 30, 80, 0.15);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.25s ease,
        box-shadow 0.3s ease;
    cursor: pointer;
    will-change: transform;
}

#mini-player:hover {
    transform: translateX(-50%) scale(1.12);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(200, 40, 100, 0.25);
    border-color: rgba(220, 50, 90, 0.45);
}

#mini-player:active {
    transform: translateX(-50%) scale(0.95);
}

#mini-player.hidden {
    transform: translate(-50%, 150%);
    opacity: 0;
    pointer-events: none;
}

.mini-player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-ctrl-btn {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.mini-ctrl-btn svg {
    width: 24px;
    height: 24px;
}

.mini-ctrl-btn:hover {
    background: transparent;
}


.load-more-comments-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.load-more-comments-btn:hover {
    background: var(--surface3);
    border-color: var(--accent);
}

.load-more-comments-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s ease;
    }

    #sidebar.open {
        left: 0;
    }

    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 199;
    }

    #sidebar-overlay.active {
        display: block;
    }

    .mobile-only {
        display: flex !important;
    }

    #main-header .logo:not(.mobile-only) {
        display: none;
    }
}

@media (min-width: 769px) {
    #sidebar.desktop-hidden {
        display: none !important;
    }
}

#sidebar-subs-list {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    padding-right: 4px;
}

/* ---- HEADER ---- */
#main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #FF4500 0%, #FF6B3D 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 12px rgba(255, 69, 0, 0.2);
}

.logo h1 .faded {
    background: none;
    -webkit-text-fill-color: var(--text-secondary);
    color: var(--text-secondary);
    font-weight: 400;
    text-shadow: none;
}

.header-actions-pill {
    display: flex;
    align-items: center;
    background: rgba(24, 24, 27, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pill-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.pill-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.pill-btn:active {
    transform: scale(0.92);
}

.pill-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: var(--text);
}

.icon-btn:active {
    transform: scale(0.92);
}

.time-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 100px;
    margin-left: 12px;
    vertical-align: middle;
    border: 2px solid var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 12px rgba(255, 69, 0, 0.4), 0 0 24px rgba(255, 69, 0, 0.15);
    animation: badge-glow 2s ease-in-out infinite alternate;
}

@keyframes badge-glow {
    from {
        box-shadow: 0 0 8px rgba(255, 69, 0, 0.3);
    }

    to {
        box-shadow: 0 0 16px rgba(255, 69, 0, 0.6), 0 0 30px rgba(255, 69, 0, 0.2);
    }
}

/* ---- SECTION HEADER ---- */
.section-header {
    padding: 24px 20px 12px;
}

.section-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}



.feed-select {
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.feed-select:hover {
    border-color: var(--accent);
}

.feed-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.feed-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pill-btn.locked {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

/* ---- THREAD CARDS ---- */
#threads-container {
    padding: 8px 16px 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread-card {
    background: rgba(18, 18, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.thread-card:hover {
    background: rgba(255, 69, 0, 0.12);
    border-color: rgba(255, 69, 0, 0.4);
    border-left-color: rgba(255, 69, 0, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 24px rgba(255, 69, 0, 0.2), 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Trail glow — applied when mouse leaves, fades out slowly */
.thread-card.hover-trail {
    background: rgba(255, 69, 0, 0.06);
    border-color: rgba(255, 69, 0, 0.18);
    border-left-color: rgba(255, 69, 0, 0.45);
    box-shadow: 0 2px 16px rgba(255, 69, 0, 0.08);
    transition: background 1.2s ease-out, border-color 1.2s ease-out, border-left-color 1.2s ease-out, box-shadow 1.2s ease-out, transform 0.15s ease;
}

/* When trail is fading AND not hovered, return to baseline smoothly */
.thread-card.hover-trail-fade {
    background: rgba(18, 18, 20, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
    border-left-color: transparent;
    box-shadow: none;
    transition: background 1.4s ease-out, border-color 1.4s ease-out, border-left-color 1.4s ease-out, box-shadow 1.4s ease-out, transform 0.15s ease;
}

/* ================== LOCKED FEED STYLING ================== */
/* When feed is locked/pinned, always show a solid emerald green left edge */
#threads-container.locked-feed .thread-card {
    border-left-color: rgba(16, 185, 129, 0.85) !important;
}

.thread-card:active {
    transform: translateY(0) scale(0.98);
}

.thread-card.playing {
    background: rgba(255, 69, 0, 0.1);
    border-color: rgba(255, 69, 0, 0.3);
    border-left-color: rgba(255, 69, 0, 0.8);
}

.thread-subreddit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.thread-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}

/* Thread card top row: title area + share button */
.thread-card-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.thread-card-top>div:first-child {
    flex: 1;
    min-width: 0;
}

.thread-card-top-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.share-card-btn,
.bookmark-card-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.thread-card:hover .share-card-btn,
.thread-card:hover .bookmark-card-btn {
    opacity: 1;
}

.share-card-btn:hover,
.bookmark-card-btn:hover {
    color: var(--accent);
    background: var(--accent-glow);
}

.bookmark-card-btn.bookmarked {
    color: var(--yellow);
    opacity: 1;
}

.bookmark-card-btn.bookmarked svg {
    fill: currentColor;
}

/* Player header share button */
.share-btn {
    flex-shrink: 0;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thread-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.thread-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.thread-comments-count {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- PLAYER VIEW ---- */
#player-view {
    position: fixed;
    inset: 0;
    width: 100%;
    margin: 0 auto;
    background: var(--bg);
    z-index: 200;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s;
}

@media (min-width: 768px) {
    #player-view {
        max-width: 640px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
    }
}

#player-view.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.player-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
}

.player-header .icon-btn {
    flex-shrink: 0;
    margin-top: 2px;
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.player-header .icon-btn:hover {
    color: var(--text);
}

.player-title-area {
    flex: 1;
    min-width: 0;
}

.player-subreddit {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.player-thread-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 4px;
    letter-spacing: -0.2px;
}

.player-post-body {
    padding: 0 20px 16px 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: none;
    overflow: visible;
}

/* ---- NOW PLAYING CARD ---- */
.now-playing-card {
    margin: 0 16px 12px 16px;
    padding: 16px 20px;
    background: linear-gradient(145deg, var(--surface) 0%, var(--surface2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.voice-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.voice-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    transition: background 0.3s;
    box-shadow: 0 0 20px var(--accent-glow);
}

.voice-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
}

.voice-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

/* ---- WAVEFORM ---- */
.waveform-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 24px;
    margin-bottom: 8px;
}

.wave-bar {
    width: 4px;
    height: 8px;
    border-radius: 2px;
    background: var(--accent);
    opacity: 0.3;
    transition: height 0.1s, opacity 0.2s;
}

.waveform-active .wave-bar {
    opacity: 0.8;
    animation: waveAnim 0.8s ease-in-out infinite alternate;
}

.wave-bar:nth-child(1) {
    animation-delay: 0s;
}

.wave-bar:nth-child(2) {
    animation-delay: 0.05s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.15s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(6) {
    animation-delay: 0.25s;
}

.wave-bar:nth-child(7) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(8) {
    animation-delay: 0.35s;
}

.wave-bar:nth-child(9) {
    animation-delay: 0.4s;
}

.wave-bar:nth-child(10) {
    animation-delay: 0.45s;
}

.wave-bar:nth-child(11) {
    animation-delay: 0.5s;
}

.wave-bar:nth-child(12) {
    animation-delay: 0.55s;
}

.wave-bar:nth-child(13) {
    animation-delay: 0.6s;
}

.wave-bar:nth-child(14) {
    animation-delay: 0.65s;
}

.wave-bar:nth-child(15) {
    animation-delay: 0.7s;
}

.wave-bar:nth-child(16) {
    animation-delay: 0.75s;
}

.wave-bar:nth-child(17) {
    animation-delay: 0.8s;
}

.wave-bar:nth-child(18) {
    animation-delay: 0.85s;
}

.wave-bar:nth-child(19) {
    animation-delay: 0.9s;
}

.wave-bar:nth-child(20) {
    animation-delay: 0.95s;
}

@keyframes waveAnim {
    0% {
        height: 4px;
    }

    100% {
        height: 20px;
    }
}

.spoken-word {
    transition: color 0.08s ease, background-color 0.08s ease;
    border-radius: 4px;
    padding: 0 1px;
}

.spoken-word.word-active {
    color: var(--accent);
    background: rgba(255, 69, 0, 0.14);
}

/* ---- PROGRESS ---- */
.progress-area {
    display: none !important;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background: var(--surface3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    width: 0%;
    min-width: 0;
    transition: width 0.3s;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- CONTROLS ---- */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.skip-thread-btn {
    width: 32px;
    height: 32px;
    color: var(--text);
    opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
    .skip-thread-btn:hover {
        color: var(--accent);
        background: var(--surface3);
    }

    .control-btn:hover {
        background: var(--surface3);
    }
}

.control-btn:focus {
    outline: none;
}

.control-btn:focus:not(:focus-visible) {
    background: transparent;
}





.control-btn:active {
    transform: scale(0.9);
}

.play-btn {
    width: 52px;
    height: 52px;
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 8px 32px var(--accent-glow);
    transition: all 0.2s;
}

.play-btn:hover {
    background: var(--accent2) !important;
    transform: scale(1.05);
    box-shadow: 0 12px 40px var(--accent-glow);
}

.play-btn:active {
    transform: scale(0.95) !important;
}

.play-btn.loading {
    animation: pulseGlow 1.2s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 4px 24px var(--accent-glow);
    }

    50% {
        box-shadow: 0 4px 40px rgba(255, 69, 0, 0.5);
    }
}

.waveform-loading .wave-bar {
    opacity: 0.4;
    animation: waveLoad 1s ease-in-out infinite;
}

@keyframes waveLoad {

    0%,
    100% {
        height: 8px;
        opacity: 0.3;
    }

    50% {
        height: 16px;
        opacity: 0.6;
    }
}

.shuffle-btn {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.shuffle-btn.active {
    color: var(--green);
    background: rgba(74, 222, 128, 0.1);
}

.shuffle-btn.active:hover {
    background: rgba(74, 222, 128, 0.2);
}

/* Shuffle button in header */
#btn-shuffle-all.active {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--green);
    color: var(--green);
}

.hidden {
    display: none !important;
}

/* ---- SPEED ---- */
.speed-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.speed-pills {
    display: flex;
    gap: 6px;
    flex: 1;
}

.speed-pill {
    flex: 1;
    padding: 4px 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-pill:hover {
    border-color: var(--accent);
    color: var(--text);
}

.speed-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ---- QUEUE / SEGMENT LIST ---- */
.queue-section {
    padding: 0 16px 100px;
}

.queue-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

#segment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.segment-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.segment-item:hover {
    background: var(--surface2);
    border-color: var(--border);
}

.segment-item.active {
    background: rgba(255, 69, 0, 0.15);
    border-color: transparent;
}

.segment-item.active .segment-author {
    color: var(--accent);
}

.segment-item.segment-reply {
    margin-left: calc(16px * var(--reply-depth, 1));
    padding-left: 12px;
    border-left: 2px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.02);
}

.segment-item.segment-reply.active {
    background: rgba(255, 69, 0, 0.08);
    border-color: rgba(255, 69, 0, 0.25);
    border-left-color: rgba(255, 69, 0, 0.55);
}

.segment-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.segment-content {
    flex: 1;
    min-width: 0;
}

.segment-author {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.segment-author .op-badge {
    font-size: 0.6rem;
    background: var(--accent);
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
}

.segment-author .post-badge {
    font-size: 0.6rem;
    background: rgba(59, 130, 246, 0.2);
    color: var(--blue);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
}

.segment-author .title-badge {
    font-size: 0.6rem;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
}

.segment-author .score {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.7rem;
}

.segment-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.segment-item.segment-skeleton {
    pointer-events: none;
    cursor: default;
}

.segment-item.segment-skeleton:hover {
    background: var(--surface);
    border-color: transparent;
}

.segment-dot.skeleton-dot {
    background: var(--surface3);
    margin-top: 2px;
}

.segment-skeleton-line {
    height: 10px;
    background: var(--surface3);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.segment-skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 1.5s infinite;
}

.segment-skeleton-author {
    width: 42%;
    margin-bottom: 8px;
}

.segment-skeleton-text {
    width: 88%;
    height: 12px;
}

/* ---- MODAL ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 28px 24px 32px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.modal-content>p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: var(--accent);
}

.modal-content input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.quick-subs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.quick-sub-btn {
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.quick-sub-btn:hover {
    background: var(--surface3);
    color: var(--text);
    border-color: var(--text-muted);
}

.quick-sub-btn.selected {
    background: rgba(255, 69, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.quick-sub-btn.selected::before {
    content: '✓';
    font-size: 0.7rem;
}

.modal-content select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
}

.modal-content select:focus {
    border-color: var(--accent);
}

.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-tab:hover {
    color: var(--text);
}

.modal-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content.hidden {
    display: none;
}

.search-results {
    max-height: 50vh;
    overflow-y: auto;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-card {
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-card:hover {
    background: var(--surface3);
    border-color: var(--accent);
}

.search-result-card.added {
    opacity: 0.5;
    pointer-events: none;
}

.search-result-sub {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

.search-result-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 6px;
}

.search-result-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.search-results-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-results-empty.pulsing {
    animation: searchPulse 1.2s ease-in-out infinite;
}

@keyframes searchPulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.btn-secondary,
.btn-primary {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface3);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent2);
}

.btn-primary:active {
    transform: scale(0.97);
}

.modal-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 16px;
    text-align: center;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 640px) {
    #main-header {
        padding: 20px 24px;
    }

    .section-header {
        padding: 32px 24px 16px;
    }

    #threads-container {
        padding: 8px 20px 100px;
    }

    .now-playing-card {
        margin: 24px 20px;
        padding: 28px;
    }

    .queue-section {
        padding: 0 20px 100px;
    }
}

/* ---- LOADING STATE ---- */
.thread-card.loading {
    pointer-events: none;
    opacity: 0.6;
}

.thread-card.loading .thread-title::after {
    content: '  Loading...';
    color: var(--accent);
    font-weight: 400;
    font-size: 0.85rem;
}

/* ---- SCROLL BAR ---- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- TOGGLE SWITCH ---- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 22px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
    background: white;
}

/* ============================================
   NEW UI/UX ENHANCEMENTS
   ============================================ */

/* ---- ANIMATED BACKGROUND GLOWS ---- */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.4;
    animation: floatGlow 20s infinite alternate ease-in-out;
    pointer-events: none;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 70%);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15), transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.bg-glow-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 69, 0, 0.1), transparent 70%);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(50px, 50px) scale(1.1);
    }

    100% {
        transform: translate(-50px, -50px) scale(0.9);
    }
}

/* ---- TOAST NOTIFICATIONS ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: rgba(24, 24, 27, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 14px 20px;
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(20px);
    opacity: 0;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}

.toast.toast-error {
    border-left: 4px solid var(--accent);
}

.toast.toast-success {
    border-left: 4px solid var(--green);
}

.toast.toast-info {
    border-left: 4px solid var(--blue);
}

.toast.toast-fade-out {
    animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    to {
        transform: translateY(-10px);
        opacity: 0;
    }
}

/* ---- SKELETON LOADERS ---- */
.skeleton-card {
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.skeleton-line {
    height: 14px;
    background: var(--surface3);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 1.5s infinite;
}

.skeleton-sub {
    width: 20%;
    height: 12px;
}

.skeleton-title-1 {
    width: 90%;
    height: 18px;
}

.skeleton-title-2 {
    width: 60%;
    height: 18px;
}

.skeleton-meta {
    width: 40%;
    height: 12px;
    margin-top: 8px;
}

@keyframes shimmer {
    100% {
        left: 200%;
    }
}

/* ---- NOW PLAYING EQUALIZER ---- */
.now-playing-eq {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}

.eq-bar {
    width: 3px;
    background: var(--accent);
    border-radius: 1px;
    animation: eqBounce 0.5s infinite alternate ease-in-out;
}

.eq-bar:nth-child(1) {
    animation-delay: 0s;
    height: 60%;
}

.eq-bar:nth-child(2) {
    animation-delay: 0.2s;
    height: 100%;
}

.eq-bar:nth-child(3) {
    animation-delay: 0.4s;
    height: 40%;
}

@keyframes eqBounce {
    0% {
        transform: scaleY(0.3);
    }

    100% {
        transform: scaleY(1);
    }
}

/* ---- AVATAR PULSE ---- */
.avatar-pulse {
    animation: avatarGlow 2s infinite alternate;
}

@keyframes avatarGlow {
    0% {
        box-shadow: 0 0 10px var(--voice-color, var(--accent));
        transform: scale(1);
    }

    100% {
        box-shadow: 0 0 30px var(--voice-color, var(--accent));
        transform: scale(1.05);
    }
}

/* ---- INFINITE SCROLL LOADER ---- */
.load-more-spinner {
    padding: 8px 0;
    opacity: 0.6;
}

/* ---- LOCK SUBREDDIT BUTTON ---- */
.lock-sub-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.lock-sub-btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.lock-sub-btn.locked {
    background: rgba(0, 200, 83, 0.12);
    border-color: rgba(0, 200, 83, 0.4);
    color: #00c853;
    box-shadow: 0 0 8px rgba(0, 200, 83, 0.15);
}

.lock-sub-btn.locked svg {
    fill: rgba(0, 200, 83, 0.3);
}

/* ---- LOADING COMMENTS PULSE ---- */
.queue-section.loading-comments h3::after {
    content: ' Loading...';
    animation: searchPulse 1.2s ease-in-out infinite;
    font-weight: 400;
    color: var(--text-muted);
}

/* ---- SHUFFLE GLOW ---- */
#btn-shuffle-all.active {
    color: #00c853;
    position: relative;
}

#btn-shuffle-all.active::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 200, 83, 0.4);
    pointer-events: none;
}