:root {
    --bg-dark: #202225;
    --bg-panel: #2f3136;
    --bg-chat: #36393f;
    --bg-members: #2f3136;
    --accent: #5865f2;
    --text-main: #dcddde;
    --text-muted: #72767d;
    --sidebar-width: 240px;
    --members-width: 200px;
    --sidebar-resizer-width: 6px;
}

/* Custom Scrollbar Styles */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-dark) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--bg-dark);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--bg-panel);
}

body { margin: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg-chat); color: var(--text-main); height: 100vh; display: flex; overflow: hidden; }
body { height: 100dvh; }

/* LAYOUT */
#app-container { display: flex; flex: 1 1 auto; min-width: 0; height: 100%; position: relative; }
#app-container { height: calc(var(--app-vh, 1vh) * 100); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box; }
#app-container.app-hidden #sidebar,
#app-container.app-hidden #members-sidebar,
#app-container.app-hidden #main-pane,
#app-container.app-hidden #sidebar-resizer {
    visibility: hidden;
}
#sidebar { width: var(--sidebar-width); min-width: 200px; max-width: 400px; background: var(--bg-dark); display: flex; flex-direction: column; flex: 0 0 var(--sidebar-width); }
#server-switcher {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 3px;
    font-weight: 700;
    font-size: 0.9em;
    border-bottom: 1px solid #202225;
    background: #1f2124;
}
#sidebar input { width: 100%; box-sizing: border-box; }
#sidebar select { width: 100%; box-sizing: border-box; }
#sidebar-resizer { width: var(--sidebar-resizer-width); cursor: col-resize; background: #1a1b1e; flex: 0 0 var(--sidebar-resizer-width); height: 100%; align-self: stretch; }
#main-pane { flex: 1 1 auto; display: flex; flex-direction: row; background: var(--bg-chat); min-width: 0; min-height: 0; position: relative; }
#main-content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#members-sidebar { width: var(--members-width); background: var(--bg-members); display: flex; flex-direction: column; border-left: 1px solid #202225; transition: width 0.15s ease; flex: 0 0 var(--members-width); }
#members-sidebar.collapsed { width: 0; border-left: none; overflow: hidden; }
#members-sidebar.collapsed #members-list { display: none; }
#members-sidebar.collapsed #status-bar { display: none; }

#connection-warning {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: #f28c2c;
    color: #111;
    padding: 3px 3px;
    border-radius: 6px;
    font-size: 0.75em;
    z-index: 3000;
    display: none;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

#app-container.mobile-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) var(--sidebar-resizer-width) minmax(0, 1fr);
    grid-template-rows: var(--mobile-top, 50%) 1fr;
    position: relative;
}
#app-container.mobile-layout #sidebar {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    overflow: hidden;
}
#app-container.mobile-layout #sidebar-resizer {
    grid-column: 2;
    grid-row: 1;
    justify-self: stretch;
    align-self: stretch;
}
#app-container.mobile-layout #members-sidebar {
    grid-column: 3;
    grid-row: 1;
    width: 100%;
    overflow: hidden;
}
#app-container.mobile-layout #main-pane {
    grid-column: 1 / span 3;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
}
#main-pane-resizer {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--mobile-top, 50%) - 6px);
    height: 12px;
    cursor: row-resize;
    display: none;
    z-index: 25;
    pointer-events: none;
    touch-action: none;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    border-radius: 6px;
}
#main-pane-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}
#app-container.mobile-layout #main-pane-resizer {
    display: block;
    pointer-events: all;
}
#app-container.mobile-layout #main-content {
    max-height: calc(100vh - var(--mobile-top, 50%));
    overflow-y: auto;
}
#app-container.mobile-layout #members-sidebar.collapsed {
    width: 100%;
    border-left: 1px solid #202225;
}
#app-container.mobile-layout #channels-container { height: 100%; }
#app-container.mobile-layout #members-list { height: 100%; }
#app-container.mobile-layout #messages { min-height: 50px; }

/* CHAT */
#messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 3px; list-style: none; margin: 0; }
#messages li { margin-bottom: 3px; position: relative; }
#messages li:hover .reaction-btn { opacity: 1; }

