*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg:          #0e1014;
    --surface:     #181c22;
    --text:        #f3f4f6;
    --muted:       #9aa3b2;
    --accent:      #F7EB49;
    --accent-hi:   #fff36b;
    --accent-text: #0e1014;  /* Text auf accent-Hintergrund — gelb braucht dunklen Kontrast */
    --border:      #2a2f38;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    line-height: 1.4;
}

#player {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
    display: grid;
    gap: 1.25rem;
    justify-items: center;
}

#cover {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#nowPlaying {
    text-align: center;
    width: 100%;
}

#nowPlaying .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-top: 0.5rem;
}

#currentTitle {
    font-size: 1.4rem;
    font-weight: 600;
}

#currentArtist {
    font-size: 1rem;
    color: var(--muted);
}

/* Roh-Metadata vom AdsWizz-SDK (title="…",artist="…") ist redundant zur
   STOMP-Anzeige (Titel/Künstler kommen schon aus displaySongData) und wird
   nirgendwo im Player gezeigt. Wer den Roh-Wert braucht, sieht ihn im
   Debug-Console-Log als [meta] metadataChanged: …. */
#metadataLabel { display: none; }

#controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    width: 100%;
    justify-content: center;
}

#playPause {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

#playPause:hover  { background: var(--accent-hi); }
#playPause:active { transform: scale(0.96); }

#playPause svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    pointer-events: none;
}

/* Default-State (paused): Play-Icon sichtbar, Pause-Icon versteckt */
#playPause .icon-pause { display: none; }

/* Playing-State: Pause-Icon zeigen, Play-Icon weg */
#playPause.playing .icon-play  { display: none; }
#playPause.playing .icon-pause { display: block; }

/* Loading-State: beide Icons weg, Spinner per ::before */
#playPause.loading .icon-play,
#playPause.loading .icon-pause { display: none; }

#playPause.loading {
    cursor: progress;
}

#playPause.loading::before {
    content: "";
    width: 26px;
    height: 26px;
    border: 3px solid var(--accent-text);
    border-top-color: transparent;
    border-radius: 50%;
    animation: playPauseSpin 0.8s linear infinite;
}

@keyframes playPauseSpin {
    to { transform: rotate(360deg); }
}

#radioVolume {
    flex: 1;
    max-width: 240px;
    accent-color: var(--accent);
}

#companionBannerDiv {
    width: 300px;
    height: 250px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

#companionBannerDiv:empty { display: none; }

#latestSongsWrap {
    width: 100%;
    margin-top: 1rem;
}

#latestSongsWrap h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin: 0 0 0.75rem;
}

#latestSongs { display: grid; gap: 0.5rem; }

.songLine {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem;
    background: var(--surface);
    border-radius: 8px;
}

.songImage img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
}

.TimeTitleArtist {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.6rem;
    row-gap: 0.1rem;
    min-width: 0;
}

.songTime   { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.songTitle  { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.songArtist { grid-column: 2; color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#legal {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

#legal a {
    color: var(--muted);
    text-decoration: none;
}

#legal a:hover {
    color: var(--text);
    text-decoration: underline;
}

#legal #cookieReset { cursor: pointer; }

/* ========== DSGVO-Consent-Banner ========== */

#cookieBanner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(20, 22, 28, 0.97);
    color: var(--text);
    border-top: 1px solid var(--border);
    padding: 1rem 1.25rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#cookieBanner[hidden] { display: none; }

#cookieBanner .cb-content {
    max-width: 720px;
    margin: 0 auto;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    #cookieBanner .cb-content {
        grid-template-columns: 1fr auto;
        align-items: start;
    }
}

#cookieBanner .cb-text {
    font-size: 0.9rem;
    line-height: 1.45;
}

#cookieBanner .cb-text strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 1rem;
    color: var(--text);
}

#cookieBanner .cb-text p {
    margin: 0.4rem 0;
    color: var(--muted);
}

#cookieBanner .cb-text p strong {
    display: inline;
    color: var(--text);
    font-size: inherit;
    margin: 0;
}

#cookieBanner .cb-text a {
    color: var(--accent);
    text-decoration: none;
}

#cookieBanner .cb-text a:hover { text-decoration: underline; }

#cookieBanner .cb-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

#cookieBanner button {
    padding: 0.55rem 1.1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    white-space: nowrap;
}

#cookieBanner button:hover { background: #232830; }

#cb-accept {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
    font-weight: 600;
}

#cb-accept:hover {
    background: var(--accent-hi);
    border-color: var(--accent-hi);
}

/* ========== Adblocker-/Tracking-Schutz-Warnung ========== */

