* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Реальная высота плавающего плеера + отступ, выставляется из JS
       (см. updatePlayerOffset в script.js). Нужна, чтобы нижний элемент
       списков (треков/альбомов) никогда не скрывался под плеером. */
    --player-offset: 20px;
    /* Реальная высота закреплённой (position: fixed) шапки на мобильных,
       выставляется из JS (см. updateHeaderOffset в script.js). Нужна,
       чтобы контент не оказывался под шапкой. */
    --header-offset: 88px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0ebe5;
    display: flex;
    justify-content: center;
    /* Раньше было "center" — на невысоких экранах (например, телефон в
       горизонтальной ориентации, где высота окна всего ~375-430px) .app
       мог оказаться выше реальной видимой области из-за min-height ниже.
       При вертикальном центрировании и overflow: hidden лишняя высота
       обрезалась ПОРОВНУ сверху и снизу — обрезался именно верх, то есть
       шапка сайта. Прижимаем .app к верху: тогда обрезаться (в редких
       крайних случаях) может только низ, а шапка гарантированно видна. */
    align-items: flex-start;
    height: 100vh;
    /* dvh учитывает появление/скрытие адресной строки браузера на мобильных
       устройствах — без этого 100vh иногда "уезжает" и обрезает шапку. */
    height: 100dvh;
    padding: 20px;
}

.app {
    max-width: 1400px;
    width: 100%;
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
    /* Было 500px: на низких экранах (телефон в landscape) это превышало
       реальную высоту окна и приводило к обрезке контента. Понижаем до
       безопасного минимума — реальная высота почти всегда и так больше
       за счёт calc() выше, а это лишь подстраховка от нулевой высоты. */
    min-height: 220px;
    max-height: 100vh;
    max-height: 100dvh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease;
}

body.player-hidden .app {
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
}

