html, body {
    height: 100%;
}

body {
    overflow: hidden;
    padding-bottom: 0;
}

.main-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 24px;
}

.page-home,
.page-search,
.page-favorites,
.page-history,
.page-newreleases,
.page-recognize {
    min-height: 100%;
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid #E1E1E1;
    border-radius: 10px;
    background: #FAFAFA;
    color: #1F1F1F;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
}

.stats-info {
    margin-top: 4px;
    font-size: 12px;
    color: #9C9C9C;
}

.search-submit-btn {
    padding: 10px 16px;
    background: #1F1F1F;
    color: #FAFAFA;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.search-submit-btn:hover {
    opacity: 0.85;
}

.user-chip {
    font-size: 13px;
    color: #1F1F1F;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user {
    margin-top: auto;
    padding: 12px 8px 0;
    font-size: 13px;
    color: #9C9C9C;
    border-top: 1px solid #E1E1E1;
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.tracks-chart {
    grid-template-columns: 1fr;
}

.chart-item.active {
    background: #1F1F1F;
}

.chart-item.active .playlist-name,
.chart-item.active .playlist-artist,
.chart-item.active .playlist-time {
    color: #FAFAFA;
}

.chart-item.active .playlist-like {
    color: #FAFAFA;
}

.playlist-like.in-favorites {
    color: #F52929;
}

.loading,
.empty {
    text-align: center;
    padding: 48px 16px;
    color: #9C9C9C;
    font-size: 14px;
}

.bottom-player {
    z-index: 12000;
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 80px;
    height: auto;
}

.bottom-track-info {
    cursor: pointer;
}

.bottom-cover img {
    background: #E1E1E1;
}

.bottom-btn.play-btn svg,
.bottom-btn.play-btn img {
    width: 40px;
    height: 40px;
    display: block;
}

.bottom-btn.play-btn svg {
    width: 28px;
    height: 28px;
}

.cast-btn {
    color: #9C9C9C;
    font-size: 13px;
    min-width: 40px;
    height: 40px;
    border-radius: 50%;
}

.cast-btn.active {
    color: #1F1F1F;
}

.cast-btn.casting {
    color: #1F1F1F;
    animation: castPulse 2s infinite;
}

@keyframes castPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

#castLauncherWrap,
#castLauncherWrapNp {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

google-cast-launcher {
    --connected-color: #1F1F1F;
    --disconnected-color: #9C9C9C;
    width: 32px;
    height: 32px;
}

.volume-mute-icon {
    width: 16px;
    height: 16px;
    cursor: pointer;
    filter: invert(69%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(92%) contrast(85%);
}

.like-btn.in-favorites {
    color: #F52929;
}

audio,
#audioPlayer {
    display: none;
}

.now-playing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 15000;
    background: #FAFAFA;
    color: #1F1F1F;
}

.now-playing-overlay.open {
    display: flex;
    flex-direction: column;
}

body.now-playing-active .bottom-player {
    visibility: hidden;
}

.np-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #E1E1E1;
    flex-shrink: 0;
    font-weight: 700;
}

.np-close {
    background: #E1E1E1;
    border: none;
    color: #1F1F1F;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.now-playing-layout {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.now-playing-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 32px;
    gap: 20px;
    overflow-y: auto;
}

.np-cover-wrap {
    width: min(320px, 70vw);
    height: min(320px, 70vw);
    border-radius: 16px;
    overflow: hidden;
    background: #E1E1E1;
    border: 1px solid #E1E1E1;
    flex-shrink: 0;
}

.np-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.np-meta {
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.np-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    word-break: break-word;
}

.np-artist,
.np-album {
    font-size: 14px;
    color: #9C9C9C;
    margin-bottom: 4px;
}

.np-controls-block {
    width: 100%;
    max-width: 520px;
}

.np-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.np-progress,
.np-volume {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.np-volume {
    max-width: 220px;
    margin: 0 auto;
}

.now-playing-queue {
    width: 360px;
    max-width: 42vw;
    border-left: 1px solid #E1E1E1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #FAFAFA;
}

.np-queue-title {
    padding: 16px 16px 8px;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.np-queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 16px;
}

.np-queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 2px;
}

.np-queue-item:hover {
    background: #E1E1E1;
}

.np-queue-item.active {
    background: #1F1F1F;
    color: #FAFAFA;
}

.np-queue-item.active .np-queue-sub,
.np-queue-item.active .np-queue-dur {
    color: #C8C8C8;
}

.np-queue-cover {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #E1E1E1;
    flex-shrink: 0;
}

.np-queue-info {
    flex: 1;
    min-width: 0;
}

.np-queue-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-queue-sub,
.np-queue-dur {
    font-size: 12px;
    color: #9C9C9C;
}

