/* ===== Gostcord – motyw "grafit i bursztyn" ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Atrybut hidden musi wygrywać z regułami display:flex na tych samych elementach */
[hidden] { display: none !important; }

:root {
    --bg-deep: #101418;
    --bg-panel: #171d24;
    --bg-chat: #1c232b;
    --bg-hover: #242d37;
    --bg-active: #2b3642;
    --border: #2a333e;
    --text: #d7dee6;
    --text-muted: #8494a3;
    --text-header: #f0f4f8;
    --accent: #e0a458;
    --accent-hover: #ecb872;
    --accent-dim: rgba(224, 164, 88, .12);
    --green: #5fb96a;
    --red: #e05252;
    --radius: 10px;
    --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

html, body {
    height: 100%;
    font-family: system-ui, "Segoe UI", Roboto, Ubuntu, sans-serif;
    background: var(--bg-chat);
    color: var(--text);
    font-size: 15px;
}

button { font: inherit; cursor: pointer; }
ul { list-style: none; }

/* ===== Strony logowania / rejestracji ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1100px 520px at 50% -10%, rgba(224, 164, 88, .14), transparent 65%),
        var(--bg-deep);
    padding: 16px;
}

.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    text-align: center;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 18px;
}

.auth-card h1 { color: var(--text-header); font-size: 23px; text-align: center; font-weight: 650; }
.auth-subtitle { color: var(--text-muted); text-align: center; margin: 8px 0 24px; }

.auth-card label {
    display: block;
    margin: 16px 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    color: var(--text) !important;
    cursor: pointer;
}
.checkbox-row input { accent-color: var(--accent); }

.btn-primary {
    width: 100%;
    margin-top: 22px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #1a1206;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .02em;
    transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.auth-errors { color: #f08d8d; margin-bottom: 8px; font-size: 14px; }
.auth-errors ul { padding-left: 18px; list-style: disc; }
.field-error { color: #f08d8d; font-size: 13px; display: block; margin-top: 4px; }

.auth-switch { margin-top: 22px; text-align: center; color: var(--text-muted); font-size: 14px; }
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ===== Główny układ aplikacji ===== */
#app {
    display: grid;
    grid-template-columns: 240px 1fr 220px;
    height: 100vh;
}

/* --- Lewy panel --- */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.server-header {
    padding: 15px 16px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    line-height: 1.35;
    text-transform: uppercase;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Chowanie/wysuwanie menu kanałów na wąskich ekranach — bazowo niewidoczne,
   pokazywane w media query poniżej. */
.sidebar-toggle-btn, .sidebar-close-btn { display: none; flex-shrink: 0; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1090;
}
.sidebar-backdrop.visible { display: block; }

.channel-list { flex: 1; overflow-y: auto; padding: 12px 8px; }

.channel-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 8px 5px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px 6px 10px;
    margin: 1px 0;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text); }
.channel-item.active {
    background: var(--accent-dim);
    border-left-color: var(--accent);
    color: var(--text-header);
}
.channel-item .channel-hash {
    font-family: var(--mono);
    font-size: 15px;
    color: var(--accent);
    opacity: .75;
}
.channel-item .channel-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-item .delete-channel {
    visibility: hidden;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    padding: 0 2px;
}
.channel-item:hover .delete-channel { visibility: visible; }
.channel-item .delete-channel:hover { color: var(--red); }

/* Uczestnicy kanału głosowego */
.voice-members { padding-left: 26px; }
.voice-member {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
}
.voice-member:hover { background: var(--bg-hover); }
.mini-avatar {
    width: 20px; height: 20px;
    border-radius: 6px;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
    flex-shrink: 0;
}

/* Pasek stanu głosu */
.voice-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-deep);
    border-top: 1px solid var(--border);
    gap: 6px;
}
.voice-status-info { display: flex; flex-direction: column; min-width: 0; }
.voice-status-label { color: var(--green); font-size: 13px; font-weight: 600; }
#voice-status-channel {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-status-actions { display: flex; gap: 4px; }

/* Zawsze na pełną szerokość, pod resztą paska — muzyka Party gra dla wszystkich na kanale,
   ten pasek pokazuje co gra i pozwala ściszyć u siebie, niezależnie od otwartego panelu Party. */