/* ===== HEADER ===== */
header {
    /* clamp() плавно уменьшает отступы на средних экранах (планшеты),
       без резкого скачка на единственном брейкпоинте 768px. */
    padding: clamp(10px, 2.5vw, 20px) clamp(14px, 4vw, 40px);
    background: linear-gradient(135deg, #2c1810, #4a2c1e);
    color: white;
    flex-shrink: 0;
    min-height: 60px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* flex-wrap: wrap — обязательная подстраховка: если элементам шапки
       (заголовок + поиск + кнопки) не хватает места в одну строку, они
       переносятся на вторую строку, а НЕ обрезаются/пропадают за пределами
       .app (overflow: hidden). Раньше на мобильных это было nowrap, из-за
       чего при нехватке места часть шапки визуально исчезала. */
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.header-left {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.header-left h1 {
    /* Заголовок плавно уменьшается в диапазоне от 1rem до 2rem в
       зависимости от ширины экрана — вместо жёсткого прыжка между
       десктопным (2rem) и мобильным (0.9rem) размером. */
    font-size: clamp(1rem, 1.1rem + 1.6vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.header-left p {
    color: #c4b5a8;
    margin-top: 3px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.header-contact {
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    flex-wrap: wrap;
    min-width: 0;
}

.contact-label {
    color: #c4b5a8;
}

.contact-email {
    color: #e8e0d8;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    border-bottom: 1px solid transparent;
}

.contact-email:hover {
    color: #ffffff;
    border-bottom-color: #8a6d5a;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* ===== КНОПКА ПЕРЕКЛЮЧЕНИЯ ВЕРСИИ ===== */
.version-toggle {
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.version-toggle:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.02);
}

.version-toggle.mobile-mode {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
}

.version-toggle.mobile-mode:hover {
    background: rgba(76, 175, 80, 0.4);
}

/* ===== ПОИСК ===== */
.search-container {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.search-input {
    padding: 10px 12px 10px 35px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    /* Ширина плавно масштабируется между экранами планшета и десктопа —
       раньше фиксированные 260/320px не помещались на планшетах и в
       альбомной ориентации телефона. */
    width: clamp(140px, 24vw, 260px);
    min-width: 0;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-input:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    width: clamp(160px, 30vw, 320px);
}

.search-input.active {
    background: white;
    color: #2c1f16;
    border-color: #8a6d5a;
}

.search-input.active::placeholder {
    color: #999;
}

.search-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.02);
}

.search-clear {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    transition: all 0.2s;
}

.search-clear:hover {
    color: white;
    transform: translateY(-50%) scale(1.2);
}

/* ===== ПЛАНШЕТЫ (портрет и альбомная ориентация) =====
   Раньше на этих ширинах (примерно от 769 до 1180px — типичный диапазон
   планшетов в обеих ориентациях) применялись десктопные стили шапки:
   подзаголовок, email обратной связи и широкое поле поиска — вместе они
   не помещались в одну строку и шапка либо переносилась некрасиво, либо
   часть контента оказывалась обрезана. Здесь убираем второстепенные
   элементы и урезаем поиск, оставляя гарантированно достаточно места
   для заголовка сайта и кнопок. */
@media (min-width: 769px) and (max-width: 1180px) {
    .header-left p,
    .header-contact {
        display: none;
    }

    .search-input {
        width: clamp(110px, 22vw, 200px);
    }

    .search-input:focus {
        width: clamp(140px, 28vw, 240px);
    }

    .auth-status {
        display: none;
    }
}

/* ===== АВТОРИЗАЦИЯ ===== */
.auth-btn {
    padding: 8px 20px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.auth-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.02);
}

.auth-btn.logged-in {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
}

.auth-btn.logged-in:hover {
    background: rgba(76, 175, 80, 0.4);
}

.auth-status {
    font-size: 0.8rem;
    color: #81C784;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ===== МОДАЛЬНОЕ ОКНО ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #2c1810, #4a2c1e);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a3f36;
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #8a6d5a;
    box-shadow: 0 0 0 3px rgba(138, 109, 90, 0.1);
}

.auth-error {
    background: #ffebee;
    color: #c62828;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.auth-submit {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #8a6d5a, #6a4f3a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-submit:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(138, 109, 90, 0.3);
}

.auth-submit:active {
    transform: scale(0.98);
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: row;
}

/* ===== НАВИГАЦИЯ ===== */
.nav-tree {
    width: 320px;
    background: #f8f5f2;
    padding: 20px 20px;
    padding-bottom: var(--player-offset);
    border-right: 1px solid #e8e0d8;
    overflow-y: auto;
    flex-shrink: 0;
}

.nav-tree h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8a7a6a;
    margin-bottom: 15px;
    padding-left: 10px;
}

.nav-tree.hidden {
    display: none;
}

.year-group {
    margin-bottom: 20px;
}

.year-label {
    font-weight: 700;
    font-size: 1rem;
    color: #3d322a;
    padding: 6px 12px;
    background: #ede6de;
    border-radius: 8px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.year-label span {
    background: #d5cbc0;
    color: #4a3f36;
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 400;
}

.album-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 15px 8px 25px;
    margin: 2px 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #4a3f36;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.album-link:hover {
    background: #ede6de;
    border-left-color: #b5a69a;
}

.album-link.active {
    background: #e0d5ca;
    border-left-color: #8a6d5a;
    font-weight: 500;
    color: #2c1f16;
}

.album-track-count {
    float: right;
    background: #d5cbc0;
    color: #4a3f36;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 400;
    margin-left: 8px;
}

.album-link.active .album-track-count {
    background: #8a6d5a;
    color: white;
}

.album-link:hover .album-track-count {
    background: #c4b5a8;
}

/* ===== КОНТЕНТ ===== */
.content {
    flex: 1;
    padding: 20px 30px;
    padding-bottom: var(--player-offset);
    overflow-y: auto;
    min-height: 0;
}

.content .album-panel-wrapper {
    flex: 1;
    min-height: 0;
}

.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #b5a69a;
    font-size: 1.2rem;
}

/* ===== МОБИЛЬНАЯ НАВИГАЦИЯ ===== */
.mobile-back-header {
    display: none;
    padding: 8px 12px;
    background: #f8f5f2;
    border-bottom: 1px solid #e8e0d8;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.mobile-back-header.hidden {
    display: none;
}

.mobile-back-btn {
    padding: 10px 16px;
    background: #e8e0d8;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #4a3f36;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.mobile-back-btn:hover {
    background: #d5cbc0;
}

.mobile-back-btn:active {
    transform: scale(0.95);
}

.mobile-current-album {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c1f16;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== АЛЬБОМ ===== */
.album-header {
    display: flex;
    gap: 25px;
    padding: 20px;
    background: #f8f5f2;
    border-radius: 16px;
    margin-bottom: 20px;
    align-items: center;
    flex-shrink: 0;
}

.album-cover {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    background: #e8e0d8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    flex-shrink: 0;
    overflow: hidden;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-info h2 {
    font-size: 1.8rem;
    color: #2c1f16;
    margin-bottom: 5px;
}

.album-info .year-badge {
    display: inline-block;
    background: #e0d5ca;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #4a3f36;
}

.album-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.album-title-row h2 {
    margin: 0;
}

/* ===== КНОПКА СКАЧИВАНИЯ АЛЬБОМА ===== */
.btn-download-album {
    padding: 8px 20px;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 15px;
}

.btn-download-album:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
}

.btn-download-album:active {
    transform: scale(0.95);
}

/* ===== СПИСОК ТРЕКОВ ===== */
.track-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 10px;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #faf8f6;
    border-radius: 10px;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
}

.track-item:hover {
    background: #f5f0eb;
    border-color: #e8e0d8;
}

.track-item.active-track {
    background: #ede6de;
    border-color: #d5cbc0;
}

.track-item.search-result-found {
    border-left: 3px solid #ffeb3b;
    background: #fffde7;
}

.track-item.search-result-found:hover {
    background: #fff9c4;
}

.track-number {
    width: 35px;
    color: #8a7a6a;
    font-weight: 500;
    font-size: 0.85rem;
}

.track-name {
    flex: 1;
    font-size: 0.95rem;
    color: #2c1f16;
}

.track-controls {
    display: flex;
    gap: 6px;
}

/* ===== КНОПКИ В СПИСКЕ ТРЕКОВ ===== */
.btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #e8e0d8;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background: #d5cbc0;
    transform: scale(1.05);
}

.btn-play.active {
    background: #8a6d5a;
    color: white;
}

.btn-stop {
    background: #e8e0d8;
}

.btn-stop:hover {
    background: #d5cbc0;
}

.btn-download {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-download:hover {
    background: #388E3C;
    transform: scale(1.05);
}

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

.playing-indicator {
    margin-left: 10px;
    color: #8a6d5a;
    font-size: 0.75rem;
    font-weight: 500;
}

.active-marker {
    margin-left: 8px;
    color: #4CAF50;
    font-size: 0.8rem;
    animation: pulse-marker 1.5s ease-in-out infinite;
}

@keyframes pulse-marker {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ===== РЕЗУЛЬТАТЫ ПОИСКА ===== */
.search-results-info {
    padding: 12px 16px;
    background: #f0ebe5;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #4a3f36;
}

.search-results-info .close-results {
    background: none;
    border: none;
    color: #8a7a6a;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 8px;
    transition: all 0.2s;
}

.search-results-info .close-results:hover {
    color: #d32f2f;
    transform: scale(1.2);
}

.search-highlight {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 500;
    color: #1e1a16;
}

.search-highlight-id {
    background: #ffeb3b;
    color: #1e1a16;
}

.search-status {
    font-size: 0.8rem;
    color: #8a7a6a;
    margin-left: 8px;
}

.search-continue-container {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
}

.search-continue-btn {
    padding: 10px 30px;
    background: linear-gradient(135deg, #8a6d5a, #6a4f3a);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(138, 109, 90, 0.3);
}

.search-continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(138, 109, 90, 0.4);
}

.search-continue-btn:active {
    transform: scale(0.95);
}

.found-indicator {
    margin-left: 8px;
    font-size: 0.8rem;
    font-weight: bold;
}

.track-item.match-by-id .found-indicator {
    color: #4CAF50;
}

/* ===== ТРЕК-ИДЕНТИФИКАТОР ===== */
.track-id {
    color: #8a7a6a;
    font-size: 0.75rem;
    font-weight: 400;
    margin-left: 8px;
    background: #f0ebe5;
    padding: 1px 8px;
    border-radius: 10px;
    display: inline-block;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.track-item:hover .track-id {
    background: #e8e0d8;
    color: #5a4f46;
}

.track-item.active-track .track-id {
    background: #d5cbc0;
    color: #4a3f36;
}

.track-item.search-result-found .track-id {
    background: #fff9c4;
    color: #6d5a3a;
}

/* ===== ОБЛОЖКА ИЗ MP3 ===== */
.track-cover-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 8px;
    border: 1px solid #e8e0d8;
    background: #f0ebe5;
}

.track-item.active-track .track-cover-icon {
    border-color: #8a6d5a;
}

/* ===== ПЛЕЕР ===== */
.player-wrapper {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 1400px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.player {
    position: relative;
    background: linear-gradient(135deg, #1e1a16, #2c241e);
    color: white;
    padding: 10px 20px;
    border-radius: 16px;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.3);
    border: 1px solid #4a3f36;
}

.player-close {
    position: absolute;
    top: -12px;
    right: 60px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #4a3f36;
    color: #c4b5a8;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 1px solid #5a4f46;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.player-close:hover {
    background: #5a4f46;
    color: #e8e0d8;
    transform: scale(1.1);
    border-color: #8a6d5a;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

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

.player-mini .player-close {
    right: 55px;
    top: -10px;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
}

.player-toggle {
    position: absolute;
    top: -12px;
    right: 20px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #3a322a;
    color: white;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.2s;
    border: 1px solid #4a3f36;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-toggle:hover {
    background: #4a3f36;
    transform: scale(1.1);
}

.player-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
    flex: 0 0 220px;
}

.player-cover {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #3a322a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
    overflow: hidden;
}

.player-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-track-info {
    flex: 1;
    min-width: 0;
}

.player-track-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-track-album {
    font-size: 0.7rem;
    color: #c4b5a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls {
    flex: 1;
    min-width: 250px;
}

.player-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.player-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

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

.player-btn-play {
    width: 40px;
    height: 40px;
    background: #8a6d5a;
    font-size: 1.2rem;
}

.player-btn-play:hover {
    background: #a0806a;
}

.player-btn-play.playing {
    background: #6a8a5a;
}

.player-mode-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.player-mode-indicator {
    font-size: 0.6rem;
    color: #c4b5a8;
    min-width: 50px;
    text-align: left;
}

.player-mode-btn,
.player-shuffle-btn {
    background: rgba(255,255,255,0.08);
    color: #c4b5a8;
    font-size: 1rem;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.player-mode-btn:hover,
.player-shuffle-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #e8e0d8;
    transform: scale(1.05);
}

.player-mode-btn.active-mode {
    background: #8a6d5a;
    color: white;
    border-color: #8a6d5a;
    box-shadow: 0 2px 12px rgba(138, 109, 90, 0.3);
}

.player-mode-btn.active-mode:hover {
    background: #a0806a;
    border-color: #a0806a;
    box-shadow: 0 4px 20px rgba(138, 109, 90, 0.4);
}

.player-shuffle-btn.active-shuffle {
    background: #8a6d5a;
    color: white;
    border-color: #8a6d5a;
    box-shadow: 0 2px 12px rgba(138, 109, 90, 0.3);
}

.player-shuffle-btn.active-shuffle:hover {
    background: #a0806a;
    border-color: #a0806a;
    box-shadow: 0 4px 20px rgba(138, 109, 90, 0.4);
}

.player-mode-btn.active-mode + .player-mode-indicator {
    color: #e8e0d8;
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-time {
    font-size: 0.7rem;
    color: #c4b5a8;
    min-width: 35px;
    font-variant-numeric: tabular-nums;
}

.player-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #4a3f36;
    outline: none;
    transition: background 0.2s;
}

.player-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #c4b5a8;
    cursor: pointer;
    transition: all 0.2s;
}

.player-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #e8e0d8;
}

.player-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #c4b5a8;
    cursor: pointer;
    border: none;
}

.player-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
}