#changelog-panel {
    transition: max-height 0.15s ease;
}
#changelog-list {
    overflow-y: auto;
}
#changelog-panel.log-min {
    max-height: 32px;
}
#changelog-panel.log-full {
    max-height: 320px;
}
#changelog-panel.log-full #changelog-list {
    max-height: 260px;
}

/* Chat input (index.html uses inline layout, keep input reasonable) */
#msgInput { width: 100%; }

/* Req 4: Reactions */
.msg-content p { margin: 0; } /* Markdown paragraphs */
.msg-header { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: bold; color: #fff; cursor: pointer; }
.msg-time { font-size: 0.7em; color: var(--text-muted); }
.reactions-bar { display: flex; gap: 4px; margin-top: 3px; }
.reaction-tag { background: #2f3136; padding: 2px 3px; border-radius: 4px; font-size: 0.8em; border: 1px solid #202225; cursor: pointer; }
.reaction-btn { opacity: 0; position: absolute; right: 0; top: -10px; background: var(--bg-panel); border: 1px solid #202225; cursor: pointer; border-radius: 4px; padding: 3px; }

/* USER INFO (Bottom Left) */
#user-info-area {
    background: #292b2f;
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    height: 260px;
    max-height: var(--user-info-expanded, 275px);
    transition: max-height 0.2s ease;
    font-size: 12px;
}
#user-info-area * {
    font-size: 12px !important;
}
#user-info-area.collapsed { max-height: 70px; }
#user-info-area.popover-open { overflow: visible; }
#user-info-area .styled-btn { padding: 3px; }
#user-info-area .view-toggle { padding: 3px; }
#user-info-area .view-toggle-btn { padding: 3px; }
.user-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 10px;
    cursor: pointer;
}
.user-info-header::after {
    content: 'v';
    font-size: 0.75em;
    color: #5f646b;
}
#user-info-area.collapsed .user-info-header::after {
    content: '>';
}
.control-row { display: flex; justify-content: space-around; background: #202225; padding: 3px; border-radius: 4px; gap: 5px; }
.control-row-2 { display: flex; justify-content: space-around; background: #202225; padding: 3px; border-radius: 4px; gap: 5px; }
.media-selects { display: flex; flex-direction: column; gap: 4px; }
.media-selects label { font-size: 0.7em; color: var(--text-muted); }
.media-selects select { margin: 0; }
.camera-consent-selects { margin-top: 4px; }
.user-info-row { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 3px; border-radius: 4px; }
.icon-btn:hover { background: #40444b; color: white; }
.icon-btn.active { color: #3ba55c; }
.icon-btn.danger { color: #ed4245; }
.icon-btn[title="Close"], .icon-btn.close-button {
  background: #421112;
  color: #f0b7b7;
  border: 1px solid #7a1a1a;
}
.icon-btn[title="Close"]:hover, .icon-btn.close-button:hover {
  background: #7a1a1a;
  color: #fff;
}

.styled-btn {
    background-color: #2f3136;
    color: #dcddde;
    border: 1px solid #202225;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    flex-grow: 1;
}

.styled-btn:hover {
    background-color: #36393f;
}

.view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: #2f3136;
    color: #dcddde;
    border: 1px solid #202225;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    flex-grow: 1;
}

.view-toggle-label {
    color: #dcddde;
}

.view-toggle select {
    background-color: #1f2124;
    border: 1px solid #202225;
    color: #dcddde;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    cursor: pointer;
    width: auto;
    margin: 0;
}

.view-toggle-btn {
    background-color: #1f2124;
    border: 1px solid #202225;
    padding: 3px 6px;
    border-radius: 4px;
}

.view-toggle-btn:hover {
    background-color: #36393f;
    color: white;
}

.login-code-menu { position: relative; display: inline-flex; }
.login-code-popover {
    position: absolute;
    left: -125px;
    bottom: calc(100% + 6px);
    width: 190px;
    background: #1f2124;
    border: 1px solid #202225;
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    z-index: 4000;
}
.draggable-popover {
    cursor: grab;
    touch-action: none;
}
.draggable-popover.dragging {
    cursor: grabbing;
}
.login-code-popover.open { display: block; }
.login-code-title { font-size: 0.8em; font-weight: 700; color: #fff; margin-bottom: 3px; }
.login-code-value {
    font-family: monospace;
    font-size: 0.8em;
    color: #fff;
    background: #2b2d31;
    border: 1px solid #202225;
    border-radius: 6px;
    padding: 3px;
    word-break: break-all;
    margin-bottom: 3px;
}
.login-code-row { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; }
.login-code-row .login-code-value { flex: 1; margin-bottom: 0; }
.login-code-actions { display: flex; gap: 6px; margin-bottom: 3px; }
.login-code-actions .btn-green { width: auto; flex: 1; }
.login-code-hint { font-size: 0.7em; color: var(--text-muted); }
.quality-menu { position: relative; display: inline-flex; }
.quality-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    width: 260px;
    background: #1f2124;
    border: 1px solid #202225;
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    z-index: 4000;
}
.quality-popover.open { display: block; width: 250px; }
.quality-title { font-size: 0.8em; font-weight: 700; color: #fff; margin-bottom: 3px; }
.quality-section { margin-bottom: 3px; }
.quality-label { font-size: 0.75em; color: var(--text-muted); margin-bottom: 3px; }
.quality-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.quality-field { display: flex; flex-direction: column; gap: 2px; }
.quality-field label { font-size: 0.7em; color: var(--text-muted); }
.quality-grid input { width: 100%; margin: 0; }
.quality-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.quality-preset-btn { background: #2b2d31; border: 1px solid #202225; color: #fff; }
.quality-preset-btn:hover { background: #35373c; }
.quality-popover-quick { width: 230px; }
.quality-actions { display: flex; gap: 6px; margin-bottom: 3px; }
.quality-actions .btn-green { width: auto; flex: 1; }
.quality-hint { font-size: 0.7em; color: var(--text-muted); }
.quality-actions-secondary { justify-content: flex-end; margin-top: 2px; }
.quality-actions-secondary .icon-btn { width: 100%; text-align: center; }
.media-menu { position: relative; display: inline-flex; }
.media-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    width: 240px;
    background: #1f2124;
    border: 1px solid #202225;
    border-radius: 0px;
    padding: 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    z-index: 4000;
}
.media-popover.open { display: block; }
.media-title { font-size: 0.8em; font-weight: 700; color: #fff; margin-bottom: 3px; }
.media-actions { display: flex; gap: 6px; margin-top: 3px; }
.media-actions .icon-btn { width: 100%; text-align: center; }
.maximizer-popover {
    position: fixed;
    width: 300px;
    background: #1f2124;
    border: 1px solid #202225;
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    z-index: 4000;
}
.maximizer-popover.open { display: block; }
.maximizer-title { font-size: 0.8em; font-weight: 700; color: #fff; margin-bottom: 3px; }
.maximizer-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.maximizer-row label { font-size: 0.75em; color: var(--text-muted); min-width: 44px; }
.maximizer-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #3b3f46 0%,
        #3ba55c 40%,
        #f5c451 70%,
        #ed4245 100%
    );
    margin: 0;
    outline: none;
}
.maximizer-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #3b3f46 0%,
        #3ba55c 40%,
        #f5c451 70%,
        #ed4245 100%
    );
}
.maximizer-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e3e5e8;
    border: 1px solid #202225;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    margin-top: -3px;
}
.maximizer-slider::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #3b3f46 0%,
        #3ba55c 40%,
        #f5c451 70%,
        #ed4245 100%
    );
}
.maximizer-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e3e5e8;
    border: 1px solid #202225;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.maximizer-value { font-size: 0.75em; color: var(--text-muted); min-width: 52px; text-align: right; }
.maximizer-actions { display: flex; gap: 6px; }
.maximizer-actions .btn-green { width: auto; flex: 1; }

/* MEMBERS LIST (Req 1) */
.members-header { padding: 3px; font-size: 0.8em; font-weight: bold; color: var(--text-muted); letter-spacing: 1px; }
#members-list { overflow-y: auto; flex: 1; padding: 0 3px; }
#status-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px;
    border-top: 1px solid #202225;
    background: #1f2124;
    font-size: 0.75em;
    color: var(--text-muted);
}
.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}
.status-encrypted {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid #2b2d31;
    background: #222428;
    color: #9ad3ff;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: help;
    user-select: none;
}
.status-encrypted::after,
.status-encrypted::before {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 10;
}
.status-encrypted::after {
    content: attr(data-tooltip);
    bottom: calc(100% + 8px);
    left: -10px;
    width: 178px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #121316;
    border: 1px solid #2b2d31;
    color: #e3e5e8;
    font-size: 0.9em;
    line-height: 1.3;
    white-space: normal;
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}
.status-encrypted::before {
    content: '';
    bottom: calc(100% + 2px);
    right: 12px;
    width: 8px;
    height: 8px;
    background: #121316;
    border-left: 1px solid #2b2d31;
    border-top: 1px solid #2b2d31;
    transform: translateY(4px) rotate(45deg);
}
.status-encrypted:hover::after,
.status-encrypted:hover::before {
    opacity: 1;
    transform: translateY(0);
}
.status-metric { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.status-up { color: #3ba55c; }
.status-down { color: #ed4245; }
.member-card { display: flex; align-items: center; padding: 3px; border-radius: 4px; gap: 10px; opacity: 0.5; } /* Offline by default */
.member-card.online { opacity: 1; }
.member-card:hover { background: #35373c; }
.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-size: cover;
    position: relative;
    border: 1px solid #4f545c;
    box-sizing: border-box;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; position: absolute; bottom: -2px; right: -2px; border: 2px solid var(--bg-members); }
.member-info { display: flex; flex-direction: column;  }
.member-status { font-size: 0.7em; color: var(--text-muted); max-height:40px; max-width:140px; overflow: hidden; text-overflow: ellipsis; }

/* VIDEO GRID */
.video-wrapper {
    position: absolute;
    width: 300px;
    height: auto;
    aspect-ratio: 16 / 9;
    background: #202225;
    border-radius: 0px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(0,0,0,0.45);
    cursor: grab;
    z-index: 2000;
    resize: none;
    min-width: 160px;
    min-height: 120px;
    max-width: 90vw;
    max-height: 90vh;
    touch-action: none;
}
.video-wrapper.video-hidden {
    display: none !important;
}
.video-wrapper:active { cursor: grabbing; }
.video-wrapper .resize-handle {
    position: absolute;
    background: transparent;
    z-index: 5;
    touch-action: none;
}
.video-wrapper .resize-handle.e,
.video-wrapper .resize-handle.w {
    top: 6px;
    bottom: 6px;
    width: 10px;
}
.video-wrapper .resize-handle.e { right: -4px; cursor: ew-resize; }
.video-wrapper .resize-handle.w { left: -4px; cursor: ew-resize; }
.video-wrapper .resize-handle.n,
.video-wrapper .resize-handle.s {
    left: 6px;
    right: 6px;
    height: 10px;
}
.video-wrapper .resize-handle.n { top: -4px; cursor: ns-resize; }
.video-wrapper .resize-handle.s { bottom: -4px; cursor: ns-resize; }
.video-wrapper .resize-handle.ne,
.video-wrapper .resize-handle.nw,
.video-wrapper .resize-handle.se,
.video-wrapper .resize-handle.sw {
    width: 12px;
    height: 12px;
}
.video-wrapper .resize-handle.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.video-wrapper .resize-handle.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.video-wrapper .resize-handle.se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.video-wrapper .resize-handle.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.floating-video-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1500;
}
.floating-video-layer .video-wrapper { pointer-events: auto; }
.dm-panel {
    position: fixed;
    right: 3px;
    bottom: 3px;
    width: 280px;
    height: 240px;
    min-width: 180px;
    min-height: 160px;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-panel);
    border: 1px solid #202225;
    border-radius: 2px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    flex-direction: column;
    z-index: 2500;
    resize: both;
    overflow: hidden;
}
.dm-panel.open { display: flex; }
.dm-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #202225;
    padding: 3px;
    cursor: grab;
    touch-action: none;
}
.channel-panel {
    position: fixed;
    right: 290px; /* next to dm-panel */
    bottom: 3px;
    width: 280px;
    height: 240px;
    min-width: 180px;
    min-height: 160px;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-panel);
    border: 1px solid #202225;
    border-radius: 2px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
    flex-direction: column;
    z-index: 2400;
    resize: both;
    overflow: hidden;
}
.channel-panel.open { display: flex; }
.channel-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #202225;
    padding: 3px;
    cursor: grab;
    touch-action: none;
}
.channel-panel-header:active { cursor: grabbing; }
.channel-panel-title { display: flex; align-items: center; gap: 3px; min-width: 0; }
.channel-panel-name { font-weight: 600; font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 3px;
}
.channel-panel-input { padding: 3px; border-top: 1px solid #202225; background: #1f2124; display: flex; gap: 4px; }
.channel-panel-input input { flex: 1; margin: 0; width: auto; }
.dm-panel-header:active { cursor: grabbing; }
.dm-panel-title { display: flex; align-items: center; gap: 3px; min-width: 0; }
.dm-panel-avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: #1f2124;
    border: 1px solid #202225;
    flex: 0 0 25px;
}
.dm-panel-name { font-weight: 600; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 3px;
}
.dm-panel-input { padding: 3px; border-top: 1px solid #202225; background: #1f2124; display: flex; gap: 4px; }
.dm-panel-input input { flex: 1; margin: 0; width: auto; }
.btn-send-small {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}
.btn-send-small:hover {
    background: #4752c4;
}
video { width: 100%; height: 100%; object-fit: cover; }
.video-label { position: absolute; bottom: 5px; left: 5px; background: rgba(0,0,0,0.6); color: white; padding: 2px 3px; border-radius: 4px; font-size: 0.8em; }

/* MODAL & LOGIN */
.modal { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.8); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.modal-content, .login-box { background: var(--bg-chat); padding: 3px; border-radius: 8px; width: 300px; text-align: center; }
#loginAvatarPreview {
    background: radial-gradient(circle at 35% 30%, #4a4d55, #2a2c31);
    border: 2px dashed #3b3f46;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    color: var(--text-muted);
}
.btn-green { background: var(--accent); color: white; border: none; padding: 3px; border-radius: 4px; width: 100%; cursor: pointer; }
input, select { background: #202225; border: 1px solid #202225; color: white; padding: 3px; width: 90%; margin-bottom: 3px; border-radius: 4px; }
input[type="range"] { padding: 0; }
.link-notice { background: #1f2124; border: 1px solid #2a2d31; border-radius: 6px; padding: 6px; text-align: left; }
.link-notice-text { font-size: 0.85em; color: #e3e5e8; margin-bottom: 4px; }
.link-notice-actions { display: flex; gap: 6px; margin-bottom: 4px; }
.link-notice-actions .btn-green { width: auto; flex: 1; }
.link-notice-actions .icon-btn { width: auto; flex: 1; }
.link-notice-hint { font-size: 0.7em; color: var(--text-muted); }

@media (max-width: 480px) {
    .modal { padding: 3px; }
    .modal-content, .login-box { width: 100%; max-width: 320px; }
}

.channel-password-prompt {
  margin: 4px 6px 6px 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.channel-password-prompt input {
  width: 180px;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #202225;
}
.channel-password-actions {
  display: flex;
  gap: 6px;
}
.channel-password-actions button {
  margin: 0;
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}
    #login-overlay { gap: 6px; }
    .quality-popover,
    .media-popover {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 72px;
        width: auto;
        z-index: 4000;
    }
    .quality-popover-quick { width: auto; }
    .dm-panel-header { height: 32px; }

/* Channels */
.channel-item { margin-bottom: 3px; border-bottom:#2a2d31; border-bottom-width: 1px;
border-bottom-style: solid; }
.channel-row {
    padding: 3px; cursor: pointer; border-radius: 4px; color: #8e9297;
    display: flex; align-items: center; font-weight: 500;
}
.channel-row.active-text { background: #40444b; color: #fff; }
.channel-row:hover { background: #35373c; color: #dcddde; }
.channel-icon { margin-right: 3px; font-size: 1.1em; }
.channel-badges { display: inline-flex; gap: 6px; margin-left: 3px; align-items: center; }
.channel-badge { font-size: 0.7em; color: var(--text-muted); background: #202225; border: 1px solid #1a1b1e; padding: 1px 3px; border-radius: 999px; }

/* Channel name + text button helpers used by the modular app */
.channel-name { flex: 1; cursor: pointer; user-select: none; }
.channel-name.active-voice { color: #3ba55c; }
.text-chat-btn { cursor: pointer; font-size: 1.1em; opacity: 0.55; padding: 2px 3px; border-radius: 4px; }
.text-chat-btn:hover { opacity: 1; background: #40444b; }
.text-chat-btn.active-text { opacity: 1; color: #fff; }
.voice-leave-btn { cursor: pointer; font-size: 1.1em; opacity: 0.7; padding: 2px 3px; border-radius: 4px; }
.voice-leave-btn:hover { opacity: 1; background: #40444b; }

/* Voice User List (Indented under channel) */
.voice-user-list { padding-left: 0; margin-left: 3px; margin-bottom: 3px; }
.voice-user { display: flex; flex-direction: column; gap: 4px; margin-bottom: 3px; padding: 2px; }
.voice-user-row { display: flex; align-items: center; gap: 8px; }
.voice-user-icons { margin-left: auto; display: inline-flex; gap: 4px; opacity: 0.85; }
.voice-user-icon { font-size: 0.9em; }
.voice-quality { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; margin-left: 3px; flex: 0 0 auto; }
.voice-quality.quality-good { background: #3ba55c; }
.voice-quality.quality-ok { background: #f5c451; }
.voice-quality.quality-warn { background: #f28c2c; }
.voice-quality.quality-bad { background: #ed4245; }
.voice-meter { height: 2px; background: #1a1b1e; border-radius: 2px; overflow: hidden; margin-left: 3px; }
.voice-meter-fill { height: 100%; width: 0; background: #3ba55c; transition: width 0.05s linear; }
.voice-meter-fill.silent { width: 0; }
.voice-user-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    width: calc(100% - 32px);
    margin-left: 3px;
    padding: 0 3px;
    box-sizing: border-box;
    overflow: visible;
}
.voice-user-volume input[type="range"] { width: 100%; margin: 0; box-sizing: border-box; min-width: 0; }
.voice-avatar { width: 24px; height: 24px; border-radius: 50%; background-size: cover; background-color: #333; }
.voice-avatar.speaking { box-shadow: 0 0 0 2px #3ba55c; }
.voice-name { font-size: 0.9em; color: #dcddde; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-avatar { width: 20px; height: 20px; border-radius: 50%; background-size: cover; background-color: #333; flex: 0 0 auto; }

.context-menu {
    position: fixed;
    z-index: 3000;
    background: #1f2124;
    border: 1px solid #202225;
    border-radius: 8px;
    padding: 3px;
    min-width: 160px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    display: none;
}
.context-btn {
    width: 100%;
    background: #2b2d31;
    color: #fff;
    border: none;
    padding: 3px 3px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}
.context-btn:hover { background: #35373c; }
.dm-indicator { font-size: 0.85em; }

.version-badge {
    right: 0px;
    bottom: 40px;
    font-size: 0.65em;
    color: #8e9297;
    background: rgba(0,0,0,0.35);
    padding: 2px 3px;
    border-radius: 6px;
    z-index: 1;
    pointer-events: none;
}

.version-update {
    right: 6px;
    bottom: 28px;
    font-size: 0.9em;
    background: #2b2d31;
    color: #fff;
    border: 1px solid #202225;
    border-radius: 999px;
    padding: 2px 3px;
    z-index: 11;
    display: none;
    cursor: pointer;
}
.version-update:hover { background: #35373c; }

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    min-height: 28px;
    flex-wrap: wrap;
}

.typing-indicator-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
