﻿/* wwwroot/css/chat.css — PL-Signum Project Chat
   Layout: Launcher bar (bottom-left) + Side panel (opens to the right of launcher)
   Font: Arial (via --font CSS variable from typography.css)
*/

/* ═══════════════════════════════════════════════════════════════════════
   LAUNCHER BAR  (bottom-left strip, always visible when module on)
   ═══════════════════════════════════════════════════════════════════════ */
#chatLauncher {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 268px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 0 10px 0 0;
    z-index: 8000;
    display: none;
    flex-direction: column;
    box-shadow: 2px -3px 18px rgba(0,0,0,.25);
    font-family: var(--font);
}

#chatLauncherHdr {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: border-color .15s;
}

#chatLauncher.open #chatLauncherHdr {
    border-bottom-color: var(--border);
}

.chat-launcher-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    font-family: var(--font);
}

.chat-launcher-online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 9px;
    height: 9px;
    background: var(--cat1);
    border-radius: 50%;
    border: 2px solid var(--surface2);
}

.chat-launcher-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-launcher-badge {
    min-width: 18px;
    height: 18px;
    background: var(--cat3);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-family: var(--font);
}

    .chat-launcher-badge.visible {
        display: flex;
    }

.chat-launcher-chevron {
    font-size: 10px;
    color: var(--muted);
    transition: transform .2s;
}

#chatLauncher.open .chat-launcher-chevron {
    transform: rotate(180deg);
}

/* Launcher body */
#chatLauncherBody {
    display: none;
    flex-direction: column;
    height: 460px;
    overflow: hidden;
}

#chatLauncher.open #chatLauncherBody {
    display: flex;
}

/* ── Tab bar ─────────────────────────────────────────────────────────── */
.chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface2);
}

.chat-tab-btn {
    flex: 1;
    padding: 7px 4px 5px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: var(--font);
    transition: color .12s, border-color .12s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

    .chat-tab-btn .tab-icon {
        font-size: 15px;
        line-height: 1;
    }

    .chat-tab-btn:hover {
        color: var(--text);
    }

    .chat-tab-btn.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }

.chat-tab-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

    .chat-tab-panel.active {
        display: flex;
    }

/* ── Search bar ──────────────────────────────────────────────────────── */
.chat-search-bar {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

    .chat-search-bar input {
        width: 100%;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 20px;
        padding: 5px 12px;
        font-size: 12px;
        color: var(--text);
        font-family: var(--font);
        outline: none;
        box-sizing: border-box;
    }

        .chat-search-bar input:focus {
            border-color: var(--accent);
        }

        .chat-search-bar input::placeholder {
            color: var(--muted);
        }

/* ── List ────────────────────────────────────────────────────────────── */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

    .chat-list::-webkit-scrollbar {
        width: 3px;
    }

    .chat-list::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .1s;
    position: relative;
}

    .chat-list-item:hover {
        background: rgba(79,142,247,.06);
    }

        .chat-list-item:hover .chat-item-actions {
            opacity: 1;
        }

    .chat-list-item.active {
        background: rgba(79,142,247,.12);
    }

.chat-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font);
}

    .chat-item-avatar.channel {
        border-radius: 9px;
        background: rgba(79,142,247,.15);
        color: var(--accent);
        font-size: 15px;
        font-weight: 400;
    }

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font);
    line-height: 1.3;
}

.chat-item-preview {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
    font-family: var(--font);
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.chat-item-time {
    font-size: 10px;
    color: var(--muted);
    font-family: var(--font);
}

.chat-item-badge {
    min-width: 17px;
    height: 17px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-family: var(--font);
}

    .chat-item-badge.mention {
        background: var(--cat3);
    }

.chat-item-name.unread {
    font-weight: 700;
}

/* Per-item action buttons (delete) */
.chat-item-actions {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity .12s;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.chat-item-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--muted);
    transition: color .1s, background .1s;
}

    .chat-item-action-btn:hover {
        color: var(--danger,#ef4444);
        background: rgba(239,68,68,.08);
    }

/* New channel / DM buttons */
.chat-new-item-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    transition: background .1s;
}

    .chat-new-item-btn:hover {
        background: rgba(79,142,247,.08);
    }