@media (max-width: 980px) {
    .app {
        height: calc(100vh - 92px);
        height: calc(100dvh - 92px);
    }

    .menu-toggle {
        display: flex;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(31, 31, 31, 0.4);
        z-index: 13000;
    }

    .sidebar-backdrop.open {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 14000;
        transform: translateX(-110%);
        transition: transform 0.22s ease;
        box-shadow: none;
        width: min(280px, 86vw);
        min-width: 0;
        padding-bottom: 100px;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
    }

    .main-content {
        padding: 16px 14px 20px;
    }

    .banner {
        padding: 24px 20px;
    }

    .banner-content h2 {
        font-size: 20px;
    }

    .card-row .music-card {
        flex: 0 0 140px;
        width: 140px;
        min-width: 140px;
        max-width: 140px;
    }

    .header {
        gap: 10px;
        align-items: flex-start;
    }

    .header-left,
    .header-right {
        flex-wrap: wrap;
    }

    .header-left h2 {
        font-size: 20px;
    }

    .search-input-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .user-chip {
        display: none;
    }

    #pageSearch .search-submit-btn {
        display: inline-flex;
        padding: 8px 12px;
        font-size: 12px;
    }

    .bottom-player {
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    }

    .bottom-player-content {
        flex-wrap: wrap;
        gap: 8px;
        max-width: none;
    }

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

    .bottom-player-center {
        order: 3;
        max-width: none;
        width: 100%;
        flex: 1 0 100%;
    }

    .bottom-controls {
        gap: 18px;
    }

    .bottom-player-right {
        min-width: 0;
        gap: 8px;
    }

    .volume-wrapper .volume-slider {
        display: none;
    }

    .now-playing-queue {
        display: none;
    }

    .now-playing-main {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    .chart-item {
        padding: 8px 6px;
        gap: 8px;
    }

    .playlist-time {
        display: none;
    }
}

body.auth-mode {
    background-color: #fafafa !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    color: #1f1f1f;
}

body.auth-mode .app-shell {
    display: none !important;
}

body.app-mode {
    background: #FAFAFA !important;
    display: block !important;
    height: 100vh;
    overflow: hidden;
    color: #1F1F1F;
}

body.app-mode #authGate {
    display: none !important;
}

body.app-mode #load-screen {
    display: none !important;
}

#authGate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 20;
}

#authGate .error-message {
    display: none;
    color: #f52929;
    font-size: 14px;
    margin: 5px 0 0 0;
    text-align: left;
    width: 100%;
}

#authGate .error-message.visible {
    display: block;
}

.app-shell {
    height: 100%;
}

@media (max-width: 768px) {
    #authGate .toggle-container {
        display: none;
    }

    #authGate .container {
        width: 100%;
        max-width: 420px;
        min-height: 0;
        height: auto;
        border-radius: 20px;
        overflow: visible;
    }

    #authGate .form-container,
    #authGate .form-container.sign-in,
    #authGate .form-container.sign-up,
    #authGate .container.active .form-container.sign-in,
    #authGate .container.active .form-container.sign-up {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        height: auto;
        opacity: 1;
        transform: none;
        animation: none;
        z-index: 2;
        padding: 24px;
    }

    #authGate .form-container.sign-up {
        display: none;
    }

    #authGate .container.active .form-container.sign-in {
        display: none;
    }

    #authGate .container.active .form-container.sign-up {
        display: block;
    }

    #authGate .container form {
        height: auto;
        padding: 0;
    }
}

.auth-mobile-switch {
    display: none;
    margin-top: 14px;
    font-size: 13px;
    text-align: center;
    width: 100%;
    color: #565656;
}

.auth-mobile-switch a {
    color: #0c2cb9;
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 768px) {
    .auth-mobile-switch {
        display: block;
    }
}

.nav-item.nav-item-disabled,
.nav-item[aria-disabled="true"] {
    opacity: 0.42;
    color: #9C9C9C;
    cursor: not-allowed;
    pointer-events: auto;
}

.nav-item.nav-item-disabled:hover,
.nav-item[aria-disabled="true"]:hover {
    background: transparent;
    color: #9C9C9C;
}

.nav-item.nav-item-disabled.active,
.nav-item[aria-disabled="true"].active {
    background: transparent;
    color: #9C9C9C;
}

.favorite-link.is-active h3 {
    color: #1F1F1F;
}

.menu-item-disabled,
.profile-menu-item.menu-item-disabled,
.profile-add-track.menu-item-disabled,
.settings-item.menu-item-disabled {
    opacity: 0.42;
    cursor: not-allowed;
    pointer-events: none;
}

.profile-menu-item.menu-item-disabled:hover,
.profile-add-track.menu-item-disabled:hover,
.settings-item.menu-item-disabled:hover {
    background: transparent;
    border-color: inherit;
}