.voice-now-playing { flex-basis: 100%; min-width: 0; display: flex; align-items: center; gap: 8px; }
.voice-now-playing-title {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-now-playing .party-volume input[type="range"] { width: 56px; }

.voice-ping {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}
.voice-ping.ping-good { color: var(--green); }
.voice-ping.ping-ok { color: var(--accent); }
.voice-ping.ping-bad { color: var(--red); }

/* Panel użytkownika */
.user-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    background: var(--bg-deep);
    border-top: 1px solid var(--border);
}

.user-avatar, .member-avatar {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}

.user-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#me-name {
    font-size: 14px; font-weight: 600; color: var(--text-header);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role { font-size: 11px; color: var(--text-muted); }

.logout-form { display: flex; }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 6px;
}
/* Kontrolki rozmowy głosowej (mikrofon/ekran/party/rozłącz) — jeden spójny,
   bursztynowy kolor zamiast domyślnych, natywnych kolorów ikon. Musi być
   zadeklarowane przed regułami stanu (.muted/.danger:hover) poniżej, żeby
   te nadal wygrywały mimo równej specyficzności selektorów. */
.voice-status-actions .icon-btn,
.voice-view-controls .icon-btn,
.browser-nav-controls .icon-btn {
    color: var(--accent);
}
.voice-status-actions .icon-btn:hover:not(.danger),
.voice-view-controls .icon-btn:hover:not(.danger),
.browser-nav-controls .icon-btn:hover:not(:disabled) {
    color: var(--accent-hover);
}
.browser-nav-controls .icon-btn:disabled { color: var(--text-muted); opacity: .4; cursor: default; }

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); }
.icon-btn.muted { color: var(--red); }

/* --- Środkowy panel: czat --- */
/* min-height: 0 — bez tego element grid/flex rośnie do wysokości swojej zawartości zamiast
   się przewijać w środku (domyślne min-height:auto), co przy wysokim panelu Party (zdalna
   przeglądarka 1080p) rozciągało całą stronę zamiast scrollować sam panel. */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-chat); }

/* Nakładka pokazywana podczas przeciągania pliku nad panelem czatu (patrz app.js: dragenter/drop). */
.chat-dropzone {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 21, .75);
    pointer-events: none;
}
.chat-dropzone-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 48px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 15px;
    font-weight: 650;
}
.chat-dropzone-box svg { width: 32px; height: 32px; }

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 18px;
    font-weight: 650;
    color: var(--text-header);
    border-bottom: 1px solid var(--border);
}
#channel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#channel-title svg { vertical-align: -2px; color: var(--accent); }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message { display: flex; gap: 12px; padding: 4px 10px; border-radius: 8px; position: relative; }
.message:hover { background: rgba(255, 255, 255, .025); }
.message.first-of-group { margin-top: 14px; }

.message.message-mentions-me {
    background: var(--accent-dim);
    box-shadow: inset 2px 0 0 var(--accent);
}
.message.message-mentions-me:hover { background: var(--accent-dim); }

.message .member-avatar { margin-top: 2px; }
.message .avatar-spacer { width: 32px; flex-shrink: 0; }

.message-body { flex: 1; min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-author { font-weight: 650; color: var(--text-header); }
.message-time { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.message-content { color: var(--text); word-wrap: break-word; white-space: pre-wrap; }

.message .delete-msg {
    position: absolute;
    top: -8px; right: 8px;
    visibility: hidden;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 6px;
}
.message:hover .delete-msg { visibility: visible; }
.message .delete-msg:hover { color: var(--red); }

.system-note { text-align: center; color: var(--text-muted); font-size: 13px; padding: 12px; }

/* Linki i osadzenia w wiadomościach */
.msg-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.msg-link:hover { color: var(--accent-hover); text-decoration: underline; }

.mention {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 4px;
    padding: 0 2px;
    font-weight: 600;
}
.mention-me { background: var(--accent); color: var(--bg-deep); }

/* Podpowiedzi @oznaczeń podczas pisania */
.mention-dropdown {
    position: fixed;
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

.mention-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.mention-dropdown-item.active, .mention-dropdown-item:hover { background: var(--bg-hover); }

.embed { margin-top: 6px; max-width: 480px; }
.embed iframe {
    width: 100%;
    border: 0;
    border-radius: 8px;
    display: block;
    background: var(--bg-deep);
}
.embed-video iframe { aspect-ratio: 16 / 9; }
.embed-audio iframe { height: 166px; }
.embed-tall iframe { height: 352px; }

.embed-media img {
    max-width: 420px;
    max-height: 320px;
    border-radius: 8px;
    display: block;
}
.embed-media video {
    max-width: 480px;
    max-height: 360px;
    width: 100%;
    border-radius: 8px;
    display: block;
    background: var(--bg-deep);
}
.embed-media audio { width: 100%; max-width: 420px; display: block; }

/* Załączniki */
.attachment-name { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }

.attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    padding: 10px 14px;
    max-width: 420px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
}
.attachment-file:hover { border-color: var(--accent); }
.attachment-file .file-size {
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--mono);
    white-space: nowrap;
}

.load-more {
    align-self: center;
    margin-bottom: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    padding: 5px 16px;
    font-size: 13px;
}
.load-more:hover { color: var(--text); background: var(--bg-hover); }

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 0 16px 18px;
}

