/* ============================================================
 * Сигнал — Corporate Chat UI Styles
 * ============================================================
 * Two-pane layout: Sidebar + Chat Viewport
 * Dark corporate theme with glassmorphism elements
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --brand:           #b72c43;
    --brand-light:     #d4435c;
    --brand-dark:      #8e1f33;
    --brand-glow:      rgba(183, 44, 67, 0.25);
    --brand-glass:     rgba(183, 44, 67, 0.08);

    --bg-base:         #f8fafc;
    --bg-sidebar:      #ffffff;
    --surface:         rgba(255, 255, 255, 0.7);
    --surface-solid:   #ffffff;
    --text-h:          #0f172a;
    --text-p:          #334155;
    --text-muted:      #94a3b8;
    --glass-border:    rgba(0, 0, 0, 0.05);
    --shadow:          0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-lg:       0 10px 25px rgba(0, 0, 0, 0.05);
    --input-bg:        #f1f5f9;

    --msg-sent-bg:     #e0e7ff;
    --msg-sent-text:   #312e81;
    --msg-sent-meta:   #4338ca;

    --sidebar-width:   320px;
    --header-height:   64px;
    --composer-height: 64px;

    --radius-lg:       24px;
    --radius-md:       16px;
    --radius-sm:       12px;

    --transition:      0.2s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-base:         #0f172a;
        --bg-sidebar:      #1e293b;
        --surface:         rgba(30, 41, 59, 0.6);
        --surface-solid:   #262f45;
        --text-h:          #f8fafc;
        --text-p:          #e2e8f0;
        --text-muted:      #94a3b8;
        --brand:           #ef4444;
        --glass-border:    rgba(255, 255, 255, 0.05);
        --shadow:          0 4px 6px rgba(0, 0, 0, 0.3);
        --shadow-lg:       0 20px 40px rgba(0, 0, 0, 0.4);
        --input-bg:        #334155;

        --msg-sent-bg:     #312e81;
        --msg-sent-text:   #e0e7ff;
        --msg-sent-meta:   #818cf8;
    }
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-p);
    height: 100vh;
    height: 100dvh; /* Fallback to native dvh if supported */
    height: calc(var(--vh, 1vh) * 100); /* Our precise JS calculation wins */
    overflow: hidden;
    margin: 0;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

h1, h2, h3 { color: var(--text-h); font-weight: 700; letter-spacing: -0.3px; }

a { color: var(--brand); text-decoration: none; }

.hidden { display: none !important; }

/* ── App Container ─────────────────────────────────────────── */
#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
    display: none;
    height: 100%;
    width: 100%;
    flex-direction: column;
    animation: fadeScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.screen.active { display: flex; }

@keyframes fadeScale {
    0% { opacity: 0; transform: scale(0.98) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.center-screen {
    justify-content: center;
    align-items: center;
    padding: 24px;
}

/* ── Glass Card (Install / Login) ────────────────────────── */
.glass-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface-solid);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 40px 32px;
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    text-align: center;
}

.icon-container {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--brand), #d63852);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px auto;
    box-shadow: 0 12px 24px var(--brand-glow);
    transform: rotate(-3deg);
}
.icon-container svg { width: 44px; height: 44px; }

.install-title { font-size: 28px; margin-bottom: 12px; }
.install-desc { font-size: 15px; margin-bottom: 32px; line-height: 1.6; }

.android-instruction { display: none; width: 100%; }
.ios-instruction { display: none; width: 100%; text-align: left; background: var(--input-bg); padding: 20px; border-radius: 20px; margin-bottom: 24px; border: 1px solid var(--glass-border); }
.ios-instruction ol { margin-left: 24px; line-height: 1.8; font-size: 14px; }
.ios-instruction li strong { color: var(--text-h); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 16px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 99px;
    cursor: pointer;
    background-color: var(--brand);
    color: #fff;
    box-shadow: 0 8px 20px var(--brand-glow);
    transition: all var(--transition);
    letter-spacing: 0.3px;
    outline: none;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.98); box-shadow: 0 4px 10px var(--brand-glow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-outline {
    background: transparent;
    color: var(--text-h);
    border: 2px solid var(--glass-border);
    box-shadow: none;
    width: auto;
    padding: 10px 20px;
}
.btn-outline:hover { background: var(--input-bg); }

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
    border-radius: 12px;
}

