/* --- ПЛЕЕР: УЛУЧШЕННАЯ ВЕРСИЯ --- */

/* Глобальные переменные и сброс */
:root {
    --accent: #25b1ff;
    --accent-2: #1a8cd8;
    --bg: #ffffff;
    --bg-darker: #f5f5f7;
    --bg-content: rgba(255, 255, 255, 0.9);
    --tt: #1e1e2f;
    --tt-fade: #6b6b7b;
    --bdc: rgba(0, 0, 0, 0.1);

    /* Размеры и отступы */
    --player-height: 80px;
    --player-height-mobile: 90px;
    --player-expanded-min-height: 320px;
    --control-btn-size: 44px;
    --cover-size: 64px;
    --cover-size-expanded: 70px;
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 25px;

    /* Тени */
    --shadow-light: 0 -5px 25px rgba(0, 0, 0, 0.08);
    --shadow-heavy: 0 -100px 200px rgba(0, 0, 0, 0.5);

    /* Анимации */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* Z-индексы */
    --z-player: 9000;
    --z-popover: 9005;
}

* {
    box-sizing: border-box;
}

/* ============================================================
   1. ЛИПКИЙ БАР (DESKTOP)
   ============================================================ */
.dap-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--player-height);
    background: var(--bg-content);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--bdc);
    box-shadow: var(--shadow-light);
    z-index: var(--z-player);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-xl);
    gap: 0;
    transition: transform var(--transition-normal);
    will-change: transform;
}

.dap-fixed.hidden {
    transform: translateY(120%);
}

@media (prefers-reduced-motion: reduce) {
    .dap-fixed,
    .dap-popover,
    .dap-speed-popover,
    .dap-timer-popover,
    .dap-spin {
        animation: none !important;
        transition: none !important;
    }
    .dap-fixed {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bg-darker);
    }
}

.dap-mobile-toggle,
.dap-mini-play {
    display: none;
}

/* --- БЛОК 1: КНОПКИ (Слева) --- */
.dap-controls-center {
    order: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-right: var(--spacing-xl);
    flex-shrink: 0;
}