.attach-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    transition: color .15s, border-color .15s;
}
.attach-btn:hover { color: var(--accent); border-color: var(--accent); }
.attach-btn:disabled { opacity: .5; }
.emoji-btn { font-size: 20px; }

/* --- Panel emoji --- */
.emoji-panel {
    position: fixed;
    z-index: 1000;
    width: 320px;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    overflow: hidden;
}

.emoji-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.emoji-tab {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.emoji-tab:hover { background: var(--bg-deep); }
.emoji-tab.active { background: var(--accent-dim); }

.emoji-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 8px;
}

.emoji-grid-empty {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

.emoji-item {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.emoji-item:hover { background: var(--bg-deep); }

.chat-input {
    flex: 1;
    min-width: 0;
    resize: none;
    outline: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    max-height: 40vh;
    transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:disabled { opacity: .5; }

/* --- Prawy panel: online --- */
.members {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 12px 8px;
    overflow-y: auto;
}

/* Obciążenie serwera (CPU) — pusty i zielony przy niskim obciążeniu, wypełnia się i
   czerwienieje wraz ze wzrostem (patrz app.js: ServerLoadChanged). */
.server-load-bar {
    height: 6px;
    margin: 4px 8px 10px;
    background: var(--bg-deep);
    border-radius: 3px;
    overflow: hidden;
}
.server-load-fill {
    height: 100%;
    width: 0%;
    background: hsl(120, 70%, 45%);
    border-radius: 3px;
    transition: width .6s ease, background-color .6s ease;
}

.members-header {
    padding: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px;
    border-radius: 8px;
    color: var(--text);
}
.member-item:hover { background: var(--bg-hover); }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.member-status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(95, 185, 106, .15);
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== Streamowanie ekranu ===== */
.stream-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    max-height: 46vh;
    overflow-y: auto;
}

.stream-tile {
    position: relative;
    flex: 1 1 320px;
    max-width: 640px;
}
.stream-tile video {
    width: 100%;
    max-height: 40vh;
    border-radius: 8px;
    background: #000;
    display: block;
}
.stream-caption {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, .65);
    border-radius: 6px;
    font-size: 12px;
    color: #fff;
    pointer-events: none;
}

.icon-btn.streaming { color: var(--red); }

.live-badge {
    flex-shrink: 0;
    margin-left: 6px;
    padding: 1px 5px;
    background: var(--red);
    border-radius: 4px;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
}

.mute-badge {
    flex-shrink: 0;
    margin-left: 6px;
    font-size: 12px;
    line-height: 1;
}

/* Okno ustawień streamu */
.stream-dialog {
    margin: auto;
    width: min(440px, calc(100vw - 32px));
    padding: 24px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.stream-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.stream-dialog h2 { font-size: 18px; color: var(--text-header); }

.stream-opts { display: flex; gap: 14px; margin-top: 16px; }
.stream-opts fieldset {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px 12px;
}
.stream-opts legend {
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stream-opts label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 14px;
    cursor: pointer;
}
.stream-opts input[type="radio"] { accent-color: var(--accent); }

.stream-hint {
    margin-top: 14px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-muted);
}

.stream-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.stream-actions .btn-primary { width: auto; margin: 0; padding: 10px 18px; }

.btn-secondary {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-hover);
    color: var(--text);
}
.btn-secondary:hover { background: var(--bg-active); }

/* Pasek utraty połączenia */
.connection-lost {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--red);
    color: #fff;
    text-align: center;
    padding: 8px;
    font-weight: 600;
    z-index: 100;
}

