@font-face {
    font-display: swap;
    font-family: Bungee;
    src: url('../fonts/bungee-v17-latin-regular.woff2') format('woff2');
}

@font-face {
    font-display: swap;
    font-family: 'Syncopate';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/syncopate-v24-latin-regular.woff2') format('woff2');
}

@font-face {
    font-display: swap;
    font-family: 'Syncopate';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/syncopate-v24-latin-700.woff2') format('woff2');
}

@font-face {
    font-display: swap;
    font-family: 'Lato';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/lato-v25-latin-regular.woff2') format('woff2');
}

@font-face {
    font-display: swap;
    font-family: 'Lato';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/lato-v25-latin-700.woff2') format('woff2');
}

/* ============================================
   ROOT & RESET
   ============================================ */

:root {
    --scroller-height: 0px;
    --player-height: 300px;
    --playlist-header-height: 150px;
    --playlist-padding: 60px;
    --scroll-padding: 30px;
    --container-padding: 20px;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-main: 0 16px 32px -12px rgba(0, 0, 0, 0.25);
    --glow-soft: 0 0 1px rgba(255, 255, 255, 0.6), 0 0 2px rgba(255, 255, 255, 0.4), 0 0 4px rgba(255, 255, 255, 0.2);
    --glow-hover: 0 0 5px rgba(255, 255, 255, 0.8), 0 0 10px rgba(255, 255, 255, 0.6), 0 0 15px rgba(255, 255, 255, 0.4);
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.2s ease;
    --transition-smooth: 0.3s ease;
}

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

/* ============================================
   BASE LAYOUT
   ============================================ */

html {
    background-color: black;
    min-height: 100vh;
}

body {
    font-family: 'Lato', sans-serif;
    background: transparent;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    margin: 0;
    padding: 0;
    transform: none !important;
    scale: none !important;
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 66%, rgb(10, 32, 51) 0%, rgba(0, 12, 24, 0.3) 50%);
}

.equalizer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 1;
}

/* ============================================
   ANTI-HIGHLIGHT & USER-SELECT
   ============================================ */

.btn,
.playlist-item,
.download-btn,
.like-btn,
.view-toggle,
.progress-bar,
.volume-bar,
button,
a,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.container,
.container * {
    user-select: none !important;
}

/* ============================================
   CONTAINER
   ============================================ */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--container-padding) var(--container-padding) 0;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--scroller-height));
    max-height: calc(100vh - var(--scroller-height));
    overflow: hidden;
    contain: style;
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 20px;
    font-size: clamp(1.5em, 5vw, 2.5em);
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
    font-family: Bungee, sans-serif;
    flex-shrink: 0;
}

/* ============================================
   GLASSMORPHISM BASE (gemeinsame Styles)
   ============================================ */

.player,
.playlist {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px; /* Festes Padding statt clamp() */
    box-shadow: var(--shadow-main);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    will-change: transform;
    transform: translateZ(0);
    flex-shrink: 0;
}

/* ============================================
   PLAYER
   ============================================ */

.player-container {
    min-width: 100%;
    display: flex;
    flex-direction: column;
    align-self: center;
    justify-content: center;
}

.player {
    margin-bottom: 20px;
    min-width: 100%;
}

.now-playing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    min-width: 0;
}

.track-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* ============================================
   PROGRESS & VOLUME BAR (DRY)
   ============================================ */

.progress-container,
.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    user-select: none;
}

.progress-bar,
.volume-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.progress-bar {
    flex: 1;
}

.volume-bar {
    width: clamp(80px, 20vw, 120px);
    height: 6px;
}

.progress-fill,
.volume-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    border-radius: inherit;
    box-shadow: var(--glow-soft);
    will-change: width;
    transform: translateZ(0);
}

.progress-fill {
    width: 0%;
}

.volume-fill {
    width: 70%;
    background: rgba(255, 255, 255, 0.7);
}

.progress-bar:hover .progress-fill,
.volume-bar:hover .volume-fill {
    box-shadow: var(--glow-hover);
}

.time {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    min-width: 45px;
    font-variant-numeric: tabular-nums;
}

.volume-container {
    justify-content: center;
    flex-wrap: wrap;
}

.volume-container svg {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   CONTROLS
   ============================================ */

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 3vw, 20px);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    padding: clamp(8px, 2vw, 10px);
    border-radius: 50%;
    transition: transform var(--transition-smooth), background var(--transition-smooth);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transform: translateZ(0);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05) translateZ(0);
}

