/* =========================================================================
   RyMixes Radio Panel - design system
   Premium, mobile-first admin UI. Themed via CSS variables so white-label
   branding and light/dark modes work without recompilation.
   ========================================================================= */

:root {
    /* Brand accent (overridden inline from station/global branding) */
    --accent: #0ea5b7;
    --accent-strong: #0c8f9f;
    --accent-soft: rgba(14, 165, 183, 0.12);
    --accent-contrast: #ffffff;

    /* Status palette (deliberately avoids AI-purple) */
    --live: #e11d48;
    --live-soft: rgba(225, 29, 72, 0.12);
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.12);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.14);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.12);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, 0.12);

    /* Light theme surfaces */
    --bg: #f4f6fb;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e3e8f0;
    --border-strong: #cdd5e2;
    --text: #0f1b2d;
    --text-muted: #5b6b82;
    --text-faint: #8695a9;
    --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.06);
    --shadow: 0 6px 24px rgba(15, 27, 45, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 27, 45, 0.16);

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;

    --sidebar-w: 264px;
    --topbar-h: 66px;
    --minibar-h: 64px;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg: #0b1220;
    --bg-elevated: #111a2c;
    --surface: #131d31;
    --surface-2: #182338;
    --surface-3: #1e2b44;
    --border: #24324c;
    --border-strong: #33455f;
    --text: #eef3fb;
    --text-muted: #9fb0c9;
    --text-faint: #6d7f9c;
    --accent-soft: rgba(14, 165, 183, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    margin: 0 0 0.4em;
    line-height: 1.2;
    letter-spacing: -0.01em;
    font-weight: 700;
}

h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 1rem; }

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { color: var(--accent-strong); }

img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft); }

/* ---- Layout shell ---------------------------------------------------- */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
    grid-row: 1 / -1;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 22px;
    min-height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
}

.sidebar__logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: grid;
    place-items: center;
    color: var(--accent-contrast);
    font-weight: 800;
    flex: none;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.sidebar__logo img { width: 100%; height: 100%; object-fit: cover; }

.sidebar__title {
    font-weight: 700;
    font-size: 0.98rem;
    line-height: 1.15;
}
.sidebar__subtitle {
    font-size: 0.72rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar__nav {
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    padding: 16px 12px 6px;
    font-weight: 700;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 550;
    font-size: 0.92rem;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    min-height: 42px;
}
.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}
[data-theme="dark"] .nav-link.is-active { color: #6fe3ef; }
.nav-link svg { width: 20px; height: 20px; flex: none; }

.sidebar__footer {
    padding: 14px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-faint);
}

/* ---- Main column ---------------------------------------------------- */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
}

.topbar__title { font-size: 1.05rem; font-weight: 700; }
.topbar__spacer { flex: 1; }

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 20px; height: 20px; }

.menu-toggle { display: none; }

.content {
    padding: 26px 22px calc(var(--minibar-h) + 40px);
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head__text { flex: 1; min-width: 220px; }
.page-head__lead { color: var(--text-muted); margin: 0; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- User chip ------------------------------------------------------ */

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: var(--accent-contrast);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex: none;
}
.user-chip__meta { line-height: 1.1; }
.user-chip__name { font-weight: 650; font-size: 0.85rem; }
.user-chip__role { font-size: 0.72rem; color: var(--text-faint); text-transform: capitalize; }

/* ---- Cards & grid --------------------------------------------------- */

.grid { display: grid; gap: 18px; }
.grid--stats { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card__body { padding: 20px; }
.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card__head h3 { margin: 0; }
.card__head .topbar__spacer { flex: 1; }

.stat-card { padding: 20px; position: relative; }
.stat-card__label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 650;
}
.stat-card__value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 6px;
}
.stat-card__meta { font-size: 0.82rem; color: var(--text-faint); margin-top: 4px; }
.stat-card__icon {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
}
.stat-card__icon svg { width: 22px; height: 22px; }