/* Contacts */
.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .1s;
}

    .chat-contact-item:hover {
        background: rgba(79,142,247,.06);
    }

.chat-contact-info {
    flex: 1;
    min-width: 0;
}

.chat-contact-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font);
}

.chat-contact-role {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
    font-family: var(--font);
}

.chat-contact-dm-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
    transition: color .12s, border-color .12s;
}

    .chat-contact-dm-btn:hover {
        color: var(--accent);
        border-color: var(--accent);
    }

/* ═══════════════════════════════════════════════════════════════════════
   SIDE PANEL  (opens to the right of the launcher, full height)
   ═══════════════════════════════════════════════════════════════════════ */
#chatSidePanel {
    position: fixed;
    bottom: 0;
    left: 268px; /* right edge of launcher */
    width: 320px;
    height: 504px; /* 44px launcher hdr + 460px body */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
    z-index: 7999;
    display: none;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0,0,0,.25);
    font-family: var(--font);
    animation: panel-in .18s cubic-bezier(.4,0,.2,1);
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#chatSidePanel.open {
    display: flex;
}

/* Panel header */
.csp-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    flex-shrink: 0;
}

.csp-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font);
}

    .csp-header-avatar.channel {
        border-radius: 8px;
        background: rgba(79,142,247,.15);
        color: var(--accent);
        font-size: 16px;
        font-weight: 400;
    }

.csp-header-info {
    flex: 1;
    min-width: 0;
}

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

.csp-header-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
    font-family: var(--font);
}

.csp-header-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    transition: color .12s, background .12s;
    flex-shrink: 0;
}

    .csp-header-btn:hover {
        color: var(--text);
        background: var(--border);
    }

/* Messages */
#cspMessages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

    #cspMessages::-webkit-scrollbar {
        width: 3px;
    }

    #cspMessages::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }

.cw-date-sep {
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    padding: 8px 0 4px;
    letter-spacing: .05em;
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .cw-date-sep::before, .cw-date-sep::after {
        content: '';
        flex: 1;
        height: 1px;
        background: var(--border);
    }

/* Message bubble */
.cw-msg {
    display: flex;
    gap: 9px;
    padding: 4px 6px;
    border-radius: 8px;
    position: relative;
    transition: background .1s;
}

    .cw-msg:hover {
        background: var(--surface2);
    }

        .cw-msg:hover .cw-msg-actions {
            opacity: 1;
            pointer-events: auto;
        }

.cw-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    font-family: var(--font);
}

.cw-msg-body {
    flex: 1;
    min-width: 0;
}

.cw-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}

.cw-msg-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font);
}

.cw-msg-time {
    font-size: 10px;
    color: var(--muted);
    font-family: var(--font);
}

.cw-msg-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    font-family: var(--font);
}

    .cw-msg-text.deleted {
        color: var(--muted);
        font-style: italic;
    }

.cw-mention {
    color: var(--accent);
    background: rgba(79,142,247,.1);
    border-radius: 4px;
    padding: 0 4px;
    font-weight: 600;
}

/* Hover actions */
.cw-msg-actions {
    position: absolute;
    top: 2px;
    right: 6px;
    display: flex;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    transition: opacity .1s;
}

.cw-msg-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 5px;
    font-size: 14px;
    line-height: 1;
    color: var(--muted);
    transition: background .1s, color .1s;
}

    .cw-msg-action-btn:hover {
        background: var(--surface2);
        color: var(--text);
    }

    .cw-msg-action-btn.danger:hover {
        color: var(--danger,#ef4444);
    }

/* Reactions */
.cw-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.cw-rxn-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background .1s, border-color .1s;
    user-select: none;
}

    .cw-rxn-pill:hover, .cw-rxn-pill.mine {
        background: rgba(79,142,247,.12);
        border-color: var(--accent);
    }

.cw-rxn-count {
    font-size: 11px;
    color: var(--muted);
    font-family: var(--font);
}

/* Typing */
#cspTyping {
    padding: 2px 14px 5px;
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    min-height: 18px;
    flex-shrink: 0;
    font-family: var(--font);
}