/* ── Input ───────────────────────────────────────────────── */
.login-title { font-size: 26px; margin-bottom: 32px; }
.input-group { position: relative; margin-bottom: 16px; }
.input-group input {
    width: 100%;
    padding: 18px 18px 18px 52px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-h);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    -webkit-user-select: auto;
    user-select: auto;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.input-group input:focus {
    border-color: var(--brand);
    background: var(--surface-solid);
    box-shadow: 0 0 0 4px var(--brand-glow);
}
.input-group input::placeholder { color: var(--text-muted); }
.input-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}
.input-group input:focus + .input-icon { color: var(--brand); }

.status-message {
    margin: 12px auto 0 auto;
    border-radius: 14px;
    padding: 10px 14px;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: #f87171;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}
.status-message--loading {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border-color: transparent;
}
.status-message--subscribed {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

/* ── Keyboard handling ───────────────────────────────────── */
body.keyboard-visible #screen-login.center-screen {
    justify-content: center;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
body.keyboard-visible #screen-login .glass-card {
    transform: translateY(calc(-1 * var(--keyboard-shift, 0px)));
}

/* ================ CHAT LAYOUT (Two-Pane) ================ */

#screen-chat {
    flex-direction: row;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    min-height: 64px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
    border-radius: 12px;
    flex-shrink: 0;
    background: var(--brand-glass);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-h);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.sidebar-icon-btn:hover { background: var(--brand-glass); color: var(--brand); }

/* Dropdown */
.sidebar-dropdown {
    position: absolute;
    top: 56px;
    right: 12px;
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 240px;
    padding: 6px;
    animation: fadeScale 0.2s ease;
}
.sidebar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-p);
    cursor: pointer;
    border-radius: 10px;
    transition: background var(--transition);
    text-align: left;
}
.sidebar-dropdown-item:hover { background: var(--input-bg); }
.sidebar-dropdown-item--danger { color: var(--brand); }
.sidebar-dropdown-item--danger:hover { background: rgba(183, 44, 67, 0.06); }
.sidebar-dropdown-separator { height: 1px; background: var(--glass-border); margin: 4px 8px; }

/* Sidebar list */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 8px 10px 6px;
}

.search-toggle {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition);
}
.search-toggle:hover { opacity: 1; color: var(--brand); }

.sidebar-search {
    padding: 4px 10px 8px;
}
.sidebar-search-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-h);
    outline: none;
    font-family: inherit;
    transition: border-color var(--transition);
}
.sidebar-search-input:focus {
    border-color: var(--brand);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.sidebar-item:hover { background: var(--input-bg); }
.sidebar-item.active { background: var(--brand-glass); }

.sidebar-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 15px;
}

.sidebar-item-icon--group {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
}

.sidebar-item-icon--user {
    background: var(--brand-glass);
    color: var(--brand);
}

.sidebar-item-text {
    min-width: 0;
    flex: 1;
}

.sidebar-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-h);
    margin-bottom: 2px;
}

.sidebar-item-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(183, 44, 67, 0.4);
    animation: fadeIn 0.2s ease;
}

.sidebar-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.footer-text {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Chat Viewport ───────────────────────────────────────── */
.chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg-base);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface-solid);
    border-bottom: 1px solid var(--glass-border);
    min-height: var(--header-height);
    z-index: 10;
}

.chat-header-back {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    color: var(--text-h);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.chat-header-back:hover { background: var(--brand-glass); color: var(--brand); }

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
}

.chat-header-text { min-width: 0; }

.chat-header-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-h);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.chat-header-action {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 99px;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px var(--brand-glow);
}
.chat-header-action:hover { filter: brightness(1.1); transform: translateY(-1px); }

.chat-header-action--leave {
    background: transparent;
    color: var(--brand);
    border: 1.5px solid var(--brand);
    box-shadow: none;
    font-size: 12px;
    padding: 6px 14px;
}
.chat-header-action--leave:hover { background: rgba(183, 44, 67, 0.06); }

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-anchor: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    padding: 40px;
}

.chat-empty-icon { opacity: 0.3; }
.chat-empty-text { font-size: 15px; text-align: center; }

/* Messages */
.date-pill {
    align-self: center;
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 4px 14px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    margin: 12px 0 8px;
    box-shadow: var(--shadow);
}

#chat-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.message {
    background: var(--surface-solid);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    max-width: 85%;
    align-self: flex-start;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    position: relative;
    animation: msgIn 0.2s ease;
}

.message--sent {
    align-self: flex-end;
    background: var(--msg-sent-bg);
    color: var(--msg-sent-text);
    border-color: transparent;
    border-radius: 20px 20px 4px 20px;
}
.message--sent .message-sender { color: var(--msg-sent-meta); opacity: 0.8; }
.message--sent .message-text { color: var(--msg-sent-text); }
.message--sent .message-meta { color: var(--msg-sent-meta); opacity: 0.7; }
.message--sent .message-group-label { background: rgba(0, 0, 0, 0.05); color: var(--msg-sent-meta); }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand);
    margin-bottom: 2px;
    filter: brightness(1.2);
}