/* ---- Badges & pills ------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 650;
    line-height: 1.5;
    border: 1px solid transparent;
}
.badge--live { background: var(--live-soft); color: var(--live); }
.badge--online, .badge--ok, .badge--success { background: var(--success-soft); color: var(--success); }
.badge--offline, .badge--danger, .badge--error { background: var(--danger-soft); color: var(--danger); }
.badge--warn, .badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--muted { background: var(--surface-3); color: var(--text-muted); }
.badge--accent { background: var(--accent-soft); color: var(--accent-strong); }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.badge--live .dot { animation: pulse 1.6s var(--ease) infinite; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--live-soft); }
    70% { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- Buttons -------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 650;
    font-size: 0.9rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    min-height: 44px;
    white-space: nowrap;
    font-family: inherit;
}
.btn svg { width: 18px; height: 18px; }
.btn--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
}
.btn--primary:hover { filter: brightness(1.05); color: var(--accent-contrast); }
.btn--ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.btn--ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.05); color: #fff; }
.btn--subtle { background: var(--surface-2); color: var(--text-muted); }
.btn--sm { padding: 6px 12px; min-height: 36px; font-size: 0.82rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Forms ---------------------------------------------------------- */

.form-grid { display: grid; gap: 18px; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
    font-weight: 620;
    font-size: 0.86rem;
}
.field__hint { font-size: 0.78rem; color: var(--text-faint); }

.input, .select, .textarea {
    width: 100%;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
    min-height: 46px;
}
.textarea { min-height: 108px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-faint); }

.input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}
.input-group__addon {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.86rem;
    border-right: 1px solid var(--border);
    white-space: nowrap;
}
.input-group .input { border: 0; border-radius: 0; }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] {
    width: 52px; height: 46px; border: 1px solid var(--border-strong);
    border-radius: 12px; background: var(--surface); padding: 4px; cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ---- Tables --------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    white-space: nowrap;
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table__primary { font-weight: 650; }
.table__sub { color: var(--text-faint); font-size: 0.82rem; }

/* ---- Flash / alerts ------------------------------------------------- */

.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.9rem;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert--success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert--error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert--warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert--info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert__close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: 0.7; }

.banner-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.85rem;
    font-weight: 600;
}
.banner-warning svg { width: 18px; height: 18px; }

/* ---- Equalizer animation ------------------------------------------- */

.equalizer { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.equalizer span {
    width: 3px;
    background: currentColor;
    border-radius: 2px;
    animation: eq 1s ease-in-out infinite;
}
.equalizer span:nth-child(1) { animation-delay: -0.4s; height: 40%; }
.equalizer span:nth-child(2) { animation-delay: -0.2s; height: 90%; }
.equalizer span:nth-child(3) { animation-delay: -0.6s; height: 60%; }
.equalizer span:nth-child(4) { animation-delay: -0.1s; height: 100%; }
@keyframes eq {
    0%, 100% { transform: scaleY(0.35); }
    50% { transform: scaleY(1); }
}
.equalizer--paused span { animation-play-state: paused; opacity: 0.4; }

/* ---- Mini bar (now playing / station health) ----------------------- */

.minibar {
    position: fixed;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    height: var(--minibar-h);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    z-index: 35;
    box-shadow: 0 -6px 24px rgba(15, 27, 45, 0.06);
}
.minibar__art {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--surface-3); display: grid; place-items: center;
    color: var(--accent); flex: none;
}
.minibar__meta { min-width: 0; }
.minibar__title { font-weight: 650; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minibar__sub { font-size: 0.78rem; color: var(--text-faint); }
.minibar__spacer { flex: 1; }
.minibar__stat { text-align: right; font-size: 0.78rem; color: var(--text-muted); }
.minibar__stat strong { display: block; font-size: 1rem; color: var(--text); }
.minibar__sub a { color: inherit; text-decoration: none; }
.minibar__sub a:hover { color: var(--accent); }

/* ---- Live monitoring (stats) --------------------------------------- */

.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
}
.metric {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 12px);
    padding: 14px 16px;
}
.metric__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.metric__value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; color: var(--text); }
.metric__value--sm { font-size: 0.95rem; font-weight: 600; }
.metric__unit { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }

.nowplaying {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-sm, 12px);
    background: var(--accent-soft);
}
.nowplaying__icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; flex: none;
    background: var(--bg-elevated); color: var(--accent-strong, var(--accent));
}
.nowplaying__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.nowplaying__title { font-weight: 650; font-size: 1.02rem; color: var(--text); }

.spark-wrap { margin-top: 8px; }
.spark { display: block; width: 100%; height: 90px; }
.spark--empty {
    display: grid; place-items: center; height: 90px; text-align: center;
    color: var(--text-faint); font-size: 0.85rem;
    border: 1px dashed var(--border); border-radius: var(--radius-sm, 12px);
    padding: 0 16px;
}

/* ---- Slide-over panel & modal -------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 14, 24, 0.5);
    backdrop-filter: blur(2px);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ease), visibility 0.2s var(--ease);
}
.overlay.is-open { opacity: 1; visibility: visible; }

.modal {
    position: fixed;
    z-index: 70;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%);
    width: min(460px, calc(100vw - 32px));
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s var(--ease);
}
.modal.is-open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.modal__body { padding: 24px; }
.modal__title { font-size: 1.1rem; margin-bottom: 6px; }
.modal__text { color: var(--text-muted); margin-bottom: 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Empty states --------------------------------------------------- */

.empty {
    text-align: center;
    padding: 54px 24px;
    color: var(--text-muted);
}
.empty__icon {
    width: 64px; height: 64px; margin: 0 auto 16px;
    border-radius: 18px; background: var(--accent-soft); color: var(--accent-strong);
    display: grid; place-items: center;
}
.empty__icon svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text); }

/* ---- Definition list ------------------------------------------------ */

.dl { display: grid; gap: 2px; }
.dl__row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.dl__row:last-child { border-bottom: 0; }
.dl__key { color: var(--text-muted); }
.dl__val { font-weight: 600; text-align: right; }

/* ---- Progress ------------------------------------------------------- */

.progress {
    height: 8px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    border-radius: 999px;
    transition: width 0.4s var(--ease);
}
.progress__bar--warn { background: var(--warning); }
.progress__bar--danger { background: var(--danger); }

/* ---- Auth screen ---------------------------------------------------- */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent),
        radial-gradient(1000px 500px at 110% 110%, var(--accent-soft), transparent),
        var(--bg);
}
.auth__card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 34px;
}
.auth__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    text-align: center;
}
.auth__logo {
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: grid; place-items: center; color: var(--accent-contrast);
    font-weight: 800; font-size: 1.3rem; overflow: hidden;
}
.auth__logo img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Utilities ------------------------------------------------------ */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.hide { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.code-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text);
    overflow-x: auto;
    white-space: pre;
}

/* ---- Mobile bottom navigation -------------------------------------- */

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 45;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, 1fr);
}
.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 10px;
}
.mobile-nav a.is-active { color: var(--accent-strong); }
.mobile-nav svg { width: 22px; height: 22px; }

/* ---- Responsive ----------------------------------------------------- */

@media (max-width: 1024px) {
    :root { --sidebar-w: 0px; }

    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }

    .menu-toggle { display: grid; }

    .minibar { left: 0; bottom: 60px; }

    .mobile-nav { display: grid; }

    .content { padding-bottom: calc(var(--minibar-h) + 90px); }
}

@media (max-width: 560px) {
    .content { padding-left: 16px; padding-right: 16px; }
    .topbar { padding: 0 16px; }
    .stat-card__value { font-size: 1.7rem; }
    .page-head__actions { width: 100%; }
    .page-head__actions .btn { flex: 1; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .user-chip__meta { display: none; }
}

/* ---- Stream connection test & hosting note ------------------------- */

.hosting-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.4;
    background: var(--success-soft);
    color: var(--success);
}
.hosting-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.hosting-note--warn { background: var(--warning-soft); color: var(--warning); }