/* Empty / loading */
.cw-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 10px;
    padding: 28px;
    text-align: center;
}

.cw-empty-icon {
    font-size: 38px;
    opacity: .28;
}

.cw-empty-text {
    font-size: 13px;
    line-height: 1.6;
    font-family: var(--font);
}

.cw-loading {
    text-align: center;
    padding: 28px;
    font-size: 12px;
    color: var(--muted);
    font-family: var(--font);
}

.cw-load-more {
    text-align: center;
    padding: 6px;
    flex-shrink: 0;
}

.cw-load-more-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px 16px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    transition: color .12s, border-color .12s;
}

    .cw-load-more-btn:hover {
        color: var(--accent);
        border-color: var(--accent);
    }

/* ── Composer ────────────────────────────────────────────────────────── */
.cw-composer {
    border-top: 1px solid var(--border);
    padding: 8px 12px 10px;
    flex-shrink: 0;
    background: var(--surface);
}

.cw-composer-box {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 22px;
    padding: 5px 8px 5px 13px;
    transition: border-color .15s;
}

    .cw-composer-box:focus-within {
        border-color: var(--accent);
    }

#cspInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-size: 13px;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.45;
    min-height: 22px;
    max-height: 100px;
    padding: 2px 0;
}

    #cspInput::placeholder {
        color: var(--muted);
        font-size: 13px;
    }

.cw-tool-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 6px;
    font-size: 16px;
    color: var(--muted);
    line-height: 1;
    transition: color .12s, background .12s;
    flex-shrink: 0;
}

    .cw-tool-btn:hover {
        color: var(--accent);
        background: rgba(79,142,247,.08);
    }

.cw-send-btn {
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity .12s, transform .1s;
}

    .cw-send-btn:hover {
        opacity: .88;
        transform: scale(1.06);
    }

    .cw-send-btn:disabled {
        opacity: .3;
        cursor: not-allowed;
        transform: none;
    }

    .cw-send-btn svg {
        width: 14px;
        height: 14px;
        fill: #fff;
    }

/* ── Emoji picker ────────────────────────────────────────────────────── */
.cw-emoji-picker {
    position: absolute;
    bottom: 58px;
    left: 8px;
    right: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 -4px 24px rgba(0,0,0,.22);
    z-index: 8010;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: panel-in .15s ease;
}

.cw-emoji-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

    .cw-emoji-search input {
        width: 100%;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 6px 10px;
        font-size: 12px;
        color: var(--text);
        font-family: var(--font);
        outline: none;
        box-sizing: border-box;
    }

        .cw-emoji-search input:focus {
            border-color: var(--accent);
        }

        .cw-emoji-search input::placeholder {
            color: var(--muted);
        }

.cw-emoji-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    flex-shrink: 0;
    overflow-x: auto;
}

    .cw-emoji-tabs::-webkit-scrollbar {
        display: none;
    }

.cw-emoji-tab {
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    line-height: 1;
    transition: background .1s;
}

    .cw-emoji-tab:hover {
        background: rgba(79,142,247,.08);
    }

    .cw-emoji-tab.active {
        border-bottom-color: var(--accent);
    }

.cw-emoji-body {
    overflow-y: auto;
    height: 180px;
    padding: 6px;
}

    .cw-emoji-body::-webkit-scrollbar {
        width: 3px;
    }

    .cw-emoji-body::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }

.cw-emoji-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 1px;
}

.cw-emoji-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
    transition: background .1s, transform .08s;
    text-align: center;
}

    .cw-emoji-btn:hover {
        background: rgba(79,142,247,.1);
        transform: scale(1.2);
    }

/* ── Modals ──────────────────────────────────────────────────────────── */
#chatNewChModal, #chatSearchModal, #chatAttachmentsModal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 8020;
    display: none;
    align-items: center;
    justify-content: center;
}

    #chatNewChModal.open, #chatSearchModal.open, #chatAttachmentsModal.open {
        display: flex;
    }

.chat-modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    width: 420px;
    max-width: 95vw;
    font-family: var(--font);
    box-shadow: 0 20px 50px rgba(0,0,0,.4);
}