.dap-btn-play {
    width: var(--control-btn-size);
    height: var(--control-btn-size);
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(37, 177, 255, 0.4);
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.dap-btn-play:active {
    transform: scale(0.95);
}
.dap-btn-play:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.dap-btn-skip {
    background: transparent !important;
    border: none;
    cursor: pointer;
    color: var(--tt);
    opacity: 0.6;
    width: 40px;
    height: 40px;
    padding: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.dap-btn-skip:active {
    transform: scale(0.9);
    color: var(--accent);
}
.dap-btn-skip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.dap-skip-txt {
    position: absolute;
    font-size: 9px;
    font-weight: 800;
    margin-top: 1px;
}
.dap-btn-skip svg {
    width: 26px;
    height: 26px;
}

/* --- БЛОК 2: ИНФО (Слева) --- */
.dap-info {
    order: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 240px;
    margin-right: 30px;
    flex-shrink: 0;
}

.dap-cover {
    width: var(--cover-size);
    height: var(--cover-size);
    border-radius: var(--border-radius-sm);
    object-fit: cover;
    background: var(--bg-darker);
    border: 1px solid var(--bdc);
    flex-shrink: 0;
}

.dap-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: center;
}

.dap-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--tt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.dap-author {
    font-size: 12px;
    color: var(--tt-fade);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- БЛОК 3: ПРОГРЕСС (Центр) --- */
.dap-progress-wrap {
    order: 3;
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 150px;
}

.dap-time {
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-fade);
    min-width: 35px;
    text-align: center;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.dap-bar-bg {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.dap-bar-line {
    width: 100%;
    height: 5px;
    background: var(--bg-darker);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: visible;
}

.dap-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    width: 0%;
    position: relative;
}

.dap-bar-knob {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    position: absolute;
    right: -7px;
    top: -4.5px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
    pointer-events: none;
}

/* --- БЛОК 4: ИНСТРУМЕНТЫ (Справа) --- */
.dap-tools {
    order: 4;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

.dap-tool-btn {
    background: transparent !important;
    border: none;
    cursor: pointer;
    color: var(--tt-fade);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    font-size: 13px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}
.dap-tool-btn:active {
    transform: scale(0.95);
}
.dap-tool-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.dap-tool-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.dap-tool-btn.active-timer {
    color: var(--accent);
    background: rgba(37, 177, 255, 0.1) !important;
}

/* ============================================================
   2. ПОПАПЫ (МЕНЮ)
   ============================================================ */
.dap-popover,
.dap-speed-popover,
.dap-timer-popover {
    position: absolute;
    bottom: 90px;
    right: 25px;
    background: var(--bg);
    border: 1px solid var(--bdc);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-md);
    display: none;
    flex-direction: column;
    z-index: var(--z-popover);
    animation: dapFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    will-change: transform, opacity;
}

@keyframes dapFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dap-popover.active,
.dap-speed-popover.active,
.dap-timer-popover.active {
    display: flex;
}

.dap-pop-header {
    padding: 12px 15px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--bdc);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dap-pop-title {
    font-weight: 700;
    font-size: 12px;
    color: var(--tt);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.dap-pop-close {
    background: transparent !important;
    border: none;
    cursor: pointer;
    color: var(--tt-fade);
    padding: 5px;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
}
.dap-pop-close:focus-visible {
    outline: 2px solid var(--accent);
}
.dap-pop-close svg {
    width: 16px;
    height: 16px;
}

/* СПИСОК ГЛАВ */
.dap-popover {
    width: 340px;
    max-height: 60vh;
}

.dap-pop-list {
    overflow-y: auto;
    padding: 0;
    margin: 0;
}

.dap-pop-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--bdc);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    color: var(--tt);
    transition: background 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.dap-pop-item:active {
    background: var(--bg-darker);
}

/* Активный трек */
.dap-pop-item.active {
    background: rgba(37, 177, 255, 0.08);
    color: var(--accent);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    padding-left: 12px;
}

.dap-pop-item.played {
    color: var(--tt-fade);
    opacity: 0.8;
}
.dap-pop-item.played span:first-child::before {
    content: '✓';
    display: inline-block;
    margin-right: 8px;
    color: #27ae60;
    font-weight: 800;
}

.dap-pop-dur {
    opacity: 0.5;
    font-size: 11px;
}

/* СЕТКИ */
.dap-speed-popover {
    width: 300px;
    right: 60px;
}
.dap-timer-popover {
    width: 220px;
    right: 100px;
}

.dap-speed-grid,
.dap-timer-grid {
    display: grid;
    gap: 5px;
    padding: 10px;
}
.dap-speed-grid { grid-template-columns: repeat(5, 1fr); }
.dap-timer-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

.dap-speed-item,
.dap-timer-item {
    padding: 8px 0;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--tt);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: var(--bg-darker);
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.dap-speed-item:active,
.dap-timer-item:active {
    transform: scale(0.95);
}
.dap-speed-item.active,
.dap-timer-item.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============================================================
   3. МОБИЛЬНАЯ ВЕРСИЯ (УЛУЧШЕННАЯ)
   ============================================================ */
@media (max-width: 1000px) {
    .dap-controls-center,
    .dap-tools,
    .dap-progress-wrap {
        display: none;
    }

    .dap-fixed {
        position: fixed;
        left: 0;
        width: 100%;
        /* Учитываем челку iPhone снизу */
        height: calc(var(--player-height-mobile) + env(safe-area-inset-bottom));
        min-height: calc(var(--player-height-mobile) + env(safe-area-inset-bottom));
        bottom: 0;
        transform: translateZ(0);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0 var(--spacing-md);
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg-darker);
        border-top: 1px solid var(--bdc);
        border-radius: 0;
        z-index: var(--z-player);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .dap-mobile-toggle,
    .dap-mini-play {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--control-btn-size);
        height: var(--control-btn-size);
        background: transparent !important;
        border: none;
        padding: 0;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .dap-mini-play {
        order: 2;
        color: var(--accent);
        margin-right: 5px;
    }
    .dap-mini-play svg {
        width: 32px;
        height: 32px;
    }

    .dap-mobile-toggle {
        order: 3;
        color: var(--tt);
        opacity: 0.6;
    }
    .dap-mobile-toggle svg {
        width: 24px;
        height: 24px;
        transform: rotate(0deg);
        transition: transform var(--transition-fast);
    }

    .dap-info {
        order: 1;
        flex: 1;
        width: auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        margin: 0;
        overflow: hidden;
        padding-right: 10px;
    }

    .dap-fixed .dap-cover {
        display: block;
        width: var(--cover-size);
        height: var(--cover-size);
        border-radius: var(--border-radius-sm);
        margin-right: 12px;
        flex-shrink: 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .dap-fixed .dap-meta {
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: hidden;
    }
    .dap-title {
        font-size: 13px;
        margin: 0;
        width: 100%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }
    .dap-author {
        font-size: 11px;
        margin: 2px 0 0;
        width: 100%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        display: block;
    }

    /* --- РАЗВЕРНУТЫЙ ВИД --- */
    .dap-fixed.is-expanded {
        height: auto;
        min-height: var(--player-expanded-min-height);
        max-height: 85vh; /* Даем больше места плееру на мобилке */
        flex-direction: column;
        justify-content: flex-start;
        background: var(--bg);
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        box-shadow: var(--shadow-heavy);
        padding: var(--spacing-lg);
        padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .dap-fixed.is-expanded .dap-mobile-toggle {
        position: absolute;
        top: 15px;
        right: 15px;
        order: 0;
        background: rgba(0, 0, 0, 0.05) !important;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        opacity: 1;
    }
    .dap-fixed.is-expanded .dap-mobile-toggle svg {
        transform: rotate(180deg);
    }

    .dap-fixed.is-expanded .dap-mini-play { display: none; }

    .dap-fixed.is-expanded .dap-info {
        flex-direction: row;
        align-items: center;
        margin-bottom: var(--spacing-xl);
        width: 100%;
        padding-right: 40px;
    }
    .dap-fixed.is-expanded .dap-cover {
        width: var(--cover-size-expanded);
        height: var(--cover-size-expanded);
        border-radius: var(--border-radius-sm);
        margin-right: 15px;
        border: none;
    }
    .dap-fixed.is-expanded .dap-title { font-size: 16px; white-space: normal; }
    .dap-fixed.is-expanded .dap-author { font-size: 13px; margin-top: 4px; }

    .dap-fixed.is-expanded .dap-progress-wrap {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        order: 2;
        margin-bottom: var(--spacing-xl);
        min-width: 0;
        gap: 5px;
    }
    .dap-fixed.is-expanded .dap-bar-bg { width: 100%; height: 20px; order: 1; margin-bottom: 5px; }
    .dap-fixed.is-expanded .dap-bar-line { height: 6px; }
    .dap-fixed.is-expanded .dap-bar-knob { opacity: 1; }
    .dap-fixed.is-expanded .dap-time { font-size: 12px; color: var(--tt-fade); }
    .dap-fixed.is-expanded .dap-time:last-child { margin-left: auto; order: 3; }

    .dap-fixed.is-expanded .dap-controls-center {
        display: flex;
        width: 100%;
        justify-content: center;
        gap: 30px;
        order: 3;
        margin: 0;
    }
    .dap-fixed.is-expanded .dap-btn-play {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: var(--accent) !important;
        box-shadow: 0 5px 20px rgba(37, 177, 255, 0.3);
    }
    .dap-fixed.is-expanded .dap-btn-skip { display: flex; width: 40px; height: 40px; }

    .dap-fixed.is-expanded .dap-tools {
        display: flex;
        width: 100%;
        justify-content: space-between;
        order: 4;
        margin-top: var(--spacing-xl);
        padding-top: var(--spacing-md);
        border-top: 1px solid var(--bdc);
    }
    .dap-fixed.is-expanded .dap-tool-btn {
        width: auto;
        height: 34px;
        background: var(--bg-darker) !important;
        padding: 0 15px;
        border-radius: var(--border-radius-sm);
        font-size: 12px;
    }

    .dap-fixed.is-expanded .dap-popover,
    .dap-fixed.is-expanded .dap-speed-popover,
    .dap-fixed.is-expanded .dap-timer-popover {
        position: fixed;
        z-index: calc(var(--z-popover) + 100);
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        right: auto;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        max-height: 80vh;
    }
}

/* ============================================================
   4. МИНИ ПЛЕЕР (КОНЦЕПТ "ЕДИНАЯ КАПСУЛА")
   ============================================================ */
.dap-mini-player {
    width: 100%;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.85); /* Слегка прозрачный фон */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 100px; /* Идеальный овал */
    padding: 6px 12px; 
    display: flex;
    align-items: center;
    gap: 12px; 
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: var(--spacing-xl);
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden; /* Важно для нижней полосы прогресса */
}

@media (max-width: 650px) {
    .dap-mini-player { max-width: 100%; }
}

/* 1. ИКОНКИ (ТЕПЕРЬ В ЕДИНОМ СТИЛЕ) */
.dap-mini-main-btn,
.dap-mini-list-btn {
    width: 36px; 
    height: 36px; 
    background: transparent !important; /* Убрали синий кружок */
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; 
    cursor: pointer;
    color: var(--tt); /* Цвет как у текста */
    opacity: 0.7;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.dap-mini-main-btn:hover,
.dap-mini-list-btn:hover {
    opacity: 1;
    color: var(--accent); /* При наведении становятся акцентными */
    transform: scale(1.05);
}

.dap-mini-main-btn:focus-visible,
.dap-mini-list-btn:focus-visible {
    outline: none;
}

.dap-mini-main-btn svg,
.dap-mini-list-btn svg {
    width: 24px; 
    height: 24px; 
    fill: currentColor !important; /* Иконки берут цвет из color: */
}

/* 2. ИНФО-БЛОК (ЦЕНТР) */
.dap-mini-info {
    flex: 1;
    min-width: 0; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.dap-mini-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.dap-mini-tag span {
    font-size: 13px; 
    font-weight: 600; 
    color: var(--tt);
    font-feature-settings: "tnum";
    white-space: nowrap;
}

/* Прячем проценты в HTML (если они там остались) */
#dap-mini-percent {
    display: none !important;
}

/* 3. ПОЛОСА ПРОГРЕССА ВНИЗУ КАПСУЛЫ */
.dap-mini-progress {
    display: block !important;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: transparent;
    pointer-events: none;
}

#dap-mini-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.25s linear;
}

@keyframes dap-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.dap-spin {
    animation: dap-spin 1s linear infinite;
    transform-origin: 50% 50%;
    display: inline-block;
}

.dap-loading {
    opacity: 0.6;
    pointer-events: none;
}

.dap-player-link {
    color: inherit !important;        
    text-decoration: none !important; 
    cursor: pointer;
    position: relative;
    z-index: 20;                      
    pointer-events: auto !important;  
}

/* --- ФИКС ИКОНОК И СПИННЕРА --- */
.dap-btn-play svg { 
    width: 24px; 
    height: 24px; 
    fill: currentColor; 
    display: block; 
    margin: auto; 
}
.dap-mini-play svg { 
    width: 32px; 
    height: 32px; 
    fill: currentColor; 
}

/* --- КРУГОВОЙ ПРОГРЕСС ВОКРУГ ОБЛОЖКИ --- */
.dap-cover-wrap {
    position: relative;
    width: var(--cover-size);
    height: var(--cover-size);
    flex-shrink: 0;
    margin-right: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dap-fixed.is-expanded .dap-cover-wrap {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px auto; 
}

/* Сама картинка теперь круглая и чуть меньше, чтобы влезло кольцо */
.dap-cover {
    width: calc(100% - 8px) !important;
    height: calc(100% - 8px) !important;
    border-radius: 50% !important;
    object-fit: cover;
    margin: 0 !important;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    
    /* Анимация вращения с возможностью ставить на паузу */
    animation: dap-spin 20s linear infinite;
    animation-play-state: paused;
}

.dap-cover.is-spinning {
    animation-play-state: running;
}

/* SVG кольцо прогресса */
.dap-cover-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    transform: rotate(-90deg); 
}

.dap-cover-progress circle {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
}

.dap-cover-progress-bg {
    stroke: var(--bg-darker);
}

.dap-cover-progress-fill {
    stroke: var(--accent);
    stroke-dasharray: 201; 
    stroke-dashoffset: 201; 
    transition: stroke-dashoffset 0.25s linear; /* Синхронизировано со скриптом (0.25s) */
}

/* Цифра процентов по центру поверх обложки */
.dap-cover-pct {
    position: absolute;
    z-index: 3;
    background: rgba(30, 30, 47, 0.75);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

/* Показываем при тапе пальцем на свернутом плеере */
.dap-cover-wrap:active .dap-cover-pct {
    opacity: 1;
}

/* В развернутом виде на мобилке проценты показываются всегда */
.dap-fixed.is-expanded .dap-cover-pct {
    font-size: 14px;
    padding: 6px 12px;
    opacity: 1; /* Вот то, что вернуло их к жизни */
}

/* ============================================================
   5. КАСТОМНЫЙ СКРОЛЛБАР (ДЛЯ WINDOWS)
   ============================================================ */
.dap-pop-list::-webkit-scrollbar {
    width: 6px;
}
.dap-pop-list::-webkit-scrollbar-track {
    background: transparent;
}
.dap-pop-list::-webkit-scrollbar-thumb {
    background: var(--bdc);
    border-radius: 10px;
}

/* ============================================================
   6. ЗАЩИТА ОТ "ЗАЛИПАНИЯ" ЭФФЕКТОВ НА ТАЧСКРИНАХ
   ============================================================ */
@media (hover: hover) {
    .dap-btn-play:hover { transform: scale(1.05); background: var(--accent-2); }
    .dap-btn-skip:hover { opacity: 1; color: var(--accent); }
    .dap-bar-bg:hover .dap-bar-knob { opacity: 1; }
    .dap-tool-btn:hover { color: var(--accent); background: var(--bg-darker) !important; }
    .dap-pop-close:hover { color: var(--accent); background: var(--bg) !important; }
    .dap-pop-item:hover { background: var(--bg-darker); }
    .dap-speed-item:hover, .dap-timer-item:hover { border-color: var(--accent); color: var(--accent); background: var(--bg); }
    .dap-mini-main-btn:hover { color: var(--accent); transform: scale(1.05); }
    .dap-mini-list-btn:hover { color: var(--accent); transform: scale(1.1); }
    .dap-player-link:hover { opacity: 0.8; text-decoration: underline !important; }
    .dap-cover-wrap:hover .dap-cover-pct { opacity: 1; }
    .dap-pop-list::-webkit-scrollbar-thumb:hover { background: var(--tt-fade); }
}

/* ============================================================
   7. ТЕМНАЯ ТЕМА (DARK MODE) ДЛЯ МИНИ-ПЛЕЕРА
   ============================================================ */

/* 1. Автоматическое переключение (если зависит от настроек ОС/Браузера) */
@media (prefers-color-scheme: dark) {
    .dap-mini-player {
        background: rgba(30, 30, 35, 0.85); /* Темный стеклянный фон */
        border: 1px solid rgba(255, 255, 255, 0.08); /* Едва заметный светлый бордер */
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); /* Более густая тень для глубины */
    }
    
    /* Делаем неактивные иконки чуть светлее, чтобы не сливались с фоном */
    .dap-mini-main-btn,
    .dap-mini-list-btn {
        color: rgba(255, 255, 255, 0.7); 
    }
    
    .dap-mini-tag span {
        color: #e2e8f0; /* Светлый текст названия */
    }
}

/* 2. Принудительное переключение (если на сайте есть переключатель тем) */
/* Подставь сюда класс твоей темной темы, например body.dark, data-theme="dark" и т.д. */
body.dark .dap-mini-player,
body.theme-dark .dap-mini-player,
[data-theme="dark"] .dap-mini-player {
    background: rgba(30, 30, 35, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

body.dark .dap-mini-main-btn, body.theme-dark .dap-mini-main-btn, [data-theme="dark"] .dap-mini-main-btn,
body.dark .dap-mini-list-btn, body.theme-dark .dap-mini-list-btn, [data-theme="dark"] .dap-mini-list-btn {
    color: rgba(255, 255, 255, 0.7);
}

body.dark .dap-mini-tag span, body.theme-dark .dap-mini-tag span, [data-theme="dark"] .dap-mini-tag span {
    color: #e2e8f0;
}

/* Проценты на мобилках видны всегда */
    .dap-fixed:not(.is-expanded) .dap-cover-pct {
        opacity: 1;
        font-size: 10px;
        padding: 2px 6px;
        bottom: 4px; /* Прижимаем чуть ниже центра */
        background: rgba(30, 30, 47, 0.85); /* Чуть темнее для читаемости */
    }
    
/* --- Компенсация высоты плеера, чтобы он не перекрывал футер --- */

/* Для десктопа (высота плеера 80px + небольшой запас) */
body.has-audio-player {
    padding-bottom: calc(var(--player-height) + 20px) !important;
}

/* Для мобилок (высота 90px + челка айфона) */
@media (max-width: 1000px) {
    body.has-audio-player {
        padding-bottom: calc(var(--player-height-mobile) + env(safe-area-inset-bottom) + 20px) !important;
    }
}

/* ============================================================
   7. PWA ИНТЕРФЕЙС (НАВИГАЦИЯ И TABBAR)
   ============================================================ */
/* Бронебойное скрытие для обычного браузера (десктоп и обычный мобильный веб) */
.pwa-back-btn, 
.pwa-tab-bar {
    display: none !important;
}

@media (display-mode: standalone) {
    /* Кнопка назад в шапке */
    .pwa-back-btn {
        background: transparent;
        border: none;
        color: var(--tt);
        font-size: 20px;
        padding: 5px 15px 5px 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Скрываем кнопку "Назад" на главной странице */
    body.is-home-page .pwa-back-btn {
        display: none !important;
    }
    
    /* Принудительно показываем на внутренних страницах в PWA */
    body:not(.is-home-page) .pwa-back-btn {
        display: flex !important;
    }

    /* Принудительно показываем нижний TabBar в PWA */
    .pwa-tab-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: calc(55px + env(safe-area-inset-bottom));
        background: var(--bg-content);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--bdc);
        z-index: 8999; /* Ниже плеера */
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Иконки в нижнем меню */
    .pwa-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--tt-fade);
        text-decoration: none !important;
        font-size: 10px;
        font-weight: 600;
        gap: 4px;
        width: 100%;
        height: 100%;
        transition: color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }
    .pwa-tab-item i { font-size: 20px; }
    .pwa-tab-item.is-active { color: var(--accent); }

    /* --- ПОДНИМАЕМ ПЛЕЕР НАД TABBAR --- */
    .dap-fixed {
        bottom: calc(55px + env(safe-area-inset-bottom)) !important;
    }
    
    /* Если плеер развернут на весь экран - он должен перекрыть TabBar */
    .dap-fixed.is-expanded {
        bottom: 0 !important;
        z-index: 9999;
    }
    
    /* Поднимаем всплывающие окна (таймер, скорость) */
    .dap-popover, .dap-speed-popover, .dap-timer-popover {
        bottom: calc(90px + 55px + env(safe-area-inset-bottom)) !important;
    }
}