/* ── Reset & Tokens ──────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #080d14;
    --bg2: #0d1520;
    --surface: #111927;
    --surface2: #1a2740;
    --border: rgba(255, 255, 255, .07);
    --text: #e8edf5;
    --muted: #6b7a96;
    --primary: #5b6af0;
    --primary-h: #4756e0;
    --accent: #f0456b;
    --gold: #f5a623;
    --radius: 12px;
    --topbar-h: 60px;
    --sidebar-w: 280px;
    --ctrl-h: 52px;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* ── Utilities ──────────────────────────────────────── */
.hidden {
    display: none !important;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem 1.1rem;
    border: none;
    border-radius: 8px;
    font: 600 .875rem 'Inter', sans-serif;
    cursor: pointer;
    transition: background .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 18px rgba(91, 106, 240, .35);
}

.btn-primary:hover {
    background: var(--primary-h);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--surface2);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
}

.btn-ghost:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-icon {
    background: transparent;
    color: var(--muted);
    padding: .4rem;
    border-radius: 6px;
}

.btn-icon:hover {
    color: var(--text);
    background: var(--surface2);
}

.btn-sm {
    padding: .4rem .85rem;
    font-size: .8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-discord {
    background: #5865F2;
    color: #fff;
    font-weight: 600;
    padding: .85rem;
}

.btn-discord:hover {
    background: #4752c4;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(88, 101, 242, .3);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
}

.badge-host {
    background: linear-gradient(135deg, #f5a623, #e04545);
    color: #fff;
    box-shadow: 0 2px 10px rgba(240, 69, 107, .25);
}

.field-error {
    color: var(--accent);
    font-size: .8rem;
    min-height: 1.1em;
}

/* ── Login ──────────────────────────────────────────── */
.screen-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 60% 20%, #1a1f5e 0%, var(--bg) 65%);
    z-index: 200;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem 2.2rem;
    width: min(420px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    animation: fadeUp .35s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

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

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.75rem;
    font-weight: 800;
}

.brand i {
    color: var(--primary);
}

.brand em {
    color: var(--primary);
    font-style: normal;
}

.subtitle {
    color: var(--muted);
    font-size: .88rem;
    margin-top: -.25rem;
}

.login-card label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .72rem 1rem;
    color: var(--text);
    font: 500 .95rem 'Inter', sans-serif;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 106, 240, .18);
}

input::placeholder {
    color: var(--muted);
}

/* ── Modals ─────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: min(400px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
    animation: fadeUp .25s ease;
}

.modal-card h3 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: .25rem;
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(11, 17, 27, .92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.topbar .brand {
    font-size: 1.3rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .8rem;
}

#host-controls {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.viewers-toggle {
    gap: .5rem;
}

.viewers-toggle span {
    background: var(--primary);
    color: #fff;
    border-radius: 50px;
    padding: .05rem .45rem;
    font-size: .72rem;
    font-weight: 700;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: .75rem;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
    margin-left: .25rem;
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
}

.user-profile #user-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.logout-link {
    color: var(--muted);
    font-size: 1rem;
    transition: color .2s;
    margin-left: .25rem;
}

.logout-link:hover {
    color: #f0456b;
}

/* ── Layout ─────────────────────────────────────────── */
#app {
    height: 100%;
}

.layout {
    display: flex;
    height: 100vh;
    padding-top: var(--topbar-h);
}

.player-wrap {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    gap: .75rem;
}

.host-banner {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: rgba(240, 69, 107, .12);
    border: 1px solid rgba(240, 69, 107, .3);
    color: #f07090;
    padding: .5rem 1.2rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    width: 100%;
    max-width: 1280px;
    animation: fadeUp .2s ease;
}

.ready-banner {
    background: rgba(91, 106, 240, .12);
    border: 1px solid rgba(91, 106, 240, .3);
    color: #7985f5;
}

/* ── Player ─────────────────────────────────────────── */
.player {
    position: relative;
    width: 100%;
    max-width: 1280px;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}