.message-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-p);
    white-space: normal;
    word-break: break-word;
}

/* mrkdwn inline formatting */
.message-text b { font-weight: 700; color: var(--text-h); }
.message-text i { font-style: italic; }
.message-text s { text-decoration: line-through; opacity: 0.7; }
.message-text code {
    font-family: 'Roboto Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
    .message-text code { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.05); }
}
.message-text a { color: var(--brand); text-decoration: underline; word-break: break-all; font-weight: 500; }
.message-text a:hover { opacity: 0.7; }

.msg-divider {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 12px -16px; /* Bleed to bubble edges if needed, or 12px 0 */
    margin: 14px 0;
    opacity: 0.5;
}

/* Images from Slack blocks */
.msg-image {
    display: block;
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 12px;
    margin: 12px 0;
    object-fit: contain;
    background: var(--input-bg);
    animation: msgIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--glass-border);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    justify-content: flex-end;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.message-group-label {
    font-size: 10px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.message-status {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    opacity: 0.6;
    margin-left: -2px;
}

.message--sent .message-status {
    color: var(--msg-sent-meta);
}

.message-status--read {
    color: #3b82f6 !important;
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .message-status--read {
        color: #60a5fa !important;
    }
}

.message-status svg {
    width: 15px;
    height: 15px;
}


/* Composer */
.chat-composer {
    padding: 10px 16px;
    padding-bottom: calc(max(12px, env(safe-area-inset-bottom)) + 12px);
    background: var(--surface-solid);
    border-top: 1px solid var(--glass-border);
    position: relative;
    z-index: 10;
}

.chat-composer-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 99px;
    padding: 6px 8px 6px 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-composer-inner:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.chat-composer-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-h);
    outline: none;
    padding: 8px 0;
}
.chat-composer-input::placeholder { color: var(--text-muted); }

.chat-composer-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    box-shadow: 0 4px 12px var(--brand-glow);
}
.chat-composer-send:hover:not(:disabled) { filter: brightness(1.15); transform: scale(1.05); }
.chat-composer-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Subscription CTA */
#subscription-required {
    padding: 12px 16px;
    background: var(--surface-solid);
    border-top: 1px solid var(--glass-border);
}

.sub-card {
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
}

.sub-text {
    font-size: 14px;
    color: var(--text-p);
    line-height: 1.5;
    margin-bottom: 12px;
    font-weight: 500;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeScale 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--input-bg);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--brand-glass); color: var(--brand); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.modal-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    margin-bottom: 8px;
    transition: background var(--transition);
}
.modal-group-item:hover { background: var(--input-bg); }

.modal-group-info { min-width: 0; flex: 1; }
.modal-group-name { font-size: 14px; font-weight: 600; color: var(--text-h); }
.modal-group-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.modal-group-members { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

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

/* ── Loader Dots ─────────────────────────────────────────── */
.loader-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}
.loader-dots span {
    width: 8px;
    height: 8px;
    background: var(--brand);
    border-radius: 50%;
    display: inline-block;
    animation: loaderDots 1.4s infinite ease-in-out both;
    opacity: 0.6;
}
.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loaderDots {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); opacity: 1; }
}

.loader-text {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.history-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Instruction Box (Install screen) ────────────────────── */
.instruction-box {
    background: var(--input-bg);
    padding: 20px;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
    color: var(--text-p);
    width: 100%;
}
.instruction-box strong { color: var(--text-h); }
.instruction-header {
    font-weight: 700;
    color: var(--text-h);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.instruction-header svg { opacity: 0.8; color: var(--brand); }

/* ================ RESPONSIVE ================ */

/* Mobile: sidebar overlays, toggleable */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    #screen-chat {
        position: relative;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        z-index: 50;
        transform: translateX(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.sidebar--hidden {
        transform: translateX(-100%);
        pointer-events: none;
    }

    .chat-header-back {
        display: flex;
    }

    .chat-viewport {
        width: 100%;
    }
}

/* Desktop: wider messages */
@media (min-width: 769px) {
    .chat-header-back { display: none; }

    .message { max-width: 65%; }

    .chat-messages { padding: 24px; gap: 4px; }
}

/* Large screens */
@media (min-width: 1200px) {
    :root { --sidebar-width: 360px; }
}
