:root {
    --bg-color: #000000;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #fa2d48;
    --glass: rgba(20, 20, 20, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --mini-player-height: 72px;
    --nav-height: 85px;
}

/* Shared Mode Styles */
body.shared-mode .library-view,
body.shared-mode .mini-player,
body.shared-mode .nav-bar,
body.shared-mode .close-btn,
body.shared-mode .drag-handle,
body.shared-mode .main-app {
    display: none !important;
}

/* Скрываем старый UI когда показывается новый */
.main-app.active ~ .library-view,
.main-app.active ~ .nav-bar {
    display: none !important;
}

body.shared-mode .full-player {
    top: 0 !important;
    background: #000;
    /* Скрываем контент до полной загрузки */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

body.shared-mode .full-player.loaded {
    opacity: 1;
}

/* Скрываем кнопки навигации в shared mode (одиночный трек) */
body.shared-mode .main-controls .control-btn:first-child,
body.shared-mode .main-controls .control-btn:last-child {
    display: none !important;
}

/* Показываем и центрируем кнопку лайка и поделиться в shared mode */
body.shared-mode .player-like-section {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    margin-top: 10px !important;
    flex-wrap: wrap !important;
}

body.shared-mode .mini-like-btn {
    display: none !important;
}

/* Центрируем кнопку play в shared mode */
body.shared-mode .main-controls {
    justify-content: center !important;
    gap: 0 !important;
    padding: 0 !important;
}

body.shared-mode .main-controls .control-btn.play-large {
    margin: 0 !important;
    flex: 0 0 auto !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
}

/* Базовые стили для shared mode будут переопределены более специфичными правилами ниже */

/* Адаптация для маленьких экранов и квадратных устройств (умные часы и т.д.) */
/* Используем динамическое масштабирование на основе высоты экрана */
@media (max-height: 700px) {
    body.shared-mode .player-content,
    .player-content {
        padding: clamp(10px, 2vh, 15px) clamp(15px, 4vw, 25px) !important;
        justify-content: space-between !important;
        height: calc(100% - 40px) !important;
    }
    
    body.shared-mode .visual-container,
    .visual-container {
        margin-bottom: 15px !important;
        /* Даем больше места для обложки на малых экранах, если есть место */
        flex: 1 1 auto !important;
        max-height: 45vh !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    
    body.shared-mode .album-art-large,
    .album-art-large {
        /* Гибкие размеры */
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        aspect-ratio: 1/1 !important;
        object-fit: cover !important;
    }
    
    .player-track-info {
        margin-bottom: clamp(8px, 1.5vh, 15px) !important;
    }
    
    .player-track-text h2 {
        font-size: clamp(16px, 4vw, 24px) !important;
    }
    
    .player-track-text p {
        font-size: clamp(13px, 3.5vw, 18px) !important;
    }
    
    .main-controls {
        margin-bottom: clamp(8px, 1.5vh, 15px) !important;
        padding: 0 clamp(10px, 3vw, 20px) !important;
    }
    
    .control-btn {
        font-size: clamp(28px, 7vw, 42px) !important;
    }
    
    .control-btn.play-large {
        font-size: clamp(48px, 12vw, 72px) !important;
    }
    
    .progress-area {
        margin-bottom: clamp(6px, 1vh, 10px) !important;
    }
    
    .time-codes {
        font-size: clamp(10px, 2.5vw, 12px) !important;
        margin-top: clamp(4px, 1vh, 8px) !important;
    }
}

/* Специальная адаптация для квадратных экранов (1:1) */
@media (aspect-ratio: 1/1) {
    body.shared-mode .player-content,
    .player-content {
        padding: 10px 15px !important;
        justify-content: space-evenly !important;
    }
    
    body.shared-mode .visual-container,
    .visual-container {
        max-height: 45vh !important;
        margin-bottom: 5px !important;
    }
    
    body.shared-mode .album-art-large,
    .album-art-large {
        /* Для квадратных экранов используем меньший размер */
        width: auto !important;
        height: auto !important;
        max-width: min(300px, 80vw) !important;
        max-height: min(300px, 45vh) !important;
        aspect-ratio: 1/1 !important;
    }
    
    .player-track-info {
        margin-bottom: clamp(5px, 1vh, 10px) !important;
    }
    
    .player-track-text h2 {
        font-size: clamp(14px, 3.5vw, 20px) !important;
        margin-bottom: 2px !important;
    }
    
    .player-track-text p {
        font-size: clamp(12px, 3vw, 16px) !important;
        margin-top: 2px !important;
    }
    
    .main-controls {
        margin-bottom: clamp(5px, 1vh, 10px) !important;
        padding: 0 clamp(8px, 2vw, 15px) !important;
    }
    
    .control-btn {
        font-size: clamp(24px, 6vw, 36px) !important;
    }
    
    .control-btn.play-large {
        font-size: clamp(40px, 10vw, 60px) !important;
    }
    
    .progress-area {
        margin-bottom: clamp(4px, 0.8vh, 8px) !important;
    }
    
    .time-codes {
        font-size: clamp(9px, 2.2vw, 11px) !important;
        margin-top: clamp(3px, 0.8vh, 6px) !important;
    }
    
    .btn-lyrics-toggle {
        width: clamp(36px, 9vw, 44px) !important;
        height: clamp(36px, 9vw, 44px) !important;
        font-size: clamp(16px, 4vw, 20px) !important;
    }
}

/* Комбинированная адаптация: квадратный экран + маленькая высота */
@media (aspect-ratio: 1/1) and (max-height: 600px) {
    body.shared-mode .player-content,
    .player-content {
        padding: clamp(8px, 2vh, 12px) clamp(12px, 3vw, 18px) clamp(10px, 2vh, 14px) clamp(12px, 3vw, 18px) !important;
        justify-content: flex-start !important;
        gap: 8px !important;
    }
    
    body.shared-mode .visual-container,
    .visual-container {
        margin-bottom: 10px !important;
        flex: 0 1 auto !important;
        max-height: 40vh !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    
    body.shared-mode .album-art-large,
    .album-art-large {
        width: auto !important;
        height: auto !important;
        max-width: min(75vw, 100%) !important;
        max-height: 100% !important;
        aspect-ratio: 1/1 !important;
        object-fit: cover !important;
    }
    
    .player-track-info {
        margin-bottom: 10px !important;
    }
    
    .player-track-text h2 {
        font-size: clamp(14px, 3.5vw, 18px) !important;
    }
    
    .player-track-text p {
        font-size: clamp(12px, 3vw, 15px) !important;
    }
    
    .main-controls {
        margin-bottom: 10px !important;
        padding: 0 clamp(10px, 3vw, 15px) !important;
    }
    
    .control-btn {
        font-size: clamp(24px, 6vw, 32px) !important;
    }
    
    .control-btn.play-large {
        font-size: clamp(40px, 10vw, 56px) !important;
    }
    
    .progress-area {
        margin-bottom: 8px !important;
    }
    
    .time-codes {
        margin-top: 6px !important;
    }
}

/* Гибкая адаптация для shared-mode (автоматическая подстройка под любой размер) - УДАЛЕНО ДЛЯ УНИФИКАЦИИ С АЛЬБОМНЫМ ПЛЕЕРОМ */
/* body.shared-mode .player-content { ... } и другие специфичные стили удалены */

/* SKELETON LOADER */
.skeleton-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 20000; /* Выше всего: модалок (10000), плееров (1500-2000), навигации (1000) */
    display: none; /* По умолчанию скрыт, показываем через JS/HTML только в shared mode */
    flex-direction: column;
    padding: 15px 30px 20px 30px;
    box-sizing: border-box;
    justify-content: center; /* Центрируем контент, как в плеере */
}

body.shared-mode .skeleton-loader {
    display: flex;
}

/* Анимация мерцания */
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-item {
    background: linear-gradient(90deg, #1c1c1e 25%, #2c2c2e 50%, #1c1c1e 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

.skeleton-header {
    height: 50px;
    margin-top: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    height: calc(100% - 60px);
    min-height: 0;
}

.skeleton-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    min-height: 0;
    width: calc(100% + 40px);
    margin-left: -20px;
    margin-right: -20px;
    padding: 0 20px;
}

.skeleton-cover {
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1/1;
    border-radius: 16px;
    box-shadow: none;
}

.skeleton-info {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.skeleton-title {
    height: 28px;
    width: 60%;
    margin-bottom: 10px;
    border-radius: 6px;
}

.skeleton-artist {
    height: 20px;
    width: 40%;
    border-radius: 4px;
}

.skeleton-progress {
    width: 100%;
    height: 4px;
    margin-bottom: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.skeleton-time {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    margin-bottom: 15px;
}

.skeleton-time-text {
    height: 12px;
    width: 30px;
    border-radius: 2px;
}

.skeleton-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 20px;
    flex-shrink: 0;
}

.skeleton-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
}

.skeleton-btn.large {
    width: 72px;
    height: 72px;
}

/* Адаптация скелетона под мобильные (аналогично плееру) */
@media (max-width: 767px) {
    .skeleton-loader {
        padding: 15px 20px 20px 20px;
    }
    .skeleton-content {
        justify-content: center;
        padding-top: 3vh;
        padding-bottom: 3vh;
    }
    .skeleton-header {
        display: none; /* В мобилке хедера нет или он другой */
    }
    .skeleton-visual {
        width: calc(100% + 40px);
        margin-left: -20px;
        margin-right: -20px;
        padding: 0 20px;
    }
    .skeleton-cover {
        max-height: 40vh;
    }
    .skeleton-btn { width: 36px; height: 36px; }
    .skeleton-btn.large { width: 64px; height: 64px; }
    .skeleton-title { height: 24px; }
    .skeleton-artist { height: 16px; }
}

/* Telegram WebView стили */
.tg-view {
    /* Используем цвета из Telegram WebApp если доступны */
    background-color: var(--bg-color);
}

/* Адаптация для Telegram WebView */
html.tg-view body {
    background-color: var(--bg-color);
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Скрываем элементы которые не нужны в Telegram */
.tg-view .nav-bar {
    display: none;
}

/* Улучшаем отображение в Telegram WebView */
.tg-view .library-view {
    padding-bottom: 100px;
    height: 100%;
    overflow-y: auto;
}

.tg-view .mini-player {
    bottom: 20px;
}

/* Используем высоту viewport из Telegram если доступна */
html.tg-view {
    height: auto;
    min-height: var(--tg-viewport-height, 100vh);
}

html.tg-view body {
    height: auto;
    min-height: var(--tg-viewport-height, 100vh);
}

/* Улучшаем отображение в Telegram на разных устройствах */
.tg-view .header {
    padding-top: env(safe-area-inset-top, 20px);
}

.tg-view .mini-player {
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
}

/* НЕ применяем margin-bottom для .tg-view .mini-player на других страницах, только в .main-app */
body:not(:has(.main-app)) .tg-view .mini-player {
    margin-bottom: 0 !important;
}

/* Скрываем стандартную навигацию браузера в Telegram */
.tg-view .library-view {
    -webkit-overflow-scrolling: touch;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === ГЛАВНЫЙ ЭКРАН (БИБЛИОТЕКА) === */
.library-view {
    min-height: 100vh;
    width: 100%;
    padding: 20px 20px 120px 20px;
    overflow-y: visible;
    background: linear-gradient(180deg, #1c1c1e 0%, #000000 100%);
    -webkit-overflow-scrolling: touch;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-top: 40px;
}
.header h1 { 
    margin: 0; 
    font-size: 34px; 
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Кнопка "Назад" */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}

.back-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(-2px);
}

.back-btn:active {
    transform: translateX(-2px) scale(0.95);
}

.header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.header h1 {
    flex: 1;
}

.track-list { display: flex; flex-direction: column; gap: 0; }

.track-item {
    display: flex; 
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}
.track-item:last-child { border-bottom: none; }
.track-item:active { 
    background-color: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding-left: 12px;
    padding-right: 12px;
    margin: 0 -12px;
}

/* Убираем активное состояние после клика */
.track-item {
    -webkit-tap-highlight-color: transparent;
}

.track-item:not(.playing-now):active {
    transition: background 0.1s, transform 0.1s;
}

/* Сбрасываем активное состояние после клика */
.track-item:not(:active) {
    background-color: transparent;
}
.track-item img {
    width: 52px; 
    height: 52px; 
    min-width: 52px;
    border-radius: 8px;
    object-fit: cover; 
    margin-right: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.track-info { 
    flex: 1; 
    min-width: 0; 
    margin-right: 12px;
}
.track-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin-left: 8px;
}
.btn-play-track {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-play-track:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}
.btn-play-track ion-icon {
    margin-left: 2px;
    font-size: 20px;
}
.track-title { 
    font-size: 17px; 
    font-weight: 600; 
    margin-bottom: 4px; 
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.track-artist { 
    font-size: 14px; 
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Активный трек в списке */
.track-item.playing-now .track-title { color: var(--accent); }

/* Анимация эквалайзера */
.equalizer-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 16px;
    padding: 0 8px;
    flex-shrink: 0;
}
.equalizer-bar {
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    animation: equalizer 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.equalizer-bar:nth-child(1) { height: 6px; animation-delay: 0s; }
.equalizer-bar:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.equalizer-bar:nth-child(3) { height: 16px; animation-delay: 0.2s; }
.equalizer-bar:nth-child(4) { height: 10px; animation-delay: 0.3s; }
.equalizer-bar:nth-child(5) { height: 8px; animation-delay: 0.4s; }

.equalizer-animation.paused .equalizer-bar {
    animation: none;
    height: 3px !important;
    opacity: 0.3;
}

@keyframes equalizer {
    0%, 100% { transform: scaleY(0.3); opacity: 0.8; }
    50% { transform: scaleY(1); opacity: 1; }
}

/* === MINI PLAYER (Float Style) === */
.mini-player {
    position: fixed;
    bottom: max(90px, calc(85px + env(safe-area-inset-bottom, 20px))); /* Выше навигации (навигация ~60-70px) */
    left: 15px; 
    right: 15px;
    width: auto;
    height: var(--mini-player-height);
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 18px;
    display: flex; 
    align-items: center;
    padding: 8px 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), inset 0 0 0 0.5px rgba(255,255,255,0.1);
    z-index: 1500; /* Выше навигации (z-index: 1000), но НИЖЕ модалок (z-index: 10000+) */
}

/* На десктопе ограничиваем ширину и центрируем, как остальные элементы */
@media (min-width: 768px) {
    .mini-player {
        left: 50%;
        transform: translate(-50%, 0);
        right: auto;
        max-width: 1200px;
        width: calc(100% - 40px);
    }
}

/* В приложении миниплеер должен быть намного выше - переопределяется в app.css */
/* Стили для .main-app .mini-player теперь в app.css с более высокой специфичностью */

/* НЕ применяем margin-bottom для миниплеера на других страницах */
body:not(:has(.main-app)) .mini-player {
    margin-bottom: 0 !important;
}
.mini-player.hidden { 
    transform: translateY(150%); 
    opacity: 0; 
    pointer-events: none;
}

/* Скрываем миниплеер когда full player открыт */
.full-player.open ~ .mini-player,
.full-player.open + .mini-player,
body:has(.full-player.open) .mini-player {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.mini-cover {
    width: 48px; 
    height: 48px; 
    border-radius: 8px; 
    margin-right: 14px;
    object-fit: cover; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.mini-info { 
    flex: 1; 
    overflow: hidden; 
    min-width: 0;
    margin-right: 10px;
}
.mini-title { 
    font-size: 15px; 
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.mini-artist { 
    font-size: 13px; 
    color: var(--text-secondary); 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-controls { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    font-size: 24px;
    flex-shrink: 0;
    color: white;
    position: relative;
    filter: grayscale(100%);
}
.mini-controls > div {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.mini-controls > div:active { opacity: 0.5; }

.mini-like-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    transition: color 0.2s;
}

.mini-like-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    transition: color 0.2s;
}

.mini-like-btn.liked {
    color: #fa2d48;
}

.mini-like-btn.liked ion-icon {
    fill: #fa2d48;
}

.track-like-btn.liked, .album-like-btn.liked {
    color: #fa2d48;
}

.track-like-btn.liked ion-icon, .album-like-btn.liked ion-icon {
    fill: #fa2d48;
    cursor: pointer;
    transition: color 0.2s;
}

/* Стили для кнопки лайка в фулл плеере */
.player-like-btn.liked {
    background: rgba(250, 45, 72, 0.2) !important;
    border-color: #fa2d48 !important;
}

.player-like-btn.liked ion-icon {
    color: #fa2d48 !important;
}

.player-like-btn.liked #player-likes-count {
    color: #fa2d48 !important;
}

/* Стили для кнопки поделиться в фулл плеере (модульная, работает везде) */
.player-share-btn {
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.player-share-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.05);
}

.player-share-btn:active {
    transform: scale(0.95);
}

.player-share-btn ion-icon {
    transition: transform 0.2s ease;
}

.player-share-btn:hover ion-icon {
    transform: rotate(15deg);
}
.mini-like-btn:hover {
    color: #fa2d48;
}
.mini-like-btn.liked {
    color: #fa2d48;
}
.mini-like-btn.liked ion-icon {
    fill: #fa2d48;
}

.mini-volume-btn {
    cursor: pointer;
    transition: opacity 0.2s;
    position: relative;
    /* Убеждаемся, что контейнер громкости позиционируется относительно этой кнопки */
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-volume-btn:hover {
    opacity: 0.7;
}

/* Контейнер громкости позиционируется над кнопкой громкости */
.mini-volume-container {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(calc(-50% + 50px));
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 20001;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 48px;
    display: none;
    align-items: center;
    justify-content: center;
    /* Предотвращаем скролл при взаимодействии */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.mini-volume-container[style*="flex"] {
    display: flex !important;
}

.mini-volume-slider-wrapper {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    /* Предотвращаем скролл */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Современный вертикальный слайдер с круглым thumb */
.mini-volume-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 4px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: block;
    flex-shrink: 0;
    transition: background 0.2s ease;
    /* Предотвращаем скролл страницы при взаимодействии */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.mini-volume-slider:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Webkit (Chrome, Safari, Edge) - круглый thumb */
.mini-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 255, 255, 0.1);
    margin-left: -7px;
    position: relative;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.mini-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.mini-volume-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Дорожка слайдера */
.mini-volume-slider::-webkit-slider-runnable-track {
    width: 4px;
    height: 120px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* Firefox - круглый thumb */
.mini-volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.mini-volume-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.mini-volume-slider::-moz-range-thumb:active {
    transform: scale(1.1);
}

/* Дорожка для Firefox */
.mini-volume-slider::-moz-range-track {
    width: 4px;
    height: 120px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

@media (max-width: 767px) {
    .mini-controls {
        gap: 10px;
        font-size: 20px;
    }
    .mini-like-btn {
        font-size: 16px;
    }
    .mini-volume-container {
        bottom: calc(100% + 10px);
        padding: 14px 8px;
        width: 44px;
    }
    .mini-volume-slider-wrapper {
        height: 100px;
    }
    .mini-volume-slider {
        height: 100px;
        width: 3px;
    }
    .mini-volume-slider::-webkit-slider-runnable-track {
        width: 3px;
        height: 100px;
    }
    .mini-volume-slider::-moz-range-track {
        width: 3px;
        height: 100px;
    }
    .mini-volume-slider::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
        margin-left: -6.5px;
    }
    .mini-volume-slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }
}

/* === FULL PLAYER (MODAL) === */
.full-player {
    position: fixed; 
    top: 100%; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: #000;
    z-index: 2000; /* Выше миниплеера (1500), но НИЖЕ модалок (10000+) */
    display: flex; 
    flex-direction: column;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.full-player.open { top: 0; }

/* Динамический фон плеера */
.player-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    filter: blur(100px) brightness(0.3) saturate(120%);
    transform: scale(1.2); /* Чтобы размытые края не были видны */
    z-index: -1; 
    transition: background-image 0.8s ease;
}

/* Шапка плеера */
.player-header {
    height: 50px; 
    display: flex; 
    justify-content: center; 
    align-items: center;
    position: relative; 
    margin-top: 10px;
    flex-shrink: 0;
}
.drag-handle {
    width: 36px; 
    height: 4px; 
    background: rgba(255,255,255,0.2);
    border-radius: 4px; 
    cursor: pointer;
}
.close-btn {
    position: absolute; 
    right: 20px; 
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.05); 
    border-radius: 50%;
    width: 32px; 
    height: 32px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border: none; 
    color: rgba(255,255,255,0.8); 
    font-size: 20px;
    transition: background 0.2s;
}
.close-btn:active { background: rgba(255,255,255,0.15); }

/* Контент плеера */
.player-content {
    flex: 1; 
    display: flex; 
    flex-direction: column;
    padding: 15px 30px 20px 30px;
    max-width: 500px; 
    margin: 0 auto; 
    width: 100%;
    height: calc(100% - 60px);
    box-sizing: border-box;
    overflow: visible;
    min-height: 0;
    /* Возвращаем space-between для равномерного распределения */
    justify-content: space-between;
    gap: 10px;
}

/* Визуальный контейнер (Обложка/Текст) */
.visual-container {
    /* Возвращаем flex-grow, чтобы занимать свободное место */
    flex: 1 1 auto; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    position: relative; 
    margin-bottom: 10px;
    min-height: 0;
    /* Ограничиваем высоту, но даем занимать пространство */
    max-height: 55vh; 
    width: 100%;
    /* Убираем отрицательные марджины, они могут ломать лейаут */
    /* margin-left: -20px; */
    /* margin-right: -20px; */
    padding: 0;
    overflow: visible;
    /* Предотвращаем "телепортацию" при переключении */
    transition: min-height 0.4s ease;
}

/* Обложка */
.album-art-large {
    width: auto;
    height: auto; 
    max-width: 100%; 
    /* Ограничиваем высоту обложки, чтобы она не выталкивала контролы */
    max-height: 100%; 
    aspect-ratio: 1/1; 
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
    transform: scale(1);
    opacity: 1;
    display: block;
    margin: 0 auto;
    min-width: 0;
    min-height: 0;
}

/* Плейсхолдер для отсутствующей обложки */
.album-art-large[src=""],
.album-art-large:not([src]) {
    background-color: #333;
    position: relative;
}
.album-art-large[src=""]::after,
.album-art-large:not([src])::after {
    content: '♪';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: rgba(255,255,255,0.2);
}

.shrink .album-art-large { 
    transform: scale(0.75); 
    opacity: 0.8; 
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.album-art-large {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* === TEKST (LYRICS) === */
.lyrics-wrapper {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.4s ease;
    /* Маска только сверху и снизу, НЕ ПО БОКАМ */
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    /* Убеждаемся, что контейнер видим и имеет содержимое */
    visibility: hidden;
    pointer-events: none;
}
.lyrics-wrapper[style*="flex"] { 
    opacity: 1; 
    visibility: visible;
    pointer-events: auto;
}

.lyrics-scroll {
    overflow-y: scroll; 
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    padding: 0 40px;
    box-sizing: border-box;
    text-align: left;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.lyrics-scroll::-webkit-scrollbar { display: none; }

.lyric-line {
    font-size: clamp(24px, 6vw, 32px); 
    font-weight: 800;
    color: rgba(255,255,255,0.35);
    margin: 24px 0;
    padding: 0;
    transition: color 0.5s cubic-bezier(0.4, 0, 0.2, 1), text-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none; 
    line-height: 1.3;
    overflow-wrap: break-word;
    hyphens: auto;
    transform: none !important;
}

.lyric-line.active {
    color: #ffffff;
    text-shadow: 
        0 0 4px rgba(255,255,255,0.05),
        0 0 8px rgba(255,255,255,0.03);
    filter: none;
    opacity: 1;
    position: relative;
    z-index: 10;
    transform: none !important;
}

.lyric-line:not(.active) { 
    filter: blur(1.5px); 
    opacity: 0.5;
}

/* Пустые блоки для центрирования скролла */
.lyric-spacer { height: 40vh; flex-shrink: 0; }

/* Инфо о треке */
.player-track-info {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}
.player-track-text { 
    flex: 1; 
    min-width: 0; 
    margin-right: 15px;
}
.player-track-text h2 { 
    margin: 0; 
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-track-text p { 
    margin: 4px 0 0 0; 
    color: rgba(255,255,255,0.7); 
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Кнопка Lyrics в инфо */
.btn-lyrics-toggle {
    background: rgba(255,255,255,0.1); 
    border: none;
    width: 44px; 
    height: 44px; 
    border-radius: 50%;
    color: white; 
    font-size: 20px; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.3s ease;
}
.btn-lyrics-toggle.active { 
    background: #ffffff; 
    color: #000000;
}
.btn-lyrics-toggle:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Прогресс бар */
.progress-area { 
    width: 100%; 
    margin-bottom: 10px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.progress-bar {
    width: 100%; 
    height: 4px; 
    background: rgba(255,255,255,0.15);
    border-radius: 2px; 
    position: relative; 
    cursor: pointer;
    overflow: visible; /* Для точки */
}
.progress-fill {
    width: 0%; 
    height: 100%; 
    background: #fff; 
    border-radius: 2px;
    position: relative;
}
.progress-fill::after {
    content: ''; 
    position: absolute; 
    right: -6px; 
    top: 50%;
    transform: translateY(-50%);
    width: 12px; 
    height: 12px; 
    background: #fff; 
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    opacity: 1; /* Всегда видно */
}

.time-codes {
    display: flex; 
    justify-content: space-between;
    font-size: 12px; 
    color: rgba(255,255,255,0.5); 
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Кнопки управления */
.main-controls {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 15px; /* Уменьшил отступ */
    padding: 0 20px;
    flex-shrink: 0;
}
.control-btn {
    background: none; 
    border: none; 
    color: white; 
    font-size: 42px; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: transform 0.1s;
    opacity: 0.9;
}
.control-btn:active { transform: scale(0.9); opacity: 0.7; }
.control-btn.play-large { 
    font-size: 72px; 
    opacity: 1;
}
.control-btn.play-large:active { transform: scale(0.95); }

/* Громкость */
.bottom-controls {
    display: none; /* Скрыто по умолчанию, чтобы не прыгало */
    align-items: center;
    gap: 15px;
    margin-top: auto; /* Прижимаем к низу */
    flex-shrink: 0;
}

/* Показываем только если есть класс has-volume и это не iOS */
body.has-volume .bottom-controls {
    display: flex;
}

/* Скрываем управление громкостью на iOS - там используется системное управление */
@supports (-webkit-touch-callout: none) {
    .bottom-controls {
        display: none !important;
    }
    .mini-volume-btn,
    .mini-volume-container {
        display: none !important;
    }
}

/* Также скрываем через класс для надежности */
.ios-device .bottom-controls {
    display: none !important;
}
.ios-device .mini-volume-btn,
.ios-device .mini-volume-container {
    display: none !important;
}
.volume-slider {
    flex: 1; 
    height: 4px; 
    -webkit-appearance: none; 
    appearance: none;
    background: rgba(255,255,255,0.15); 
    border-radius: 2px;
    outline: none;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; 
    appearance: none;
    width: 20px; 
    height: 20px; 
    background: white; 
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3); 
    cursor: pointer;
    transform: scale(0.8);
    transition: transform 0.1s;
}
.volume-slider:active::-webkit-slider-thumb { transform: scale(1); }


/* === Media Queries === */
@media (min-width: 768px) {
    /* Для десктопов - центрируем контент */
    .player-content {
        justify-content: center;
        padding-top: 5vh;
        padding-bottom: 5vh;
    }
    
    .album-art-large {
        max-width: 350px;
        max-height: 45vh;
    }
}

@media (max-width: 767px) {
    /* Для мобильных */
    .player-content {
        justify-content: center;
        padding-top: 3vh;
        padding-bottom: 3vh;
    }
    
    .album-art-large {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        aspect-ratio: 1/1 !important;
        object-fit: cover !important;
        margin: 0 auto;
        display: block;
    }
    
    /* Улучшения для мобильных */
    .header {
        padding-top: 20px;
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 28px;
    }
    
    .track-item {
        padding: 10px 0;
    }
    
    .track-item img {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }
    
    .track-title {
        font-size: 16px;
    }
    
    .track-artist {
        font-size: 13px;
    }
    
    .mini-player {
        bottom: 15px;
        left: 10px;
        right: 10px;
        height: 64px;
        padding: 6px 12px;
    }
    
    .mini-cover {
        width: 44px;
        height: 44px;
    }
    
    .mini-title {
        font-size: 14px;
    }
    
    .mini-artist {
        font-size: 12px;
    }
    
    .mini-controls {
        gap: 10px;
        font-size: 20px;
    }
    .mini-like-btn {
        font-size: 16px;
    }
    .mini-volume-container {
        bottom: calc(100% + 10px);
        padding: 14px 8px;
        width: 44px;
    }
    .mini-volume-slider-wrapper {
        height: 100px;
    }
    .mini-volume-slider {
        height: 100px;
        width: 3px;
    }
    .mini-volume-slider::-webkit-slider-runnable-track {
        width: 3px;
        height: 100px;
    }
    .mini-volume-slider::-moz-range-track {
        width: 3px;
        height: 100px;
    }
    .mini-volume-slider::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
        margin-left: -6.5px;
    }
    .mini-volume-slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }
    
    .player-content {
        padding: 15px 20px 20px 20px;
    }
    
    .player-track-text h2 {
        font-size: 20px;
    }
    
    .player-track-text p {
        font-size: 16px;
    }
    
    .main-controls {
        padding: 0 10px;
    }
    
    .control-btn {
        font-size: 36px;
    }
    
    .control-btn.play-large {
        font-size: 64px;
    }
}

@media (max-width: 380px) {
    .player-content { 
        padding: 12px 15px 15px 15px; 
    }
    
    .visual-container { 
        margin-bottom: 15px;
    }
    
    .album-art-large {
        max-height: 35vh;
        aspect-ratio: 1/1; /* Убеждаемся что квадратная на маленьких экранах */
    }
    
    .lyric-line { 
        font-size: 20px; 
        margin: 14px 0; 
    }
    
    .main-controls { 
        margin-bottom: 12px; 
        padding: 0 5px;
    }
    
    .control-btn { 
        font-size: 32px; 
    }
    
    .control-btn.play-large { 
        font-size: 56px; 
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .track-item {
        padding: 8px 0;
    }
    
    .track-item img {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    
    .mini-player {
        bottom: 10px;
        left: 8px;
        right: 8px;
        height: 60px;
        padding: 5px 10px;
    }
    .mini-controls {
        gap: 8px;
        font-size: 18px;
    }
    .mini-like-btn {
        font-size: 14px;
    }
    .mini-volume-container {
        bottom: calc(100% + 8px);
        padding: 12px 6px;
        width: 40px;
    }
    .mini-volume-slider-wrapper {
        height: 80px;
    }
    .mini-volume-slider {
        height: 80px;
        width: 3px;
    }
    .mini-volume-slider::-webkit-slider-runnable-track {
        width: 3px;
        height: 80px;
    }
    .mini-volume-slider::-moz-range-track {
        width: 3px;
        height: 80px;
    }
    .mini-volume-slider::-webkit-slider-thumb {
        width: 14px;
        height: 14px;
        margin-left: -5.5px;
    }
    .mini-volume-slider::-moz-range-thumb {
        width: 14px;
        height: 14px;
    }
}

/* Адаптация для горизонтальных планшетов (landscape) */
@media (min-width: 768px) and (orientation: landscape) {
    .full-player {
        padding: 20px 40px;
    }
    
    .player-content {
        max-width: 1200px;
        margin: 0 auto;
        padding-bottom: 250px;
        padding: 20px 40px 30px 40px;
    }
    
    .visual-container {
        margin-bottom: 30px;
    }
    
    .album-art-large {
        max-width: 400px;
    }
    
    .player-track-info {
        margin-bottom: 25px;
    }
    
    .main-controls {
        margin-bottom: 25px;
    }
    
    .control-btn {
        font-size: 42px;
    }
    
    .control-btn.play-large {
        font-size: 72px;
    }
    
    .lyric-line {
        font-size: 28px;
        margin: 20px 0;
    }
    
    /* Админка для горизонтальных планшетов */
    .container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 20px 40px;
    }
    
    .track-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 25px;
    }
}

/* Специальные стили для iOS */
@supports (-webkit-touch-callout: none) {
    /* Убираем отступ снизу в плеере, так как нет управления громкостью */
    .player-content {
        padding-bottom: 20px;
    }
    
    /* Улучшаем отображение на iPhone */
    .library-view {
        padding-bottom: 100px;
    }
    
    /* Убеждаемся что обложка квадратная на iOS */
    .album-art-large {
        aspect-ratio: 1/1 !important;
        width: auto !important;
        height: auto !important;
        max-width: min(350px, 90vw) !important;
        max-height: 100% !important;
        object-fit: cover !important;
        margin: 0 auto !important;
    }
    
    /* Безопасная зона для iPhone с вырезом */
    @supports (padding: max(0px)) {
        .library-view {
            padding-bottom: max(100px, env(safe-area-inset-bottom) + 100px);
        }
        
        .mini-player {
            bottom: max(15px, env(safe-area-inset-bottom) + 15px);
        }
        
        .player-content {
            padding-bottom: max(20px, env(safe-area-inset-bottom) + 20px);
        }
    }
}