        /* =============================================
           CSS Reset & Variables
           ============================================= */
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        /* Prevent iOS text-size inflation */
        html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

        /* iOS auto-zoom prevention: Safari zooms any input with font-size < 16px.
           This catch-all uses absolute px to guarantee the threshold is met.
           touch-action: manipulation also disables double-tap-to-zoom on inputs. */
        input, textarea, select, [contenteditable] {
            font-size: 16px !important;
            touch-action: manipulation;
        }

        /* -- Dark theme (default) -- */
        [data-theme="dark"] {
            --bg:            #0f172a;
            --bg-surface:    #1e293b;
            --bg-elevated:   #334155;
            --bg-hover:      #283548;
            --bg-message-own:#1e3a5f;
            --text:          #f1f5f9;
            --text-muted:    #94a3b8;
            --text-faint:    #64748b;
            --accent:        #3b82f6;
            --accent-hover:  #2563eb;
            --accent-faint:  rgba(59,130,246,0.12);
            --danger:        #ef4444;
            --success:       #22c55e;
            --border:        #334155;
            --border-light:  #1e293b;
            --radius:        10px;
            --radius-lg:     16px;
            --radius-full:   9999px;
            --shadow:        0 1px 3px rgba(0,0,0,0.3);
            --shadow-lg:     0 8px 24px rgba(0,0,0,0.4);
            --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            --font-mono:     'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
            --scrollbar-thumb: #475569;
            --scrollbar-track: transparent;
        }

        /* -- Light theme -- */
        [data-theme="light"] {
            --bg:            #f1f5f9;
            --bg-surface:    #ffffff;
            --bg-elevated:   #e2e8f0;
            --bg-hover:      #f0f4f8;
            --bg-message-own:#dbeafe;
            --text:          #0f172a;
            --text-muted:    #64748b;
            --text-faint:    #94a3b8;
            --accent:        #2563eb;
            --accent-hover:  #1d4ed8;
            --accent-faint:  rgba(37,99,235,0.08);
            --danger:        #dc2626;
            --success:       #16a34a;
            --border:        #e2e8f0;
            --border-light:  #f1f5f9;
            --radius:        10px;
            --radius-lg:     16px;
            --radius-full:   9999px;
            --shadow:        0 1px 3px rgba(0,0,0,0.08);
            --shadow-lg:     0 8px 24px rgba(0,0,0,0.1);
            --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            --font-mono:     'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
            --scrollbar-thumb: #cbd5e1;
            --scrollbar-track: transparent;
        }

        html, body {
            height: 100%;
            overflow: hidden;
            /* Prevent iOS bounce scroll and horizontal overflow */
            overscroll-behavior: none;
            overflow-x: hidden;
            width: 100%;
            max-width: 100vw;
            /* Disable double-tap-to-zoom globally; preserves tap, scroll, pinch */
            touch-action: manipulation;
        }

        body {
            font-family: var(--font);
            background: var(--bg);
            color: var(--text);
            transition: background 0.25s, color 0.25s;
        }

        /* =============================================
           Scrollbar Styling
           ============================================= */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
        ::-webkit-scrollbar-thumb {
            background: var(--scrollbar-thumb);
            border-radius: 3px;
        }

        /* =============================================
           Screens: Auth, Chat List, Conversation
           ============================================= */
        .screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            flex-direction: column;
            overflow: hidden;
            /* iOS safe areas — top/bottom only, no left/right to avoid horizontal overflow */
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
        }
        .screen.active {
            display: flex;
        }

        /* ----------- AUTH SCREEN ----------- */
        #authScreen {
            align-items: center;
            justify-content: center;
        }
        .auth-container {
            width: 100%;
            max-width: 400px;
            padding: 2rem;
        }
        .logo {
            text-align: center;
            margin-bottom: 2rem;
        }
        .logo h1 {
            font-size: 1.75rem;
            font-weight: 700;
            letter-spacing: -0.025em;
        }
        .logo p {
            color: var(--text-muted);
            font-size: 0.875rem;
            margin-top: 0.5rem;
        }
        .card {
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
        }
        .tabs {
            display: flex;
            margin-bottom: 1.5rem;
            border-radius: var(--radius);
            overflow: hidden;
            border: 1px solid var(--border);
        }
        .tab {
            flex: 1;
            padding: 0.625rem;
            text-align: center;
            font-size: 0.875rem;
            font-weight: 500;
            background: transparent;
            color: var(--text-muted);
            border: none;
            cursor: pointer;
            transition: all 0.15s;
        }
        .tab.active {
            background: var(--accent);
            color: white;
        }
        .form-group {
            margin-bottom: 1rem;
        }
        .form-group label {
            display: block;
            font-size: 0.8125rem;
            font-weight: 500;
            color: var(--text-muted);
            margin-bottom: 0.375rem;
        }
        .form-group input {
            width: 100%;
            padding: 0.625rem 0.875rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 1rem;
            font-family: var(--font);
            outline: none;
            transition: border-color 0.15s;
        }
        .form-group input:focus {
            border-color: var(--accent);
        }
        .btn {
            width: 100%;
            padding: 0.75rem;
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius);
            font-size: 0.9375rem;
            font-weight: 600;
            font-family: var(--font);
            cursor: pointer;
            transition: background 0.15s;
            margin-top: 0.5rem;
        }
        .btn:hover { background: var(--accent-hover); }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn-sm {
            width: auto;
            padding: 0.375rem 0.875rem;
            font-size: 0.8125rem;
            margin-top: 0;
        }
        .btn-outline {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
        }
        .btn-outline:hover {
            background: var(--bg-elevated);
            color: var(--text);
        }
        .error-msg {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.3);
            color: var(--danger);
            padding: 0.625rem 0.875rem;
            border-radius: var(--radius);
            font-size: 0.8125rem;
            margin-bottom: 1rem;
            display: none;
        }
        .hidden { display: none !important; }

        /* ----------- CHAT LIST SCREEN ----------- */
        .chat-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.875rem 1rem;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }
        .chat-header h1 {
            font-size: 1.25rem;
            font-weight: 700;
            letter-spacing: -0.02em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0;
        }
        .header-actions {
            display: flex;
            align-items: center;
            gap: 0.375rem;
            flex-shrink: 1;
            flex-wrap: nowrap;
            overflow: hidden;
        }
        .icon-btn {
            width: 36px;
            height: 36px;
            min-width: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: var(--radius);
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            transition: all 0.15s;
            font-size: 1.125rem;
        }
        .icon-btn:hover {
            background: var(--bg-elevated);
            color: var(--text);
        }
        .icon-btn svg {
            width: 20px;
            height: 20px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* Filter bar */
        .filter-bar {
            display: flex;
            gap: 0.375rem;
            padding: 0.625rem 1rem;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            overflow-x: auto;
        }
        .filter-chip {
            padding: 0.3125rem 0.75rem;
            border-radius: var(--radius-full);
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            font-size: 0.8125rem;
            font-family: var(--font);
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .filter-chip.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }
        .filter-chip:not(.active):hover {
            background: var(--bg-hover);
        }

        /* Conversation list */
        .conversation-list {
            flex: 1;
            overflow-y: auto;
            padding: 0.375rem 0;
        }
        .conv-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem 1rem;
            cursor: pointer;
            transition: background 0.1s;
            border-bottom: 1px solid var(--border-light);
        }
        .conv-item:hover {
            background: var(--bg-hover);
        }
        .conv-avatar {
            width: 48px;
            height: 48px;
            border-radius: var(--radius-full);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 1rem;
            color: white;
            flex-shrink: 0;
            position: relative;
        }
        .conv-avatar .online-dot {
            position: absolute;
            bottom: 1px;
            right: 1px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--success);
            border: 2px solid var(--bg-surface);
        }
        .conv-body {
            flex: 1;
            min-width: 0;
        }
        .conv-top {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            gap: 0.5rem;
        }
        .conv-name {
            font-weight: 600;
            font-size: 0.9375rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .conv-time {
            font-size: 0.75rem;
            color: var(--text-faint);
            flex-shrink: 0;
        }
        .conv-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 0.5rem;
            margin-top: 0.1875rem;
        }
        .conv-preview {
            font-size: 0.8125rem;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .conv-badge {
            background: var(--accent);
            color: white;
            font-size: 0.6875rem;
            font-weight: 700;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: var(--radius-full);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .conv-fav {
            color: #fbbf24;
            font-size: 0.75rem;
            margin-left: 0.25rem;
        }
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 3rem 1rem;
            color: var(--text-muted);
            text-align: center;
            gap: 0.75rem;
        }
        .empty-state svg {
            width: 48px;
            height: 48px;
            stroke: var(--text-faint);
            fill: none;
            stroke-width: 1.5;
        }
        .empty-state p {
            font-size: 0.875rem;
        }

        /* FAB - New Chat */
        .fab {
            position: fixed;
            bottom: calc(1.5rem + env(safe-area-inset-bottom));
            right: 1.5rem;
            width: 52px;
            height: 52px;
            border-radius: var(--radius-full);
            background: var(--accent);
            color: white;
            border: none;
            cursor: pointer;
            box-shadow: var(--shadow-lg);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.15s, background 0.15s;
            z-index: 10;
        }
        .fab:hover {
            background: var(--accent-hover);
            transform: scale(1.05);
        }
        .fab svg {
            width: 24px;
            height: 24px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        /* ----------- CONVERSATION VIEW SCREEN ----------- */
        .conv-header {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.875rem 1rem;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            overflow: hidden;
        }
        .conv-header-info {
            flex: 1;
            min-width: 0;
            cursor: pointer;
        }
        .conv-header-name {
            font-weight: 600;
            font-size: 1rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .conv-header-status {
            font-size: 0.75rem;
            color: var(--text-muted);
        }
        .back-btn {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text);
            cursor: pointer;
            border-radius: var(--radius);
            transition: background 0.15s;
            flex-shrink: 0;
        }
        .back-btn:hover {
            background: var(--bg-elevated);
        }
        .back-btn svg {
            width: 22px;
            height: 22px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* Messages area */
        .messages-area {
            flex: 1;
            overflow-y: auto;
            padding: 1rem;
            display: flex;
            flex-direction: column;
            gap: 0.125rem;
        }
        .msg-date-divider {
            text-align: center;
            color: var(--text-faint);
            font-size: 0.75rem;
            margin: 1rem 0 0.5rem;
            position: relative;
        }
        .msg-date-divider span {
            background: var(--bg);
            padding: 0 0.75rem;
            position: relative;
            z-index: 1;
        }
        .msg-date-divider::before {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            top: 50%;
            height: 1px;
            background: var(--border);
        }
        .msg-group {
            display: flex;
            flex-direction: row;
            align-items: flex-end;
            gap: 0.5rem;
            margin-bottom: 0.375rem;
        }
        .msg-group.own {
            flex-direction: row-reverse;
        }
        .msg-group.other {
            flex-direction: row;
        }
        .msg-avatar {
            width: 32px;
            height: 32px;
            border-radius: var(--radius-full);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 0.6875rem;
            color: white;
            overflow: hidden;
            align-self: flex-end;
        }
        .msg-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: var(--radius-full);
        }
        .msg-content {
            display: flex;
            flex-direction: column;
            gap: 0.125rem;
            min-width: 0;
            max-width: 75%;
        }
        .msg-group.own .msg-content {
            align-items: flex-end;
        }
        .msg-group.other .msg-content {
            align-items: flex-start;
        }
        .msg-sender {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--accent);
            margin-bottom: 0.125rem;
            margin-left: 0.25rem;
        }
        .msg-bubble {
            padding: 0.5rem 0.75rem;
            border-radius: var(--radius-lg);
            word-wrap: break-word;
            overflow-wrap: break-word;
            white-space: pre-wrap;
            font-size: 0.9375rem;
            line-height: 1.45;
            position: relative;
        }
        .msg-group.own .msg-bubble {
            background: var(--bg-message-own);
            border-bottom-right-radius: 4px;
        }
        .msg-group.other .msg-bubble {
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-bottom-left-radius: 4px;
        }
        .msg-time {
            font-size: 0.625rem;
            color: var(--text-faint);
            margin-top: 0.125rem;
            padding: 0 0.25rem;
            display: flex;
            align-items: center;
            gap: 0.25rem;
        }
        .msg-lock {
            display: inline-flex;
            color: var(--success);
            opacity: 0.8;
        }
        .msg-lock svg {
            width: 10px;
            height: 10px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2.5;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .msg-group.own .msg-time {
            justify-content: flex-end;
        }

        /* Typing indicator */
        .typing-indicator {
            display: none;
            padding: 0.25rem 1rem;
            font-size: 0.8125rem;
            color: var(--text-muted);
            font-style: italic;
            flex-shrink: 0;
        }
        .typing-indicator.visible {
            display: block;
        }

        /* Load more sentinel */
        .load-more-sentinel {
            height: 1px;
            width: 100%;
        }
        .loading-spinner {
            text-align: center;
            padding: 0.5rem;
            color: var(--text-faint);
            font-size: 0.8125rem;
        }

        /* Message input */
        .message-input-area {
            display: flex;
            align-items: flex-end;
            gap: 0.5rem;
            padding: 0.75rem 1rem;
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
            background: var(--bg-surface);
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }
        .message-input-area textarea {
            flex: 1;
            padding: 0.625rem 0.875rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            color: var(--text);
            font-size: 1rem;
            font-family: var(--font);
            outline: none;
            resize: none;
            min-height: 42px;
            max-height: 120px;
            line-height: 1.4;
            transition: border-color 0.15s;
        }
        .message-input-area textarea:focus {
            border-color: var(--accent);
        }
        .send-btn {
            width: 42px;
            height: 42px;
            border-radius: var(--radius-full);
            background: var(--accent);
            border: none;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, transform 0.1s;
            flex-shrink: 0;
        }
        .send-btn:hover {
            background: var(--accent-hover);
        }
        .send-btn:active {
            transform: scale(0.95);
        }
        .send-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .send-btn svg {
            width: 20px;
            height: 20px;
            fill: currentColor;
        }

        /* ----------- MODALS ----------- */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            z-index: 100;
            align-items: flex-end;
            justify-content: center;
        }
        .modal-overlay.active {
            display: flex;
        }
        .modal {
            background: var(--bg-surface);
            border-radius: var(--radius-lg) var(--radius-lg) 0 0;
            width: 100%;
            max-width: 480px;
            max-height: 80vh;
            max-height: min(80vh, calc(var(--vh, 100vh) * 0.8));
            display: flex;
            flex-direction: column;
            animation: slideUp 0.2s ease-out;
        }
        @keyframes slideUp {
            from { transform: translateY(100%); }
            to { transform: translateY(0); }
        }
        .modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 1.25rem;
            border-bottom: 1px solid var(--border);
        }
        .modal-header h2 {
            font-size: 1.125rem;
            font-weight: 600;
        }
        .modal-close {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: var(--radius);
            font-size: 1.25rem;
        }
        .modal-close:hover {
            background: var(--bg-elevated);
        }
        .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 1rem 1.25rem;
        }
        .modal-footer {
            padding: 0.75rem 1.25rem;
            border-top: 1px solid var(--border);
        }

        /* Modal tabs */
        .modal-tabs {
            display: flex;
            gap: 0;
            margin-bottom: 1rem;
            border-radius: var(--radius);
            overflow: hidden;
            border: 1px solid var(--border);
        }
        .modal-tab {
            flex: 1;
            padding: 0.5rem;
            text-align: center;
            font-size: 0.8125rem;
            font-weight: 500;
            background: transparent;
            color: var(--text-muted);
            border: none;
            cursor: pointer;
            transition: all 0.15s;
        }
        .modal-tab.active {
            background: var(--accent);
            color: white;
        }

        /* User list in modals */
        .user-select-list {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }
        .user-select-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.625rem 0.5rem;
            border-radius: var(--radius);
            cursor: pointer;
            transition: background 0.1s;
        }
        .user-select-item:hover {
            background: var(--bg-hover);
        }
        .user-select-item.selected {
            background: var(--accent-faint);
        }
        .user-select-item .mini-avatar {
            width: 36px;
            height: 36px;
            border-radius: var(--radius-full);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 0.8125rem;
            color: white;
            flex-shrink: 0;
        }
        .user-select-item .user-select-info {
            flex: 1;
            min-width: 0;
        }
        .user-select-item .user-select-name {
            font-weight: 500;
            font-size: 0.9375rem;
        }
        .user-select-item .user-select-username {
            font-size: 0.75rem;
            color: var(--text-muted);
        }
        .user-select-item .check-mark {
            color: var(--accent);
            font-weight: 700;
            font-size: 1.125rem;
        }
        .group-name-input {
            width: 100%;
            padding: 0.625rem 0.875rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 1rem;
            font-family: var(--font);
            outline: none;
            margin-bottom: 0.75rem;
        }
        .group-name-input:focus {
            border-color: var(--accent);
        }

        /* Conversation settings modal extras */
        .settings-section {
            margin-bottom: 1.25rem;
        }
        .settings-section h3 {
            font-size: 0.8125rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 0.5rem;
        }
        .settings-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.625rem 0;
            border-bottom: 1px solid var(--border-light);
        }
        .settings-row:last-child {
            border-bottom: none;
        }
        .member-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.5rem 0;
        }
        .member-row .mini-avatar {
            width: 32px;
            height: 32px;
            border-radius: var(--radius-full);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 0.75rem;
            color: white;
            flex-shrink: 0;
        }
        .member-row .member-info {
            flex: 1;
        }
        .member-row .member-name {
            font-size: 0.875rem;
            font-weight: 500;
        }
        .member-row .member-role {
            font-size: 0.6875rem;
            color: var(--text-muted);
            text-transform: capitalize;
        }

        /* Toggle switch */
        .toggle-switch {
            position: relative;
            width: 44px;
            height: 24px;
            cursor: pointer;
        }
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        .toggle-slider {
            position: absolute;
            inset: 0;
            background: var(--bg-elevated);
            border-radius: 12px;
            transition: background 0.2s;
        }
        .toggle-slider::before {
            content: '';
            position: absolute;
            width: 18px;
            height: 18px;
            left: 3px;
            top: 3px;
            background: white;
            border-radius: 50%;
            transition: transform 0.2s;
        }
        .toggle-switch input:checked + .toggle-slider {
            background: var(--accent);
        }
        .toggle-switch input:checked + .toggle-slider::before {
            transform: translateX(20px);
        }

        /* E2E Encryption indicators */
        .e2e-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.6875rem;
            color: var(--success);
            margin-left: 0.375rem;
            vertical-align: middle;
        }
        .e2e-badge svg {
            width: 12px;
            height: 12px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .safety-number {
            font-family: var(--font-mono);
            font-size: 1.125rem;
            letter-spacing: 0.15em;
            text-align: center;
            padding: 1rem;
            background: var(--bg);
            border-radius: var(--radius);
            border: 1px solid var(--border);
            color: var(--text);
            word-spacing: 0.5em;
            line-height: 1.8;
        }
        .safety-number-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            text-align: center;
            margin-top: 0.5rem;
        }
        .encrypt-status {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.6875rem;
            color: var(--success);
        }
        .encrypt-status svg {
            width: 10px;
            height: 10px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2.5;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* Update banner */
        .update-banner {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 10000;
            background: var(--accent);
            color: white;
            padding: 0.75rem 1rem;
            padding-top: max(0.75rem, env(safe-area-inset-top));
            font-size: 0.875rem;
            text-align: center;
            cursor: pointer;
            animation: slideBannerDown 0.3s ease-out;
            box-shadow: var(--shadow-lg);
        }
        .update-banner.visible { display: flex; align-items: center; justify-content: center; gap: 0.75rem; }
        .update-banner-text { flex: 1; }
        .update-banner-btn {
            padding: 0.375rem 0.75rem;
            background: rgba(255,255,255,0.2);
            border: 1px solid rgba(255,255,255,0.4);
            border-radius: var(--radius);
            color: white;
            font-size: 0.8125rem;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
        }
        .update-banner-btn:hover { background: rgba(255,255,255,0.3); }
        .update-banner-dismiss {
            background: none; border: none; color: rgba(255,255,255,0.7);
            font-size: 1.25rem; cursor: pointer; padding: 0 0.25rem; line-height: 1;
        }
        @keyframes slideBannerDown {
            from { transform: translateY(-100%); }
            to { transform: translateY(0); }
        }

        /* Small screens: tighten spacing */
        @media (max-width: 380px) {
            .chat-header { padding: 0.75rem 0.5rem; }
            .header-actions { gap: 0.125rem; }
            .icon-btn { width: 32px; height: 32px; }
            .icon-btn svg { width: 18px; height: 18px; }
            .conv-header { padding: 0.5rem; }
            .conv-item { padding: 0.625rem 0.5rem; gap: 0.5rem; }
            .message-input-area { padding: 0.5rem; gap: 0.375rem; }
            .messages-area { padding: 0.5rem; }
        }

        /* Desktop: side-by-side layout */
        @media (min-width: 768px) {
            .desktop-layout {
                display: flex;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
            }
            .desktop-layout #chatListScreen {
                width: 380px;
                border-right: 1px solid var(--border);
                flex-shrink: 0;
                display: flex !important;
                position: relative;
                padding: 0;
            }
            .desktop-layout #conversationScreen {
                flex: 1;
                display: flex !important;
                position: relative;
                padding: 0;
            }
            .desktop-layout #conversationScreen .back-btn {
                display: none;
            }
            .desktop-layout .fab {
                position: absolute;
                bottom: 1.5rem;
                right: 1.5rem;
            }
            .desktop-layout #chatListScreen {
                position: relative;
            }
            .modal {
                border-radius: var(--radius-lg);
                max-width: 480px;
                margin-bottom: 0;
            }
            .modal-overlay {
                align-items: center;
            }
        }

        /* Stage 6: Call UI */
        .call-overlay {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 9000;
            background: var(--bg);
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 1.5rem;
        }
        .call-overlay.active { display: flex; }
        .call-avatar-lg {
            width: 96px; height: 96px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 2rem; font-weight: 700; color: white;
            overflow: hidden;
        }
        .call-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
        .call-name { font-size: 1.5rem; font-weight: 600; }
        .call-status { font-size: 0.875rem; color: var(--text-muted); }
        .call-timer { font-size: 1rem; font-weight: 500; font-family: var(--font-mono); }
        .call-actions {
            display: flex; gap: 1.25rem; margin-top: 1rem;
        }
        .call-action-btn {
            width: 56px; height: 56px; border-radius: 50%; border: none;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer; transition: opacity 0.15s;
        }
        .call-action-btn:hover { opacity: 0.85; }
        .call-action-btn svg { width: 24px; height: 24px; stroke: white; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
        .call-action-btn.accept { background: var(--success); }
        .call-action-btn.reject { background: var(--danger); }
        .call-action-btn.mute-btn { background: var(--bg-elevated); }
        .call-action-btn.mute-btn.muted { background: var(--danger); }
        .call-action-btn.cam-btn { background: var(--bg-elevated); }
        .call-action-btn.cam-btn.off { background: var(--danger); }
        .call-action-btn.end-btn { background: var(--danger); }
        .call-video-container {
            position: fixed; inset: 0; z-index: 8999; background: #000;
        }
        .call-video-container video.remote-video {
            width: 100%; height: 100%; object-fit: cover;
        }
        .call-video-container video.local-video {
            position: absolute; bottom: 100px; right: 16px;
            width: 120px; height: 160px; border-radius: var(--radius);
            object-fit: cover; border: 2px solid rgba(255,255,255,0.3);
            z-index: 1;
        }
        .call-video-controls {
            position: absolute; bottom: 0; left: 0; right: 0;
            display: flex; justify-content: center; gap: 1.25rem;
            padding: 1.5rem; background: linear-gradient(transparent, rgba(0,0,0,0.7));
            z-index: 2;
        }
        .call-ring-pulse {
            animation: ringPulse 2s ease-in-out infinite;
        }
        @keyframes ringPulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
            50% { box-shadow: 0 0 0 20px rgba(59,130,246,0); }
        }
        .conv-header-actions {
            display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0;
        }
        .call-header-btn {
            width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
            border: none; background: transparent; color: var(--text-muted); cursor: pointer;
            border-radius: var(--radius); transition: background 0.15s, color 0.15s;
        }
        .call-header-btn:hover { background: var(--bg-elevated); color: var(--success); }
        .call-header-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

        /* Stage 4: Reply bar */
        .reply-bar {
            display: none;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: var(--bg-surface);
            border-top: 1px solid var(--border);
            border-left: 3px solid var(--accent);
            flex-shrink: 0;
        }
        .reply-bar.visible { display: flex; }
        .reply-bar-content { flex: 1; min-width: 0; }
        .reply-bar-sender { font-size: 0.75rem; font-weight: 600; color: var(--accent); }
        .reply-bar-text { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .reply-bar-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: var(--radius); font-size: 1rem; flex-shrink: 0; }
        .reply-bar-close:hover { background: var(--bg-elevated); }

        /* Stage 4: Message reply quote */
        .msg-reply-quote {
            font-size: 0.75rem;
            padding: 0.25rem 0.5rem;
            margin-bottom: 0.25rem;
            border-left: 2px solid var(--accent);
            color: var(--text-muted);
            cursor: pointer;
            overflow: hidden;
        }
        .msg-reply-quote-sender { font-weight: 600; color: var(--accent); }
        .msg-reply-quote-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

        /* Stage 4: Message context menu */
        .msg-context-menu {
            display: none;
            position: fixed;
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow-lg);
            z-index: 200;
            min-width: 140px;
            overflow: hidden;
        }
        .msg-context-menu.active { display: block; }
        .msg-ctx-item {
            padding: 0.5rem 0.875rem;
            font-size: 0.8125rem;
            cursor: pointer;
            color: var(--text);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .msg-ctx-item:hover { background: var(--bg-hover); }
        .msg-ctx-item.danger { color: var(--danger); }
        .msg-ctx-item svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

        /* Stage 4: Edited / deleted indicators */
        .msg-edited { font-size: 0.625rem; color: var(--text-faint); font-style: italic; }
        .msg-deleted-bubble {
            font-style: italic;
            color: var(--text-faint);
            padding: 0.5rem 0.75rem;
            border-radius: var(--radius-lg);
            border: 1px dashed var(--border);
            font-size: 0.8125rem;
        }

        /* Stage 4: Edit mode input */
        .msg-edit-area {
            display: flex;
            gap: 0.375rem;
        }
        .msg-edit-area textarea {
            flex: 1;
            padding: 0.375rem 0.5rem;
            background: var(--bg);
            border: 1px solid var(--accent);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 0.875rem;
            font-family: var(--font);
            resize: none;
            min-height: 36px;
            max-height: 80px;
        }
        .msg-edit-btn {
            padding: 0.25rem 0.5rem;
            border: none;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 0.75rem;
            font-family: var(--font);
        }
        .msg-edit-save { background: var(--accent); color: white; }
        .msg-edit-cancel { background: var(--bg-elevated); color: var(--text-muted); }

        /* Stage 4: File attachment card */
        .msg-file-card {
            display: flex;
            align-items: center;
            gap: 0.625rem;
            padding: 0.5rem 0.75rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            cursor: pointer;
            max-width: 280px;
            transition: background 0.15s;
        }
        .msg-file-card:hover { background: var(--bg-hover); }
        .msg-file-icon {
            width: 36px; height: 36px;
            display: flex; align-items: center; justify-content: center;
            background: var(--accent-faint);
            border-radius: var(--radius);
            flex-shrink: 0;
        }
        .msg-file-icon svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
        .msg-file-info { flex: 1; min-width: 0; }
        .msg-file-name { font-size: 0.8125rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .msg-file-size { font-size: 0.6875rem; color: var(--text-muted); }

        /* Stage 4: Inline image */
        .msg-image {
            max-width: 280px;
            max-height: 300px;
            border-radius: var(--radius);
            cursor: pointer;
            object-fit: cover;
            display: block;
        }

        /* Stage 4: Voice message */
        .msg-voice {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.375rem 0.5rem;
            min-width: 200px;
        }
        .msg-voice-play {
            width: 32px; height: 32px;
            border-radius: 50%;
            background: var(--accent);
            border: none;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .msg-voice-play svg { width: 14px; height: 14px; fill: currentColor; }
        .msg-voice-wave { flex: 1; height: 32px; display: flex; align-items: center; gap: 1px; }
        .msg-voice-wave .bar { width: 3px; background: var(--text-faint); border-radius: 1px; transition: background 0.2s; }
        .msg-voice-wave .bar.active { background: var(--accent); }
        .msg-voice-dur { font-size: 0.6875rem; color: var(--text-muted); flex-shrink: 0; }

        /* Stage 4: Voice record button & indicator */
        .voice-btn {
            width: 42px; height: 42px;
            border-radius: var(--radius-full);
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.15s;
        }
        .voice-btn:hover { background: var(--bg-elevated); color: var(--text); }
        .voice-btn.recording { background: var(--danger); border-color: var(--danger); color: white; animation: pulse-record 1.5s infinite; }
        .voice-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
        @keyframes pulse-record { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

        .record-indicator {
            display: none;
            align-items: center;
            gap: 0.5rem;
            flex: 1;
            padding: 0 0.5rem;
        }
        .record-indicator.visible { display: flex; }
        .record-indicator .rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse-record 1s infinite; }
        .record-indicator .rec-time { font-size: 0.875rem; color: var(--text-muted); font-family: var(--font-mono); }
        .record-indicator .rec-cancel { font-size: 0.8125rem; color: var(--text-faint); cursor: pointer; margin-left: auto; }
        .record-indicator .rec-cancel:hover { color: var(--danger); }

        /* Stage 4: File attach button */
        .attach-btn {
            width: 42px; height: 42px;
            border-radius: var(--radius-full);
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.15s;
        }
        .attach-btn:hover { background: var(--bg-elevated); color: var(--text); }
        .attach-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

        /* Stage 4: Lightbox */
        .lightbox {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.85);
            z-index: 300;
            align-items: center;
            justify-content: center;
            cursor: zoom-out;
        }
        .lightbox.active { display: flex; }
        .lightbox img {
            max-width: 95vw;
            max-height: 95vh;
            object-fit: contain;
            border-radius: var(--radius);
        }
        .lightbox-close {
            position: fixed;
            top: 1rem;
            right: 1rem;
            width: 40px; height: 40px;
            border-radius: 50%;
            background: rgba(255,255,255,0.15);
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Stage 4: Avatar images in conv list */
        .conv-avatar img, .mini-avatar img {
            width: 100%; height: 100%;
            border-radius: var(--radius-full);
            object-fit: cover;
        }

        /* Stage 4: Hover actions on messages */
        .msg-bubble-wrap {
            position: relative;
        }
        .msg-actions {
            display: none;
            position: absolute;
            top: -4px;
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 2px;
            z-index: 5;
            gap: 2px;
        }
        .msg-group.own .msg-actions { left: -4px; right: auto; }
        .msg-group.other .msg-actions { right: -4px; left: auto; }
        .msg-bubble-wrap:hover .msg-actions { display: flex; }
        .msg-action-btn {
            width: 24px; height: 24px;
            display: flex; align-items: center; justify-content: center;
            border: none; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: 4px;
        }
        .msg-action-btn:hover { background: var(--bg-hover); color: var(--text); }
        .msg-action-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

        /* =============================================
           Stage 5: Group Management Depth
           ============================================= */

        /* System messages */
        .msg-system {
            text-align: center;
            padding: 0.5rem 0;
        }
        .msg-system-bubble {
            display: inline-block;
            padding: 0.375rem 0.875rem;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            font-size: 0.75rem;
            color: var(--text-muted);
            font-style: italic;
            max-width: 80%;
        }

        /* Member action buttons in settings */
        .member-row-actions {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            flex-shrink: 0;
        }
        .member-action-btn {
            width: 28px; height: 28px;
            display: flex; align-items: center; justify-content: center;
            border: none; background: transparent;
            color: var(--text-faint); cursor: pointer;
            border-radius: var(--radius);
            transition: all 0.1s;
        }
        .member-action-btn:hover { background: var(--bg-hover); color: var(--text); }
        .member-action-btn.danger:hover { color: var(--danger); }
        .member-action-btn svg {
            width: 14px; height: 14px; stroke: currentColor;
            fill: none; stroke-width: 2;
            stroke-linecap: round; stroke-linejoin: round;
        }

        /* Role badge */
        .role-badge {
            font-size: 0.625rem;
            padding: 0.125rem 0.375rem;
            border-radius: 99px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        .role-badge.owner { background: rgba(251,191,36,0.15); color: #f59e0b; }
        .role-badge.admin { background: rgba(99,102,241,0.15); color: #818cf8; }

        /* Role dropdown */
        .role-select {
            font-size: 0.6875rem;
            padding: 0.2rem 0.375rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-family: var(--font);
            cursor: pointer;
        }

        /* Editable settings fields */
        .settings-input {
            width: 100%;
            padding: 0.5rem 0.75rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 0.875rem;
            font-family: var(--font);
            outline: none;
            margin-bottom: 0.5rem;
        }
        .settings-input:focus { border-color: var(--accent); }
        .settings-textarea {
            width: 100%;
            padding: 0.5rem 0.75rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 0.8125rem;
            font-family: var(--font);
            outline: none;
            resize: vertical;
            min-height: 60px;
            max-height: 120px;
            margin-bottom: 0.5rem;
        }
        .settings-textarea:focus { border-color: var(--accent); }
        .settings-status-text {
            font-size: 0.75rem;
            color: var(--text-faint);
            font-style: italic;
            margin-top: 0.125rem;
        }

        /* Search input in modals */
        .modal-search {
            width: 100%;
            padding: 0.5rem 0.75rem 0.5rem 2rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 1rem;
            font-family: var(--font);
            outline: none;
            margin-bottom: 0.5rem;
        }
        .modal-search:focus { border-color: var(--accent); }
        .modal-search-wrap {
            position: relative;
            margin-bottom: 0.5rem;
        }
        .modal-search-wrap svg {
            position: absolute;
            left: 0.625rem;
            top: 50%;
            transform: translateY(-50%);
            width: 14px; height: 14px;
            stroke: var(--text-faint);
            fill: none; stroke-width: 2;
            stroke-linecap: round; stroke-linejoin: round;
            pointer-events: none;
        }

        /* Invite link card */
        .invite-card {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            margin-bottom: 0.5rem;
            font-size: 0.75rem;
        }
        .invite-card-info { flex: 1; min-width: 0; }
        .invite-card-token {
            font-family: var(--font-mono);
            font-size: 0.6875rem;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .invite-card-meta {
            font-size: 0.625rem;
            color: var(--text-faint);
        }
        .invite-card-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
        .invite-copy-btn, .invite-revoke-btn {
            width: 28px; height: 28px;
            display: flex; align-items: center; justify-content: center;
            border: none; background: transparent;
            color: var(--text-faint); cursor: pointer;
            border-radius: var(--radius);
        }
        .invite-copy-btn:hover { background: var(--bg-hover); color: var(--accent); }
        .invite-revoke-btn:hover { background: var(--bg-hover); color: var(--danger); }
        .invite-copy-btn svg, .invite-revoke-btn svg {
            width: 14px; height: 14px; stroke: currentColor;
            fill: none; stroke-width: 2;
            stroke-linecap: round; stroke-linejoin: round;
        }

        /* Admin panel */
        .admin-tab-bar {
            display: flex;
            gap: 0;
            margin-bottom: 1rem;
            border-radius: var(--radius);
            overflow: hidden;
            border: 1px solid var(--border);
        }
        .admin-tab {
            flex: 1;
            padding: 0.5rem;
            text-align: center;
            font-size: 0.75rem;
            font-weight: 500;
            background: transparent;
            color: var(--text-muted);
            border: none;
            cursor: pointer;
            transition: all 0.15s;
        }
        .admin-tab.active {
            background: var(--accent);
            color: white;
        }
        .admin-user-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.625rem 0.25rem;
            border-bottom: 1px solid var(--border-light);
        }
        .admin-user-row:last-child { border-bottom: none; }
        .admin-user-info { flex: 1; min-width: 0; }
        .admin-user-name { font-size: 0.875rem; font-weight: 500; }
        .admin-user-name .deactivated-label {
            font-size: 0.625rem;
            color: var(--danger);
            font-weight: 600;
            margin-left: 0.25rem;
        }
        .admin-user-meta { font-size: 0.6875rem; color: var(--text-muted); }
        .admin-user-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
        .admin-action-btn {
            padding: 0.25rem 0.5rem;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--bg);
            color: var(--text-muted);
            font-size: 0.625rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.1s;
            font-family: var(--font);
        }
        .admin-action-btn:hover { border-color: var(--accent); color: var(--accent); }
        .admin-action-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
        .admin-conv-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.5rem 0.25rem;
            border-bottom: 1px solid var(--border-light);
        }
        .admin-conv-row:last-child { border-bottom: none; }
        .admin-conv-info { flex: 1; min-width: 0; }
        .admin-conv-name { font-size: 0.875rem; font-weight: 500; }
        .admin-conv-meta { font-size: 0.6875rem; color: var(--text-muted); }
        .announce-textarea {
            width: 100%;
            padding: 0.625rem 0.875rem;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            font-size: 0.875rem;
            font-family: var(--font);
            resize: vertical;
            min-height: 80px;
            max-height: 200px;
            outline: none;
            margin-bottom: 0.5rem;
        }
        .announce-textarea:focus { border-color: var(--accent); }

        /* Add member picker in settings (reuses user-select-item but inline) */
        .add-member-section {
            margin-top: 0.5rem;
            padding-top: 0.5rem;
            border-top: 1px solid var(--border-light);
        }
        .add-member-section .user-select-list {
            max-height: 180px;
            overflow-y: auto;
        }

        /* Invite accept page */
        .invite-accept-card {
            text-align: center;
            padding: 1.5rem 1rem;
        }
        .invite-accept-card h3 {
            font-size: 1.125rem;
            margin: 0.75rem 0 0.25rem;
        }
        .invite-accept-card .invite-member-count {
            font-size: 0.8125rem;
            color: var(--text-muted);
            margin-bottom: 1rem;
        }

        /* (P2 · 2.5) Screen-reader-only utility */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        .sr-only-focusable:focus {
            position: fixed;
            top: 0;
            left: 0;
            width: auto;
            height: auto;
            padding: 0.75rem 1.25rem;
            margin: 0;
            overflow: visible;
            clip: auto;
            white-space: normal;
            background: var(--accent);
            color: #fff;
            font-size: 0.875rem;
            z-index: 100000;
            border-radius: 0 0 var(--radius) 0;
        }