:root {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;

    /* Theme */
    --bg: #0b0f14;
    --panel: #0f1620;
    --player: #080c11;
    --border: #1c2633;
    --border2: #263447;
    --text: #e8eef7;
    --muted: #a8b6c8;
    --accent: #5aa7ff;

    /* Sizing */
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 12px 40px rgba(0, 0, 0, .35);
    --container: 1200px;
    --panel-w: 420px;

    /* Safe areas (iOS) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    min-height: 100svh;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===================== Header ===================== */
header {
    padding: calc(12px + var(--safe-top)) calc(14px + var(--safe-right)) 12px calc(14px + var(--safe-left));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
}

input,
select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border2);
    background: var(--panel);
    color: var(--text);
    min-width: 160px;
}

header input {
    flex: 1 1 420px;
}

button {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border2);
    background: #152232;
    color: var(--text);
    cursor: pointer;
}

/* Polish */
button,
input,
select {
    transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .18);
}

button:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    margin-left: auto;
    white-space: nowrap;
    pointer-events: none;
    /* <- wichtig: blockt keine Klicks mehr */
}

.spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(232, 238, 247, .25);
    border-top-color: rgba(90, 167, 255, .95);
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================== Main Layout ===================== */
main {
    width: 100%;
    max-width: var(--container);
    margin: 14px auto;
    padding: 0 14px calc(14px + var(--safe-bottom));
    display: grid;
    grid-template-columns: minmax(280px, var(--panel-w)) minmax(0, 1fr);
    gap: 0;
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);

    /* Make it adapt: never taller than viewport, but comfy */
    height: min(800px, calc(100vh - 120px));
}

/* Left Panel */
.panel {
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow: auto;
    overscroll-behavior: contain;
}

/* Right Player */
.player {
    background: var(--player);
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

/* ===================== Toolbar ===================== */
.toolbar {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar input {
    flex: 1 1 240px;
    max-width: 420px;
}

.select {
    max-width: 260px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, .03);
}

.tab {
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    letter-spacing: .3px;
}

.tab.active {
    background: rgba(90, 167, 255, .14);
    border-color: rgba(90, 167, 255, .35);
}

/* ===================== Hints / Errors ===================== */
.hint {
    font-size: 12px;
    color: var(--muted);
    padding: 8px 12px;
}

#nowPlaying {
    font-size: 13px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .03);
    font-weight: 750;
}

.err {
    color: #ff7b7b;
    white-space: pre-wrap;
    padding: 10px 12px;
}

/* ===================== List ===================== */
.list {
    padding: 10px;
    display: grid;
    gap: 10px;
}

/* (Optional) LIVE grid:
.list.grid{
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
*/

.item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, .02);
    display: grid;
    gap: 6px;
    outline: none;
    cursor: pointer;
    overflow: hidden;
    transition: transform .10s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

.item:hover {
    border-color: rgba(90, 167, 255, .35);
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .12);
}

.item:focus {
    transform: scale(1.012);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .22);
}

.item.playing {
    border-color: rgba(90, 167, 255, .75);
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .18), 0 0 22px rgba(90, 167, 255, .15);
    background: rgba(90, 167, 255, .06);
}

.titleRow {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.titleText {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 850;
    letter-spacing: .2px;
}

.item.playing .titleText {
    color: #fff;
    text-shadow: 0 0 10px rgba(90, 167, 255, .35);
}

.meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Fav */
.favBtn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .03);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex: 0 0 auto;
    padding: 0;
}

.favBtn:hover {
    border-color: rgba(90, 167, 255, .45);
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .12);
}

/* Logos */
.logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--bg);
}

.footer {
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
    padding: 14px 16px;
}

.footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.footer__title {
    font-weight: 800;
    letter-spacing: .2px;
    margin-bottom: 6px;
}

.footer__text {
    margin: 6px 0;
    color: var(--muted);
    line-height: 1.4;
    font-size: 12px;
}

.footer__muted {
    opacity: .85;
}

/* ===================== Video ===================== */
video {
    width: 100%;
    height: 100%;
    background: black;
    border-bottom: 1px solid var(--border);
}

/* ===================== Responsive ===================== */

/* Medium: tighter panel, better fit */
@media (max-width: 1100px) {
    :root {
        --panel-w: 380px;
    }

    main {
        height: min(760px, calc(100vh - 120px));
    }
}

/* Stack layout on smaller screens (portrait & small tablets) */
@media (max-width: 920px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(260px, 45vh) 1fr;
        height: auto;
        margin: 0;
        padding: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    header {
        border-bottom: 1px solid var(--border);
    }

    .loading {
        margin-left: 0;
    }
}

/* Phone landscape: keep video usable, panel scrollable */
@media (max-width: 920px) and (orientation: landscape) {
    main {
        grid-template-columns: 1fr 1.15fr;
        grid-template-rows: 1fr;
        height: calc(100vh - 74px);
        border-radius: 0;
    }

    .panel {
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    .toolbar {
        position: sticky;
        top: 0;
        background: var(--panel);
        z-index: 5;
    }

    .hint {
        display: none;
        /* more space */
    }

    video {
        border-bottom: none;
    }
}

/* Very small phones: tighten controls */
@media (max-width: 420px) {
    header {
        gap: 8px;
        padding-left: calc(10px + var(--safe-left));
        padding-right: calc(10px + var(--safe-right));
    }

    input,
    select,
    button {
        padding: 9px 10px;
        border-radius: 10px;
    }

    .tab {
        padding: 7px 9px;
    }

    .favBtn {
        width: 32px;
        height: 32px;
        border-radius: 11px;
    }

    .logo {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }
}