/* --- CYBER PLAYER --- */
.cyber-player {
    --cp-scale: 1; /* Базовый масштаб */
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 580px;
    background: rgba(var(--bg-rgb), 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    z-index: 9999;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cyber-player.compact {
    width: 260px !important;
    --cp-scale: 1 !important; /* В свернутом состоянии масштаб всегда 1х */
}

.cp-main {
    display: flex;
    align-items: center;
    padding: calc(12px * var(--cp-scale));
    gap: calc(8px * var(--cp-scale));
}

.cp-cover-wrap {
    width: calc(50px * var(--cp-scale));
    height: calc(50px * var(--cp-scale));
    border-radius: calc(8px * var(--cp-scale));
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
    position: relative;
    cursor: pointer;
}

.cp-expand-hint {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s ease;
    color: #fff;
}

.cp-expand-hint svg {
    width: calc(18px * var(--cp-scale));
    height: calc(18px * var(--cp-scale));
}

.cp-cover-wrap:hover .cp-expand-hint {
    opacity: 1;
}

.cyber-player:not(.compact) .icon-expand { display: none; }
.cyber-player.compact .icon-collapse { display: none; }

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

.cp-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.cp-title {
    font-size: calc(0.8rem * var(--cp-scale));
    font-weight: 900;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-artist {
    font-size: calc(0.65rem * var(--cp-scale));
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: none;
}

.cp-progress-row {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--cp-scale));
    font-size: calc(0.6rem * var(--cp-scale));
    font-family: monospace;
    color: var(--text-sub);
}

.cp-progress-bar {
    flex-grow: 1;
    height: calc(10px * var(--cp-scale));
    background: rgba(var(--fg-rgb), 0.2);
    border-radius: calc(5px * var(--cp-scale));
    cursor: pointer;
    position: relative;
    transition: height 0.1s ease;
}

.cp-progress-bar:hover {
    height: calc(14px * var(--cp-scale));
}

.cp-progress-fill {
    height: 100%;
    background: var(--fg);
    border-radius: calc(5px * var(--cp-scale));
    width: 0%;
    pointer-events: none;
    position: relative;
    box-shadow: 0 0 8px var(--fg);
}

.cp-actions {
    display: flex;
    align-items: center;
    gap: calc(4px * var(--cp-scale));
    overflow: hidden;
    transition: max-width 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    max-width: calc(400px * var(--cp-scale));
    opacity: 1;
    padding: 25px 0;
    margin: -25px 0;
}

.cyber-player.compact .cp-actions {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}

.cp-controls {
    display: flex;
    align-items: center;
    gap: calc(4px * var(--cp-scale));
}

.cp-btn {
    background: transparent;
    border: none;
    color: var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(28px * var(--cp-scale));
    height: calc(28px * var(--cp-scale));
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cp-btn:hover {
    background: rgba(var(--fg-rgb), 0.1);
    transform: scale(1.1);
}

.cp-btn.active {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

.cp-btn svg {
    width: calc(14px * var(--cp-scale));
    height: calc(14px * var(--cp-scale));
    fill: currentColor;
}

.cp-btn.play-btn {
    width: calc(30px * var(--cp-scale));
    height: calc(30px * var(--cp-scale));
    background: var(--fg);
    color: var(--bg);
    box-shadow: 0 0 15px rgba(var(--fg-rgb), 0.2);
}

.cp-btn.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(var(--fg-rgb), 0.6);
}

.cp-btn.play-btn svg {
    width: calc(16px * var(--cp-scale));
    height: calc(16px * var(--cp-scale));
}

.cp-volume {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--cp-scale));
    width: calc(90px * var(--cp-scale));
    opacity: 1;
    padding-left: calc(10px * var(--cp-scale));
    margin-left: calc(6px * var(--cp-scale));
    border-left: 1px solid var(--border-light);
}

.cp-volume svg {
    width: calc(14px * var(--cp-scale));
    height: calc(14px * var(--cp-scale));
    color: var(--text-muted);
    flex-shrink: 0;
}

.cp-volume input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(var(--fg-rgb), 0.2);
    border-radius: 2px;
    outline: none;
}

.cp-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: calc(10px * var(--cp-scale));
    height: calc(10px * var(--cp-scale));
    border-radius: 50%;
    background: var(--fg);
    cursor: pointer;
}

.cp-playlist {
    border-top: 1px solid var(--border-light);
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.cp-playlist.collapsed {
    max-height: 0 !important;
    opacity: 0;
    border-top-color: transparent;
}

.cp-playlist::-webkit-scrollbar { width: 4px; }
.cp-playlist::-webkit-scrollbar-track { background: transparent; }
.cp-playlist::-webkit-scrollbar-thumb { background: rgba(var(--fg-rgb), 0.3); border-radius: 2px; }

.cp-playlist-header {
    padding: calc(8px * var(--cp-scale)) calc(16px * var(--cp-scale));
    font-size: calc(0.65rem * var(--cp-scale));
    font-weight: bold;
    letter-spacing: 1px;
    background: rgba(var(--bg-rgb), 0.95);
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--fg);
}

.cp-track-item {
    display: flex;
    align-items: center;
    padding: calc(8px * var(--cp-scale)) calc(16px * var(--cp-scale));
    gap: calc(12px * var(--cp-scale));
    cursor: pointer;
    transition: background 0.2s ease;
}

.cp-track-item:hover {
    background: rgba(var(--fg-rgb), 0.05);
}