.btn.is-loading { opacity: 0.7; pointer-events: none; }

.test-result { font-size: 0.85rem; color: var(--text-muted); }
.test-result--pending { color: var(--text-muted); }
.test-result--ok { color: var(--success); font-weight: 600; }
.test-result--error { color: var(--danger); font-weight: 600; }

/* ---- Public station page ------------------------------------------- */

.public-body {
    background:
        radial-gradient(1100px 480px at 50% -10%, var(--accent-soft), transparent 70%),
        var(--bg);
    min-height: 100vh;
}
.pub {
    max-width: 560px;
    margin: 0 auto;
    padding: 32px 18px 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.pub-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius, 18px);
    padding: 22px;
    box-shadow: 0 16px 40px rgba(15, 27, 45, 0.08);
}

.pub-hero__top { display: flex; align-items: center; gap: 16px; }
.pub-hero__logo {
    position: relative;
    width: 72px; height: 72px; flex: none;
    border-radius: 18px; overflow: hidden;
    background: var(--surface-2); color: var(--accent);
    display: grid; place-items: center;
}
.pub-hero__logo img { width: 100%; height: 100%; object-fit: cover; }
.pub-hero__logo svg { width: 34px; height: 34px; }
.pub-hero__id { min-width: 0; }
.pub-hero__id h1 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.1; }
.pub-hero__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pub-hero__desc { color: var(--text-muted); font-size: 0.9rem; }