.chat-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.chat-modal-field {
    margin-bottom: 12px;
}

.chat-modal-label {
    display: block;
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
    font-family: var(--font);
}

.chat-modal-input, .chat-modal-select {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    box-sizing: border-box;
    transition: border-color .12s;
}

    .chat-modal-input:focus, .chat-modal-select:focus {
        border-color: var(--accent);
    }

.chat-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.chat-modal-save {
    flex: 1;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 9px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity .12s;
}

    .chat-modal-save:hover {
        opacity: .88;
    }

.chat-modal-cancel {
    flex: 1;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 9px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: color .12s, border-color .12s;
}

    .chat-modal-cancel:hover {
        color: var(--text);
        border-color: var(--accent);
    }

/* Member multi-select for channel creation */
.chat-member-select {
    max-height: 160px;
    overflow-y: auto;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
}

    .chat-member-select::-webkit-scrollbar {
        width: 3px;
    }

    .chat-member-select::-webkit-scrollbar-thumb {
        background: var(--border);
    }

.chat-member-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .1s;
}

    .chat-member-row:hover {
        background: rgba(79,142,247,.06);
    }

    .chat-member-row.selected {
        background: rgba(79,142,247,.12);
    }

    .chat-member-row input[type=checkbox] {
        accent-color: var(--accent);
        flex-shrink: 0;
    }

.chat-member-row-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font);
}

.chat-member-row-sub {
    font-size: 10px;
    color: var(--muted);
    font-family: var(--font);
}

.chat-selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.chat-selected-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(79,142,247,.15);
    border: 1px solid rgba(79,142,247,.3);
    border-radius: 12px;
    padding: 2px 8px 2px 10px;
    font-size: 11px;
    color: var(--accent);
    font-family: var(--font);
}

    .chat-selected-tag button {
        background: none;
        border: none;
        cursor: pointer;
        color: var(--accent);
        font-size: 12px;
        padding: 0;
        line-height: 1;
    }

/* Search results */
.chat-search-result {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s;
}

    .chat-search-result:hover {
        background: rgba(79,142,247,.06);
    }

.chat-search-result-channel {
    font-size: 10px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 3px;
    font-family: var(--font);
}

.chat-search-result-content {
    font-size: 13px;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.4;
}

.chat-search-result-meta {
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
    font-family: var(--font);
}

.chat-search-highlight {
    background: rgba(255,200,0,.25);
    border-radius: 2px;
    padding: 0 2px;
}

/* Attachment list */
.chat-attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s;
}

    .chat-attachment-item:hover {
        background: rgba(79,142,247,.06);
    }

.chat-attachment-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.chat-attachment-info {
    flex: 1;
    min-width: 0;
}

.chat-attachment-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attachment-meta {
    font-size: 10px;
    color: var(--muted);
    margin-top: 1px;
    font-family: var(--font);
}


/* ── Participants two-column layout ──────────────────────────────────── */
.cw-participants-wrap {
    display: flex;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.cw-participants-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

    .cw-participants-col:last-child {
        border-right: none;
    }

.cw-participants-col-hdr {
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-family: var(--font);
    background: var(--surface2);
}

    .cw-participants-col-hdr span {
        font-size: 10px;
        font-weight: 400;
        color: var(--muted);
        text-transform: none;
        letter-spacing: 0;
        margin-left: 4px;
        font-family: var(--font);
    }

.cw-participants-search {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

    .cw-participants-search input {
        width: 100%;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 5px 9px;
        font-size: 11px;
        color: var(--text);
        font-family: var(--font);
        outline: none;
        box-sizing: border-box;
    }

        .cw-participants-search input:focus {
            border-color: var(--accent);
        }

        .cw-participants-search input::placeholder {
            color: var(--muted);
        }

.cw-participants-list {
    flex: 1;
    overflow-y: auto;
}

    .cw-participants-list::-webkit-scrollbar {
        width: 3px;
    }

    .cw-participants-list::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }

.cw-participant-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid var(--border);
}

    .cw-participant-row:hover:not(.already-added) {
        background: rgba(79,142,247,.06);
    }

    .cw-participant-row.already-added {
        opacity: .4;
        cursor: not-allowed;
    }

        .cw-participant-row.already-added:hover {
            background: none;
        }