.cp-track-item.active {
    background: rgba(var(--fg-rgb), 0.1);
}

.cp-track-num {
    font-size: calc(0.7rem * var(--cp-scale));
    font-family: monospace;
    color: var(--text-muted);
    width: calc(20px * var(--cp-scale));
    text-align: center;
}

.cp-track-cover {
    width: calc(32px * var(--cp-scale));
    height: calc(32px * var(--cp-scale));
    border-radius: calc(4px * var(--cp-scale));
    object-fit: cover;
    border: 1px solid var(--border-light);
    flex-shrink: 0;
    display: block;
}

.cp-track-details {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cp-track-title {
    font-size: calc(0.75rem * var(--cp-scale));
    font-weight: bold;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-track-artist {
    font-size: calc(0.65rem * var(--cp-scale));
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: none;
}

/* Эквалайзер для активного трека */
.cp-eq {
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 12px;
    width: 20px;
}

.cp-track-item.active.playing .num-text { display: none; }
.cp-track-item.active.playing .cp-eq { display: flex; }

.cp-eq-bar {
    width: 3px;
    background: #4caf50;
    animation: eqPlay 0.8s infinite alternate ease-in-out;
}

.cp-eq-bar:nth-child(2) { animation-delay: 0.2s; }
.cp-eq-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes eqPlay {
    0% { height: 3px; }
    100% { height: 12px; }
}

/* =========================================
   АДАПТАЦИЯ ПЛЕЕРА (MACBOOK, IPAD, PHONE)
   ========================================= */

/* MacBooks и небольшие экраны (до 1440px) */
@media (max-width: 1440px) {
    .cyber-player {
        width: 480px;
        --cp-scale: 0.9;
    }
    .cyber-player.compact {
        width: 260px !important;
    }
}

/* Планшеты (iPad) (до 1024px) */
@media (max-width: 1024px) {
    .cyber-player {
        width: 420px;
        bottom: 1.5rem;
        right: 1.5rem;
        --cp-scale: 0.8;
    }
    .cyber-player.compact {
        width: 240px !important;
        --cp-scale: 0.9 !important;
    }
    /* Отключаем ресайз пальцем на тач-устройствах */
    .cp-resize-corner { display: none; }
}

/* Мобильные телефоны */
@media (max-width: 768px) {
    .cyber-player {
        width: calc(100% - 2rem) !important; /* Принудительно на всю ширину с отступами */
        max-width: 400px !important; /* Чтобы на больших телефонах не был слишком длинным */
        bottom: 1rem;
        right: 1rem;
        --cp-scale: 0.85 !important; 
        border-radius: 16px;
    }
    .cyber-player.compact {
        width: 260px !important;
        --cp-scale: 0.9 !important;
    }

    .cp-volume { display: none !important; } /* Прячем громкость на телефоне */
    
    .cp-playlist { max-height: 40vh !important; } /* Ограничиваем высоту плейлиста */
    
    /* Восстанавливаем читаемость шрифтов, игнорируя scale */
    .cp-title { font-size: 0.95rem !important; }
    .cp-artist { font-size: 0.8rem !important; }
    .cp-progress-row { font-size: 0.75rem !important; }
    .cp-track-title { font-size: 0.9rem !important; }
    .cp-track-artist { font-size: 0.75rem !important; }
    
    /* Делаем кнопки крупнее для удобного нажатия пальцем */
    .cp-btn { width: 36px !important; height: 36px !important; }
    .cp-btn svg { width: 16px !important; height: 16px !important; }
    
    .cp-btn.play-btn { width: 44px !important; height: 44px !important; }
    .cp-btn.play-btn svg { width: 20px !important; height: 20px !important; }
    
    /* Полоска перемотки толще для тача */
    .cp-progress-bar { height: 12px !important; border-radius: 6px !important; }
    .cp-progress-fill { border-radius: 6px !important; }
    
    /* Подсказка раскрытия всегда слегка видна на мобилках */
    .cp-expand-hint { opacity: 1; background: rgba(0,0,0,0.4); }
}

/* --- РЕСАЙЗЕР ПЛЕЕРА --- */
.cp-resize-corner {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 100;
}

.cyber-player.compact .cp-resize-corner {
    display: none;
}

.cp-resize-corner::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 6px;
    height: 6px;
    border-top: 2px solid var(--text-muted);
    border-left: 2px solid var(--text-muted);
    transition: border-color 0.2s ease;
}

.cp-resize-corner:hover::before {
    border-color: var(--fg);
}

/* =========================================
   МАЛЕНЬКИЕ ТЕЛЕФОНЫ (до 480px)
   ========================================= */
@media (max-width: 480px) {
    .cyber-player {
        width: calc(100% - 1rem) !important;
        bottom: 0.5rem;
        right: 0.5rem;
        --cp-scale: 0.75 !important;
    }
    .cyber-player.compact {
        width: 220px !important;
        --cp-scale: 0.8 !important;
    }
    .cp-cover { width: 50px; height: 50px; }
    .cp-title { font-size: 0.85rem !important; }
    .cp-artist { font-size: 0.7rem !important; }
}

/* =========================================
   ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (до 375px)
   ========================================= */
@media (max-width: 375px) {
    .cyber-player {
        --cp-scale: 0.7 !important;
    }
    .cyber-player.compact {
        width: 200px !important;
        --cp-scale: 0.75 !important;
    }
    .cp-btn.play-btn { width: 38px !important; height: 38px !important; }
}