.pub-status {
    font-size: 0.75rem; font-weight: 700; padding: 3px 10px;
    border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.pub-status[data-state="online"] { background: var(--success-soft); color: var(--success); }
.pub-status[data-state="offline"] { background: var(--danger-soft); color: var(--danger); }

.pub-player { display: flex; align-items: center; gap: 16px; margin-top: 22px; }
.pub-play {
    width: 66px; height: 66px; flex: none;
    border: 0; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; cursor: pointer;
    box-shadow: 0 10px 24px var(--accent-soft);
    transition: transform 0.15s ease;
}
.pub-play:hover { transform: scale(1.06); }
.pub-play:disabled { opacity: 0.5; cursor: not-allowed; }
.pub-play__pause { display: none; }
.pub-hero.is-playing .pub-play__play { display: none; }
.pub-hero.is-playing .pub-play__pause { display: block; }

.pub-now { flex: 1; min-width: 0; }
.pub-now__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.pub-now__title { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub-now__artist { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub-now__stat { text-align: right; flex: none; }
.pub-now__listeners { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.pub-now__listeners svg { width: 16px; height: 16px; color: var(--text-muted); }
.pub-now__audio { display: block; font-size: 0.72rem; color: var(--text-faint); margin-top: 4px; }

.pub-controls { margin-top: 18px; display: flex; align-items: center; gap: 14px; }
.pub-vol { display: flex; align-items: center; gap: 10px; color: var(--text-muted); flex: 1; }
.pub-vol svg { width: 16px; height: 16px; }
.pub-vol input[type="range"] { flex: 1; accent-color: var(--accent); }
.pub-share { flex: none; }
.pub-share svg { margin-right: 4px; vertical-align: -2px; }

.pub-h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 0 0 12px; }
.pub-h2 svg { width: 18px; height: 18px; color: var(--accent); }
.pub-muted { color: var(--text-muted); margin: 0; }
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-list li {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 10px 0; border-top: 1px solid var(--border); font-size: 0.9rem;
}
.pub-list li:first-child { border-top: 0; }
.pub-list__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-list__time { color: var(--text-faint); flex: none; }

.pub__powered { text-align: center; }
.pub__powered a { color: var(--text-faint); font-size: 0.78rem; text-decoration: none; }
.pub__powered a:hover { color: var(--accent); }

/* Equalizer overlay on the public hero logo (shown while playing) */
.pub-hero__logo .w-eq {
    display: none;
    position: absolute; left: 0; right: 0; bottom: 6px;
    justify-content: center; align-items: flex-end; gap: 3px; height: 16px;
}
.pub-hero.is-playing .pub-hero__logo .w-eq { display: flex; }
.pub-hero__logo .w-eq i {
    width: 3px; height: 40%; background: #fff; border-radius: 2px;
    animation: w-eq 0.9s ease-in-out infinite;
}
.pub-hero__logo .w-eq i:nth-child(2) { animation-delay: -0.2s; height: 90%; }
.pub-hero__logo .w-eq i:nth-child(3) { animation-delay: -0.6s; height: 60%; }
.pub-hero__logo .w-eq i:nth-child(4) { animation-delay: -0.1s; }
@keyframes w-eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }

@media (max-width: 480px) {
    .pub-now__stat { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* =========================================================================
   Music library
   ========================================================================= */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}
.link-button {
    background: none; border: 0; padding: 0;
    color: var(--accent-strong); font: inherit; cursor: pointer;
    text-decoration: underline; text-underline-offset: 2px;
}
.row--end { justify-content: flex-end; }
.gap-1 { gap: 8px; }

/* ---- Uploader ------------------------------------------------------- */
.uploader { margin-bottom: 18px; }
.uploader__drop {
    display: flex; align-items: center; gap: 18px;
    padding: 22px 24px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.uploader__drop:hover,
.uploader__drop:focus-visible { border-color: var(--accent); outline: none; }
.uploader__drop.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.uploader__icon {
    flex: none;
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: var(--accent-soft); color: var(--accent-strong);
}
.uploader__icon svg { width: 26px; height: 26px; }
.uploader__copy { display: flex; flex-direction: column; gap: 3px; }
.uploader__copy strong { font-size: 1.02rem; }
.uploader__copy span { color: var(--text-muted); font-size: 0.9rem; }
.uploader__copy small { color: var(--text-faint); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.upload-queue { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upload-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.upload-item__body { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.upload-item__name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item__status { flex: none; font-size: 0.8rem; color: var(--text-muted); }
.upload-item__bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.upload-item__fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.2s var(--ease); }
.upload-item.is-done .upload-item__fill { background: var(--success); }
.upload-item.is-done .upload-item__status { color: var(--success); }
.upload-item.is-error .upload-item__fill { background: var(--danger); }
.upload-item.is-error .upload-item__status { color: var(--danger); }

/* ---- Toolbar & search ---------------------------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 420px; }
.search__icon { position: absolute; left: 12px; color: var(--text-faint); display: grid; place-items: center; pointer-events: none; }
.search__icon svg { width: 18px; height: 18px; }
.search input {
    width: 100%;
    padding: 10px 38px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit; font-size: 0.92rem;
}
.search input:focus-visible { outline: none; border-color: var(--accent); background: var(--surface); }
.search__clear { position: absolute; right: 10px; color: var(--text-faint); display: grid; place-items: center; }
.search__clear svg { width: 16px; height: 16px; }

/* ---- Track table --------------------------------------------------- */
.music-table td { vertical-align: middle; }
.music-play {
    position: relative;
    width: 44px; height: 44px;
    border: 0; padding: 0;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-3);
    color: var(--text-faint);
    cursor: pointer;
    display: grid; place-items: center;
}
.music-play img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.music-play__ph svg { width: 20px; height: 20px; }
.music-play__icon {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: rgba(9, 14, 24, 0.55);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s var(--ease);
}
.music-play__icon svg { width: 18px; height: 18px; }
.music-play:hover .music-play__icon,
.music-play:focus-visible .music-play__icon,
.music-play.is-playing .music-play__icon { opacity: 1; }
.music-play.is-playing .music-play__icon { background: var(--accent); }

.music-edit > td { background: var(--surface-2); padding: 16px 18px !important; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.edit-form .field input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.edit-form .field input:focus-visible { outline: none; border-color: var(--accent); }

/* ---- Pagination ---------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pagination__info { color: var(--text-muted); font-size: 0.86rem; }

/* ---- Preview player bar -------------------------------------------- */
.preview-bar {
    position: fixed;
    left: 50%; bottom: 18px;
    transform: translateX(-50%);
    z-index: 60;
    width: min(680px, calc(100% - 32px));
    display: flex; align-items: center; gap: 14px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.preview-bar__toggle {
    flex: none;
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    background: var(--accent); color: var(--accent-contrast);
    display: grid; place-items: center; cursor: pointer;
}
.preview-bar__toggle svg { width: 20px; height: 20px; }
.preview-bar__art {
    flex: none; width: 44px; height: 44px;
    border-radius: 10px; overflow: hidden;
    background: var(--surface-3); color: var(--text-faint);
    display: grid; place-items: center;
}
.preview-bar__art img { width: 100%; height: 100%; object-fit: cover; }
.preview-bar__art svg { width: 20px; height: 20px; }
.preview-bar__meta { display: flex; flex-direction: column; min-width: 0; flex: none; width: 150px; }
.preview-bar__title { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-bar__artist { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-bar__audio { flex: 1; min-width: 0; height: 36px; }
.preview-bar__close {
    flex: none; border: 0; background: none; color: var(--text-faint); cursor: pointer;
    display: grid; place-items: center; padding: 6px;
}
.preview-bar__close svg { width: 18px; height: 18px; }

@media (max-width: 640px) {
    .uploader__drop { flex-direction: column; text-align: center; }
    .preview-bar__meta { display: none; }
    .music-table th:nth-child(3),
    .music-table td:nth-child(3) { display: none; }
}

/* ============================================================ *
 *  Phase 5 - Playlists & AutoDJ
 * ============================================================ */
.badge--soft { background: var(--surface-3); color: var(--text-muted); }
.link { color: var(--accent); font-weight: 600; }
.link:hover { color: var(--accent-strong); }

.back-link {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 15px; height: 15px; }

.empty--sm { padding: 26px 16px; }
.empty--sm .empty__icon { width: 44px; height: 44px; }

.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger-soft); }

/* AutoDJ control card */
.autodj-card.is-live { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.autodj-form { margin-top: 4px; }

/* Two-pane builder */
.playlist-builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
}
.playlist-side { display: flex; flex-direction: column; gap: 20px; }
.playlist-summary { font-size: 0.85rem; color: var(--text-muted); }
.playlist-summary b { color: var(--text); }

.pl-tracks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pl-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    background: var(--surface-2);
    transition: opacity .15s var(--ease, ease), border-color .15s var(--ease, ease);
}
.pl-item.is-removing { opacity: 0.4; }
.pl-item__art {
    flex: none; width: 40px; height: 40px; border-radius: 8px; overflow: hidden;
    background: var(--surface-3); color: var(--text-faint);
    display: grid; place-items: center;
}
.pl-item__art img { width: 100%; height: 100%; object-fit: cover; }
.pl-item__art svg { width: 18px; height: 18px; }
.pl-item__meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pl-item__title { font-weight: 620; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-item__artist { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-item__len { flex: none; font-size: 0.82rem; color: var(--text-muted); }
.pl-item__actions { flex: none; display: flex; align-items: center; gap: 2px; }

/* Library picker */
.pl-picker { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 460px; overflow-y: auto; }
.pl-picker__item { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; }
.pl-picker__item:hover { background: var(--surface-2); }
.pl-picker__art {
    flex: none; width: 34px; height: 34px; border-radius: 7px; overflow: hidden;
    background: var(--surface-3); color: var(--text-faint); display: grid; place-items: center;
}
.pl-picker__art img { width: 100%; height: 100%; object-fit: cover; }
.pl-picker__art svg { width: 16px; height: 16px; }
.pl-picker__meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pl-picker__title { font-weight: 600; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-picker__artist { font-size: 0.74rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-add { flex: none; }
.pl-add:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 900px) {
    .playlist-builder { grid-template-columns: minmax(0, 1fr); }
}
