:root {
    --wave-svg: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDIwIDEyIj48cGF0aCBkPSJNMCA2IFEgNSAxLCAxMCA2IFQgMjAgNiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJub25lIiAvPjwvc3ZnPg==');
}

.view-home {
    padding-top: var(--safe-area-top);
    padding-bottom: 100px;
    overflow-y: auto;
    height: 100%;
    transition: padding-right 0.5s var(--ease-emphasized), width 0.5s var(--ease-emphasized);
    width: 100%;
}

.home-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 16px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.home-header h1 {
    font-family: 'Space Grotesk';
    font-size: 2rem;
    font-weight: 400;
}

#search-bar-container {
    display: flex;
    gap: 8px;
    background: var(--surface-container);
    padding: 8px 16px;
    border-radius: 24px;
    transition: 0.3s;
}

#search-bar-container.hidden {
    display: none;
}

#search-input {
    background: transparent;
    border: none;
    color: var(--on-surface);
    flex: 1;
    font-size: 1rem;
    outline: none;
}

#sort-select {
    background: var(--surface-container-high);
    color: var(--on-surface);
    border: none;
    outline: none;
    padding: 4px 8px;
    border-radius: 8px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 0 16px;
}

.track-card {
    background: var(--surface-container);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.track-card:hover {
    background: var(--surface-container-high);
    transform: translateY(-4px);
}

.track-card:active {
    transform: scale(0.98);
}

.track-card img,
.no-art {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-container-high);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-text {
    display: flex;
    flex-direction: column;
}

.card-text b {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}

.card-text:hover b {
    text-overflow: clip;
    overflow: visible;
}

.card-text:hover b span {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 10s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-100%, 0);
    }
}

.card-text span {
    font-size: 0.8rem;
    color: var(--outline);
}

.mini-player {
    position: fixed;
    bottom: calc(12px + var(--safe-area-bottom));
    left: 12px;
    right: 12px;
    height: 64px;
    background: var(--surface-container-high);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(150%);
    transition: transform 0.4s var(--ease-emphasized), opacity 0.3s;
    z-index: 90;
    cursor: pointer;
}

.mini-player.visible {
    transform: translateY(0);
}

.mini-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mini-info span:first-child {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--on-surface);
}

.mini-info span:last-child {
    font-size: 0.8rem;
    color: var(--outline);
}

.mini-art {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: #333;
    object-fit: cover;
}

.mini-progress {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

#mini-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
}

.view-player {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.player-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    position: relative;
    z-index: 20;
    touch-action: none;
    flex-shrink: 0;
}

.pill {
    background: var(--surface-container-high);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.visual-stage {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
}

.album-box {
    width: 80vw;
    max-width: 340px;
    aspect-ratio: 1;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s var(--ease-emphasized), width 0.5s, border-radius 0.5s;
    z-index: 5;
    background: #222;
}

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

.fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: #555;
}

#visualizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.3;
    pointer-events: none;
    z-index: 1;
}

.meta-data {
    padding: 0 16px;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
    text-align: center;
    flex-shrink: 0;
}

.meta-data h2 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    line-height: 1.2;
    font-weight: 600;
}

.meta-data p {
    font-size: 1rem;
    color: var(--outline);
}

