
        :root {
            --bg-0: #0c0d11;      /* server rail */
            --bg-1: #12141a;      /* channel + member panes */
            --bg-2: #181b22;      /* main area */
            --bg-3: #20232c;      /* inputs, hover */
            --bg-4: #2a2e39;      /* raised */
            --border: #272a34;
            --border-focus: #3b4050;
            --text: #bcc1cc;
            --bright: #f2f3f5;
            --muted: #868b99;   /* was #7b8190: 4.0:1 on the input background, now 4.5:1 or more on every pane */
            --accent: #8b5cf6;
            --accent-hi: #a78bfa;
            --accent-bg: rgba(139, 92, 246, 0.14);
            --green: #23a55a;
            --yellow: #f0b232;
            --red: #f23f43;
            --offline: #5b6170;
            /* shared surface + hover tokens (several dialogs and buttons used these names before they existed) */
            --panel: var(--bg-2);
            --panel2: rgba(127, 127, 127, .1);
            --bg-5: color-mix(in srgb, var(--bg-4) 82%, var(--bright));
            --hover: rgba(255, 255, 255, .06);
            --hover-strong: rgba(255, 255, 255, .09);
            --font: 'Segoe UI', 'Inter', system-ui, -apple-system, 'Noto Sans', 'Noto Sans Arabic', sans-serif;
            --mono: 'Consolas', 'Courier New', monospace;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        html, body { height: 100%; }
        body {
            background: var(--bg-0); color: var(--text); font-family: var(--font); font-size: 14px;
            overflow: hidden; -webkit-font-smoothing: antialiased;
        }
        button, input, textarea, select { font-family: inherit; }
        ::-webkit-scrollbar { width: 10px; height: 10px; }
        ::-webkit-scrollbar-thumb { background: #2c303b; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
        ::-webkit-scrollbar-thumb:hover { background: #3a3f4d; background-clip: content-box; border: 2px solid transparent; }
        ::-webkit-scrollbar-track { background: transparent; }

        .app { display: flex; height: 100vh; height: 100dvh; width: 100vw; }

        /* ---------- toasts / misc ---------- */
        #footer-credits { position: fixed; bottom: 3px; right: 10px; font-size: 10px; color: var(--muted); opacity: .55; pointer-events: none; z-index: 5; }
        #toast-container { position: fixed; top: 16px; right: 16px; z-index: 999999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
        .toast-item {
            background: var(--bg-4); border-left: 4px solid var(--accent); color: var(--bright); font-size: 13px; padding: 10px 14px;
            border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.55); display: flex; align-items: center; gap: 8px; max-width: 340px; word-break: break-word;
            animation: toastIn .18s ease-out;
        }
        .toast-item.error { border-left-color: var(--red); }
        .toast-item.success { border-left-color: var(--green); }
        @keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

        /* ---------- buttons / inputs ---------- */
        .btn {
            background: var(--accent-bg); border: 1px solid var(--accent); color: #d8c8ff; padding: 6px 12px; cursor: pointer;
            border-radius: 5px; font-size: 12px; font-weight: 600; transition: .15s;
        }
        .btn:hover { background: var(--accent); color: #fff; }
        .btn:disabled { opacity: .5; cursor: default; }
        .btn-danger { background: rgba(242,63,67,.1); border-color: var(--red); color: #ff8a8d; }
        .btn-danger:hover { background: var(--red); color: #fff; }
        .btn-success { background: rgba(35,165,90,.14); border-color: var(--green); color: #6fd49a; }
        .btn-success:hover { background: var(--green); color: #04130a; }
        .icon-btn {
            background: transparent; border: none; color: var(--muted); cursor: pointer; border-radius: 5px; min-width: 28px; height: 28px;
            display: inline-flex; align-items: center; justify-content: center; font-size: 15px; padding: 0 5px; transition: .12s;
        }
        .icon-btn:hover { color: var(--bright); background: rgba(255,255,255,.07); }
        .icon-btn.active { color: var(--accent-hi); }
        .icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
        .icon-btn svg[fill="none"] { fill: none; }   /* outline icons (GIF) keep their own fill: painting them solid hid the letters */
        .system-input, select.system-input {
            background: var(--bg-0); border: 1px solid var(--border); color: var(--bright); font-family: var(--font); padding: 9px 10px;
            border-radius: 5px; outline: none; font-size: 13px; width: 100%;
        }
        .system-input:focus { border-color: var(--accent); }
        .system-input:disabled { opacity: .6; }
        .field-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
        .field-group label, .field-label { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
        .check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
        .empty-note { color: var(--muted); font-size: 13px; padding: 14px 6px; }
        .badge-pill { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 18px; font-size: 10px; font-weight: 700; line-height: 1; letter-spacing: .03em; padding: 1px 7px 0; border-radius: 9px; vertical-align: middle; white-space: nowrap; unicode-bidi: isolate; background: var(--accent-bg); color: var(--accent-hi); border: 1px solid var(--accent); }

        /* ---------- dialogs ---------- */
        dialog {
            background: rgba(4, 5, 8, .78); border: none; padding: 0; margin: auto;
            position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none;
            display: none; align-items: center; justify-content: center; z-index: 99999; color: var(--text);
        }
        dialog[open] { display: flex !important; }
        dialog::backdrop { background: transparent; }
        .dialog-box {
            width: 480px; max-width: calc(100vw - 24px); max-height: 90vh; overflow-y: auto; background: var(--bg-2);
            border: 1px solid var(--border-focus); padding: 22px; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
        }
        .panel-label { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px; font-weight: 700; }
        .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
        .brand-title { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); text-align: center; font-weight: 800; user-select: none; }

        #auth-dialog, #boot-screen { position: fixed; inset: 0; z-index: 99990; display: flex; align-items: center; justify-content: center; padding: 12px;
            background: #0c0d11 radial-gradient(circle at 50% 30%, #231a45 0%, #0c0d11 75%); }
        #auth-dialog:not(.open), #boot-screen:not(.open) { display: none; }
        #auth-dialog { overflow-y: auto; overscroll-behavior: contain; align-items: flex-start; } #auth-dialog > * { margin-top: auto; margin-bottom: auto; flex-shrink: 0; }   /* a short window or a big font: the sign-in card scrolls instead of being cut off */
        #boot-screen { z-index: 99995; flex-direction: column; gap: 14px; text-align: center; color: var(--muted); font-size: 13px; }
        .boot-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: boot-spin .8s linear infinite; }
        @keyframes boot-spin { to { transform: rotate(360deg); } }
        #boot-screen.error .boot-spinner { display: none; }
        #boot-error-box { display: none; max-width: 380px; }
        #boot-screen.error #boot-error-box { display: block; }
        #boot-screen.error #boot-loading-text { display: none; }
        .boot-error-title { font-size: 18px; font-weight: 800; color: var(--bright); margin-bottom: 6px; }
        .auth-error { display: none; background: rgba(239,68,68,.12); border: 1px solid var(--red); color: var(--red); font-size: 13px; padding: 9px 11px; border-radius: 5px; margin-bottom: 14px; }
        .auth-error.visible { display: block; }
        #offline-banner { position: fixed; top: calc(env(safe-area-inset-top,0px) + 6px); left: 50%; transform: translateX(-50%); z-index: 99980; background: var(--red); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: none; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.4); pointer-events: none; }
        #offline-banner.show { animation: ofpulse 1.6s ease-in-out infinite; } @keyframes ofpulse { 50% { opacity: .55; } }
        #offline-banner.show { display: flex; }
        .auth-card { width: 420px; max-width: calc(100vw - 24px); background: var(--bg-2); border: 1px solid var(--border-focus); border-radius: 10px; padding: 30px; box-shadow: 0 12px 40px rgba(0,0,0,.7); }
        .auth-header-title { font-size: 22px; font-weight: 800; color: var(--bright); text-align: center; margin-bottom: 6px; }
        .auth-header-sub { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 20px; }
        .auth-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .5px; display: flex; gap: 4px; margin-bottom: 6px; text-transform: uppercase; }
        .auth-req-star { color: var(--red); }
        .auth-input { width: 100%; background: var(--bg-0); border: 1px solid var(--border); border-radius: 5px; color: var(--bright); padding: 11px; font-size: 14px; outline: none; margin-bottom: 16px; font-family: var(--font); }
        .auth-input:focus { border-color: var(--accent); }
        .auth-submit-action { width: 100%; background: var(--accent); color: #fff; border: none; padding: 12px; border-radius: 5px; font-weight: 700; font-size: 14px; cursor: pointer; margin-bottom: 12px; transition: .15s; }
        .auth-submit-action:hover { background: #7c3aed; }
        .auth-submit-action:disabled { opacity: .6; }
        .auth-switch-text { font-size: 12px; color: var(--muted); }
        .auth-switch-link { color: var(--accent-hi); cursor: pointer; font-weight: 700; }
        .auth-switch-link:hover { text-decoration: underline; }
        .auth-note { display: none; background: rgba(34,197,94,.10); border: 1px solid #22c55e; color: #4ade80; font-size: 13px; padding: 9px 11px; border-radius: 5px; margin-bottom: 14px; }
        .auth-note.visible { display: block; }
        .auth-pw-wrap { position: relative; }
        .auth-pw-wrap .auth-input { padding-right: 60px; }
        .auth-eye { position: absolute; right: 6px; top: 6px; height: 30px; padding: 0 9px; background: transparent; border: 0; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; border-radius: 4px; }
        .auth-eye:hover { color: var(--bright); background: var(--bg-2); }
        .auth-forgot { margin: -10px 0 16px; font-size: 13px; position: relative; z-index: 1; width: max-content; }
        .auth-caps { margin: -8px 0 12px; font-size: 12px; color: #f59e0b; }
        .auth-code-in { text-align: center; font-size: 26px; letter-spacing: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; }
        .auth-done-ic { text-align: center; font-size: 44px; line-height: 1; margin: 4px 0 18px; }
        body.has-mail-bar .app { height: calc(100vh - 36px); height: calc(100dvh - 36px); }
        html.desk-tb body.has-mail-bar .app { height: calc(100dvh - 68px - var(--desk-bot)); }
        #mail-bar { display: none; position: relative; z-index: 50; height: 36px; white-space: nowrap; align-items: center; justify-content: center; background: #f0b232; color: #1e1f22; font-size: 14px; font-weight: 500; padding: 8px 40px; text-align: center; line-height: 20px; }
        #mail-bar.show { display: flex; }
        #mail-bar-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
        #mail-bar button.mb-act { flex: none; }
        @media (max-width: 640px) { #mail-bar { font-size: 12px; padding: 8px 34px 8px 10px; text-align: left; } #mail-bar button.mb-act { margin-left: 6px; padding: 1px 7px; font-size: 12px; } #mail-bar { white-space: normal; font-size: 11.5px; line-height: 14px; padding-top: 4px; padding-bottom: 4px; } #mail-bar-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; } }
        #mail-bar.red { background: #da373c; color: #fff; }
        #mail-bar button.mb-act { margin-left: 10px; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 3px; padding: 2px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
        #mail-bar button.mb-act:hover { background: rgba(0,0,0,.08); }
        #mail-bar .mb-x { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: inherit; font-size: 16px; cursor: pointer; opacity: .8; }

        .quality-options-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
        .quality-btn { background: var(--bg-0); border: 1px solid var(--border); color: var(--text); padding: 11px 4px; border-radius: 6px; cursor: pointer; text-align: center; font-size: 13px; font-weight: 700; transition: .15s; }
        .quality-btn:hover { border-color: var(--accent); }
        .quality-btn.selected { background: var(--accent-bg); border-color: var(--accent); color: #fff; box-shadow: 0 0 10px rgba(139,92,246,.35); }
        .role-tag { font-size: 10px; padding: 1px 6px; border-radius: 10px; border: 1px solid; }
        .role-badge-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
        .menu-list { display: flex; flex-direction: column; gap: 2px; }
        .menu-item { background: transparent; border: none; text-align: left; padding: 10px 12px; border-radius: 5px; color: var(--text); font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; }
        .menu-item:hover { background: var(--accent); color: #fff; }
        .menu-item.danger { color: #ff8a8d; }
        .menu-item.danger:hover { background: var(--red); color: #fff; }

        /* ---------- avatars + presence ---------- */
        .user-avatar {
            border-radius: 50%; background-color: var(--bg-4); background-size: cover; background-position: center; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--bright); position: relative; user-select: none;
            transition: box-shadow .12s;
        }
        .user-avatar.speaking, .tile.speaking .user-avatar { box-shadow: 0 0 0 3px var(--green); }
        .sdot { position: absolute; right: -2px; bottom: -2px; border-radius: 50%; border: 2px solid var(--bg-1); background: var(--offline); }
        .sdot.s-online { background: var(--green); } .sdot.s-idle { background: var(--yellow); } .sdot.s-dnd { background: var(--red); }
        .member-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--offline); }
        .member-dot.online { background: var(--green); }

        /* ---------- server rail ---------- */
        .rail { width: 72px; flex-shrink: 0; background: var(--bg-0); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; overflow-x: hidden; z-index: 30; }
        .rail::-webkit-scrollbar { width: 0; }
        .rail-btn {
            width: 48px; height: 48px; flex-shrink: 0; border: none; border-radius: 50%; background: var(--bg-3); color: var(--bright); cursor: pointer;
            font-weight: 800; font-size: 13px; position: relative; display: flex; align-items: center; justify-content: center;
            background-size: cover; background-position: center; transition: border-radius .15s, background-color .15s;
        }
        .rail-btn:hover, .rail-btn.active { border-radius: 16px; background-color: var(--accent); }
        .rail-btn.has-img:hover, .rail-btn.has-img.active { background-color: var(--bg-3); }
        .rail-btn::before { content: ''; position: absolute; left: -12px; width: 4px; height: 0; background: #fff; border-radius: 0 4px 4px 0; transition: height .15s; }
        .rail-btn.active::before { height: 32px; }
        .rail-btn.unread::before { height: 8px; }
        .rail-btn.action { background: var(--bg-3); color: var(--green); font-size: 20px; }
        .rail-btn.action:hover { background: var(--green); color: #fff; }
        .rail-btn.admin { color: #ff8a8d; font-size: 11px; }
        .rail-btn.admin:hover, .rail-btn.admin.active { background: var(--red); color: #fff; }
        .rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 2px; flex-shrink: 0; }
        #servers-container { display: flex; flex-direction: column; gap: 8px; align-items: center; }
        .badge { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: none; align-items: center; justify-content: center; border: 3px solid var(--bg-0); box-sizing: content-box; }
        .badge.show { display: flex; }
        .db-status-pill { font-size: 9px; text-align: center; color: var(--green); margin-top: auto; user-select: none; letter-spacing: .5px; font-weight: 700; }
        .db-status-pill.error { color: var(--red); }

        /* ---------- channel pane ---------- */
        .channels-pane { width: 240px; flex-shrink: 0; background: var(--bg-1); display: flex; flex-direction: column; z-index: 20; min-height: 0; }
        .pane-header { height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 14px; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
        .server-title-btn { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--bright); cursor: pointer; font-size: 15px; overflow: hidden; flex: 1; padding: 4px 0; }
        .server-title-btn span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .server-title-btn:hover { color: var(--accent-hi); }
        .section-header { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; padding: 12px 10px 4px 14px; }
        .channel-list { list-style: none; overflow-y: auto; flex: 1; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
        .list-label { font-size: 11px; color: var(--muted); font-weight: 700; margin: 14px 6px 4px; text-transform: uppercase; letter-spacing: .5px; list-style: none; }
        .channel-item { padding: 6px 8px; border-radius: 5px; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 500; min-height: 32px; }
        .channel-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; min-width: 0; }
        .channel-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
        .channel-item.active { background: var(--bg-4); color: var(--bright); }
        .channel-item.unread { color: var(--bright); font-weight: 700; }
        .channel-gear-btn { opacity: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0 4px; }
        @media (hover: hover) { .channel-item:hover .channel-gear-btn { opacity: 1; } }
        @media (hover: none) { .channel-gear-btn { opacity: .6; } }   /* touch: a hover that reveals the gear made the first tap on a channel do nothing on iPad */
        .channel-gear-btn:hover { color: var(--bright); }
        .mention-badge { background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 800; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
        .voice-member-subitem { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 26px; font-size: 13px; color: var(--text); border-radius: 5px; cursor: pointer; }
        .voice-member-subitem:hover { background: rgba(255,255,255,.05); }
        .voice-member-subitem .vm-name { color: var(--bright); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .vs-icons { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; color: var(--muted); }
        .vs-ic { display: inline-flex; width: 16px; height: 16px; }
        .vs-ic svg, .tile-icon svg { width: 100%; height: 100%; }
        .vs-ic.red { color: var(--red); }
        .vs-live { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; letter-spacing: .3px; }
        .tile-icon { display: none; align-items: center; gap: 4px; color: var(--red); }
        .tile-icon svg { width: 16px; height: 16px; }

        .voice-connected-dock { background: var(--bg-0); border-top: 1px solid var(--border); padding: 10px; display: none; flex-direction: column; gap: 8px; flex-shrink: 0; }
        .voice-dock-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
        .voice-dock-left { overflow: hidden; }
        .voice-status-title { font-weight: 700; color: var(--green); font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
        .voice-timer-badge { font-size: 11px; color: var(--muted); font-weight: 600; }
        .voice-channel-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        #voice-ping { font-size: 11px; font-weight: 700; color: var(--green); }
        .voice-dock-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
        .voice-dock-tiles:has(> :nth-child(5)) { grid-template-columns: repeat(auto-fit, minmax(28px, 1fr)); }
        .voice-dock-tile { background: var(--bg-3); border: none; color: var(--text); padding: 8px 0; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; font-size: 15px; transition: .12s; }
        .voice-dock-tile:hover { background: var(--bg-4); }
        .voice-dock-tile.active { background: var(--accent-bg); color: var(--accent-hi); box-shadow: inset 0 0 0 1px var(--accent); }

        .user-status-bar { background: var(--bg-0); height: 54px; flex-shrink: 0; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
        .user-pill { display: flex; align-items: center; gap: 8px; cursor: pointer; overflow: hidden; padding: 4px 6px; border-radius: 6px; flex: 1; min-width: 0; }
        .user-pill:hover { background: rgba(255,255,255,.06); }
        .user-pill > div:last-child { overflow: hidden; min-width: 0; }
        #current-user-name { color: var(--bright); font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .my-game { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; } .my-game svg { width: 14px; height: 14px; flex: none; color: var(--green); }
        #current-user-role { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .user-quick-controls { display: flex; align-items: center; gap: 2px; }
        .quick-icon-btn { background: transparent; border: none; color: var(--text); cursor: pointer; border-radius: 5px; }   /* size: see the shared icon-button rules below */
        .quick-icon-btn:hover { background: rgba(255,255,255,.08); }
        .quick-icon-btn.active { color: var(--red); }

        /* ---------- main ---------- */
        .main { flex: 1; min-width: 0; background: var(--bg-2); display: flex; flex-direction: column; position: relative; min-height: 0; }
        .main-header { height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
        #chat-title-heading { flex-shrink: 0; max-width: 55%; unicode-bidi: plaintext; font-weight: 700; color: var(--bright); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .channel-topic-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
        .header-spacer { flex: 1 1 0; min-width: 0; }   /* pushes search, pins and members to the far right at every width */
        #chat-search-input { width: 180px; background: var(--bg-0); border: 1px solid var(--border); border-radius: 5px; color: var(--bright); padding: 5px 10px; font-size: 12px; outline: none; transition: width .15s; }
        #chat-search-input:focus { width: 240px; border-color: var(--accent); }
        #btn-hamburger { display: none; }
        .view { flex: 1; min-height: 0; display: none; }

        .chat-view { flex-direction: column; }
        .chat-messages { flex: 1; overflow-y: auto; padding: 12px 0 8px; display: flex; flex-direction: column; min-height: 0; }
        .date-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 700; margin: 16px 16px 6px; }
        .new-divider { display: flex; align-items: center; gap: 8px; margin: 10px 16px 2px; color: var(--red); font-size: 10.5px; font-weight: 800; letter-spacing: .5px; } .new-divider::before { content: ''; height: 1px; background: var(--red); flex: 1; opacity: .8; } .new-divider span { background: var(--red); color: #fff; border-radius: 9px; padding: 0 7px; line-height: 15px; }
        .date-divider::before, .date-divider::after { content: ''; height: 1px; background: var(--border); flex: 1; }
        .msg { position: relative; display: flex; gap: 14px; padding: 2px 16px 2px 16px; margin-top: 14px; }
        .msg.grouped { margin-top: 0; }
        .msg:hover { background: rgba(255,255,255,.025); }
        .msg.mention { background: rgba(240,178,50,.07); box-shadow: inset 3px 0 0 var(--yellow); }
        .msg.flash { animation: flash 1.6s ease-out; }
        @keyframes flash { 0%, 40% { background: rgba(139,92,246,.28); } 100% { background: transparent; } }
        .msg-avatar { width: 40px; flex-shrink: 0; padding-top: 2px; }
        .msg-gutter { width: 40px; flex-shrink: 0; font-size: 10px; color: var(--muted); text-align: center; padding-top: 4px; visibility: hidden; }
        @media (hover: hover) { .msg:hover .msg-gutter { visibility: visible; } }
        .msg.tools-open .msg-gutter { visibility: visible; }
        .msg-body { min-width: 0; flex: 1; }
        .msg-head { display: flex; align-items: baseline; gap: 8px; }
        .msg-author { font-weight: 700; color: var(--bright); cursor: pointer; }
        .msg-author:hover { text-decoration: underline; }
        .msg-time { font-size: 11px; color: var(--muted); }
        .msg-edited { font-size: 10px; color: var(--muted); }
        .msg-text { color: var(--text); line-height: 1.42; word-break: break-word; font-size: 14.5px; }
        .msg-pin { color: var(--yellow); font-size: 11px; margin-left: 4px; }
        .msg-reply { display: block; font-size: 12px; color: var(--muted); margin: 0 0 3px; padding-left: 8px; border-left: 2px solid var(--border-focus); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
        .msg-reply:hover { color: var(--text); }
        .msg-reply b { color: var(--text); }
        .msg-tools { position: absolute; right: 16px; top: -14px; display: none; background: var(--bg-3); border: 1px solid var(--border-focus); border-radius: 6px; padding: 2px; box-shadow: 0 4px 14px rgba(0,0,0,.4); z-index: 3; }
        /* hover only for a pointer that can hover. On iPad a tap counts as a hover, the tools appeared, and Safari then treated the tap as "just a hover": links, images and files inside a message needed a second tap. Touch uses the tap-to-show .tools-open below. */
        @media (hover: hover) { .msg:hover .msg-tools { display: flex; } }
        .msg-tools .icon-btn { font-size: 14px; }
        .chat-attachment-img { max-width: 380px; max-height: 300px; width: auto; height: auto; border-radius: 8px; border: 1px solid var(--border); margin-top: 6px; display: block; object-fit: contain; }
        .chat-file-download { display: inline-flex; margin-top: 6px; padding: 10px 14px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; color: var(--accent-hi); text-decoration: none; font-size: 13px; }
        .chat-file-download:hover { border-color: var(--accent); }
        .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
        .reaction { display: inline-flex; align-items: center; gap: 5px; background: var(--bg-3); border: 1px solid transparent; border-radius: 8px; padding: 2px 8px; cursor: pointer; font-size: 13px; color: var(--text); }
        .reaction:hover { border-color: var(--border-focus); }
        .reaction.mine { background: var(--accent-bg); border-color: var(--accent); color: #fff; }
        .edit-input { width: 100%; background: var(--bg-3); border: 1px solid var(--accent); border-radius: 6px; color: var(--bright); padding: 8px 10px; font-family: var(--font); font-size: 14px; outline: none; resize: none; }
        .edit-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

        /* markdown */
        .md-code { background: var(--bg-0); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 13px; }
        .md-pre { background: var(--bg-0); border: 1px solid var(--border); padding: 10px 12px; border-radius: 6px; font-family: var(--mono); font-size: 13px; margin: 4px 0; overflow-x: auto; white-space: pre; }
        .mp-box { width: 460px; max-height: 80vh; display: flex; flex-direction: column; }
        .mp-box .cc-text { overflow-y: auto; }
        .mp-row { border-bottom: 1px solid var(--border); padding: 8px 0; }
        .mp-meta { font-size: 11px; color: var(--muted); }
        .mp-text { margin: 3px 0 6px; white-space: pre-wrap; word-break: break-word; }
        .mp-btns { display: flex; gap: 6px; }
        .mp-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 50vh; overflow-y: auto; }
        .mp-pick { text-align: left; }
        .mp-empty { color: var(--muted); padding: 14px 0; text-align: center; }
        .msg.flash { animation: mpFlash 1.6s ease-out; }
        @keyframes mpFlash { from { background: rgba(139,92,246,.3); } to { background: transparent; } }
        .msg-silent { display: inline-flex; vertical-align: middle; margin-right: 4px; color: var(--muted); }
        .msg-silent .ic { width: 13px; height: 13px; }
        .md-codewrap { position: relative; margin: 4px 0; }
        .md-codewrap .md-pre { margin: 0; padding-right: 58px; }
        .md-lang { position: absolute; right: 8px; bottom: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); pointer-events: none; opacity: .8; }
        .md-copy { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-3, var(--bg-0)); color: var(--text); cursor: pointer; opacity: 0; transition: opacity .12s; }
        .md-codewrap:hover .md-copy, .md-copy:focus-visible { opacity: 1; }
        @media (hover: none) { .md-copy { opacity: .85; } }
        .md-h { font-weight: 800; line-height: 1.25; margin: 6px 0 2px; }
        .md-h1 { font-size: 1.6em; } .md-h2 { font-size: 1.3em; } .md-h3 { font-size: 1.1em; }
        .md-sub { font-size: .8em; color: var(--muted); }
        .md-li { position: relative; padding-left: 18px; }
        .md-li::before { content: '•'; position: absolute; left: 5px; }
        .md-time { background: var(--bg-4); border-radius: 4px; padding: 0 4px; cursor: default; }
        :root[dir="rtl"] .md-li { padding-left: 0; padding-right: 18px; } :root[dir="rtl"] .md-li::before { left: auto; right: 5px; }
        .md-quote { border-left: 4px solid var(--border-focus); padding-left: 10px; margin: 2px 0; color: var(--muted); }
        .md-spoiler { background: #0a0b0e; color: transparent; border-radius: 4px; padding: 0 3px; cursor: pointer; user-select: none; }
        .md-spoiler.revealed { background: var(--bg-4); color: var(--text); user-select: auto; }
        .md-mention { background: rgba(139,92,246,.22); color: #d4c4ff; border-radius: 4px; padding: 0 3px; font-weight: 600; }
        .md-mention.me { background: rgba(240,178,50,.25); color: #ffe3a1; }
        .msg-text a { color: var(--accent-hi); text-decoration: none; } .msg-text a:hover { text-decoration: underline; }

        .composer-wrap { padding: 0 16px 6px; flex-shrink: 0; position: relative; }
        #reply-bar { display: none; align-items: center; justify-content: space-between; background: var(--bg-3); border-radius: 8px 8px 0 0; padding: 7px 12px; font-size: 12px; color: var(--muted); }
        #reply-bar.show { display: flex; }
        #reply-bar b { color: var(--text); }
        .composer { background: var(--bg-3); border-radius: 8px; display: flex; align-items: flex-end; padding: 6px 8px; gap: 4px; }
        #reply-bar.show + .composer { border-radius: 0 0 8px 8px; }
        #chat-input { flex: 1; background: transparent; border: none; outline: none; resize: none; color: var(--bright); font-family: var(--font); font-size: 14.5px; padding: 7px 4px; max-height: 160px; line-height: 1.4; }
        .composer .icon-btn { height: 34px; }
        .typing-indicator { height: 20px; font-size: 12px; color: var(--muted); padding: 2px 4px; font-weight: 600; }

        /* friends / terminal */
        .friends-dashboard { flex-direction: column; overflow: hidden; padding: 12px 16px; }
        .friends-top-nav { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; flex-wrap: wrap; }
        .nav-tab { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; padding: 4px 10px; border-radius: 5px; }
        .nav-tab:hover { background: rgba(255,255,255,.06); color: var(--text); }
        .nav-tab.active { background: var(--bg-4); color: var(--bright); }
        .friends-search-bar { display: flex; gap: 8px; background: var(--bg-0); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; margin-bottom: 14px; align-items: center; }
        .friends-search-bar input { background: transparent; border: none; outline: none; color: var(--bright); font-family: var(--font); font-size: 14px; width: 100%; }
        .add-friend-box { padding-bottom: 18px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
        .af-title { font-size: 15px; font-weight: 800; color: var(--bright); text-transform: uppercase; letter-spacing: .3px; }
        .af-sub { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
        .af-row { display: flex; align-items: center; gap: 8px; background: var(--bg-0); border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 12px; }
        .af-row:focus-within { border-color: var(--accent); }
        .add-friend-box.ok .af-row { border-color: var(--green); } .add-friend-box.err .af-row { border-color: var(--red); }
        .af-row input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--bright); font-family: var(--font); font-size: 14px; padding: 6px 0; }
        .af-row .btn { flex-shrink: 0; white-space: nowrap; }
        .af-row .btn:disabled { opacity: .5; cursor: default; }
        .af-msg { font-size: 13px; margin-top: 8px; min-height: 0; }
        .add-friend-box.ok .af-msg { color: var(--green); } .add-friend-box.err .af-msg { color: var(--red); }
        @media (max-width: 560px) { .af-row { flex-wrap: wrap; padding: 8px; } .af-row input { flex-basis: 100%; padding: 4px 4px 8px; } .af-row .btn { width: 100%; } }
        .friends-card-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
        .friend-row-card { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--border); border-radius: 6px; gap: 8px; }
        .friend-row-card:hover { background: rgba(255,255,255,.04); }
        .fr-ic { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-3, #1b1c20); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; transition: background .12s, color .12s; }
        .fr-ic:hover { background: var(--bg-4, #2a2b30); color: var(--bright); }
        .fr-ic.ok:hover { color: #23a559; } .fr-ic.no:hover { color: #f23f43; }
        .fr-ic svg { width: 18px; height: 18px; }
        #friends-list-header { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
        .terminal-view { padding: 16px; overflow-y: auto; font-size: 13px; }
        .terminal-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
        .terminal-table th, .terminal-table td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; }
        .terminal-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }

        /* ---------- voice stage ---------- */
        .voice-call-screen { flex-direction: column; background: var(--bg-0); position: relative; overflow: hidden; }
        .voice-stage-title { padding: 10px 16px; font-weight: 700; color: var(--bright); border-bottom: 1px solid var(--border); background: var(--bg-2); display: flex; gap: 8px; align-items: center; }
        .voice-stage-grid { flex: 1; overflow-y: auto; padding: 14px 14px 100px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
        #stage-screen-slot { display: flex; flex-direction: column; }
        #stage-screen-slot:empty { display: none; }
        #stage-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; align-content: start; }
        #voice-call-screen.sofa-on #stage-members, #voice-call-screen.sofa-on #stage-alone { display: none !important; }
        #sofa-room { position: relative; width: min(100%, 900px, calc((100vh - 210px) * 1.6)); min-width: min(100%, 320px); aspect-ratio: 16 / 10; touch-action: pan-y; margin: 0 auto; border-radius: 18px; overflow: hidden; background: #241a3a;
            box-shadow: 0 0 0 1px rgba(184,107,255,.25), 0 18px 50px rgba(0,0,0,.55); container-type: inline-size; }
        #sofa-room > .sofa-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; user-select: none; pointer-events: none; }
        .sofa-head { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 2000; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; color: #fff; font-weight: 700; font-size: 14px; }
        .sofa-head > span:first-child { display: flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 10px; background: rgba(10,6,22,.82); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
        .sofa-tools { display: flex; gap: 6px; pointer-events: auto; }
        .sofa-tool { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 30px; height: 30px; padding: 0 9px; border: 0; border-radius: 10px; background: rgba(10,6,22,.82); color: rgba(255,255,255,.85); font: 700 12px/1 inherit; cursor: pointer; }
        .sofa-tool:hover { background: rgba(88,101,242,.85); color: #fff; }
        .sofa-tool.on { background: #5865f2; color: #fff; }
        .sofa-tool svg { width: 15px; height: 15px; }
        #sofa-seats { display: contents; }
        .lr-sp { position: absolute; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
        #sofa-room.lr-hover { cursor: grab; } #sofa-room.lr-dragging { cursor: grabbing; } #sofa-room.lr-dragging .lr-sp { filter: brightness(1.06); }
        #sofa-tv { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; z-index: 1; background: #000; overflow: hidden; cursor: pointer; }
        #sofa-tv video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
        #sofa-tv::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,.07) 0, rgba(255,255,255,0) 38%); pointer-events: none; }
        /* the TV shows the stream: the normal stream card steps aside (it stays alive for sound and fullscreen) */
        #voice-call-screen.sofa-tv #voice-stage-grid #stage-screen-slot #stage-screen-card:not(:fullscreen) { position: absolute !important; width: 2px !important; height: 2px !important; min-height: 0 !important; flex: none !important; opacity: 0; pointer-events: none; overflow: hidden; }
        #voice-call-screen.sofa-tv #stage-screen-slot { flex: none !important; min-height: 0 !important; height: 0 !important; }
        #voice-call-screen.sofa-tv #sofa-room { flex: none !important; height: auto !important; width: min(100%, 900px, calc((100vh - 210px) * 1.6)) !important; }
        .sofa-head .beta { font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: #5865f2; }
        .sofa-head .dim { color: rgba(255,255,255,.6); font-weight: 600; }
        .sofa-seat { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -62%); display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; color: #fff; cursor: pointer; z-index: 2;
            --s: 9cqw; }
        .sofa-av { position: relative; width: var(--s); height: var(--s); min-width: 18px; min-height: 18px; max-width: 72px; max-height: 72px; border-radius: 50%; display: grid; place-items: center;
            box-shadow: 0 0 0 3px #1b1233, 0 6px 14px rgba(0,0,0,.55); transition: box-shadow .15s; background: #1b1233; }
        .sofa-av > :first-child { width: 100% !important; height: 100% !important; border-radius: 50%; overflow: hidden; font-size: calc(var(--s) * .38) !important; }
        .sofa-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
        .sofa-seat.speaking .sofa-av { box-shadow: 0 0 0 3px var(--green), 0 0 22px rgba(35,165,90,.75), 0 6px 14px rgba(0,0,0,.55); }
        .sofa-badge { position: absolute; right: -3px; bottom: -3px; width: 40%; height: 40%; min-width: 10px; min-height: 10px; max-width: 24px; max-height: 24px; border-radius: 50%;
            background: #da373c; box-shadow: 0 0 0 2px #1b1233; display: grid; place-items: center; }
        .sofa-badge svg { width: 62%; height: 62%; }
        .sofa-seat.me .sofa-name { box-shadow: 0 0 0 1px rgba(201,184,255,.55); }
        .sofa-name { font-size: 12px; font-weight: 600; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(10,6,22,.72); padding: 1px 8px; border-radius: 8px; }
        .sofa-seat.empty .sofa-av { width: calc(var(--s) * .72); height: calc(var(--s) * .72); min-width: 24px; min-height: 24px; border: 2px solid rgba(255,255,255,.7); background: rgba(88,101,242,.42); 
            box-shadow: 0 0 0 3px rgba(88,101,242,.3), 0 0 16px rgba(120,132,255,.55); opacity: 0; transform: scale(.85); transition: opacity .15s, transform .15s; }
        #sofa-room:hover .sofa-seat.empty .sofa-av { opacity: .8; transform: none; }
        .sofa-seat.empty:hover .sofa-av { opacity: 1; transform: scale(1.12); background: rgba(88,101,242,.6); }
        .sofa-seat.empty .sofa-av::after { content: ''; width: 46%; height: 46%; background: linear-gradient(#fff, #fff) center / 100% 2.5px no-repeat, linear-gradient(#fff, #fff) center / 2.5px 100% no-repeat; border-radius: 2px; }
        @media (hover: none) { .sofa-seat.empty .sofa-av { opacity: .65; transform: none; } }
        @media (max-width: 700px) { .sofa-name { font-size: 10px; max-width: 72px; } .sofa-head { font-size: 12px; } .sofa-head .dim, .sofa-head .beta { display: none; } }
        /* a small room (phone, or under a stream): names only on hover or while talking, so the sofa doesn't fill with labels */
        @container (max-width: 640px) { .sofa-name { display: none; position: absolute; top: 100%; margin-top: 3px; } .sofa-seat:hover .sofa-name, .sofa-seat.speaking .sofa-name { display: block; z-index: 3; }
            .sofa-av { box-shadow: 0 0 0 2px #1b1233, 0 3px 8px rgba(0,0,0,.5); } .sofa-head { font-size: 11px; padding: 3px 8px; top: 8px; left: 8px; } }
        .tile { position: relative; background: #3a3a3c; border: 2px solid transparent; border-radius: 10px; aspect-ratio: 16 / 9; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; transition: border-color .12s; }
        .tile:hover { border-color: var(--border-focus); }
        .tile.speaking { border-color: var(--green); }
        .tile-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
        .tile-label, .stream-user-overlay { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; background: rgba(8,9,12,.75); padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 700; color: #fff; z-index: 2; }
        .screen-card { position: relative; background: #000; border: 1px solid var(--border); border-radius: 10px; min-height: 340px; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
        .screen-video { width: 100%; height: 100%; max-height: 62vh; object-fit: contain; background: #000; display: block; }
        .stream-quality-badges { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; background: rgba(10,11,14,.88); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; font-size: 11px; font-weight: 700; z-index: 5; }
        .badge-resolution { padding: 5px 9px; color: #dbdee1; }
        .badge-live { background: var(--red); color: #fff; padding: 5px 8px; }
        .stream-action-badge, .fullscreen-btn-badge { background: transparent; border: none; border-left: 1px solid var(--border); color: #fff; padding: 5px 9px; font-size: 11px; cursor: pointer; font-weight: 600; }
        .stream-action-badge:hover, .fullscreen-btn-badge:hover { background: var(--accent); }
        .stream-connecting { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
        .mirror-note { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 340px; padding: 16px; }
        .mirror-note .ic { width: 40px; height: 40px; color: var(--accent); }
        .mirror-note b { color: var(--bright); font-size: 15px; }
        .stream-stop, .stream-stop:hover { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }
        .voice-floating-bar { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(24,26,33,.95); border: 1px solid var(--border-focus); border-radius: 30px; padding: 8px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.7); z-index: 50; }
        .control-pill-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--bg-4); color: var(--bright); display: flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer; transition: .12s; }
        .control-pill-btn:hover { background: #363b49; }
        .control-pill-btn.active { background: var(--accent); color: #fff; }
        .control-pill-btn.danger-leave { background: var(--red); width: 56px; border-radius: 22px; }
        .control-pill-btn.danger-leave:hover { background: #d83a3e; }
        .chat-docked { flex: none !important; height: 300px; border-top: 1px solid var(--border); }

        /* ---------- members ---------- */
        .members-pane { width: 240px; flex-shrink: 0; background: var(--bg-1); overflow-y: auto; padding-bottom: 12px; z-index: 20; }
        .members-pane.hidden-pane { display: none; }
        .member-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 16px 14px 4px; letter-spacing: .4px; }
        .member-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; margin: 0 6px; border-radius: 6px; cursor: pointer; }
        .member-row:hover { background: rgba(255,255,255,.05); }
        .member-row.offline { opacity: .45; }
        .member-row .mname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .member-row .msub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .member-row .mtext { flex: 1 1 auto; min-width: 0; }
        .member-row .mrow-end { display: none; }

        /* ---------- emoji picker ---------- */
        #emoji-picker { position: fixed; z-index: 100000; background: var(--bg-2); border: 1px solid var(--border-focus); border-radius: 12px; box-shadow: 0 16px 50px rgba(0,0,0,.65); display: none; flex-direction: column; overflow: hidden; }
        #emoji-picker.show { display: flex; }
        .ep-top { display: flex; gap: 10px; padding: 12px; align-items: center; flex-shrink: 0; }
        .ep-top input { flex: 1; min-width: 0; background: var(--bg-0); border: 2px solid var(--accent); border-radius: 8px; color: var(--bright); padding: 9px 12px; font-size: 14px; outline: none; font-family: var(--font); }
        .ep-body { flex: 1; display: flex; min-height: 0; border-top: 1px solid var(--border); }
        .ep-rail { width: 54px; flex-shrink: 0; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; border-right: 1px solid var(--border); }
        .ep-rail::-webkit-scrollbar { width: 0; }
        .ep-r { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; border: none; background: transparent; cursor: pointer; font-size: 20px; display: flex; align-items: center; justify-content: center; color: var(--text); padding: 0; }
        .ep-r:hover { background: var(--bg-4); }
        .ep-rimg { width: 34px; height: 34px; border-radius: 10px; background-size: cover; background-position: center; display: block; }
        .ep-rtxt { width: 34px; height: 34px; border-radius: 10px; background: var(--bg-4); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--bright); }
        .ep-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 10px 8px; position: relative; }
        .ep-h { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: 12px 2px 6px; position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
        .ep-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
        .ep-e { background: transparent; border: none; border-radius: 8px; padding: 3px; cursor: pointer; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; }
        .ep-e:hover { background: var(--bg-4); }
        .ep-e img { width: 100%; height: 100%; max-width: 34px; max-height: 34px; object-fit: contain; }
        .ep-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); min-height: 58px; flex-shrink: 0; background: var(--bg-1); }
        .ep-foot img { width: 38px; height: 38px; object-fit: contain; }
        .ep-fn { font-weight: 800; color: var(--bright); } .ep-fs { font-size: 12px; color: var(--muted); }
        .cemoji { width: 22px; height: 22px; vertical-align: -5px; object-fit: contain; }
        .channel-item.muted { opacity: .5; }

        .cfg-hr { height: 1px; background: var(--border); margin: 22px 0 18px; }
        .rng-scale { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
        .rng { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--f, 0%), var(--bg-4) var(--f, 0%)); outline: 0; cursor: pointer; }
        .rng::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
        .rng::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }
        .cat-gear { margin-inline-start: auto; opacity: 0; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }
        @media (hover: hover) { .cat-label:hover .cat-gear { opacity: 1; } } .cat-gear:hover { color: var(--bright); }
        @media (hover: none) { .cat-gear { opacity: .6; } }

        body.readable, body.readable .msg-text, body.readable input, body.readable textarea { letter-spacing: .03em; word-spacing: .12em; line-height: 1.75; }
        .wn-v { margin: 8px 0 4px; color: var(--bright); } .wn-v span { color: var(--muted); font-size: 12px; margin-inline-start: 6px; }
        .wn-l { margin: 0 0 8px; padding-inline-start: 20px; color: var(--text); line-height: 1.55; font-size: 14px; }

.lp-card{display:flex;gap:12px;align-items:flex-start;max-width:440px;margin-top:6px;padding:10px 12px;border-radius:8px;background:var(--panel2,rgba(127,127,127,.12));border-inline-start:4px solid var(--accent);text-decoration:none;color:inherit;overflow:hidden}
.lp-card:hover{filter:brightness(1.08)}
.lp-txt{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}
.lp-txt small{color:var(--muted);font-size:11px}
.lp-txt b{font-size:14px;color:var(--accent);overflow-wrap:anywhere}
.lp-txt span{font-size:12.5px;color:var(--muted);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.lp-card img{width:80px;height:80px;object-fit:cover;border-radius:6px;flex:none}
@media(max-width:480px){.lp-card{max-width:100%}.lp-card img{width:64px;height:64px}}

        .msg-tr { margin-top: 4px; padding: 6px 10px; border-inline-start: 3px solid var(--accent); background: var(--accent-bg); border-radius: 4px; color: var(--text); font-size: var(--msg-fs, 14px); }
        .msg-tr small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
        .sched-quick { display: flex; gap: 8px; flex-wrap: wrap; }
        .sched-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
        .sched-row .sd { margin: 0; color: var(--muted); font-size: 12px; }
        .topic-ed { position: relative; background: var(--bg-0); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
        .topic-tools { display: flex; align-items: center; gap: 2px; padding: 8px 10px; background: var(--bg-3); }
        .topic-tools button { background: transparent; border: 0; color: var(--text); width: 32px; height: 28px; border-radius: 4px; cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; }
        .topic-tools button:hover { background: rgba(127,127,140,.2); }
        .topic-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
        .topic-ed textarea { display: block; width: 100%; min-height: 150px; resize: vertical; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; padding: 12px 14px 34px; }
        .topic-count { position: absolute; bottom: 8px; inset-inline-end: 14px; font-weight: 800; font-size: 13px; color: var(--bright); }
        .field-group label.radio-row { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }
        .field-group label.radio-row small { text-transform: none; letter-spacing: 0; font-size: 13px; }
        .radio-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; cursor: pointer; font-weight: 400; }
        .radio-row input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; margin: 1px 0 0; cursor: pointer; display: grid; place-content: center; }
        .radio-row input:checked { border-color: var(--accent); background: radial-gradient(circle, #fff 0 4px, var(--accent) 5px); }
        .radio-row b { display: block; color: var(--bright); font-size: 16px; font-weight: 500; } .radio-row small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; line-height: 1.4; }
        #server-header-container.has-banner, [data-theme] #server-header-container.has-banner { height: auto !important; aspect-ratio: var(--bn-ar, 2); min-height: 88px; box-sizing: border-box; align-items: flex-end; padding: 0 8px 10px 14px; background-size: cover; background-position: center; position: relative; border-bottom: 0; box-shadow: none; }
        .pane-header.has-banner::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0) 62%); pointer-events: none; }
        .pane-header.has-banner > * { position: relative; }
        .pane-header.has-banner .server-title-btn { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); font-size: 16px; }
        .pane-header.has-banner .server-title-btn span { color: #fff !important; }
        .pane-header.has-banner > .icon-btn { position: absolute; top: 8px; inset-inline-end: 8px; background: rgba(0,0,0,.4); color: #fff; border-radius: 50%; width: 30px; height: 30px; }
        #chan-gate { position: absolute; inset: 0; z-index: 6; background: var(--bg-2); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; }
        #chan-gate.show { display: flex; } #chan-gate h3 { color: var(--bright); font-size: 22px; } #chan-gate p { color: var(--muted); max-width: 420px; line-height: 1.5; }
        .banner-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
        .banner-sw { height: 50px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; background-size: cover; background-position: center; }
        .banner-sw:hover { border-color: var(--border-focus); } .banner-sw.selected { border-color: var(--bright); box-shadow: 0 0 0 2px var(--accent); }
        .trait-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
        .sv-icon { width: 72px; height: 72px; border-radius: 20px; border: 5px solid var(--bg-1); background: var(--bg-3) center / cover; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--bright); font-size: 24px; }
        .role-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
        .rc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
        .rc-color { width: 46px; height: 38px; border: 1px solid var(--border); background: transparent; border-radius: 6px; cursor: pointer; flex-shrink: 0; }
        .rc-perms { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
        .emoji-head, .emoji-row { display: grid; grid-template-columns: 56px 1fr 1fr 50px; align-items: center; gap: 10px; padding: 8px 10px; }
        .emoji-head { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); }
        .emoji-row { border-top: 1px solid var(--border); } .emoji-row img { width: 36px; height: 36px; object-fit: contain; }
        @media (max-width: 860px) { .trait-grid, .rc-perms { grid-template-columns: 1fr; } .banner-grid { grid-template-columns: repeat(5, 1fr); } }

        #nav-overlay { display: none; }

        /* ---------- mobile ---------- */
        @media (max-width: 860px) {
            .rail { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; z-index: 200; }
            .channels-pane { position: fixed; left: 72px; top: 0; bottom: 0; width: min(260px, calc(100vw - 72px)); transform: translateX(-200%); transition: transform .2s; z-index: 200; }
            body.nav-open .rail, body.nav-open .channels-pane { transform: none; }
            #nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 150; }
            body.nav-open #nav-overlay { display: block; }
            #btn-hamburger { display: inline-flex; }
            .members-pane { position: fixed; right: 0; top: 0; bottom: 0; transform: translateX(100%); transition: transform .2s; z-index: 200; width: min(260px, 80vw); }
            body.members-open .members-pane { transform: none; display: block; }
            .members-pane.hidden-pane { display: block; }
            #chat-search-input { width: 110px; } #chat-search-input:focus { width: 150px; }
            .msg { gap: 10px; padding: 2px 10px; } .msg-tools { right: 8px; }
            .composer-wrap { padding: 0 8px 6px; }
            .channel-topic-text { display: none; }
            .voice-floating-bar { gap: 6px; padding: 6px 10px; }
            .control-pill-btn { width: 40px; height: 40px; }
        }

        /* ================= settings / profile / themes (v3) ================= */
        :root[data-theme="midnight"] { --bg-0: #000; --bg-1: #060608; --bg-2: #0b0b0e; --bg-3: #15161b; --bg-4: #1e2027; --border: #1b1d23; --border-focus: #2c2f38; }
        :root[data-theme="light"] {
            --bg-0: #dfe1e5; --bg-1: #f2f3f5; --bg-2: #ffffff; --bg-3: #ebedf0; --bg-4: #dfe2e6; --border: #d6d8dc; --border-focus: #c3c6cc;
            --text: #44474f; --bright: #0b0b0d; --muted: #60636b; --accent-bg: rgba(139, 92, 246, .12);
        }
        :root[data-theme="light"] .tile, :root[data-theme="light"] .voice-call-screen { background: #e9ebee; }
        :root[data-theme="light"] .msg-tools, :root[data-theme="light"] .dialog-box { box-shadow: 0 6px 24px rgba(0,0,0,.15); }
        .msg-text { font-size: var(--msg-fs, 14.5px); }
        body.compact .msg { margin-top: 6px; gap: 10px; }
        body.compact .msg.grouped { margin-top: 0; }
        body.compact .msg-avatar { width: 28px; } body.compact .msg-gutter { width: 28px; }
        body.compact .msg-avatar .user-avatar { width: 28px !important; height: 28px !important; font-size: 10px !important; }
        body.hc { --text: #e8eaee; --muted: #aab0bc; --border: #3a3f4d; }
        body.ul .msg-text a { text-decoration: underline; }
        body.nomotion *, body.nomotion *::before, body.nomotion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
        body.showts .msg-gutter { visibility: visible; }

        dialog.fullscreen { background: var(--bg-2); backdrop-filter: none; align-items: stretch; justify-content: stretch; }
        .settings-shell { display: flex; width: 100%; height: 100%; }
        .settings-nav { width: 34%; min-width: 250px; max-width: 420px; background: var(--bg-1); display: flex; flex-direction: column; align-items: flex-end; overflow-y: auto; padding: 24px 6px 24px 20px; flex-shrink: 0; }
        .settings-nav-inner { width: 232px; max-width: 100%; display: flex; flex-direction: column; gap: 2px; }
        .settings-me { display: flex; align-items: center; gap: 10px; padding: 8px 6px 10px; margin-bottom: 8px; }
        .settings-me b { color: var(--bright); font-size: 15px; display: block; }
        .settings-me small { color: var(--muted); cursor: pointer; } .settings-me small:hover { color: var(--text); text-decoration: underline; }
        #settings-search { margin-bottom: 8px; }
        .snav-group { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 14px 10px 4px; }
        .snav { background: transparent; border: none; text-align: left; color: var(--muted); font-size: 15px; font-weight: 600; padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
        .snav:hover { background: rgba(127,127,140,.14); color: var(--text); }
        .snav.active { background: rgba(127,127,140,.2); color: var(--bright); }
        .snav.danger { color: #ff8a8d; } .snav.danger:hover { background: rgba(242,63,67,.14); }
        .snav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
        .snav-foot { font-size: 11px; color: var(--muted); padding: 8px 10px; }
        .settings-body { flex: 1; overflow-y: auto; position: relative; padding: 36px 40px 80px; background: var(--bg-2); }
        .settings-content { max-width: 720px; }
        .settings-close { position: fixed; top: 22px; right: 28px; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; z-index: 3; }
        .settings-close small { font-size: 8px; font-weight: 800; margin-top: 1px; }
        .settings-close:hover { color: var(--bright); border-color: var(--bright); }
        .spanel { display: none; } .spanel.active { display: block; }
        .spanel h2 { color: var(--bright); font-size: 22px; font-weight: 800; margin-bottom: 18px; }
        .spanel h3 { color: var(--bright); font-size: 17px; font-weight: 800; margin: 26px 0 12px; padding-top: 22px; border-top: 1px solid var(--border); }
        .sgroup-title { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; margin: 18px 0 8px; }
        .srow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; }
        .srow + .srow { border-top: 1px solid var(--border); }
        .srow .st { color: var(--bright); font-weight: 600; font-size: 15px; } .srow .sd { color: var(--muted); font-size: 13px; margin-top: 2px; max-width: 460px; }
        .sright { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
        .settings-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px; padding: 6px 18px; margin-bottom: 14px; }
        .switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
        .switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
        .switch i { position: absolute; inset: 0; background: #6b7080; border-radius: 12px; transition: .15s; }
        .switch i::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
        .switch input:checked + i { background: var(--green); } .switch input:checked + i::after { left: 21px; }
        .choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
        .choice { background: var(--bg-1); border: 2px solid var(--border); border-radius: 10px; padding: 10px 14px; cursor: pointer; color: var(--text); font-weight: 700; min-width: 110px; text-align: center; font-size: 13px; }
        .choice:hover { border-color: var(--border-focus); } .choice.selected { border-color: var(--accent); color: var(--bright); background: var(--accent-bg); }

        .wt-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin: 0 0 12px; max-width: 760px; width: 100%; }
        .wt-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; } .wt-top b { flex: 1; min-width: 120px; }
        .wt-top .wt-by { color: var(--muted); font-size: 12px; }
        .wt-frame { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; } .wt-frame iframe { width: 100%; height: 100%; pointer-events: none; border: 0; }
        .wt-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; } .wt-bar input[type=range] { flex: 1; min-width: 0; } .wt-bar .btn { padding: 6px 10px; display: inline-flex; align-items: center; gap: 4px; }
        .wt-time { color: var(--muted); font-size: 12px; min-width: 84px; text-align: center; }
        .wt-card:fullscreen { max-width: none; width: 100%; height: 100%; border: 0; border-radius: 0; margin: 0; display: flex; flex-direction: column; background: #000; }
        .wt-card:fullscreen .wt-frame { flex: 1; aspect-ratio: auto; border-radius: 0; min-height: 0; }

        #slash-pop { display: none; position: absolute; left: 16px; right: 16px; bottom: 100%; max-height: 300px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 -8px 28px rgba(0,0,0,.45); padding: 6px; z-index: 30; }
        #slash-pop.show { display: block; }
        #ment-pop { display: none; position: absolute; left: 16px; right: 16px; bottom: 100%; max-height: 260px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 -8px 28px rgba(0,0,0,.45); padding: 6px; z-index: 30; } #ment-pop.show { display: block; }
        .mp-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 7px; cursor: pointer; } .mp-row.sel, .mp-row:hover { background: var(--bg-3); } .mp-row b { color: var(--bright); } .mp-row small { color: var(--muted); }
        .sp-head { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; padding: 6px 8px 4px; }
        .sp-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
        .sp-row.sel, .sp-row:hover { background: var(--bg-3); }
        .sp-row .sp-ic { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-3); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; } .sp-row .sp-ic .ic { width: 15px; height: 15px; }
        .sp-row code { color: var(--bright); font-weight: 700; flex: none; white-space: nowrap; } .sp-row .sp-d { color: var(--muted); font-size: 12.5px; min-width: 0; flex: 1; white-space: normal; }
        .sp-row .sp-b { color: var(--muted); font-size: 11px; flex: none; max-width: 38%; text-align: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .bp-role { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; color: var(--bright); background: var(--bg-3); } .bp-role i { width: 10px; height: 10px; border-radius: 50%; }
        .bp-cmds div { padding: 3px 0; line-height: 1.45; } .bp-hint { color: var(--muted); font-size: 12px; margin-top: 8px; } .ar-cmd { direction: rtl; unicode-bidi: isolate; color: var(--accent); }
        .bl-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; } .bl-row:hover { background: var(--bg-3); } .bl-row b { color: var(--bright); } .bl-row small { display: block; color: var(--muted); }
        .swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; } .swatch.selected { border-color: var(--bright); box-shadow: 0 0 0 2px var(--bg-2) inset; }
        .mic-meter { height: 10px; background: var(--bg-3); border-radius: 5px; overflow: hidden; margin-top: 8px; } .mic-meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width .08s; }
        input[type=range].slider { width: 220px; accent-color: var(--accent); }
        .profile-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
        .pe-label { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
        textarea.system-input { resize: vertical; min-height: 84px; font-family: var(--font); }
        .savebar { position: sticky; bottom: -60px; margin-top: 22px; background: var(--bg-1); border: 1px solid var(--border-focus); border-radius: 8px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.4); }
        .savebar span { color: var(--text); font-size: 13px; }

        /* profile card (used in the popout, the preview and the user menu) */
        .profile-card, .profile-pop { background: var(--bg-1); border: 1px solid var(--border-focus); border-radius: 12px; overflow: hidden; }
        .profile-pop { width: 360px; max-width: calc(100vw - 20px); max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
        .pc-banner { height: 96px; background-color: var(--accent); background-size: cover; background-position: center; position: relative; }
        .pc-close { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); border: none; color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
        .pc-top { display: flex; align-items: flex-end; gap: 10px; padding: 0 16px; margin-top: -42px; position: relative; }
        .pc-avatar { border-radius: 50%; border: 6px solid var(--bg-1); background: var(--bg-1); line-height: 0; }
        .pc-avatar .sdot { border-color: var(--bg-1); border-width: 4px; }
        .pc-bubble { background: var(--bg-3); border: 1px solid var(--border); padding: 7px 12px; border-radius: 14px; font-size: 13px; color: var(--bright); margin-bottom: 8px; max-width: 220px; word-break: break-word; }
        .pc-body { padding: 8px 16px 16px; }
        .pc-name { font-size: 20px; font-weight: 800; color: var(--bright); word-break: break-word; }
        .pc-sub { color: var(--text); font-size: 13px; margin-top: 2px; }
        .pc-sec { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
        .pc-h { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; letter-spacing: .4px; }
        .pc-sec div:not(.pc-h) { font-size: 13px; color: var(--text); word-break: break-word; white-space: pre-wrap; }
        .pc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
        .pc-actions .btn { flex: 1 1 auto; text-align: center; }
        .pc-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
        .rchip { display: inline-flex; align-items: center; gap: 5px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; font-size: 12px; color: var(--bright); line-height: 18px; }
        .rchip > i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
        .rchip-x { display: none; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; line-height: 0; }
        .rchip-x .ic { width: 12px; height: 12px; }
        .rchip:hover .rchip-x { display: inline-flex; }
        .rchip:hover > i { display: none; }
        .rchip:hover .rchip-x:hover { color: var(--red); }
        .rchip-add { cursor: pointer; padding: 2px 5px; color: var(--muted); }
        .rchip-add:hover { color: var(--bright); border-color: var(--accent); }
        .rchip-add .ic { width: 14px; height: 14px; }
        .role-picker { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow: auto; }
        .role-picker .system-input { margin-bottom: 4px; padding: 6px 8px; }
        .rp-item { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); text-align: start; padding: 6px 8px; border-radius: 4px; cursor: pointer; font: inherit; font-size: 13px; }
        .rp-item:hover { background: var(--accent-bg); color: var(--bright); }
        .rp-item > i { width: 10px; height: 10px; border-radius: 50%; }
        .pc-live { display: flex; align-items: center; gap: 10px; margin-top: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
        .pc-live.on { border-color: var(--red); }
        .pcl-prev { width: 64px; height: 40px; border-radius: 5px; background: var(--bg-0); display: grid; place-items: center; position: relative; color: var(--muted); flex-shrink: 0; }
        .pcl-prev .vs-live { position: absolute; top: 3px; left: 3px; font-size: 8px; padding: 0 3px; }
        .pcl-t { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
        .pcl-t b { color: var(--bright); font-size: 13px; }
        .pcl-t span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .pcl-t .ic { width: 13px; height: 13px; }
        .pcl-stack { display: flex; align-items: center; padding-inline-start: 6px; } .pcl-stack > * { margin-inline-start: -8px; border: 2px solid var(--bg-2); border-radius: 50%; } .pcl-more { background: var(--bg-3); color: var(--muted); font-size: 10px; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; border-radius: 12px !important; }
        .pcl-status { font-style: italic; opacity: .85; } .pcl-srv { opacity: .8; font-size: 11.5px; }
        .pc-links { display: flex; flex-wrap: wrap; gap: 6px; } .pc-links a { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); background: var(--bg-3); font-size: 12.5px; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pc-links a:hover { border-color: var(--accent); } .pc-links .ic { width: 13px; height: 13px; flex: none; }
        .pc-timeout { display: flex; align-items: center; gap: 8px; color: var(--yellow); border-color: var(--yellow); font-size: 12.5px; }
        .pc-foot { display: flex; gap: 8px; margin-top: 14px; align-items: stretch; }
        .pc-foot .system-input { flex: 1; min-width: 0; margin: 0; }
        .pc-foot .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
        .pc-foot .pc-wide { flex: 1; }
        .mini-menu { position: fixed; z-index: 10050; display: none; flex-direction: column; min-width: 190px; background: var(--bg-1); border: 1px solid var(--border-focus); border-radius: 6px; padding: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
        .mini-menu.show { display: flex; }
        .mm-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: none; border: 0; color: var(--text); padding: 7px 9px; border-radius: 4px; cursor: pointer; font: inherit; font-size: 13px; text-align: start; }
        .mm-item:hover { background: var(--accent); color: #fff; }
        .mm-item.danger { color: var(--red); }
        .mm-item.danger:hover { background: var(--red); color: #fff; }
        .mm-item .ic { width: 15px; height: 15px; }
        .to-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

        #user-menu { position: fixed; left: 78px; bottom: 64px; width: 290px; z-index: 100001; display: none; box-shadow: 0 16px 50px rgba(0,0,0,.6); border-radius: 12px; }
        #user-menu.show { display: block; }
        #user-menu .pc-banner { height: 60px; }
        .um-list { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; margin: 12px 12px 0; padding: 4px; }
        .um-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px; cursor: pointer; color: var(--text); font-size: 14px; }
        .um-item:hover { background: var(--accent); color: #fff; }
        .um-item .sd { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
        @media (max-width: 860px) {
            .settings-shell { flex-direction: column; }
            .settings-nav { width: 100%; max-width: none; align-items: stretch; padding: 10px 12px; flex-direction: row; overflow: visible; flex: 0 0 auto; }
            .settings-nav-inner { flex-direction: row; flex-wrap: wrap; width: 100%; align-items: center; gap: 4px; }
            .settings-me, #settings-search, .snav-group, .snav-sep, .snav-foot { display: none; }
            .snav { white-space: nowrap; font-size: 13px; padding: 7px 10px; }
            .settings-body { padding: 18px 16px 90px; } .settings-close { top: 8px; right: 8px; }
            .profile-edit-grid { grid-template-columns: minmax(0, 1fr); }
            #user-menu { left: 10px; bottom: 64px; }
        }

        /* ---- alignment fixes ---- */
        .icon-btn, .quick-icon-btn, .control-pill-btn, .voice-dock-tile, .rail-btn { display: inline-flex; align-items: center; justify-content: center; line-height: 1; padding: 0; text-align: center; font-family: var(--font), 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; }
        .icon-btn { min-width: 30px; height: 30px; font-size: 16px; }
        .quick-icon-btn { width: 32px; height: 32px; font-size: 16px; }
        .rail-btn { display: flex; }
        .ico { width: 22px; height: 22px; display: block; flex-shrink: 0; }
        .icon-btn .ico { width: 18px; height: 18px; }
        .rail-btn.action .ico { width: 22px; height: 22px; }
        .server-title-btn { line-height: 1.2; }
        .members-pane .section-header, .channels-pane > .section-header { height: 40px; padding-top: 0; padding-bottom: 0; align-items: center; }
        .members-pane .section-header { height: 48px; border-bottom: 1px solid var(--border); margin-bottom: 4px; padding-left: 16px; }
        #chat-search-input { flex: 0 1 180px; min-width: 70px; }
        .main-header .icon-btn { flex-shrink: 0; }
        .composer { align-items: center; }
        .composer .icon-btn { height: 36px; min-width: 36px; font-size: 18px; }
        #chat-input { align-self: center; }
        .user-avatar { line-height: 1; }
        .member-row .user-avatar, .msg-avatar .user-avatar { flex-shrink: 0; }
        .voice-dock-tile { height: 34px; font-size: 16px; }
        .control-pill-btn { font-size: 18px; }

        /* ---- context menu ---- */
        #ctx-menu { position: fixed; z-index: 100003; min-width: 188px; max-width: 260px; background: var(--bg-0); border: 1px solid var(--border-focus); border-radius: 8px; padding: 6px 8px; box-shadow: 0 12px 40px rgba(0,0,0,.6); display: none; }
        #ctx-menu.show { display: block; }
        .ctx-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; box-sizing: border-box; padding: 6px 8px; border-radius: 4px; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text); cursor: pointer; white-space: nowrap; }
        .ctx-item:hover { background: var(--accent); color: #fff; }
        .ctx-item.lic { justify-content: flex-start; gap: 8px; padding: 6px 8px; font-size: 14px; }
        .ctx-item.lic .ctx-ico svg { width: 16px; height: 16px; } .ctx-item.lic .ctx-lbl { flex: 1; }
        .ctx-item.lic .ctx-ico { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; }
        .ctx-box { width: 16px; height: 16px; border: 1.5px solid currentColor; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; opacity: .8; } .ctx-box.on { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; }
        #ctx-menu.srv-menu { min-width: 220px; max-width: 240px; padding: 6px 8px; border-radius: 8px; }
        .ctx-item.danger { color: #ff8a8d; } .ctx-item.danger:hover { background: var(--red); color: #fff; }
        .ctx-ico { font-size: 13px; opacity: .8; min-width: 16px; text-align: center; font-weight: 800; }
        .ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }
        .cat-label { cursor: pointer; display: flex; align-items: center; gap: 4px; user-select: none; }
        .cat-label:hover { color: var(--bright); }
        .cat-arrow { display: inline-flex; transition: transform .15s; transform: rotate(90deg); }
        .cat-arrow svg { width: 11px; height: 11px; }
        .cat-label.folded .cat-arrow { transform: rotate(0deg); }
        :root[dir="rtl"] .cat-label.folded .cat-arrow { transform: rotate(180deg); }
        :root[dir="rtl"] .cat-arrow { transform: rotate(90deg); }
        #ctx-sub { position: fixed; z-index: 100004; min-width: 190px; max-width: 280px; max-height: 70vh; overflow-y: auto; background: var(--bg-0); border: 1px solid var(--border-focus); border-radius: 8px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.6); display: none; }
        #ctx-sub.show { display: block; }
        #ctx-menu { max-height: calc(100vh - 12px); overflow-y: auto; }
        .ctx-slider { padding: 6px 10px 8px; }
        .ctx-sl-h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
        .ctx-sl-h b { color: var(--accent-hi); }
        .ctx-slider input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
        .ctx-chk { width: 16px; height: 16px; border: 1.5px solid var(--border-focus); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: #fff; }
        .ctx-chk.on { background: var(--accent); border-color: var(--accent); }
        .ctx-chk svg { width: 13px; height: 13px; }
        .ctx-item:hover .ctx-chk { border-color: #fff; }
        .ctx-hint { display: block; font-size: 11px; font-weight: 500; opacity: .65; margin-top: 1px; }
        .ctx-has-sub > .ctx-ico svg, .ctx-chev svg { width: 14px; height: 14px; }
        .ctx-item.lic .ctx-chev { margin-inline-start: auto; opacity: .7; min-width: 14px; }
        :root[dir="rtl"] .ctx-has-sub .ctx-chev svg, :root[dir="rtl"] .ctx-has-sub > .ctx-ico svg { transform: scaleX(-1); }

        /* ---- final polish ---- */
        .snav:focus, .snav:focus-visible { outline: none; }
        .snav:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
        @media (max-width: 860px) { .settings-nav { padding-right: 56px; } }

        /* ================= SYSTEM24 THEME (terminal-style panels, monospace, labelled borders) ================= */
        :root[data-theme="system24"] {
            --bg-0: #000000; --bg-1: #1c1c1e; --bg-2: #1c1c1e; --bg-3: #000000; --bg-4: #2c2c2e;
            --border: #3a3a3c; --border-focus: #5a5a5e;
            --text: #b5bac1; --bright: #f2f3f5; --muted: #80869a;   /* was #5e6471: secondary text (times, labels, topics) only reached 2.9:1 contrast */
            --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Mono', 'Consolas', 'Courier New', 'Noto Sans Arabic', monospace;
            --mono: var(--font);
        }
        [data-theme="system24"] body { font-size: 13px; letter-spacing: 0; }
        [data-theme="system24"] * { scrollbar-width: thin; scrollbar-color: #3a3a3c transparent; }
        [data-theme="system24"] ::-webkit-scrollbar { width: 6px; height: 6px; }
        [data-theme="system24"] ::-webkit-scrollbar-thumb { background: #3a3a3c; border: 0; border-radius: 3px; }
        [data-theme="system24"] #footer-credits { left: 50%; right: auto; transform: translateX(-50%); bottom: 2px; opacity: 1; font-size: 10px; letter-spacing: .5px; background: rgba(11,12,14,.7); padding: 1px 8px; border-radius: 3px; }

        /* radii: everything is small and square-ish like a TUI (avatars stay round) */
        [data-theme="system24"] .dialog-box, [data-theme="system24"] .profile-pop, [data-theme="system24"] .profile-card, [data-theme="system24"] .settings-card,
        [data-theme="system24"] .pc-sec, [data-theme="system24"] #ctx-menu, [data-theme="system24"] #emoji-picker, [data-theme="system24"] .toast-item,
        [data-theme="system24"] .role-card, [data-theme="system24"] .choice, [data-theme="system24"] .auth-card, [data-theme="system24"] .tile,
        [data-theme="system24"] .screen-card, [data-theme="system24"] .savebar, [data-theme="system24"] .quality-btn, [data-theme="system24"] .banner-sw,
        [data-theme="system24"] .voice-floating-bar, [data-theme="system24"] .friends-search-bar, [data-theme="system24"] .reaction, [data-theme="system24"] .msg-tools,
        [data-theme="system24"] .chat-file-download, [data-theme="system24"] .mic-meter, [data-theme="system24"] .ep-top input, [data-theme="system24"] .pc-bubble { border-radius: 4px; }
        [data-theme="system24"] .system-input, [data-theme="system24"] .auth-input, [data-theme="system24"] select.system-input, [data-theme="system24"] .btn,
        [data-theme="system24"] .icon-btn, [data-theme="system24"] .menu-item, [data-theme="system24"] .ctx-item, [data-theme="system24"] .um-item,
        [data-theme="system24"] .snav, [data-theme="system24"] .nav-tab, [data-theme="system24"] .channel-item, [data-theme="system24"] .member-row,
        [data-theme="system24"] .voice-member-subitem, [data-theme="system24"] .auth-submit-action, [data-theme="system24"] .friend-row-card, [data-theme="system24"] .ep-e,
        [data-theme="system24"] .ep-r, [data-theme="system24"] .quick-icon-btn, [data-theme="system24"] .voice-dock-tile, [data-theme="system24"] .edit-input { border-radius: 3px; }
        [data-theme="system24"] .control-pill-btn { border-radius: 8px; }
        [data-theme="system24"] .control-pill-btn.danger-leave { border-radius: 8px; }
        [data-theme="system24"] .voice-floating-bar { border-radius: 10px; }
        [data-theme="system24"] .btn { font-weight: 400; }
        [data-theme="system24"] .sv-icon { border-radius: 8px; }
        [data-theme="system24"] .settings-nav { border-right: 1px solid var(--border); }
        [data-theme="system24"] .pc-name, [data-theme="system24"] .auth-header-title, [data-theme="system24"] .spanel h2 { letter-spacing: 0; }

        /* ---- desktop: four bordered panels with a gap, each carrying a small label on its border ---- */
        @media (min-width: 861px) {
            [data-theme="system24"] .app { padding: 10px; gap: 10px; background: var(--bg-0); }
            [data-theme="system24"] .rail, [data-theme="system24"] .channels-pane, [data-theme="system24"] .main, [data-theme="system24"] .members-pane {
                background: var(--bg-1); border: 1px solid var(--border); border-radius: 4px; position: relative; overflow: visible;
            }
            [data-theme="system24"] .main { background: var(--bg-1); }
            [data-theme="system24"] .rail::before, [data-theme="system24"] .channels-pane::before, [data-theme="system24"] .main::before, [data-theme="system24"] .members-pane::before {
                position: absolute; top: -7px; left: 10px; padding: 0 6px; background: var(--bg-0); color: var(--muted); font-size: 10px; line-height: 12px;
                letter-spacing: 1px; text-transform: uppercase; z-index: 6; pointer-events: none;
            }
            [data-theme="system24"] .rail::before { content: 'nav'; left: 8px; }
            [data-theme="system24"] .channels-pane::before { content: 'channels'; }
            [data-theme="system24"] .main::before { content: 'readout'; }
            [data-theme="system24"] .members-pane::before { content: 'members'; }
            [data-theme="system24"] .members-pane.k-fade { -webkit-mask: none; mask: none; }   /* the scroll-fade mask cut the top half off the "members" plate label that sits on the pane's edge */
            [data-theme="system24"] .rail { width: 62px; padding: 16px 0 10px; --bg-rail: var(--bg-1); }
            [data-theme="system24"] #servers-container { overflow-y: auto; overflow-x: hidden; min-height: 0; flex: 0 1 auto; }
            [data-theme="system24"] #servers-container::-webkit-scrollbar { width: 0; }
            [data-theme="system24"] .members-pane { display: flex; flex-direction: column; padding-bottom: 0; }
            [data-theme="system24"] .members-pane.hidden-pane { display: none; }
            [data-theme="system24"] #members-container { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 12px; }
            [data-theme="system24"] .pane-header, [data-theme="system24"] .main-header { border-top-left-radius: 4px; border-top-right-radius: 4px; }
        }
        @media (max-width: 860px) {
            [data-theme="system24"] .rail, [data-theme="system24"] .channels-pane { border-right: 1px solid var(--border); }
            [data-theme="system24"] .members-pane { border-left: 1px solid var(--border); }
            [data-theme="system24"] .app { background: var(--bg-1); }
        }

        /* server rail: small square icons with an outline, like the original */
        [data-theme="system24"] .rail-btn { width: 42px; height: 42px; border-radius: 8px; background-color: #18191c; border: 1px solid var(--border); font-size: 11px; color: var(--bright); }
        [data-theme="system24"] .rail-btn::before { display: none; }
        [data-theme="system24"] .rail-btn:hover, [data-theme="system24"] .rail-btn.active { border-radius: 8px; border-color: var(--accent); background-color: var(--accent-bg); }
        [data-theme="system24"] .rail-btn.active { box-shadow: 0 0 6px var(--accent-bg); }
        [data-theme="system24"] .rail-btn.has-img:hover, [data-theme="system24"] .rail-btn.has-img.active { background-color: #18191c; }
        [data-theme="system24"] .rail-btn.unread { border-color: var(--text); }
        [data-theme="system24"] .rail-btn.admin { color: #ef4444; border-color: #ef4444; }
        [data-theme="system24"] .rail-btn.admin:hover, [data-theme="system24"] .rail-btn.admin.active { background-color: #ef4444; color: #fff; }
        [data-theme="system24"] .rail-btn.action { background-color: transparent; border-style: dashed; color: var(--muted); }
        [data-theme="system24"] .rail-btn.action:hover { color: var(--bright); border-color: var(--bright); background-color: transparent; }
        [data-theme="system24"] .rail-sep { width: 24px; height: 1px; }
        [data-theme="system24"] .badge { border-color: var(--bg-1); }

        /* channel lists / members / headers */
        [data-theme="system24"] .pane-header, [data-theme="system24"] .main-header { height: 44px; box-shadow: none; border-bottom: 1px solid var(--border); }
        [data-theme="system24"] .server-title-btn { font-size: 12px; }
        [data-theme="system24"] #chat-title-heading { font-size: 13px; color: var(--bright); }
        [data-theme="system24"] .section-header, [data-theme="system24"] .list-label, [data-theme="system24"] .member-group { letter-spacing: 1px; font-size: 10px; }
        [data-theme="system24"] .channel-item { color: var(--text); }
        [data-theme="system24"] .channel-item:hover { background: rgba(255,255,255,.04); color: var(--bright); }
        [data-theme="system24"] .channel-item.active { background: var(--accent-bg); color: var(--accent-hi); }
        [data-theme="system24"] .channel-item.unread { color: var(--bright); }
        [data-theme="system24"] .user-status-bar { background: transparent; border-top: 1px solid var(--border); }
        [data-theme="system24"] .voice-connected-dock { background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; margin: 0 8px 8px; }
        [data-theme="system24"] .sdot { border-color: var(--bg-1); }

        /* messages: flat rows with a left accent bar on hover */
        [data-theme="system24"] .chat-messages { padding: 8px 0; gap: 0; }
        [data-theme="system24"] .msg { margin: 6px 8px 0; padding: 8px 10px; border-left: 2px solid transparent; background: rgba(255,255,255,.015); border-radius: 3px; }
        [data-theme="system24"] .msg.grouped { margin-top: 2px; }
        [data-theme="system24"] .msg:hover { border-left-color: var(--accent); background: rgba(255,255,255,.03); }
        [data-theme="system24"] .msg.mention { border-left-color: var(--yellow); background: rgba(240,178,50,.06); box-shadow: none; }
        [data-theme="system24"] .msg-author { color: var(--bright); }
        [data-theme="system24"] .msg-time { color: var(--muted); }
        [data-theme="system24"] .msg-tools { right: 10px; top: -12px; }
        [data-theme="system24"] .date-divider { margin: 14px 12px 4px; letter-spacing: 1px; text-transform: uppercase; font-size: 10px; }
        [data-theme="system24"] .composer-wrap { padding: 0 10px 8px; }
        [data-theme="system24"] .composer { background: #090a0c; border: 1px solid var(--border); min-height: 40px; }
        [data-theme="system24"] .composer:focus-within { border-color: var(--accent); }
        [data-theme="system24"] #reply-bar { border: 1px solid var(--border); border-bottom: 0; border-radius: 3px 3px 0 0; background: #0d0e11; }
        [data-theme="system24"] #reply-bar.show + .composer { border-radius: 0 0 3px 3px; }
        [data-theme="system24"] .reaction { background: transparent; border: 1px solid var(--border); }
        [data-theme="system24"] .reaction.mine { background: var(--accent-bg); border-color: var(--accent); }

        /* inputs, buttons, dialogs */
        [data-theme="system24"] .system-input, [data-theme="system24"] .auth-input, [data-theme="system24"] select.system-input { background: var(--bg-3); border: 1px solid var(--border); }
        [data-theme="system24"] .btn { text-transform: lowercase; letter-spacing: .3px; padding: 6px 11px; }
        [data-theme="system24"] .dialog-box, [data-theme="system24"] .profile-pop, [data-theme="system24"] .auth-card { background: var(--bg-1); border: 1px solid var(--border-focus); box-shadow: 0 10px 40px rgba(0,0,0,.7); }
        [data-theme="system24"] dialog { background: rgba(0,0,0,.82); backdrop-filter: none; }
        [data-theme="system24"] dialog.fullscreen { background: var(--bg-0); }
        [data-theme="system24"] #auth-dialog, [data-theme="system24"] #boot-screen { background: #000000 radial-gradient(circle at center, #1b1633 0%, #000000 85%); }
        [data-theme="system24"] .panel-label { letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,.04); padding-bottom: 6px; }
        [data-theme="system24"] .settings-body, [data-theme="system24"] .settings-nav { background: var(--bg-1); }
        [data-theme="system24"] .snav.active { background: var(--accent-bg); color: var(--accent-hi); }
        [data-theme="system24"] .snav-group, [data-theme="system24"] .field-group label, [data-theme="system24"] .field-label, [data-theme="system24"] .pc-h, [data-theme="system24"] .pe-label { letter-spacing: 1px; }
        [data-theme="system24"] .profile-card, [data-theme="system24"] .profile-pop { background: var(--bg-1); }
        [data-theme="system24"] .pc-sec { background: var(--bg-3); }
        [data-theme="system24"] .toast-item { background: #1c1c1e; border: 1px solid var(--accent); border-left: 4px solid var(--accent); }
        [data-theme="system24"] .toast-item.error { border-color: var(--red); border-left-color: var(--red); }
        [data-theme="system24"] .toast-item.success { border-color: var(--green); border-left-color: var(--green); }
        [data-theme="system24"] #ctx-menu, [data-theme="system24"] #emoji-picker { background: var(--bg-1); }
        [data-theme="system24"] .ep-h { background: var(--bg-1); }
        [data-theme="system24"] .voice-call-screen { background: var(--bg-3); }
        [data-theme="system24"] .tile { background: #3a3a3c; border: 1px solid transparent; }
        [data-theme="system24"] .tile.speaking { border-color: var(--green); }
        [data-theme="system24"] .voice-stage-title { background: var(--bg-1); }

        /* ================= roles / permissions / templates / polls / quick switcher ================= */
        .roles-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
        .rl-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 4px; cursor: pointer; color: var(--text); border: 1px solid transparent; }
        .rl-item:hover { background: rgba(255,255,255,.05); }
        .rl-item.selected { background: var(--accent-bg); border-color: var(--accent); color: var(--bright); }
        .rl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
        .rl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
        .rl-n { font-size: 11px; color: var(--muted); }
        .rl-mv { display: flex; flex-direction: column; }
        .rl-mv .icon-btn { min-width: 18px; height: 14px; font-size: 9px; padding: 0; }
        .rl-mv .icon-btn:disabled { opacity: .25; cursor: default; }
        .role-editor { background: var(--bg-1); border: 1px solid var(--border); border-radius: 6px; padding: 16px; min-width: 0; }
        .re-tabs { display: flex; gap: 8px; margin: 12px 0 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
        .perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
        .perm-row .st { color: var(--bright); font-weight: 600; } .perm-row .sd { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 520px; }
        .switch input:disabled + i { opacity: .4; }
        .tri { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; flex-shrink: 0; }
        .tri-b { width: 34px; height: 30px; border: 0; background: var(--bg-3); color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 800; }
        .tri-b + .tri-b { border-left: 1px solid var(--border); }
        .tri-b.deny.on { background: var(--red); color: #fff; } .tri-b.allow.on { background: var(--green); color: #fff; } .tri-b.inh.on { background: var(--bg-4); color: var(--bright); }
        .chperm-layout { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: minmax(0, 1fr); gap: 16px; height: min(60vh, 560px); }
        #chperm-dialog .dialog-actions { position: static; margin-top: 12px; }
        #chperm-dialog .sd { line-height: 1.5; unicode-bidi: plaintext; }
        .chperm-layout > div { overflow-y: auto; min-width: 0; }
        .chperm-add { display: flex; gap: 6px; margin-top: 10px; }
        .tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
        .tpl-card { background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px; padding: 12px; cursor: pointer; }
        .tpl-card:hover { border-color: var(--accent); } .tpl-card.selected { border-color: var(--accent); background: var(--accent-bg); }
        .tpl-ico { font-size: 26px; } .tpl-name { font-weight: 800; color: var(--bright); margin: 4px 0 2px; } .tpl-desc { font-size: 11px; color: var(--muted); line-height: 1.35; }
        .tpl-line { font-size: 12px; color: var(--text); margin-top: 4px; word-break: break-word; }
        #cs-preview { margin-top: 10px; max-height: 190px; overflow-y: auto; }
        .poll { background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin-top: 6px; max-width: 460px; }
        .poll-q { font-weight: 800; color: var(--bright); margin-bottom: 8px; }
        .poll-opt { position: relative; display: flex; justify-content: space-between; width: 100%; padding: 8px 10px; margin-bottom: 5px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; overflow: hidden; text-align: start; font-family: inherit; }
        .poll-opt:disabled { cursor: default; }
        .poll-opt.mine { border-color: var(--accent); }
        .po-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-bg); z-index: 0; transition: width .2s; }
        .po-t, .po-n { position: relative; z-index: 1; } .po-n { color: var(--muted); font-size: 12px; margin-inline-start: 10px; }
        .poll-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); margin-top: 6px; }
        .qs-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 4px; cursor: pointer; }
        .qs-item.sel, .qs-item:hover { background: var(--accent-bg); color: var(--bright); } .qs-sub { color: var(--muted); font-size: 11px; }
        @media (max-width: 860px) { .roles-layout, .chperm-layout { grid-template-columns: 1fr; } .chperm-layout { grid-template-rows: auto minmax(0, 1fr); } .chperm-layout > div:first-child { max-height: 40%; } .tpl-grid { grid-template-columns: 1fr 1fr; } }

        /* ================= RTL (Arabic) ================= */
        :root[dir="rtl"] body { letter-spacing: 0; }
        :root[dir="rtl"] .md-code, :root[dir="rtl"] .md-pre, :root[dir="rtl"] code { font-family: var(--mono); direction: ltr; unicode-bidi: plaintext; }
        :root[dir="rtl"] #toast-container { right: auto; left: 16px; }
        :root[dir="rtl"] .badge { right: auto; left: -4px; }
        :root[dir="rtl"] .sdot { right: auto; left: -2px; }
        :root[dir="rtl"] .msg-tools { right: auto; left: 16px; }
        :root[dir="rtl"][data-theme="system24"] .msg-tools { right: auto; left: 10px; }
        :root[dir="rtl"] .msg-reply { border-left: 0; border-right: 2px solid var(--border-focus); padding-left: 0; padding-right: 8px; }
        :root[dir="rtl"][data-theme="system24"] .msg { border-left: 0; border-right: 2px solid transparent; }
        :root[dir="rtl"][data-theme="system24"] .msg:hover { border-right-color: var(--accent); }
        :root[dir="rtl"][data-theme="system24"] .msg.mention { border-right-color: var(--yellow); }
        :root[dir="rtl"] .msg.mention { box-shadow: inset -3px 0 0 var(--yellow); }
        :root[dir="rtl"] .md-quote { border-left: 0; border-right: 4px solid var(--border-focus); padding-left: 0; padding-right: 10px; }
        :root[dir="rtl"] .rail-btn::before { left: auto; right: -12px; border-radius: 4px 0 0 4px; }
        :root[dir="rtl"][data-theme="system24"] .rail::before { left: auto; right: 8px; }
        :root[dir="rtl"][data-theme="system24"] .channels-pane::before, :root[dir="rtl"][data-theme="system24"] .main::before, :root[dir="rtl"][data-theme="system24"] .members-pane::before { left: auto; right: 10px; }
        :root[dir="rtl"] .settings-close { right: auto; left: 28px; }
        :root[dir="rtl"] .settings-nav { padding: 24px 20px 24px 6px; }
        :root[dir="rtl"] .pc-close { right: auto; left: 8px; }
        :root[dir="rtl"] .stream-quality-badges { right: auto; left: 10px; }
        :root[dir="rtl"] .tile-label, :root[dir="rtl"] .stream-user-overlay { left: auto; right: 10px; }
        :root[dir="rtl"] #user-menu { left: auto; right: 78px; }
        :root[dir="rtl"] .menu-item, :root[dir="rtl"] .poll-opt { text-align: start; }
        :root[dir="rtl"] .po-bar { inset: 0 0 0 auto; }
        :root[dir="rtl"] .poll-opt .po-n { margin-inline-start: 10px; }
        :root[dir="rtl"] .composer-wrap, :root[dir="rtl"] #chat-input { text-align: start; }
        :root[dir="rtl"] .server-title-btn { text-align: start; }
        :root[dir="rtl"] .switch input:checked + i::after { left: auto; right: 21px; }
        :root[dir="rtl"] .switch i::after { left: auto; right: 3px; }
        :root[dir="rtl"] .switch input:checked + i::after { right: auto; left: 3px; }
        :root[dir="rtl"] .tri-b + .tri-b { border-left: 0; border-right: 1px solid var(--border); }
        :root[dir="rtl"] .rl-mv { margin-inline-start: auto; }
        :root[dir="rtl"] .friends-top-nav { direction: rtl; }
        :root[dir="rtl"] .ep-rail { border-right: 0; border-left: 1px solid var(--border); }
        :root[dir="rtl"][data-theme="system24"] .settings-nav { border-right: 0; border-left: 1px solid var(--border); }
        :root[dir="rtl"] .typing-indicator, :root[dir="rtl"] .date-divider { text-align: start; }
        :root[dir="rtl"] input[type="text"], :root[dir="rtl"] textarea { text-align: start; }
        :root[dir="rtl"] #chat-search-input { text-align: start; }

        :root[lang="ar"][data-theme="system24"] .rail::before { content: 'التنقل'; }
        :root[lang="ar"][data-theme="system24"] .channels-pane::before { content: 'القنوات'; }
        :root[lang="ar"][data-theme="system24"] .main::before { content: 'العرض'; }
        :root[lang="ar"][data-theme="system24"] .members-pane::before { content: 'الأعضاء'; }

        .voice-floating-bar { flex-wrap: wrap; justify-content: center; left: 0; right: 0; transform: none; margin: 0 auto; width: fit-content; max-width: calc(100% - 24px); gap: 8px; }
        .voice-floating-bar .control-pill-btn { width: 40px; height: 40px; font-size: 16px; }
        .voice-floating-bar .control-pill-btn.danger-leave { width: 52px; }
        .vc-caret { height: 40px; }
        .vc-split { display: flex; align-items: center; background: var(--bg-4); border-radius: 22px; }
        .vc-split .control-pill-btn { background: transparent; }
        .vc-split .control-pill-btn.active { background: var(--accent); }
        .vc-caret { border: none; background: transparent; color: var(--bright); cursor: pointer; padding: 0 9px 0 2px; height: 44px; font-size: 11px; }
        .vc-caret:hover { color: var(--accent); }
        .vc-sep { width: 1px; height: 26px; background: var(--border); }
        [data-theme="system24"] .vc-split { border-radius: 8px; }
        .vc-popover { position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%); width: 320px; max-width: calc(100% - 24px); background: var(--bg-2); border: 1px solid var(--border-focus); border-radius: 10px; padding: 14px; z-index: 60; display: none; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
        .vc-popover.open { display: block; }
        .vc-popover label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; }
        .vc-popover label:first-child { margin-top: 0; }
        .vc-popover select { width: 100%; }
        .vc-popover .vc-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--bright); }
        .tile-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 4px; z-index: 4; }
        .tile:hover .tile-tools, .tile.pinned .tile-tools { display: flex; }
        .tile-tool { width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(8,9,12,.8); color: #fff; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 0; }
        .tile-tool:hover { background: var(--accent); }
        .tile-badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; z-index: 3; }
        .tile-badge { background: rgba(8,9,12,.8); color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 11px; font-weight: 700; }
        .tile-badge.red { background: var(--red); }
        /* while a stream is on screen the controls fade out after a moment and come back when the mouse moves */
        .voice-call-screen .stream-quality-badges, .voice-call-screen .stream-viewer-bar, .voice-call-screen .vc-corner, .voice-call-screen .vc-corner-r, .voice-call-screen .voice-stage-title, .voice-call-screen .voice-floating-bar, .voice-call-screen .tile-tools { transition: opacity .25s ease; }
        .voice-call-screen.ui-idle .stream-quality-badges, .voice-call-screen.ui-idle .stream-viewer-bar, .voice-call-screen.ui-idle .vc-corner, .voice-call-screen.ui-idle .vc-corner-r, .voice-call-screen.ui-idle .voice-stage-title, .voice-call-screen.ui-idle .voice-floating-bar, .voice-call-screen.ui-idle .tile-tools { opacity: 0; pointer-events: none; }
        .voice-call-screen.ui-idle .screen-card, .voice-call-screen.ui-idle .screen-video { cursor: none; }
        body:has(#voice-call-screen.ui-idle) .main-header { opacity: 0; pointer-events: none; transition: opacity .25s ease; } .main-header { transition: opacity .25s ease; }
        .tile-av { transform: scale(var(--avs, 1)); transition: transform .15s; }
        .stream-viewer-bar { position: absolute; bottom: 10px; right: 10px; display: flex; align-items: center; gap: 8px; background: rgba(10,11,14,.88); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; z-index: 5; font-size: 12px; color: #fff; }
        .stream-viewer-bar input[type=range] { width: 90px; }
        .stream-viewer-bar button { background: transparent; border: none; color: #fff; cursor: pointer; font-size: 14px; padding: 2px 4px; }
        .stream-viewer-bar button:hover { color: var(--accent); }
        .stream-viewer-bar button { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; border-radius: 8px; padding: 0; line-height: 1; }
        .stream-viewer-bar button .ic { width: 16px; height: 16px; }
        .stream-viewer-bar button:hover { background: rgba(255,255,255,.1); }
        .stream-viewer-bar { padding: 3px 6px; }
        .stream-hidden { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-size: 13px; color: var(--bright); }
        :root[lang="ar"]:not(.font-picked) body, :root[lang="ar"]:not(.font-picked) button, :root[lang="ar"]:not(.font-picked) input, :root[lang="ar"]:not(.font-picked) textarea, :root[lang="ar"]:not(.font-picked) select, :root[lang="ar"]:not(.font-picked) #chat-input { font-family: 'Cairo', var(--font), sans-serif; }
        :root[lang="ar"] .msg-text, :root[lang="ar"] .msg-reply, :root[lang="ar"] .md-quote, :root[lang="ar"] #chat-input, :root[lang="ar"] .poll-q { unicode-bidi: plaintext; text-align: start; }
        .voice-call-screen:fullscreen { background: var(--bg-0); width: 100vw; height: 100vh; }   /* the corner Fullscreen button targets the whole call screen, not the card: without a size it kept only its content height (about half the screen) in the fullscreen top layer, where there is no flex parent */
        /* full screen streams fill the whole screen and are never cropped */
        .screen-card:fullscreen { width: 100vw; height: 100vh; min-height: 0; border: 0; border-radius: 0; }
        .screen-card:fullscreen .screen-video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
        .voice-call-screen:fullscreen .screen-video { max-height: none; }
        .tile:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; border: 0; border-radius: 0; }
        .tile:fullscreen .tile-video { object-fit: contain !important; }
        /* several streams at once cap the card at 46vh (css/02): that cap outranks the plain :fullscreen rule above, so a card
           put full screen on its own used to stay half a screen high. In full screen the cap is off. */
        #stage-screen-slot.multi .screen-card:fullscreen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; }
        #stage-screen-slot.multi .screen-card:fullscreen .screen-video { max-height: none; height: 100%; }
        /* a watched stream tile has no :fullscreen rule of its own: with its 16/9 shape it would also stop at half height */
        .ms-card:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; border: 0; border-radius: 0; }
        .ms-card:fullscreen video { width: 100%; height: 100%; max-height: none; object-fit: contain; }

        .voice-floating-bar { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; bottom: 18px; background: var(--bg-1); border-radius: 12px; }
        .voice-floating-bar .control-pill-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-4); }
        .voice-floating-bar .control-pill-btn:hover { background: var(--bg-5, #3a3f4d); }
        .voice-floating-bar .vi, .vc-item .vi { width: 22px; height: 22px; }
        .vc-split { background: var(--bg-4); border-radius: 24px; }
        .vc-split .control-pill-btn, .vc-split .control-pill-btn:hover { background: transparent; }
        .vc-caret { height: 44px; padding: 0 10px 0 0; }
        .voice-floating-bar .control-pill-btn.off, .vc-split:has(.off) { background: rgba(237,66,69,.22); color: #ff7b7e; }
        .vc-split:has(.off) .control-pill-btn { background: transparent; color: #ff7b7e; }
        .voice-floating-bar .control-pill-btn.active { background: var(--accent); color: #fff; }
        .voice-floating-bar .control-pill-btn.danger-leave { width: 56px; border-radius: 24px; background: var(--red); color: #fff; }
        .voice-floating-bar .control-pill-btn.danger-leave .vi { width: 26px; height: 26px; }
        [data-theme="system24"] .voice-floating-bar .control-pill-btn, [data-theme="system24"] .vc-split { border-radius: 8px; }
        [data-theme="system24"] .voice-floating-bar .control-pill-btn.danger-leave { border-radius: 8px; }
        .vc-more { display: none !important; }
        @media (max-width: 1100px) { .vc-extra { display: none !important; } .vc-more { display: inline-flex !important; } }
        @media (max-width: 520px) { .voice-floating-bar { gap: 4px; padding: 6px 8px; } .voice-floating-bar .control-pill-btn { width: 38px; height: 38px; } .vc-caret { height: 38px; padding: 0 6px 0 0; } .voice-floating-bar .control-pill-btn.danger-leave { width: 46px; } }
        .vc-item { display: flex; align-items: center; gap: 12px; width: 100%; background: transparent; border: none; color: var(--bright); padding: 9px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; text-align: start; }
        .vc-item:hover { background: var(--bg-4); }
        .vc-popover { bottom: 84px; }

        .quick-icon-btn .vi, .voice-dock-tile .vi { width: 18px; height: 18px; }
        .quick-icon-btn.off, .voice-dock-tile.off { color: #ff7b7e; background: rgba(237,66,69,.2); }
        .voice-floating-bar .control-pill-btn.off, .voice-floating-bar .control-pill-btn.off.active { background: rgba(237,66,69,.22); color: #ff7b7e; }

        .voice-call-screen { background: #000; }
        [data-theme="system24"] .voice-call-screen { background: var(--bg-0); }
        .voice-stage-title { position: absolute; top: 0; left: 0; right: 0; background: transparent !important; border: none !important; font-size: 14px; padding: 12px 16px; z-index: 5; pointer-events: none; }
        .voice-stage-grid { align-items: center; justify-content: safe center; padding: 56px 24px 110px; }
        .voice-stage-grid > * { width: 100%; max-width: 1150px; }
        #stage-members { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
        #stage-members .tile:only-child { aspect-ratio: 16 / 9; max-height: 62vh; width: 100%; margin: 0 auto; }
        .tile { background: #3a3a3c; border-radius: 12px; }
        [data-theme="system24"] .tile { background: var(--bg-1); }
        .tile-label { background: rgba(0,0,0,.65); border-radius: 6px; font-size: 14px; padding: 4px 10px; }
        #stage-alone { display: none; justify-content: center; gap: 10px; margin-top: 14px; }
        #stage-alone .btn { display: inline-flex; align-items: center; gap: 8px; background: #1e1f22; border: 1px solid var(--border); color: var(--bright); padding: 10px 18px; border-radius: 8px; cursor: pointer; font-size: 15px; }
        #stage-alone .btn:hover { background: var(--bg-4); }
        #stage-alone .vi { width: 20px; height: 20px; }
        /* short windows (a phone on its side): the call bar would cover these two buttons, and both are already there
           (the invite button in the bottom corner, Soundboard in the call bar), so the empty room shows only your tile */
        @media (max-height: 470px) { #stage-alone { display: none !important; } }
        .vc-corner { position: absolute; width: 40px; height: 40px; border-radius: 8px; border: none; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 6; padding: 0; }
        .vc-corner:hover { background: rgba(255,255,255,.08); color: var(--bright); }
        .vc-corner .vi { width: 22px; height: 22px; }
        .vc-chat { top: 8px; right: 10px; }
        .vc-inv { bottom: 16px; left: 14px; }
        .vc-corner-r { position: absolute; bottom: 16px; right: 14px; display: flex; gap: 4px; z-index: 6; }
        .vc-corner-r .vc-corner { position: static; }
        .voice-floating-bar { background: transparent !important; border: none !important; box-shadow: none !important; gap: 10px; bottom: 14px; padding: 0; flex-wrap: nowrap; }
        .vc-group { display: flex; align-items: center; gap: 4px; background: #121214; border: 1px solid var(--border); border-radius: 12px; padding: 5px; }
        [data-theme="system24"] .vc-group { background: var(--bg-1); border-radius: 6px; }
        .vc-group .vc-split { background: transparent; border-radius: 8px; }
        .vc-group .control-pill-btn { background: transparent; border-radius: 8px; width: 44px; height: 44px; }
        .vc-group .control-pill-btn:hover, .vc-group .vc-split:hover { background: rgba(255,255,255,.08); }
        .vc-caret { color: var(--muted); font-size: 16px; padding: 0 8px 0 0; }
        .voice-floating-bar .control-pill-btn.danger-leave { width: 64px; height: 54px; border-radius: 12px; }
        [data-theme="system24"] .voice-floating-bar .control-pill-btn.danger-leave { border-radius: 6px; }
        .vc-popover { position: fixed; transform: none; bottom: auto; width: 320px; z-index: 5000; }
        .sb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 4px; }
        .sb-btn { display: flex; align-items: center; gap: 8px; background: var(--bg-3); border: 1px solid var(--border); color: var(--bright); border-radius: 8px; padding: 10px; cursor: pointer; font-size: 13px; }
        .sb-btn:hover { background: var(--accent-bg, var(--bg-4)); border-color: var(--accent); }
        .sb-btn span { font-size: 20px; }
        /* sidebar voice panel */
        .voice-connected-dock { padding: 12px; gap: 10px; }
        .voice-dock-sig { width: 44px; height: 44px; border-radius: 10px; background: #1e1f22; border: 1px solid var(--border); color: var(--green); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
        .voice-dock-sig .vi { width: 24px; height: 24px; }
        .voice-dock-top { gap: 10px; }
        .voice-status-title { font-size: 17px; }
        .voice-ping-ico { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
        .voice-ping-ico .vi { width: 20px; height: 20px; }
        .voice-hang { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px; display: flex; }
        .voice-hang:hover { color: var(--red); }
        .voice-hang .vi { width: 24px; height: 24px; }
        .voice-dock-tile { height: 44px; background: #1e1f22; border: 1px solid var(--border); border-radius: 10px; }
        .voice-dock-tile .vi { width: 22px; height: 22px; }
        .voice-dock-tile.active { background: var(--accent-bg); color: var(--accent-hi); }
        /* user bar split buttons */
        .ub-split { display: flex; align-items: center; border-radius: 8px; }
        .ub-split:hover { background: rgba(255,255,255,.06); }
        .ub-caret { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 0 1px 0 0; font-size: 15px; height: 32px; }
        /* a little narrower so an 8-10 letter name fits next to the controls instead of cutting to "test…" */
        .ub-split .quick-icon-btn { width: 29px; }
        .user-status-bar .user-pill { padding-inline: 4px 2px; gap: 7px; }
        .user-quick-controls > .quick-icon-btn { width: 30px; }
        .user-status-bar { padding-inline: 6px; }
        .ub-split .quick-icon-btn:hover { background: transparent; }
        .ub-split:has(.off) .quick-icon-btn { color: #ff7b7e; }
        .voice-status-title { font-size: 15px; white-space: nowrap; gap: 6px; }
        .voice-dock-left { min-width: 0; }
        .voice-stage-title { display: none !important; }
        .voice-dock-sig { width: 40px; height: 40px; }

        .chat-sticker-img { width: 160px; height: 160px; object-fit: contain; display: block; margin-top: 6px; }
        .sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
        .sticker-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; font-size: 12px; position: relative; }
        .sticker-card img { width: 100%; height: 90px; object-fit: contain; margin-bottom: 6px; }
        .sticker-card .btn-danger { position: absolute; top: 4px; right: 4px; padding: 2px 6px; }
        .sticker-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 260px; overflow-y: auto; }
        .sticker-pick-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px; cursor: pointer; }
        .sticker-pick-btn:hover { background: var(--bg-4); border-color: var(--border-focus); }
        .cv-c { width: 100%; max-width: 480px; aspect-ratio: 1; image-rendering: pixelated; cursor: crosshair; border: 1px solid var(--border); border-radius: 8px; touch-action: manipulation; display: block; margin: 0 auto; }
        .cv-pal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; max-width: 480px; margin: 10px auto 6px; }
        .cv-sw { height: 28px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; padding: 0; }
        .cv-sw.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
        .cv-hint { text-align: center; color: var(--muted); font-size: 12px; }
        .gif-tabs { display: flex; gap: 6px; margin-bottom: 4px; }
        .gif-tabs .btn.on { background: var(--accent); color: #fff; }
        .gif-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 280px; overflow-y: auto; position: relative; }
        .gif-pick-btn { background: var(--bg-3); border: 1px solid transparent; border-radius: 8px; padding: 0; cursor: pointer; overflow: hidden; min-height: 70px; }
        .gif-pick-btn:hover { border-color: var(--border-focus); }
        .gif-pick-btn img { width: 100%; height: 100%; max-height: 110px; object-fit: cover; display: block; }
        .gif-unfav { position: absolute; margin: 4px 0 0 -26px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
        .sticker-pick-btn img { width: 100%; height: 62px; object-fit: contain; display: block; }
        .voice-status-title { white-space: normal; flex-wrap: wrap; font-size: 14px; line-height: 1.25; row-gap: 0; }
        .voice-dock-left { overflow: visible; }
        /* numbers never overlap or get cut: the timer and the ping keep their own room, the title and channel name give way */
        .voice-dock-top > * { min-width: 0; }
        .voice-dock-sig, .voice-ping-ico, .voice-hang { flex: none; }
        .voice-ping-ico, .voice-ping-ico b, .voice-timer-badge { white-space: nowrap; }
        .voice-timer-badge { flex: none; font-variant-numeric: tabular-nums; }
        .voice-ping-ico b { font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
        .voice-channel-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        /* as expected: "Voice Connected" stays on one line, the ping is just the signal icon (number on hover), the channel name gets the room */
        .voice-status-title { flex-wrap: nowrap !important; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; align-items: baseline; }
        .voice-status-title { font-size: 13px !important; gap: 6px !important; } .voice-dock-top { gap: 6px !important; }
        /* classic bottom panel: game row, voice row and buttons in one card, rows divided by thin lines */
        .game-dock { display: none; align-items: center; gap: 12px; padding: 12px; background: var(--bg-0); border-top: 1px solid var(--border); flex-shrink: 0; }
        .game-dock .gd-ic { width: 44px; height: 44px; border-radius: 8px; flex: none; position: relative; overflow: hidden; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 40) 50% 28%)); }
        .game-dock .gd-ic:has(.gicon.has) { background: #000; } .game-dock .gd-ic:has(.gicon.has) b { visibility: hidden; }
        .game-dock .gd-t { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
        .game-dock .gd-t b { font-size: 15px; font-weight: 600; color: var(--bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .game-dock .gd-t span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
        .game-dock kbd { font: 700 10px var(--font); padding: 2px 5px; border-radius: 4px; background: var(--bg-3); color: var(--text); border: 0; }
        .game-dock .gd-clip { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
        .game-dock .gd-clip:hover { background: var(--bg-3); color: var(--bright); } .game-dock .gd-clip svg { width: 20px; height: 20px; }
        .voice-connected-dock { gap: 12px !important; }
        .voice-connected-dock .voice-status-title { font-size: 15px !important; font-weight: 600; color: #6fc790; }
        .voice-connected-dock .voice-dock-tiles { gap: 8px; }
        .voice-connected-dock .voice-dock-tile { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 10px 0; }
        .voice-connected-dock .voice-dock-tile:hover { background: var(--bg-3); }
        .voice-ping-ico b { display: none; } .voice-connected-dock .voice-timer-badge { display: none; }
        .voice-ping-ico .vi { display: block !important; width: 20px; height: 20px; }
        .voice-dock-left { overflow: hidden !important; }
        @media (max-width: 1100px) { .voice-dock-sig { width: 36px; height: 36px; } .voice-dock-top { gap: 8px; } }
        /* ---- light themes: the base rules above were written for dark backgrounds ----
           :where() keeps these at the same weight as the rules they replace, so active / selected states still win */
        :root[data-theme="light"] { --hover: rgba(0, 0, 0, .05); --hover-strong: rgba(0, 0, 0, .08); }
        :where(:root[data-theme="light"]) .icon-btn:hover, :where(:root[data-theme="light"]) .channel-item:hover, :where(:root[data-theme="light"]) .voice-member-subitem:hover,
        :where(:root[data-theme="light"]) .user-pill:hover, :where(:root[data-theme="light"]) .nav-tab:hover, :where(:root[data-theme="light"]) .friend-row-card:hover,
        :where(:root[data-theme="light"]) .member-row:hover, :where(:root[data-theme="light"]) .rl-item:hover, :where(:root[data-theme="light"]) .ub-split:hover { background: var(--hover); }
        :where(:root[data-theme="light"]) .quick-icon-btn:hover, :where(:root[data-theme="light"]) .vc-corner:hover,
        :where(:root[data-theme="light"]) .vc-group .control-pill-btn:hover, :where(:root[data-theme="light"]) .vc-group .vc-split:hover { background: var(--hover-strong); }
        :where(:root[data-theme="light"]) .ub-split .quick-icon-btn:hover { background: transparent; }
        /* button text was a fixed pastel (#d8c8ff, #ff8a8d, #6fd49a) that almost disappears on white */
        :where(:root[data-theme="light"]) .btn { color: var(--accent-hi); }
        :where(:root[data-theme="light"]) .btn-danger, :where(:root[data-theme="light"]) .snav.danger, :where(:root[data-theme="light"]) .ctx-item.danger { color: #c4282c; }
        :where(:root[data-theme="light"]) .db-status-pill { color: #17803f; }
        :where(:root[data-theme="light"]) .btn-success { color: #17803f; }
        :where(:root[data-theme="light"]) .btn:hover, :where(:root[data-theme="light"]) .btn-danger:hover, :where(:root[data-theme="light"]) .ctx-item.danger:hover { color: #fff; }
        :where(:root[data-theme="light"]) .btn-success:hover { color: #04130a; }
        :root[data-theme="light"] .owner-tag { color: #a16207; background: rgba(250, 204, 21, .18); border-color: rgba(161, 98, 7, .35); }
        :where(:root[data-theme="light"]) .reaction.mine { color: var(--bright); }
        :where(:root[data-theme="light"]) .md-mention { color: var(--accent-hi); background: var(--accent-bg); }
        :where(:root[data-theme="light"]) .md-mention.me { color: #8a5a00; background: rgba(240, 178, 50, .25); }
        :root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c4c7ce; background-clip: content-box; }
        :root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #a9adb6; background-clip: content-box; }

        /* ---- classic alignment ---- */
        /* header: the # / speaker / friends mark is a muted line icon in front of the name */
        #chat-title-heading .hd-ic { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); margin-inline-end: 6px; vertical-align: -4px; font-weight: 600; font-size: 1.15em; line-height: 1; }
        #chat-title-heading .hd-ic .ic { width: 20px; height: 20px; }
        /* message rhythm: the name row is 22px tall, so a one-line message is as tall as its avatar and the
           gap after the first message of a group is the same as the gap between the others */
        body:not(.compact) .msg-head { line-height: 22px; }
        /* replies: the avatar lines up with the author's name (not with the quoted line above it),
           and a curved spine runs from the avatar up to the quote instead of a flat bar */
        .msg { --msg-gap: 14px; }
        .msg-reply { line-height: 18px; margin-bottom: 2px; }
        .msg:has(> .msg-body > .msg-reply:first-child) > .msg-avatar:not(.bot-av) { position: relative; padding-top: 22px; }
        .msg:has(> .msg-body > .msg-reply:first-child) > .msg-avatar:not(.bot-av)::before {
            content: ''; position: absolute; top: 9px; left: calc(50% - 1px); width: calc(50% + var(--msg-gap) - 5px); height: 9px;
            border-left: 2px solid var(--border-focus); border-top: 2px solid var(--border-focus); border-top-left-radius: 6px; pointer-events: none;
        }
        :root[dir="rtl"] .msg:has(> .msg-body > .msg-reply:first-child) > .msg-avatar:not(.bot-av)::before { left: auto; right: calc(50% - 1px); border-left: 0; border-right: 2px solid var(--border-focus); border-top-left-radius: 0; border-top-right-radius: 6px; }
        .msg:has(> .msg-avatar:not(.bot-av)) > .msg-body > .msg-reply:first-child { border-left: 0; border-right: 0; padding-inline-start: 0; }
        @media (max-width: 860px) { .msg { --msg-gap: 10px; } }
        body.compact .msg { --msg-gap: 10px; }
        /* topic sits after a thin divider, like the usual header */
        #chat-topic-display:not(:empty) { border-inline-start: 1px solid var(--border-focus); padding-inline-start: 12px; margin-inline-start: 4px; line-height: 20px; }
        .friends-search-bar .fsb-ic { display: inline-flex; color: var(--muted); } .friends-search-bar .fsb-ic .ic { width: 16px; height: 16px; }
        /* unread channel: a small white pill on the sidebar edge, as on the server rail */
        .channel-item.unread:not(.muted) { position: relative; }
        .channel-item.unread:not(.muted)::before { content: ''; position: absolute; left: -8px; top: 50%; width: 4px; height: 8px; margin-top: -4px; border-radius: 0 4px 4px 0; background: var(--bright); pointer-events: none; }
        :root[dir="rtl"] .channel-item.unread:not(.muted)::before { left: auto; right: -8px; border-radius: 4px 0 0 4px; }
    
/* download page: nothing of an older look shows while the page's own styles (css/101-site-v2.css with js/78-site-v2.js, which make it visible) are still loading,
   and the app and sign-in page behind it stay undrawn */
#landing { visibility: hidden; background: #0b0b0c; }
html:has(#landing:not([hidden])) .app { visibility: hidden; content-visibility: hidden; }
html:has(#landing:not([hidden])) #auth-dialog { display: none !important; }
html:has(#landing:not([hidden])), html:has(#landing:not([hidden])) body { background: #0b0b0c; }
html.ld-pre #boot-screen { background: #0b0b0c !important; }
/* the loading screen stays up until the download page is ready to show, so there is no empty gap between them */
html:has(#landing:not([hidden]):not(.ld-on)) #boot-screen { display: flex !important; }

/* a blocked person's messages, folded into one quiet line */
.msg-blocked { display: flex; align-items: center; gap: 8px; margin: 4px 16px; padding: 6px 10px; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--border); border-radius: 6px; cursor: pointer; }
.msg-blocked .ic { width: 14px; height: 14px; flex: none; }
.msg-blocked u { margin-inline-start: auto; text-decoration: none; color: var(--accent); }
.msg-blocked:hover, .msg-blocked:focus-visible { border-color: var(--accent); outline: none; }