.player-slider::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: #4a3f36;
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 150px;
}

.volume-icon {
    font-size: 1rem;
    color: #c4b5a8;
    cursor: pointer;
}

.volume-slider {
    flex: 1;
    min-width: 60px;
}

.volume-value {
    font-size: 0.7rem;
    color: #c4b5a8;
    min-width: 35px;
}

.player-mini {
    position: relative;
    background: linear-gradient(135deg, #1e1a16, #2c241e);
    color: white;
    padding: 8px 20px;
    border-radius: 16px;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.3);
    border: 1px solid #4a3f36;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.player-mini .player-close {
    right: 55px;
    top: -10px;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
}

.player-mini .player-toggle {
    right: 18px;
    top: -10px;
    width: 24px;
    height: 24px;
    font-size: 0.6rem;
}

.player-mini-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.player-mini-cover {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #3a322a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    overflow: hidden;
}

.player-mini-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-mini-track {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.player-mini-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-mini-album {
    font-size: 0.7rem;
    color: #c4b5a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-mini-controls {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.player-btn-mini {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
}

/* ================================================================ */
/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */
/* ================================================================ */

@media (max-width: 768px) {
    /* Обычный скролл страницы вместо точного расчёта высоты вьюпорта —
       не зависит от того, как конкретный браузер считает 100vh/100dvh
       (адресная строка, клавиатура и т.д.). */
    html, body {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    body {
        display: block;
        padding: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .app {
        width: 100%;
        max-width: none;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }
    body.player-hidden .app {
        height: auto;
    }
    
    /* ===== ЗАКРЕПЛЁННАЯ ШАПКА (2 СТРОКИ) =====
       position: sticky в Android Chrome (в т.ч. на Infinix/XOS) может
       "уезжать"/съезжать сильнее с каждым изменением высоты страницы —
       это известная проблема пересчёта sticky-контекста. position: fixed
       лишён этого недостатка: шапка жёстко прибита к вьюпорту и вообще
       не участвует в скролле документа, независимо от его высоты.
       Контенту ниже добавляется padding-top, равный РЕАЛЬНОЙ высоте
       шапки (см. --header-offset, выставляется из JS), чтобы ничего не
       оказалось под шапкой. */
    header { 
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 6px 10px;
        min-height: 44px;
    }

    .header-content { 
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
    }
    
    /* Раскрываем .header-right "наружу": его дети (кнопка версии, поиск,
       блок авторизации) становятся обычными флекс-элементами
       .header-content — это позволяет расставить их по ДВУМ строкам без
       изменения HTML: 1-я строка — название + кнопка версии + логин,
       2-я строка — поле поиска на всю ширину. */
    .header-right {
        display: contents;
    }

    /* ---- Строка 1: название + переключатель версии + логин ---- */
    .header-left {
        order: 1;
        flex: 1 1 auto;
        min-width: 40px;
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    .header-left h1 { 
        font-size: 0.85rem; 
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    
    .header-left p { display: none; }
    .header-contact { display: none; }

    .version-toggle {
        order: 2;
        padding: 4px 8px;
        font-size: 0.8rem;
        height: 32px;
        min-width: 32px;
        flex-shrink: 0;
    }

    #authSection {
        order: 3;
        flex-shrink: 0;
    }

    .auth-status {
        display: none;
    }
    
    /* ---- Строка 2: поле поиска на всю ширину ---- */
    .search-container {
        order: 4;
        flex: 0 0 100%;
        width: 100%;
        min-width: 0;
        gap: 4px;
        max-width: none;
    }
    
    .search-input {
        width: 100%;
        min-width: 0;
        padding: 6px 10px 6px 28px;
        font-size: 0.8rem;
        height: 36px;
        border-radius: 6px;
    }
    
    .search-input::placeholder {
        font-size: 0.7rem;
    }
    
    .search-btn {
        flex-shrink: 0;
        padding: 0;
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        border-radius: 6px;
        /* Показываем только иконку лупы вместо слова "Найти", текст прячем */
        font-size: 0;
    }
    
    .search-btn::before {
        content: '🔍';
        font-size: 0.95rem;
    }
    
    .search-clear {
        right: 44px;
        font-size: 0.8rem;
        padding: 4px;
    }
    
    .auth-btn { 
        padding: 4px 10px;
        font-size: 0.7rem;
        height: 32px;
        gap: 3px;
        border-radius: 6px;
    }
    
    .auth-btn span { display: none; }
    
    /* ===== LAYOUT - ВЕРТИКАЛЬНЫЙ ===== */
    /* .app больше не имеет фиксированной высоты на мобильных (см. выше),
       поэтому .layout просто раскладывается по естественной высоте
       контента — скроллится вся страница целиком, а не внутренний блок.
       padding-top равен РЕАЛЬНОЙ высоте закреплённой (position: fixed)
       шапки — выставляется из JS в переменную --header-offset, чтобы
       контент никогда не оказывался под шапкой. */
    .layout {
        flex-direction: column;
        display: flex;
        padding-top: var(--header-offset, 88px);
    }
    
    /* ===== НАВИГАЦИЯ - ПОЛНЫЙ ЭКРАН ===== */
    .nav-tree { 
        width: 100%;
        height: auto;
        max-height: none;
        padding: 10px 12px;
        padding-bottom: var(--player-offset);
        border-right: none;
        border-bottom: none;
        flex-shrink: 0;
        overflow: visible;
        display: block;
    }
    
    .nav-tree.hidden {
        display: none;
    }
    
    .nav-tree h2 {
        font-size: 0.75rem;
        margin-bottom: 10px;
        padding-left: 6px;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #8a7a6a;
    }
    
    .year-group {
        margin-bottom: 12px;
    }
    
    .year-label {
        font-size: 0.85rem;
        padding: 8px 12px;
        border-radius: 6px;
        font-weight: 700;
    }
    
    .year-label span {
        font-size: 0.65rem;
        padding: 2px 8px;
    }
    
    .album-link {
        font-size: 0.85rem;
        padding: 10px 14px 10px 20px;
        border-left-width: 3px;
        border-radius: 6px;
        margin: 3px 0;
        min-height: 44px;
    }
    
    .album-track-count {
        font-size: 0.65rem;
        padding: 2px 8px;
    }
    
    /* ===== КОНТЕНТ - ПОЛНЫЙ ЭКРАН ===== */
    .content { 
        flex: 1;
        padding: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }
    
    .content .album-panel-wrapper {
        flex: 1;
        padding: 8px 10px;
        padding-bottom: var(--player-offset);
        overflow: visible;
    }
    
    /* ===== МОБИЛЬНАЯ ШАПКА ===== */
    .mobile-back-header {
        display: flex;
        padding: 8px 12px;
        background: #f8f5f2;
        border-bottom: 1px solid #e8e0d8;
        flex-shrink: 0;
        min-height: 52px;
    }
    
    .mobile-back-header.hidden {
        display: none;
    }
    
    .mobile-back-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
        min-height: 40px;
        min-width: 40px;
    }
    
    .mobile-current-album {
        font-size: 0.85rem;
    }
    
    /* ===== АЛЬБОМ ===== */
    .album-header { 
        flex-direction: row;
        gap: 12px;
        padding: 12px 14px;
        align-items: center;
        margin-bottom: 10px;
        border-radius: 10px;
    }
    
    .album-cover { 
        width: 60px; 
        height: 60px; 
        font-size: 2.2rem; 
        border-radius: 10px;
    }
    
    .album-info h2 { 
        font-size: 1.1rem; 
        margin-bottom: 2px;
    }
    
    .album-info .year-badge {
        font-size: 0.7rem;
        padding: 3px 12px;
        border-radius: 12px;
    }
    
    .album-info p {
        font-size: 0.7rem !important;
        margin-top: 4px !important;
    }
    
    .album-title-row {
        gap: 6px;
    }
    
    .btn-download-album {
        font-size: 0.7rem;
        padding: 4px 12px;
        border-radius: 20px;
        margin-left: 0;
        min-height: 36px;
    }
    
    /* ===== ТРЕКИ ===== */
    .track-list {
        gap: 4px;
        padding-bottom: 10px;
    }
    
    .track-item { 
        padding: 10px 14px; 
        gap: 6px;
        border-radius: 8px;
        min-height: 48px;
    }
    
    .track-number { 
        width: 28px; 
        font-size: 0.75rem; 
    }
    
    .track-name { 
        font-size: 0.82rem; 
    }
    
    .track-controls {
        gap: 4px;
    }
    
    .btn { 
        width: 36px; 
        height: 36px; 
        font-size: 0.85rem; 
        min-width: 36px;
        min-height: 36px;
    }
    
    .btn-download { 
        width: 36px; 
        height: 36px; 
        font-size: 0.75rem; 
        min-width: 36px;
        min-height: 36px;
    }
    
    .track-cover-icon { 
        width: 20px; 
        height: 20px; 
        margin-right: 6px; 
        border-radius: 4px;
    }
    
    .playing-indicator {
        font-size: 0.65rem;
        margin-left: 4px;
    }
    
    .active-marker {
        font-size: 0.65rem;
        margin-left: 4px;
    }
    
    .track-id { 
        font-size: 0.6rem; 
        padding: 2px 6px; 
        margin-left: 4px; 
        border-radius: 6px;
    }
    
    .found-indicator {
        font-size: 0.65rem;
        margin-left: 4px;
    }
    
    /* ===== РЕЗУЛЬТАТЫ ПОИСКА ===== */
    .search-results-info {
        padding: 8px 12px;
        font-size: 0.75rem;
        margin-bottom: 8px;
        border-radius: 8px;
    }
    
    .search-results-info .close-results {
        font-size: 0.9rem;
        min-width: 36px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .search-continue-btn {
        padding: 8px 20px;
        font-size: 0.8rem;
        border-radius: 20px;
        min-height: 44px;
    }
    
    .search-continue-container {
        margin-top: 8px;
        padding: 8px;
    }
    
    /* ===== ПЛЕЕР — МОБИЛЬНАЯ ВЕРСИЯ =====
       На узком экране мало места, поэтому убираем обложку и название
       трека (их итак видно в списке треков) и раскладываем управление
       ПОЛНОЙ шириной в столбик: кнопки — прогресс-бар — громкость.
       Раньше все три блока пытались уместиться в один ряд (flex-wrap),
       из-за чего кнопки/бегунки сжимались и наезжали друг на друга. */
    .player-wrapper { 
        width: 98%; 
        bottom: 4px; 
    }
    
    .player { 
        padding: 8px 10px; 
        border-radius: 10px;
    }
    
    .player-container { 
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        flex-wrap: nowrap;
    }
    
    /* Обложка + название трека/альбома скрыты на мобильных — нет места,
       и эта информация уже видна выделенным треком в списке. */
    .player-info { 
        display: none;
    }
    
    .player-controls { 
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }
    
    .player-buttons {
        gap: 4px;
        margin-bottom: 6px;
        flex-wrap: nowrap;
        width: 100%;
    }
    
    .player-btn { 
        width: 34px; 
        height: 34px; 
        font-size: 0.85rem; 
        min-width: 34px;
        min-height: 34px;
        flex-shrink: 0;
    }
    
    .player-btn-play { 
        width: 42px; 
        height: 42px; 
        font-size: 1.1rem; 
        min-width: 42px;
        min-height: 42px;
    }
    
    .player-progress {
        gap: 6px;
        width: 100%;
    }
    
    .player-time {
        font-size: 0.65rem;
        min-width: 30px;
    }
    
    .player-slider {
        height: 4px;
    }
    
    .player-slider::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
    }
    
    /* Было flex: 0 0 70px — расчёт на горизонтальную раскладку рядом с
       обложкой (задавал ширину). Теперь плеер — вертикальный стек, и
       громкость — отдельная строка на всю ширину, иначе flex-basis
       по вертикальной оси сжимал бы её до 70px ВЫСОТЫ. */
    .player-volume { 
        width: 100%;
        flex: 0 0 auto;
        gap: 6px;
    }
    
    .volume-icon {
        font-size: 0.85rem;
        min-width: 24px;
        min-height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .volume-slider {
        flex: 1 1 auto;
        min-width: 0;
    }
    
    .volume-value {
        font-size: 0.65rem;
        min-width: 32px;
        flex-shrink: 0;
    }
    
    /* Текстовые подписи режима ("Альбом" и т.п.) скрыты — на мобильных
       нужны только сами кнопки-иконки, подписи только отнимают ширину и
       были одной из причин, почему кнопки теснились/наезжали друг на друга. */
    .player-mode-indicator {
        display: none;
    }
    
    .player-mode-btn,
    .player-shuffle-btn {
        font-size: 0.75rem;
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-width: 1px;
    }
    
    .player-close {
        right: 40px !important;
        top: -8px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 0.7rem !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    .player-toggle {
        right: 10px !important;
        top: -8px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 0.6rem !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    .player-mini {
        padding: 6px 12px;
        border-radius: 10px;
        justify-content: center;
    }
    
    /* Как и в развёрнутом плеере — обложка и название трека скрыты, места мало */
    .player-mini-info {
        display: none;
    }
    
    .player-mini-controls {
        gap: 10px;
    }
    
    .player-mini .player-close {
        right: 40px !important;
        top: -8px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 0.7rem !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    .player-mini .player-toggle {
        right: 10px !important;
        top: -8px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 0.6rem !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    .player-mini-cover {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 6px;
    }
    
    .player-mini-name {
        font-size: 0.7rem;
    }
    
    .player-mini-album {
        font-size: 0.6rem;
    }
    
    .player-btn-mini {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
        min-width: 32px;
        min-height: 32px;
    }
}

/* ================================================================ */
/* ===== ПРИНУДИТЕЛЬНАЯ МОБИЛЬНАЯ ВЕРСИЯ ===== */
/* ================================================================ */

body.force-mobile .nav-tree {
    width: 100%;
    height: 100%;
    max-height: none;
    border-right: none;
    border-bottom: none;
}

body.force-mobile .nav-tree.hidden {
    display: none;
}

body.force-mobile .content {
    flex: 1;
    min-height: 0;
    padding: 0;
}

body.force-mobile .mobile-back-header {
    display: flex;
}

body.force-mobile .mobile-back-header.hidden {
    display: none;
}

body.force-mobile header {
    padding: 6px 10px;
    min-height: 44px;
}

body.force-mobile .header-left h1 {
    font-size: 0.85rem;
}

body.force-mobile .header-left p {
    display: none;
}

body.force-mobile .header-contact {
    display: none;
}

body.force-mobile .album-link {
    font-size: 0.85rem;
    padding: 10px 14px 10px 20px;
    min-height: 44px;
}

body.force-mobile .track-item {
    padding: 10px 14px;
    min-height: 48px;
}

body.force-mobile .btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 0.85rem;
}

body.force-mobile .player-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 0.85rem;
}

body.force-mobile .player-btn-play {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.1rem;
}

/* Добавьте в конец файла: */

/* ===== КНОПКА "ВЕРНУТЬСЯ К АЛЬБОМАМ" В ШАПКЕ АЛЬБОМА ===== */
.album-back-btn {
    display: none;
    padding: 8px 16px;
    background: #e8e0d8;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #4a3f36;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
    min-width: 40px;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
    justify-content: center;
}

.album-back-btn:hover {
    background: #d5cbc0;
}

.album-back-btn:active {
    transform: scale(0.95);
}

/* Показываем кнопку только на мобильных */
@media (max-width: 768px) {
    .album-back-btn {
        display: flex;
    }
}

body.force-mobile .album-back-btn {
    display: flex;
}