#adblockWarning {
    background: #4a2700;
    color: #ffd49b;
    border-bottom: 1px solid #714200;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.35;
}

/* Wichtig: das HTML-`hidden`-Attribut muss `display: flex` oben überschreiben.
   Ohne diese Regel würde `<div hidden id="adblockWarning">` trotzdem sichtbar
   sein, weil id-Spezifität die UA-Default-Regel `[hidden]{display:none}` schlägt. */
#adblockWarning[hidden] {
    display: none;
}

#adblockWarning::before {
    content: "⚠";
    font-size: 1.1rem;
    flex: 0 0 auto;
}

#adblockWarningText {
    flex: 1 1 auto;
}

#adblockWarningSelfhost,
#adblockWarningClose {
    background: transparent;
    border: 1px solid #ffd49b;
    color: #ffd49b;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    flex: 0 0 auto;
}

#adblockWarningSelfhost {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

#adblockWarningClose {
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
}

#adblockWarningSelfhost:hover,
#adblockWarningClose:hover { background: rgba(255, 212, 155, 0.12); }

/* ========== Debug-Modus (nur sichtbar wenn debug.js geladen) ========== */

/* Banner-Slot wird im Debug-Modus immer mit Platzhalter sichtbar gemacht,
   damit klar ist, wo die Werbung erscheinen würde. */
body.debug-mode #companionBannerDiv:empty {
    display: flex;
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem;
}

body.debug-mode #companionBannerDiv:empty::before {
    content: "Banner-Slot 300×250 — Werbung würde hier erscheinen";
    margin: auto;
}

#dbgStatus {
    margin-top: 8px;
    padding: 6px 8px;
    background: #0e1014;
    border: 1px solid #2a2f38;
    border-radius: 4px;
    color: #9fff9f;
    line-height: 1.4;
}

.dbgStatRow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    word-break: break-word;
}

.dbgStatK {
    color: #ffcb6b;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    align-self: center;
}

#dbgLogClear {
    margin-top: 0 !important;
    padding: 2px 6px !important;
    font-size: 10px !important;
    background: transparent !important;
    color: #ffcb6b !important;
    border: 1px solid #2a2f38 !important;
    font-weight: normal !important;
}

#dbgLogClear:hover { background: rgba(255, 203, 107, 0.1) !important; }

#debugLog {
    margin-top: 4px;
    max-height: 32vh;
    overflow: auto;
    background: #0e1014;
    color: #d0d8e2;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #2a2f38;
    line-height: 1.4;
}

#debugLog .line { white-space: pre-wrap; word-break: break-word; }
#debugLog .lvl-warn  { color: #ffcb6b; }
#debugLog .lvl-error { color: #ff6b6b; }
#debugLog .src-stomp { color: #82aaff; }
#debugLog .src-banner{ color: #c3e88d; }
#debugLog .src-meta  { color: #ffcb6b; }

#debugParams {
    width: 100%;
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.92);
    color: var(--text);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #2a2f38;
}

#debugParams input[type="text"],
#debugParams input[type="number"] {
    width: 140px;
}

#debugParams summary {
    cursor: pointer;
    user-select: none;
    color: #ffcb6b;
    font-weight: 600;
}

#debugParams form {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

#debugParams label {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px;
}

#debugParams input[type="text"],
#debugParams input[type="number"] {
    width: 110px;
    background: #181c22;
    color: var(--text);
    border: 1px solid #2a2f38;
    border-radius: 4px;
    padding: 2px 4px;
    font: inherit;
}

#debugParams button {
    margin-top: 4px;
    padding: 4px 8px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

/* Klappbare Sub-Sektionen im Debug-Panel (Stream-Diagnose, Console-Log) */
#debugParams .dbgSection {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #2a2f38;
}

#debugParams .dbgSection > summary {
    cursor: pointer;
    user-select: none;
    color: #82aaff;
    font-weight: 600;
    margin-bottom: 4px;
}

#debugParams .dbgRow { margin-top: 6px; }
#debugParams .dbgK   { color: #ffcb6b; margin-right: 4px; }

#debugParams pre {
    margin: 4px 0;
    padding: 4px 6px;
    background: #0e1014;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #d0d8e2;
    max-height: 16em;
    overflow: auto;
}

#debugParams .dbgNote {
    margin-top: 8px;
    color: #9aa3b2;
    font-style: italic;
    line-height: 1.45;
}

#debugParams .dbgNote code {
    background: #0e1014;
    padding: 0 4px;
    border-radius: 3px;
    color: #d0d8e2;
    font-style: normal;
}

#diagProbe {
    margin-top: 6px;
    padding: 4px 8px;
    background: #82aaff;
    color: #0e1014;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