.player.paused .controls {
    opacity: 1;
    pointer-events: all;
}

/* ── Ambilight ── */
.ambient-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.5); /* Większa skala dla lepszego rozmycia */
    width: 100%;
    height: 100%;
    filter: blur(140px) saturate(1.8) brightness(0.8);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    transition: opacity .8s ease;
}
video { position: relative; width: 100%; height: 100%; z-index: 1; cursor: pointer; }

.player:fullscreen {
    border-radius: 0;
    max-width: 100%;
}

.player:-webkit-full-screen {
    border-radius: 0;
    max-width: 100%;
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: all;
}

/* overlays */
.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--bg2);
    color: var(--muted);
    pointer-events: none;
}

.player-overlay i {
    font-size: 3rem;
}

.player-overlay p {
    font-size: .95rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, .1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    background: rgba(0, 0, 0, .55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    pointer-events: none;
    animation: popFade .4s ease forwards;
}

@keyframes popFade {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.6);
    }
}

/* controls */
.controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, .85) 60%);
    padding: 1.5rem .75rem .5rem;
    opacity: 0;
    transition: opacity .25s;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    z-index: 10;
}

.player:hover .controls,
.player.paused .controls {
    opacity: 1;
}

.progress-wrap {
    position: relative;
    padding: 8px 0;
    cursor: pointer;
}

.progress-bg {
    height: 4px;
    background: rgba(255, 255, 255, .2);
    border-radius: 4px;
    position: relative;
    transition: height .15s;
}

.progress-wrap:hover .progress-bg {
    height: 6px;
}

.progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, .3);
    border-radius: 4px;
    pointer-events: none;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    pointer-events: none;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}

.progress-wrap:hover .progress-thumb {
    opacity: 1;
}

.progress-tooltip {
    position: absolute;
    top: -28px;
    background: rgba(0, 0, 0, .8);
    color: #fff;
    padding: .2rem .5rem;
    border-radius: 4px;
    font-size: .75rem;
    pointer-events: none;
    transform: translateX(-50%);
    white-space: nowrap;
    opacity: 0;
    transition: opacity .15s;
}

.progress-wrap:hover .progress-tooltip {
    opacity: 1;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.ctrl-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .85);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
}

.ctrl-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.volume-wrap {
    display: flex;
    align-items: center;
}

.volume-slider {
    width: 72px;
    height: 4px;
    accent-color: var(--primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s, width .2s;
}

.volume-wrap:hover .volume-slider {
    opacity: 1;
}

.time-display {
    font-size: .8rem;
    color: rgba(255, 255, 255, .75);
    padding: 0 .4rem;
    white-space: nowrap;
    user-select: none;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
    transition: width .2s, opacity .2s;
    overflow: hidden;
}

.sidebar.closed {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: .9rem;
    color: var(--muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-header i {
    color: var(--primary);
}

#viewers-list {
    list-style: none;
    padding: .75rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    overflow-y: auto;
    flex: 1;
}

#viewers-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .85rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .875rem;
    white-space: nowrap;
    overflow: hidden;
}

.viewer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
    overflow: hidden;
}

.viewer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer-avatar.sm {
    width: 24px;
    height: 24px;
    font-size: .65rem;
}

.viewer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.viewer-crown {
    color: var(--gold);
    font-size: .8rem;
    flex-shrink: 0;
}

.viewer-status {
    font-size: 1rem;
    flex-shrink: 0;
}

.viewer-status.ready {
    color: #4ade80;
}

.viewer-status.waiting {
    color: var(--muted);
}

/* ── Chat ───────────────────────────────────────────── */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, .15);
}

/* Audio Booster Sidebar Box */
.audio-booster-box {
    padding: 1.2rem;
    background: rgba(91, 106, 240, 0.05);
    border-bottom: 1px solid var(--border);
}

.audio-booster-box .section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.8rem;
    font-weight: 700;
}