.btn-play {
    gap: 5px;
    width: clamp(50px, 12vw, 70px);
    height: clamp(50px, 12vw, 70px);
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-play:hover {
    transform: scale(1.1) translateZ(0);
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.2);
}

/* ============================================
   PLAYLIST
   ============================================ */

.playlist {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.playlist h2 {
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.playlist-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 10px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    max-height: calc(
        100vh - var(--scroller-height) - var(--player-height) - var(--playlist-header-height)
        - var(--playlist-padding) - var(--scroll-padding) - var(--container-padding)
    );
    mask-image: linear-gradient(to bottom, transparent 0%, black 30px, black calc(100% - 30px), transparent 100%);
}

.playlist-scroll::-webkit-scrollbar {
    width: 8px;
}

.playlist-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.playlist-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    transition: background var(--transition-normal);
}

.playlist-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ============================================
   PLAYLIST HEADER & SEARCH
   ============================================ */

.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 10px;
    min-height: 36px;
}

.playlist-header h2 {
    margin: 0;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.playlist-count {
    font-size: 0.82rem;
    display: inline-flex;
    font-weight: 400;
    opacity: 0.5;
}

.search-toggle-container {
    position: relative;
    display: flex;
    align-items: center;
    height: 36px;
}

.search-toggle-btn {
    position: absolute;
    right: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    z-index: 2;
    color: white;
    will-change: transform;
    transform: translateZ(0);
}

.search-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05) translateZ(0);
}

.search-toggle-btn.has-filter {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.search-toggle-btn.has-filter:hover {
    background: rgba(255, 255, 255, 0.25);
}

.search-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.search-input-inline {
    position: absolute;
    right: 0;
    width: auto;
    height: 36px;
    padding: 10px 45px 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: white;
    font-size: 14px;
    outline: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.search-input-inline.active {
    width: 250px;
    opacity: 1;
    pointer-events: auto;
}

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

.search-toggle-container.active {
    max-width: 300px;
}

.search-toggle-container.active .search-toggle-btn {
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
}

.search-toggle-container.active .search-input-inline {
    opacity: 1;
    pointer-events: auto;
}

.search-toggle-container.active .search-icon {
    display: none;
}

.search-toggle-container.active .close-icon {
    display: block !important;
}

/* ============================================
   PLAYLIST ITEMS
   ============================================ */

.playlist-item {
    padding: 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-normal), border-color var(--transition-normal), transform var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    contain: layout style paint;
    will-change: background, border-color;
}

.playlist-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.playlist-item-number {
    font-weight: bold;
    opacity: 0.7;
    min-width: 30px;
    font-size: 0.9em;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.playlist-item-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.playlist-item.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.download-btn,
.like-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    transition: background var(--transition-normal), color var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
}

.download-btn svg,
.like-btn svg {
    width: 18px;
    height: 18px;
}

.download-btn:hover,
.like-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.like-btn.liked {
    color: #a30000;
    background: rgba(255, 255, 255, 0.3);
}

.like-btn.liked:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ============================================
   SVG ICONS
   ============================================ */

svg {
    width: 24px;
    height: 24px;
    shape-rendering: geometricPrecision;
}

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

/* ============================================
   CANVAS OVERLAYS
   ============================================ */

.sinus-scroller {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    pointer-events: none;
}

#sinusCanvas {
    width: 100%;
    display: none;
    vertical-align: bottom;
    pointer-events: auto;
}

.tunnel-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.3;
    pointer-events: none;
    will-change: opacity;
    transform: translateZ(0);
}

/* ============================================
   VIEW TOGGLE
   ============================================ */