/* ===== Menu kontekstowe ===== */
.context-menu {
    position: fixed;
    z-index: 1000;
    min-width: 230px;
    max-width: 290px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.context-menu-header {
    padding: 6px 10px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-header);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-menu-separator { height: 1px; background: var(--border); margin: 4px 2px; }

.context-menu-hint { padding: 4px 10px 8px; font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    padding: 7px 10px;
    border-radius: 6px;
}
.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--red); }
.context-menu-item.danger:hover { background: rgba(224, 82, 82, .12); }
.context-menu-item:disabled { color: var(--text-muted); opacity: .5; cursor: default; }
.context-menu-item:disabled:hover { background: none; }

.context-menu-slider { padding: 6px 10px 10px; }
.context-menu-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
}
.context-menu-slider input[type="range"] { width: 100%; accent-color: var(--accent); }

.context-menu-toggle .context-menu-checkbox {
    width: 14px; height: 14px;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
}
.context-menu-toggle.checked .context-menu-checkbox { background: var(--accent); border-color: var(--accent); }
.context-menu-toggle.checked .context-menu-checkbox::after {
    content: "";
    position: absolute;
    left: 3px; top: 0;
    width: 4px; height: 8px;
    border: solid #1a1206;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.context-menu-submenu-toggle { justify-content: space-between; }
.context-menu-arrow { color: var(--text-muted); font-size: 11px; }
.context-menu-submenu {
    padding-left: 4px;
    margin: 2px 0 2px 12px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* --- Widok kanału głosowego w środkowym panelu --- */
.voice-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    padding: 24px;
}

.voice-view-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 20px;
    align-items: flex-start;
}

.voice-view-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 130px;
}

.voice-view-avatar-wrap { position: relative; }

.voice-view-avatar {
    width: 88px;
    height: 88px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 32px;
}

.voice-view-mute-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    background: var(--bg-panel);
    border: 2px solid var(--bg-chat);
    border-radius: 50%;
    font-size: 14px;
    padding: 3px;
    line-height: 1;
}

.voice-view-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.voice-view-controls {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-top: 16px;
}
.voice-view-controls .icon-btn {
    width: 52px;
    height: 52px;
    font-size: 22px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-deep);
}

/* --- Panel GIF-ów (Giphy) --- */
.gif-btn { font-size: 12px; font-weight: 700; letter-spacing: .03em; }

.gif-panel {
    position: fixed;
    z-index: 1000;
    width: 340px;
    height: 420px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    overflow: hidden;
}

.gif-search {
    flex-shrink: 0;
    margin: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    outline: none;
}
.gif-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.gif-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 8px 8px;
}
.gif-grid.gif-grid-loading { opacity: .5; }

.gif-grid-empty {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

/* overflow:hidden + aspect-ratio wprost na .gif-item zerowałoby jego automatyczny
   rozmiar minimalny w wierszu grida (spec CSS: elementy grida z overflow != visible
   mają automatic minimum size = 0), więc oba trafiają na <img>, nie na przycisk. */
.gif-item {
    border: none;
    border-radius: 6px;
    background: var(--bg-deep);
    padding: 0;
    cursor: pointer;
}
.gif-item:hover { outline: 2px solid var(--accent); }
.gif-item img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
}

/* --- Panel Party (kolejka muzyki na kanale głosowym) --- */
.party-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 24px;
    gap: 16px;
}

.party-top-bar { flex-shrink: 0; }

/* Dwie kolumny: lewa (większa) — okładka/tytuł/sterowanie, prawa — wyszukiwarka i kolejka.
   Tylko ok. 1/3 wysokości panelu — reszta zostaje na inne elementy, które dojdą tu później. */
/* Cała sekcja (okładka+sterowanie oraz wyszukiwarka+kolejka) to jeden spójny "box" —
   jednoznacznie widoczny jako całość odpowiedzialna za muzykę Party. */