.booster-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.booster-controls input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    height: 5px;
    cursor: pointer;
}

#gain-value {
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    text-align: right;
    font-weight: 600;
}

.chat-header {
    padding: .75rem 1.2rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: .5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    scrollbar-width: thin;
}

.chat-msg {
    animation: fadeIn .2s ease;
}

.chat-msg-body {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
}

.chat-msg-content {
    flex: 1;
    min-width: 0;
}

.chat-msg-meta {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .2rem;
}

.chat-msg-nick {
    font-weight: 700;
    font-size: .8rem;
    color: var(--primary);
}

.chat-msg-time {
    font-size: .65rem;
    color: var(--muted);
}

.chat-msg-text {
    font-size: .875rem;
    color: rgba(255, 255, 255, .9);
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.deleted {
    opacity: 0.6;
    font-style: italic;
}

.chat-msg.deleted .chat-msg-text {
    font-size: 0;
}

.chat-msg.deleted .chat-msg-text::before {
    content: "(wiadomość usunięta)";
    font-size: 0.875rem;
    color: var(--muted);
    transition: color .2s;
}

.chat-msg.deleted:hover .chat-msg-text::before {
    content: attr(data-original);
    color: rgba(255, 255, 255, 0.5);
}

.chat-msg.deleted .msg-delete-btn {
    display: none;
}

.msg-delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: .75rem;
    padding: 0 .25rem;
    transition: opacity .2s, color .2s;
}

.chat-msg:hover .msg-delete-btn {
    opacity: 1;
}

.msg-delete-btn:hover {
    color: #f0456b;
}

.chat-input-area {
    padding: .75rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    gap: .5rem;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: .5rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    transition: border-color .2s;
}

.chat-input-area input:focus {
    border-color: var(--primary);
    outline: none;
}

#chat-send-btn {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter .2s;
}

#chat-send-btn:hover {
    filter: brightness(1.1);
}

/* ── Library Modal ──────────────────────────────────── */
.viewer-kick-btn {
    background: transparent;
    border: none;
    color: rgba(240, 69, 107, 0.7);
    cursor: pointer;
    font-size: .9rem;
    padding: .2rem;
    transition: color .2s;
    margin-left: auto;
}

.viewer-kick-btn:hover {
    color: #f0456b;
}

/* ── Library Modal ──────────────────────────────────── */
.library-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    width: min(900px, 96vw);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
    animation: fadeUp .3s ease;
}

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

.library-header h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.2rem;
}

.library-search-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .5rem 1rem;
    flex-shrink: 0;
}

.library-search-bar i {
    color: var(--muted);
}

.library-search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font: 500 .95rem 'Inter', sans-serif;
}

.library-search-bar input::placeholder {
    color: var(--muted);
}

.library-genres {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.genre-tag {
    padding: .3rem .85rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--muted);
    font: 600 .8rem 'Inter', sans-serif;
    cursor: pointer;
    transition: all .2s;
}

.genre-tag:hover {
    border-color: var(--primary);
    color: var(--text);
}

.genre-tag.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    padding-right: .25rem;
}

.library-grid::-webkit-scrollbar {
    width: 4px;
}

.library-grid::-webkit-scrollbar-thumb {
    background: var(--surface2);
    border-radius: 4px;
}

.lib-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}

.lib-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
    border-color: var(--primary);
}

.lib-thumb {
    aspect-ratio: 2/3;
    background-size: cover;
    background-position: center;
    background-color: var(--surface2);
    position: relative;
    overflow: hidden;
}

.lib-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    transition: opacity .2s;
    font-size: 2.5rem;
    color: #fff;
}

.lib-card:hover .lib-play-overlay {
    opacity: 1;
}

.lib-info {
    padding: .5rem .6rem;
}

.lib-title {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.lib-meta {
    font-size: .72rem;
    color: var(--muted);
    margin-top: .15rem;
    display: block;
}

.lib-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: var(--muted);
}