.cw-participant-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font);
}

.cw-participant-info {
    flex: 1;
    min-width: 0;
}

.cw-participant-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font);
    line-height: 1.3;
}

.cw-participant-sub {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font);
    line-height: 1.3;
}

.cw-participant-add-btn {
    background: var(--accent);
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
    transition: opacity .12s;
}

    .cw-participant-add-btn:hover {
        opacity: .85;
    }

.cw-participant-remove-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 10px;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
    transition: color .12s, border-color .12s;
}

    .cw-participant-remove-btn:hover {
        color: var(--danger,#ef4444);
        border-color: var(--danger,#ef4444);
    }

.cw-participant-owner-badge {
    font-size: 10px;
    color: var(--muted);
    flex-shrink: 0;
    font-family: var(--font);
}


/* ── Inline edit mode ────────────────────────────────────────────────── */
.cw-msg.editing {
    background: rgba(79,142,247,.08);
    border-radius: 8px;
}

.cw-edit-area {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--accent);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    resize: none;
    line-height: 1.45;
    box-sizing: border-box;
    margin-top: 4px;
}

.cw-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 5px;
    align-items: center;
}

.cw-edit-save {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    font-family: var(--font);
}

.cw-edit-cancel {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
}

.cw-edit-timer {
    font-size: 10px;
    color: var(--muted);
    font-family: var(--font);
    margin-left: auto;
}


/* ── @mention picker ─────────────────────────────────────────────────── */
.csp-mention-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .1s;
}

    .csp-mention-item:hover, .csp-mention-item.active {
        background: rgba(79,142,247,.1);
    }

.csp-mention-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font);
}

.csp-mention-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font);
}

/* ── Thread reply count badge ────────────────────────────────────────── */
.cw-reply-count {
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
    margin-top: 3px;
    display: inline-block;
    font-family: var(--font);
    font-weight: 600;
    transition: opacity .12s;
}

    .cw-reply-count:hover {
        opacity: .75;
    }

/* ── Seen-by row ─────────────────────────────────────────────────────── */
.cw-seen-row {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 1px 10px 2px;
    justify-content: flex-end;
}

/* ── Upload progress bar ─────────────────────────────────────────────── */
#cspUploadProgress {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 8px;
    right: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 8005;
    font-family: var(--font);
    box-shadow: 0 -2px 12px rgba(0,0,0,.15);
}

/* Lightbox */
#chatLightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9100;
    display: none;
    align-items: center;
    justify-content: center;
}

    #chatLightbox.open {
        display: flex;
    }

    #chatLightbox img {
        max-width: 92vw;
        max-height: 92vh;
        border-radius: 6px;
        object-fit: contain;
    }

.chat-lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    opacity: .7;
    transition: opacity .12s;
}

    .chat-lightbox-close:hover {
        opacity: 1;
    }


/* ═══════════════════════════════════════════════════════════════════════
   MINI MODE — collapse the chat launcher into a 48-px chat-bubble icon.
   Toggled by the &#8211; button next to the chevron; click the icon to restore.
   State persists across pages via localStorage (plsignum.chat.mini).
   ═══════════════════════════════════════════════════════════════════════ */
.chat-launcher-min {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    border-radius: 3px;
    font-size: 16px;
    line-height: 1;
    user-select: none;
    margin-right: 2px;
}
.chat-launcher-min:hover {
    background: var(--surface);
    color: var(--text);
}

#chatMiniIcon {
    display: none;
    position: relative;
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    color: #fff;
    transition: transform .12s ease, box-shadow .12s ease;
}
#chatMiniIcon:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.chat-mini-badge {
    display: none;
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--bg);
}
.chat-mini-badge.visible { display: flex; }

/* When .mini is on: hide the regular launcher chrome, show only the icon. */
#chatLauncher.mini {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    bottom: 16px;
    left: 16px;
    overflow: visible;
}
#chatLauncher.mini #chatLauncherHdr,
#chatLauncher.mini #chatLauncherBody {
    display: none !important;
}
#chatLauncher.mini #chatMiniIcon {
    display: flex;
}