.party-widget {
    flex: 0 0 auto;
    height: 33vh;
    min-height: 300px;
    display: flex;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.party-main {
    position: relative;
    flex: 1.6 1 0;
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

/* Rozmyta, powiększona okładka bieżącego utworu w tle panelu — efekt "liquid glass". */
.party-main-bg {
    position: absolute;
    inset: -15%;
    background-size: cover;
    background-position: center;
    filter: blur(55px) saturate(1.6) brightness(.7);
    transform: scale(1.15);
    transition: background-image .5s ease;
    z-index: 0;
}

.party-main-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    height: 100%;
}

/* Duża okładka w panelu Party — czysto wizualna, sam odtwarzacz stąd nie gra (patrz niżej).
   Gdy nic nie gra, zamiast pustego/zepsutego obrazka pokazujemy .party-art-big-placeholder. */
.party-art-big-wrap {
    position: relative;
    flex-shrink: 0;
    width: 140px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-deep);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.party-art-big {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.party-art-big-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
}
.party-art-big-placeholder svg { width: 40%; height: 40%; }

/* YT.Player musi zostać w normalnym flow i mieć realny rozmiar na ekranie — inaczej YouTube
   sam wstrzymuje odtwarzanie, uznając, że odtwarzacz jest "niewidoczny" (0×0 / poza viewportem).
   Dlatego zamiast chować iframe poza ekranem, przykrywamy go wizualnie okładką (.party-art)
   ułożoną w tym samym miejscu, o warstwę wyżej. Ten, mini wrap, żyje na stałe w pasku statusu
   głosowego (patrz .voice-now-playing) — dzięki temu muzyka gra niezależnie od tego, czy panel
   Party jest akurat otwarty, bo #party-player nigdy nie jest ukrywany razem z tym panelem. */
.party-art-wrap-mini {
    position: relative;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-panel);
}

/* !important — YouTube potrafi na błędzie odtwarzania nadpisać rozmiar swojego iframe'a
   inline stylem (np. próbując pokazać własny pełnowymiarowy ekran błędu). Rodzic ma
   overflow:hidden, ale to i tak wymusza, że nasz odtwarzacz nigdy nie urośnie ponad okładkę. */
.party-player {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    z-index: 0;
}

.party-art {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.party-now-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.party-now-title {
    color: var(--text-header);
    font-size: 18px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

.party-now-meta { color: var(--text-muted); font-size: 13px; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }

/* Boxy o stałym kolorze strony — tak, żeby sterowanie nie zlewało się z rozmytym tłem okładki. */
.party-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-deep);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.party-locked {
    align-self: flex-start;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-deep);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.party-progress {
    height: 5px;
    border-radius: 3px;
    background: var(--bg-panel);
    overflow: hidden;
    cursor: pointer;
}
.party-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .4s linear; }

.party-now-row { display: flex; align-items: center; gap: 14px; }
.party-playpause-btn { font-size: 18px; flex-shrink: 0; }
.party-now-time { color: var(--text-muted); font-size: 12.5px; flex-shrink: 0; }

.party-volume { display: flex; align-items: center; gap: 6px; color: var(--text-muted); flex-shrink: 0; }
.party-volume input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    accent-color: var(--accent);
    width: 90px;
    height: 4px;
    margin: 0;
    padding: 0;
    background: var(--bg-panel);
    border-radius: 2px;
    vertical-align: middle;
}
.party-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}
.party-volume input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}
.party-volume input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--bg-panel);
    border-radius: 2px;
}

.party-skip-btn { margin-left: auto; flex-shrink: 0; }

.party-side {
    flex: 1 1 300px;
    max-width: 340px;
    min-width: 260px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.party-search { position: relative; flex-shrink: 0; }
.party-search input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
    outline: none;
}
.party-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.party-search-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

.party-search-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 14px; }

.party-search-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
    cursor: pointer;
}
.party-search-item:last-child { border-bottom: none; }
.party-search-item:hover { background: var(--bg-hover); }
.party-search-item img { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }

.party-queue-header {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Mieści kilka utworów, dalsze przewijane w środku (reszta widgetu się nie rusza). */
.party-queue {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}

.party-queue-empty { color: var(--text-muted); font-size: 13px; padding: 10px 0; }

.party-track {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
}
.party-track-current { border-color: var(--accent); background: var(--accent-dim); }

.party-track-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }

.party-track-info { flex: 1; min-width: 0; }
.party-track-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.party-track-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.party-track-remove {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
}
.party-track-remove:hover { background: var(--bg-hover); color: var(--red); }

/* Zdalna przeglądarka (streaming obrazu i dźwięku Chromium uruchomionego na serwerze) —
   osobny box pod widgetem muzycznym, ta sama konwencja ramki/tła co .party-widget/.party-main. */
.browser-widget {
    margin-top: 16px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.browser-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-header);
    font-weight: 650;
}
.browser-controller-info { color: var(--text-muted); font-size: 12.5px; font-weight: 400; }
.browser-nav-controls { display: flex; gap: 2px; }
.browser-nav-controls .icon-btn { font-size: 15px; padding: 4px; }
/* align-items: stretch (domyślne) — panel boczny rozciąga się na pełną wysokość wideo,
   której wysokość z kolei wynika z aspect-ratio na .browser-viewport-wrap poniżej. */