.progress-area-container {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    width: 100%;
    padding: 0 16px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.time-label {
    font-size: 0.75rem;
    font-family: 'DM Sans', monospace;
    color: rgba(255, 255, 255, 0.5);
    min-width: 35px;
}

.progress-bar-wrapper {
    position: relative;
    flex-grow: 1;
    height: 30px;
    display: flex;
    align-items: center;
}

.track-bg {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.track-fill-mask {
    position: absolute;
    left: 0;
    width: 0%;
    height: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    border-radius: 6px;
}

.track-wave {
    width: 100vw;
    height: 4px;
    background-color: var(--primary);
    border-radius: 2px;
    transition: height 0.3s ease, filter 0.3s ease;
    transform-origin: left center;
    flex-shrink: 0;
}

body.playing .track-wave {
    height: 100%;
    -webkit-mask-image: var(--wave-svg);
    mask-image: var(--wave-svg);
    -webkit-mask-repeat: repeat-x;
    mask-repeat: repeat-x;
    -webkit-mask-position: 0 center;
    mask-position: 0 center;
    -webkit-mask-size: 20px 100%;
    mask-size: 20px 100%;
    animation: wave-scroll 1s linear infinite;
    filter: brightness(1.2);
}

body:not(.playing) .track-wave {
    -webkit-mask-image: none !important;
    mask-image: none !important;
    animation: none;
    filter: none;
}

@keyframes wave-scroll {
    0% {
        -webkit-mask-position: 0 center;
        mask-position: 0 center;
    }

    100% {
        -webkit-mask-position: -20px center;
        mask-position: -20px center;
    }
}

.track-thumb {
    position: absolute;
    left: 0%;
    top: 50%;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    opacity: 1;
    pointer-events: none;
    z-index: 5;
    transition: left 0.1s linear;
}

#seek-slider {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.ctrl-btn {
    font-size: 2.5rem;
    color: var(--on-surface);
    opacity: 0.9;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ctrl-btn:hover {
    transform: scale(1.1);
    opacity: 1;
}

.play-fab {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    background: var(--primary-container);
    color: var(--on-primary-container);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.play-fab span {
    font-size: 36px;
}

.play-fab:active {
    transform: scale(0.95);
}

.bottom-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-bottom: 20px;
    flex-shrink: 0;
}

.bottom-actions .m3-icon-btn span {
    font-size: 20px;
}

.eq-sliders {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    gap: 12px;
}

.eq-band {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.v-slider-container {
    width: 40px;
    height: 120px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.v-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 40px;
    background: transparent;
    transform: rotate(-90deg);
    margin: 0;
    cursor: pointer;
}

.v-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 32px;
    background: var(--surface-variant);
    border-radius: 16px;
    border: 1px solid var(--outline);
}

.v-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    background: var(--on-surface);
    border-radius: 50%;
    margin-top: 5px;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 2;
    position: relative;
}

.eq-label {
    font-size: 0.75rem;
    color: var(--outline);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.download-input {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    background: var(--surface-container-high);
    border: 1px solid var(--outline-variant);
    color: var(--on-surface);
    font-size: 1rem;
    outline: none;
}

.download-input:focus {
    border-color: var(--primary);
    background: var(--surface-variant);
}

.text-btn {
    background: transparent;
    color: var(--primary);
    border: none;
    padding: 0 24px;
    height: 40px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.text-btn:hover {
    background: rgba(208, 188, 255, 0.08);
}

.filled-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: 28px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.5px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;

    position: relative;
    overflow: hidden;
    z-index: 1;
}

#sync-btn {
    color: var(--on-surface);
    background: transparent;
    border: none;
    cursor: pointer;
}

.download-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.ctx-menu {
    position: fixed;
    background: var(--surface-container-high);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.ctx-menu.visible {
    opacity: 1;
    pointer-events: auto;
}

.ctx-menu button {
    background: transparent;
    border: none;
    color: var(--on-surface);
    padding: 12px 16px;
    text-align: left;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.ctx-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ctx-header {
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--outline);
    border-bottom: 1px solid var(--outline-variant);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sync-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.sync-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.sync-box {
    background: var(--surface-container);
    padding: 24px;
    border-radius: 24px;
    width: 300px;
    text-align: center;
}

.sync-bar {
    width: 100%;
    height: 4px;
    background: var(--surface-variant);
    border-radius: 2px;
    margin-top: 16px;
    overflow: hidden;
}

#sync-bar-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s;
}

#desktop-player-trigger {
    display: none;
}

@media (min-width: 960px) {
    .view-home {
        width: calc(100% - var(--player-width-desktop));
        padding-bottom: 20px;
        padding-right: 0;
    }

    body.desktop-player-hidden .view-home {
        width: 100%;
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        padding: 0 16px;
    }

    .home-header {
        padding: 32px 16px;
    }

    .mini-player {
        opacity: 0;
        pointer-events: none;
        transform: translateY(20px);
    }

    .view-player {
        padding-top: 40px;
    }

    .album-box {
        width: 80%;
        max-width: 280px;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    }

    .meta-data h2 {
        font-size: 1.4rem;
    }

    #close-player-btn {
        display: flex;
        
        transform: rotate(90deg);
        
    }

    body.desktop-player-hidden .m3-fullscreen {
        transform: translateX(100%) !important;
        box-shadow: none;
    }

    #desktop-player-trigger {
        position: fixed;
        bottom: 24px;
        right: 24px;
        z-index: 100;
        width: 56px;
        height: 56px;
        background: var(--primary-container);
        color: var(--on-primary-container);
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        display: none;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s var(--ease-emphasized);
        cursor: pointer;
    }

    #desktop-player-trigger:hover {
        transform: scale(1.05);
    }

    body.desktop-player-hidden #desktop-player-trigger {
        display: flex;
    }

    .ctrl-btn {
        font-size: 2.2rem;
    }

    .play-fab {
        width: 64px;
        height: 64px;
        border-radius: 20px;
    }
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--outline);
    text-align: center;
    gap: 16px;
}

.empty-state .material-symbols-rounded {
    font-size: 64px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}


.settings-tabs {
    display: flex;
    background: var(--surface-container);
    border-radius: 20px;
    padding: 4px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--on-surface-variant);
    padding: 10px;
    border-radius: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.tab-btn.active {
    background: var(--surface-variant);
    color: var(--on-surface);
    font-weight: 700;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

button:disabled,
input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(1);
}

label {
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}