.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(4px);
}

.modal-container {
    width: 90%;
    max-width: 450px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border-radius: 22px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.3s ease;
    border: 1px solid var(--border-color);
    pointer-events: auto;
    overflow: hidden;
    opacity: 0.95;
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h3 { font-size: calc(18px * var(--text-scale, 1)); font-weight: 600; }

.modal-close {
    width: 29px;
    height: 29px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.modal-close:hover { background: var(--bg-quaternary); color: var(--text-primary); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 11px; pointer-events: auto; flex-shrink: 0; }

.xailo-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.xailo-modal-dialog {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    opacity: 0.95;
}

.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border-radius: 13px;
    box-shadow: 0 7px 27px rgba(0,0,0,0.5);
    padding: 5px;
    min-width: 180px;
    z-index: var(--z-context-menu);
    display: none;
    animation: scaleIn 0.15s ease;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    opacity: 0.95;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 7px;
    cursor: pointer;
    color: #fff;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-size: calc(14px * var(--text-scale, 1));
    transition: background 0.2s ease;
    pointer-events: auto;
}

.context-menu-item:hover { background: var(--bg-tertiary); }
.context-menu-item:active { background: rgba(255, 255, 255, 0.05); }
.context-menu-item i { width: 18px; color: var(--accent); font-size: 15px; }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger i { color: var(--danger); }
.context-menu-separator { height: 1px; background: var(--border-color); margin: 7px 0; }

.chat-search-bar {
    height: var(--header-height);
    padding: 7px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: none;
    align-items: center;
    gap: 11px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    animation: slideInDown 0.3s ease;
    pointer-events: auto;
}

.chat-search-input {
    flex: 1;
    padding: 7px 14px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    border-radius: 18px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    font-family: var(--font-family);
    pointer-events: auto;
    cursor: text;
}

.chat-search-input:focus { border-color: var(--accent); }

.search-navigation { display: flex; align-items: center; gap: 7px; }

.search-nav-btn {
    width: 29px;
    height: 29px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.search-nav-btn:hover { background: var(--bg-quaternary); color: var(--text-primary); }
.search-nav-count { font-size: 13px; color: var(--text-muted); }
.highlight { background: var(--warning); color: black; padding: 0 2px; border-radius: 2px; }
.search-highlight { box-shadow: 0 0 9px var(--warning); }

.global-search-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 700;
    display: none;
    flex-direction: column;
}

.search-panel-header {
    height: var(--header-height);
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.search-panel-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    border-radius: 18px;
    color: var(--text-primary);
    font-size: calc(16px * var(--text-scale, 1));
    outline: none;
    font-family: var(--font-family);
}

.search-panel-input:focus { border-color: var(--accent); }

.search-panel-tabs {
    display: flex;
    gap: 0;
    padding: 8px 0;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    -ms-overflow-style: none;
}

.search-panel-tabs::-webkit-scrollbar { height: 0; }

.search-panel-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    border-radius: 20px;
    margin: 0 4px;
}

.search-panel-tab.active { color: #fff; background: var(--accent); }
.search-panel-tab:hover:not(.active) { color: var(--text-primary); background: var(--bg-tertiary); }

.search-panel-results { flex: 1; overflow-y: auto; padding: 0; }

.search-recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.search-recent-item:hover { background: var(--bg-tertiary); }

.search-recent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.search-recent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-recent-info { flex: 1; min-width: 0; }
.search-recent-name { font-weight: 500; font-size: 14px; }
.search-recent-username { font-size: 12px; color: var(--text-muted); }

.search-recent-clear {
    padding: 12px 16px;
    text-align: center;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.search-recent-clear:hover { color: var(--accent-hover); }

.search-recent-section {
    padding: 12px 16px 6px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.search-result-item:hover { background: var(--bg-tertiary); }

.attach-menu {
    position: absolute;
    bottom: 72px;
    left: 14px;
    background: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 7px;
    display: none;
    z-index: var(--z-dropdown);
    animation: scaleIn 0.2s ease;
    border: 1px solid var(--border-color);
    min-width: 180px;
    pointer-events: auto;
    opacity: 0.95;
}

.attach-option {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text-primary);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    transition: background 0.2s ease;
    pointer-events: auto;
}

.attach-option:hover { background: var(--bg-tertiary); }
.attach-option i { width: 22px; text-align: center; }

.mention-suggestions, .command-suggestions {
    position: absolute;
    bottom: 72px;
    left: 72px;
    background: var(--bg-secondary);
    border-radius: 11px;
    box-shadow: var(--shadow-lg);
    max-width: 270px;
    max-height: 180px;
    overflow-y: auto;
    z-index: var(--z-dropdown);
    animation: fadeIn 0.2s ease;
    border: 1px solid var(--border-color);
    pointer-events: auto;
    opacity: 0.95;
}

.mention-suggestion {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    cursor: pointer;
    transition: background 0.2s ease;
    pointer-events: auto;
}

.mention-suggestion:hover { background: var(--bg-tertiary); }

.mention-suggestion-avatar {
    width: 29px;
    height: 29px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.mention-suggestion-avatar img { width: 100%; height: 100%; object-fit: cover; }

.voters-panel {
    position: fixed;
    background: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    padding: 6px;
    min-width: 280px;
    max-width: 360px;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 10001;
    display: none;
    border: 1px solid var(--border-color);
    opacity: 0.95;
}

.voter-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 8px;
}

.voter-group-header:hover { background: var(--bg-tertiary); }
.voter-sublist { display: none; padding: 0 14px 10px 48px; }
.voter-group.expanded .voter-sublist { display: block; }