.browser-body { display: flex; }
.browser-viewport-wrap {
    position: relative;
    flex: 1.6 1 0;
    min-width: 0;
    aspect-ratio: 16 / 9;
    background: #000;
    border-right: 1px solid var(--border);
    outline: none;
}
/* Proporcje kontenera (16:9) dopasowane do rozdzielczości streamu (1920x1080, też 16:9) —
   object-fit:contain wypełnia wtedy całe pole, bez czarnych pasów. */
.browser-frame-img { display: block; width: 100%; height: 100%; object-fit: contain; cursor: crosshair; user-select: none; }

.browser-unmute-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
}

/* Pełny ekran po stronie klienta (Fullscreen API na .browser-viewport-wrap) — niezależny od
   symulowanego CSS-owo fullscreenu WEWNĄTRZ zdalnej strony, patrz RemoteBrowserService. */
.browser-fullscreen-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.browser-fullscreen-btn:hover { background: rgba(0, 0, 0, .8); }
.browser-fullscreen-btn svg { width: 18px; height: 18px; }
.browser-viewport-wrap:fullscreen {
    aspect-ratio: auto;
    width: 100vw;
    height: 100vh;
    background: #000;
}
.browser-viewport-wrap:fullscreen .browser-frame-img { cursor: crosshair; }
.browser-preset-select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
}
.browser-start-section { display: flex; flex-direction: column; gap: 8px; }
.browser-side {
    flex: 1 1 260px;
    max-width: 260px;
    min-width: 200px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.browser-control-status { color: var(--text-muted); font-size: 13px; }
/* UWAGA: żadnego flex-grow tutaj — .browser-side jest kolumną, a jedyny rosnący element
   kolumny dostaje CAŁĄ wolną wysokość panelu i (przez align-items:center z .party-volume)
   centruje suwak w pionie w środku widgetu zamiast tuż pod przyciskami. */
.browser-volume { flex: 0 0 auto; min-width: 0; }
/* input[type=range] jest FLEX ITEMEM obok emoji-ikonki w tym samym wierszu (.party-volume ma
   display:flex) — width:100% na flex itemie liczy się względem całego kontenera IGNORUJĄC
   sąsiadów, więc suwak wystawał poza panel; flex:1 to poprawne "wypełnij resztę wiersza".
   Tor musi mieć jaśniejszy kolor niż var(--bg-panel) z bazowej reguły .party-volume, bo
   .browser-widget (przodek) sam ma tło var(--bg-panel) — tor był niewidzialny (kamuflaż),
   widać było tylko akcentowy uchwyt ("kropka w powietrzu"). */
.browser-volume input[type="range"] { flex: 1 1 auto; min-width: 0; width: auto; background: var(--bg-active); }

/* Paski przewijania */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }
::-webkit-scrollbar-track { background: transparent; }

/* Węższe ekrany — schowaj listę online */
@media (max-width: 900px) {
    #app { grid-template-columns: 220px 1fr; }
    .members { display: none; }
}

/* Telefon — czat na cały ekran, lista kanałów jako chowane menu (hamburger). */
@media (max-width: 700px) {
    #app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 24px rgba(0, 0, 0, .4);
    }

    .sidebar-toggle-btn, .sidebar-close-btn { display: inline-flex; }

    /* Widget Party w jednej kolumnie — obok siebie się nie zmieści. */
    .party-widget { flex-direction: column; height: auto; }
    .party-main { flex: none; width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .party-side { flex: none; width: 100%; max-width: none; min-width: 0; }
    .party-main-content { padding: 16px; gap: 14px; }
    .party-art-big-wrap { width: 96px; height: 96px; }

    .party-queue { max-height: 260px; }

    /* Zdalna przeglądarka analogicznie — widok i panel boczny jeden pod drugim. */
    .browser-body { flex-direction: column; }
    .browser-viewport-wrap { border-right: none; border-bottom: 1px solid var(--border); }
    .browser-side { max-width: none; width: 100%; flex-direction: row; flex-wrap: wrap; }
    /* W układzie WIERSZOWYM suwak głośności potrzebuje flex-basis, żeby nie skurczyć się
       do szerokości samej ikonki (w kolumnie celowo nie rośnie — patrz reguła bazowa). */
    .browser-volume { flex: 1 1 160px; min-width: 120px; }
}