.view-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.view-toggle svg {
    width: 28px;
    height: 28px;
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   DESKTOP VIEW TOGGLE
   ============================================ */

.desktop-view-toggle {
    display: none;
    width: auto;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    position: absolute;
    bottom: 1rem;
    right: 1rem;
}

.desktop-view-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.desktop-view-toggle svg {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   MEDIA QUERIES
   ============================================ */

/* Desktop: Player-Only Mode */
@media (min-width: 1025px) {
    .desktop-view-toggle {
        display: flex;
    }

    .container.player-only {
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        display: grid;
        gap: 20px;
        align-items: start;
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .container.player-only .player {
        max-width: 600px;
    }

    .container.player-only .playlist {
        display: none;
    }
}

/* Mobile Portrait: Toggle sichtbar */
@media (max-width: 1024px) and (orientation: portrait) {
    body {
        width: 100vw !important;
        height: 100vh !important;
        min-height: 100vh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        position: relative !important;
        transform: none !important;
        scale: 1 !important;
        zoom: 1 !important;
    }

    body.show-playlist {
        overflow: hidden;
    }

    /* Container zurücksetzen */
    .container {
        position: relative !important;
        inset: auto !important;
        top: auto !important;
        left: auto !important;
        padding: 20px 20px 0 !important;
        display: flex !important;
        flex-direction: column !important;
        height: calc(100vh - var(--scroller-height)) !important;
        max-height: calc(100vh - var(--scroller-height)) !important;
        overflow: hidden !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 800px !important;
        margin: 0 auto !important;
        transform: none !important;
    }

    h1 {
        display: block !important;
    }

    /* Player & Playlist zurücksetzen */
    .player,
    .playlist {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        padding: 30px !important;
        margin-bottom: 20px !important;
        transition: opacity var(--transition-smooth) !important;
    }

    .desktop-view-toggle {
        opacity: 0.9;
        display: flex;
        padding: 6px;
        bottom: 0.5rem;
        right: 0.5rem;
        border-radius: 6px 6px 12px 6px;
    }

    /* Player-Only Mode */
    .container.player-only {
        display: grid !important;
        gap: 20px;
        align-items: start;
        grid-template-columns: 1fr;
        justify-items: center;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .container.player-only .playlist {
        display: none !important;
    }
}

/* Mobile Landscape: Spezial-Layout */
@media (max-height: 600px) and (orientation: landscape) {
    .container {
        padding: 0; /* Bleibt bei 0 im Landscape */
    }
    .playlist-header {
        gap: 5px;
    }

    .search-toggle-container.active {
        max-width: 200px;
    }

    .playlist-item {
        font-weight: normal;
        font-size: 0.7rem;
        padding: 5px;
    }

    .view-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100vh;
    }

    .container {
        position: fixed;
        inset: 0;
        display: grid;
        justify-content: center;
        align-items: center;
        padding: 0;
        overflow: hidden;
    }

    h1 {
        display: none;
    }

    .player,
    .playlist {
        position: fixed;
        top: 50%;
        left: 50%;
        width: calc(100% - 40px);
        max-width: 600px;
        min-width: 0;
        height: auto;
        max-height: calc(100vh - 40px);
        margin: 0;
        padding: 20px;
        transition: opacity var(--transition-smooth), transform var(--transition-smooth);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .player {
        transform: translate(-50%, -50%);
        opacity: 1;
        pointer-events: auto;
    }

    .playlist {
        transform: translate(150%, -50%);
        opacity: 0;
        pointer-events: none;
        display: flex;
        flex-direction: column;
    }

    body.show-playlist .player {
        transform: translate(-150%, -50%);
        opacity: 0;
        pointer-events: none;
    }

    body.show-playlist .playlist {
        transform: translate(-50%, -50%);
        opacity: 1;
        pointer-events: auto;
    }

    .player > *:not(.progress-container):not(.volume-container) {
        flex-shrink: 0;
    }

    .playlist h2,
    .search-container {
        flex-shrink: 0;
    }

    .search-container {
        margin-bottom: 10px;
    }

    .playlist-scroll {
        max-height: calc(100vh - var(--playlist-padding) - var(--playlist-header-height) - var(--scroll-padding));
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .now-playing {
        margin-bottom: 10px;
    }

    .track-title {
        font-size: 1em;
    }

    .controls {
        gap: 10px;
        margin-bottom: 10px;
    }

    .btn {
        padding: 6px;
    }

    .btn-play {
        width: 50px;
        height: 50px;
    }

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

    .progress-container,
    .volume-container {
        margin-bottom: 8px;
    }

    /* Player-Only im Landscape */
    .container.player-only .playlist {
        display: flex !important;
        transform: translate(150%, -50%);
        opacity: 0;
    }

    body.show-playlist .container.player-only .playlist {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Mobile Portrait: Kompaktes Layout */
@media (max-width: 768px) and (orientation: portrait) {
    .playlist-header:has(.search-toggle-container.active) h2 {
        display: none;
    }

    .playlist-header:has(.search-toggle-container.active) .search-toggle-container.active {
        width: 100%;
        max-width: 100%;
    }

    .playlist-header:has(.search-toggle-container.active) .search-input-inline {
        width: 100%;
    }

    .playlist-item-content {
        gap: 3px;
    }

    .playlist-item {
        font-weight: normal;
        font-size: 0.7rem;
        padding: 5px;
    }

    .playlist-item-number {
        font-weight: normal;
        opacity: 0.7;
        min-width: 20px;
        flex-shrink: 1;
    }

    .playlist-item-actions {
        gap: 4px;
        flex-shrink: 1;
    }
}