.lib-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 2rem;
    color: var(--muted);
    font-size: .9rem;
}

.lib-empty i {
    font-size: 2.5rem;
}

/* ── Library card actions (edit/delete) ─────────────── */
.lib-card {
    position: relative;
}

.lib-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: .3rem;
    padding: .3rem .5rem .5rem;
}

.lib-edit-btn,
.lib-del-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.lib-edit-btn {
    background: var(--surface2);
    color: var(--muted);
}

.lib-edit-btn:hover {
    background: var(--primary);
    color: #fff;
}

.lib-del-btn {
    background: var(--surface2);
    color: var(--muted);
}

.lib-del-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Library form backdrop ──────────────────────────── */
.lib-form-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 160;
}

.lib-form-card {
    width: min(440px, 94vw);
    gap: .75rem;
}

.lib-form-card label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ── Mobile Responsiveness ──────────────────────────── */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        padding: .5rem;
    }

    .sidebar {
        position: fixed;
        right: -300px;
        top: 60px;
        bottom: 0;
        z-index: 100;
        transition: right 0.3s ease;
        background: var(--bg);
        border-left: 1px solid var(--border);
        border-radius: 0;
    }

    .sidebar:not(.closed) {
        right: 0;
    }

    .topbar {
        padding: .5rem;
        flex-wrap: wrap;
    }

    .topbar .brand {
        font-size: 1.2rem;
    }

    .volume-wrap {
        display: none;
    }

    .controls {
        padding: 1rem .5rem;
    }

    .lib-card {
        flex-direction: column;
    }

    .lib-thumb {
        width: 100%;
        height: 120px;
    }

    .library-card {
        padding: 1.5rem;
    }
}

/* Floating Notifications (Toasts) */
#chat-toasts {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    z-index: 110;
    pointer-events: none;
}

.chat-toast {
    background: rgba(20, 20, 25, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 350px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
               toast-out 0.4s ease forwards 2.6s;
}

.toast-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

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

.toast-user {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.toast-msg {
    font-size: 0.85rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(50px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-30px); }
}

/* ── Host Settings Panel ──────────────────────────── */
.host-settings-card {
    width: min(500px, 94vw) !important;
}

.host-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.settings-section {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-section h3 i {
    color: var(--primary);
}

.settings-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.settings-desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* Audio Gain Booster */
.gain-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#gain-slider {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

#gain-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--primary);
    text-align: right;
}

/* Announcement Form */
.announcement-form {
    display: flex;
    gap: 0.5rem;
}

.announcement-form input {
    flex: 1;
}

/* Global Announcement Overlay */
.announcement-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10000;
    pointer-events: none;
    animation: fadeIn 0.3s ease;
}

.announcement-content {
    background: var(--surface);
    border: 2px solid var(--primary);
    padding: 2rem 3rem;
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(91, 106, 240, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.announcement-content i {
    font-size: 3rem;
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

#announcement-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.8); opacity: 0; }
    to { opacity: 1; transform: scale(1); }
}
/* TV Test Login Positioning */
.login-screen-top-right {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
}

/* -- Smart TV & Large Screen Optimization ---------------- */@media screen and (min-width: 1921px), screen and (tv) {
    :root {
        --topbar-h: 80px;
        --sidebar-w: 350px;
    }
    
    body {
        font-size: 18px;
    }

    .login-card {
        width: 500px;
        padding: 3rem;
    }

    .brand { font-size: 2rem; }
    .btn { padding: 0.8rem 1.5rem; font-size: 1rem; }
    
    .player {
        max-width: 1600px;
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    }

    .chat-msg-text { font-size: 1.1rem; }
    .viewer-name { font-size: 1.1rem; }
    
    :focus {
        outline: 4px solid var(--primary) !important;
        outline-offset: 4px;
    }
}

body.tv-mode .player {
    max-width: 95vw;
    height: 80vh;
}
body.tv-mode .sidebar {
    --sidebar-w: 400px;
}


