:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #16161e;
    --bg-tertiary: #1e1e2a;
    --bg-hover: #252536;
    --bg-active: #2a2a3e;
    --surface: #1a1a26;
    --surface-hover: #22223a;
    --border: #2a2a3e;
    --border-light: #333350;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #686880;
    --accent: #6366f1;
    --accent-hover: #7577f5;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-subtle: rgba(99, 102, 241, 0.1);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.3);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --warning: #f59e0b;
    --speaking: #22c55e;
    --speaking-glow: rgba(34, 197, 94, 0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ============ LOGIN SCREEN ============ */

#auth-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    text-align: center;
}

.login-logo { margin-bottom: 40px; }

.logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.logo-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 20px rgba(99, 102, 241, 0.4));
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #e8e8f0, #a0a0c0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.form-group { margin-bottom: 20px; text-align: left; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.optional { color: var(--text-muted); font-weight: 400; }

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-top: 8px;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-primary.loading .btn-text { display: none; }
.btn-primary.loading .btn-loading { display: inline-flex; align-items: center; gap: 8px; }
.btn-loading { display: none; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 13px;
}

.server-info {
    margin-top: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }

.dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ============ VOICE SCREEN ============ */

#voice-screen { background: var(--bg-primary); }

.app-layout { display: flex; width: 100%; height: 100%; }

/* Sidebar */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

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

.server-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    -webkit-user-select: none;
    user-select: none;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon:active { background: var(--bg-active); }

.sidebar-content { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.channel-tree { padding: 0 8px; }
.channel-item { margin-bottom: 2px; }

.channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    -webkit-user-select: none;
    user-select: none;
}

.channel-header:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-header.active { background: var(--accent-subtle); color: var(--accent); }
.channel-header svg { flex-shrink: 0; opacity: 0.6; }
.channel-users { padding-left: 20px; }

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
}

.user-item:hover { background: var(--bg-hover); }
.user-item.self { color: var(--text-primary); }
.user-item.speaking { color: var(--speaking); }

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
    position: relative;
}

.user-item.speaking .user-avatar { box-shadow: 0 0 0 2px var(--speaking-glow); }

.user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-item .user-status { font-size: 10px; color: var(--text-muted); }

.user-vol-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    margin-left: auto;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.5;
}

.user-vol-btn:hover {
    opacity: 1;
    background: var(--bg-tertiary);
}

/* Main Content */

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.current-channel {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
}

.current-channel svg { color: var(--accent); flex-shrink: 0; }

.current-channel span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
    white-space: nowrap;
}

/* Voice Panel */

.voice-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.speaking-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.speaking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 800px;
}

.speaking-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: var(--transition);
    min-width: 0;
}

.speaking-card.is-speaking {
    border-color: var(--speaking);
    box-shadow: 0 0 20px var(--speaking-glow);
}

.avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: white;
    position: relative;
    flex-shrink: 0;
}

.avatar.speaking-ring::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid var(--speaking);
    opacity: 0;
    transition: var(--transition);
}

.speaking-card.is-speaking .avatar.speaking-ring::after {
    opacity: 1;
    animation: speak-ring 1.5s ease-in-out infinite;
}

@keyframes speak-ring {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 0.4; }
}

.speaking-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.speaking-status {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.self-card.muted .speaking-status { color: var(--danger); }

/* Chat Area */

.chat-area {
    height: 180px;
    min-height: 100px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-messages { flex: 1; overflow-y: auto; padding: 10px 14px; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-welcome {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 16px 0;
}

.chat-hint { font-size: 12px; margin-top: 4px; }
.chat-msg { padding: 3px 0; font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-msg .chat-sender { font-weight: 600; color: var(--accent); margin-right: 6px; }
.chat-msg .chat-text { color: var(--text-primary); }
.chat-msg.system { color: var(--text-muted); font-style: italic; font-size: 12px; }

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

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

/* Controls Bar */

.controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    gap: 12px;
    position: relative;
    flex-shrink: 0;
}

.controls-center { display: flex; align-items: center; gap: 10px; }

.controls-right {
    position: absolute;
    right: 16px;
    display: flex;
    gap: 6px;
}

.ctrl-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    -webkit-user-select: none;
    user-select: none;
    flex-shrink: 0;
}

.ctrl-btn:hover { background: var(--bg-hover); }
.ctrl-btn:active { transform: scale(0.95); }
.ctrl-btn.active, .ctrl-btn.muted { background: var(--danger); color: white; }
.ctrl-btn.muted { box-shadow: 0 0 16px var(--danger-glow); }
.ctrl-btn.small { width: 36px; height: 36px; }

.ptt-btn {
    width: auto !important;
    padding: 0 24px;
    border-radius: var(--radius-xl) !important;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.ptt-btn.ptt-active {
    background: var(--success) !important;
    color: white;
    box-shadow: 0 0 16px var(--success-glow);
}

/* Scrollbar */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============ ADMIN OVERLAY ============ */

.admin-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease-out;
}

.admin-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* ============ MODAL ============ */

.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease-out;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 0 20px 16px; display: flex; justify-content: flex-end; }

.setting-group { margin-bottom: 16px; }
.setting-group:last-child { margin-bottom: 0; }

.setting-group > label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.setting-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239898b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.setting-select:focus { border-color: var(--accent); }
.setting-select option { background: var(--bg-tertiary); color: var(--text-primary); }

.setting-range {
    width: calc(100% - 48px);
    vertical-align: middle;
    accent-color: var(--accent);
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

.setting-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.setting-range::-moz-range-thumb {
    width: 20px; height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.volume-label {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.mic-level-bar {
    margin-top: 8px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.mic-level-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    border-radius: 2px;
    transition: width 0.1s;
}

.setting-divider { height: 1px; background: var(--border); margin: 16px 0; }

.setting-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    -webkit-user-select: none;
    user-select: none;
}

.setting-checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.setting-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 4px 0 8px;
    line-height: 1.4;
}

/* ============ CERT UPLOAD ============ */

.cert-upload-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cert-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.cert-upload-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    pointer-events: none;
}

.cert-upload-area:hover .cert-upload-btn {
    border-color: var(--accent);
    color: var(--text-primary);
}

.cert-upload-area.has-file .cert-upload-btn {
    border-style: solid;
    border-color: var(--success);
    color: var(--success);
}

.cert-clear {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 3;
    position: relative;
}

.cert-clear:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.cert-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* ============ AUTH ============ */

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    text-align: center;
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-switch {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* ============ PROFILE BAR ============ */

.profile-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.profile-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.profile-selector label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.profile-select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239898b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    min-width: 0;
}

.profile-select option { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-sm {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover { background: var(--accent-hover); }
.btn-accent.connected { background: var(--danger); }

.btn-outline {
    padding: 8px 16px;
    background: transparent;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ============ PROFILES LIST ============ */

.profiles-list { max-height: 300px; overflow-y: auto; }

.profile-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

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

.profile-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-item-user {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.badge {
    font-size: 10px;
    padding: 1px 6px;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: 10px;
    font-weight: 600;
}

.profile-item-actions { display: flex; gap: 4px; }

/* ============ SIDEBAR FOOTER ============ */

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 10px 14px;
    flex-shrink: 0;
}

.user-info-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Animations */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease-out; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
.slide-in { animation: slideIn 0.2s ease-out; }

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

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* Hide mobile-only by default */
.mobile-only { display: none; }

/* === Large Desktop (1200+) === */
@media (min-width: 1200px) {
    .speaking-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }
    .speaking-card { padding: 24px 20px; }
    .avatar { width: 64px; height: 64px; font-size: 24px; }
}

/* === Tablet (768 - 1024) === */
@media (max-width: 1024px) {
    .sidebar { --sidebar-width: 220px; }
    .speaking-area { padding: 20px; }
    .speaking-grid { gap: 12px; }
    .connection-status span:last-child { display: none; }
}

/* === Small Tablet / Large Phone (600 - 768) === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }
    .mobile-only { display: flex; }

    .top-bar { padding: 10px 12px; }
    .speaking-area { padding: 16px; }
    .speaking-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
    .speaking-card { padding: 16px 12px; gap: 8px; }
    .avatar { width: 48px; height: 48px; font-size: 18px; }
    .speaking-name { font-size: 12px; }

    .chat-area { height: 140px; min-height: 80px; }
    .chat-msg { font-size: 12px; }

    .controls-bar { padding: 10px 12px; gap: 8px; }
    .controls-right { right: 12px; }
    .ctrl-btn { width: 44px; height: 44px; }
    .ctrl-btn.small { width: 32px; height: 32px; }
    .ptt-btn { padding: 0 18px; font-size: 12px; }

    .modal-body { padding: 14px 16px; }
}

/* === Small Phone (< 480) === */
@media (max-width: 480px) {
    .auth-container { padding: 24px 20px; }
    .login-logo { margin-bottom: 28px; }
    .logo-icon { width: 60px; height: 60px; margin-bottom: 14px; }
    .login-logo h1 { font-size: 22px; }
    .subtitle { font-size: 13px; }
    .form-group input { padding: 10px 14px; font-size: 16px; }
    .btn-primary { padding: 12px 20px; font-size: 14px; }
    .server-info { margin-top: 24px; font-size: 12px; }

    .sidebar-header { padding: 12px 14px; }
    .server-name { font-size: 13px; }
    .channel-header { padding: 7px 10px; font-size: 12px; }
    .user-item { padding: 5px 10px; font-size: 12px; }
    .user-avatar { width: 24px; height: 24px; font-size: 10px; }

    .top-bar { padding: 8px 10px; gap: 8px; }
    .current-channel { font-size: 13px; }
    .connection-status { padding: 3px 8px; font-size: 11px; }

    .profile-bar { padding: 6px 10px; }
    .profile-selector label { font-size: 12px; }
    .profile-select { font-size: 12px; padding: 5px 8px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }

    .speaking-area { padding: 12px; }
    .speaking-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
    .speaking-card { padding: 12px 8px; gap: 6px; }
    .avatar { width: 40px; height: 40px; font-size: 16px; }
    .speaking-name { font-size: 11px; }
    .speaking-status { font-size: 10px; }

    .chat-area { height: 120px; min-height: 70px; }
    .chat-messages { padding: 8px 10px; }
    .chat-input-area { padding: 6px 10px; }
    .chat-input-area input { padding: 7px 10px; font-size: 14px; }

    .controls-bar { padding: 8px 10px; padding-bottom: calc(8px + var(--safe-bottom)); }
    .controls-center { gap: 8px; }
    .ctrl-btn { width: 44px; height: 44px; }
    .ctrl-btn.small { width: 30px; height: 30px; }

    .modal-content { border-radius: var(--radius-md); }
    .modal-header { padding: 16px 16px 0; }
    .modal-body { padding: 12px 16px; }
    .modal-footer { padding: 0 16px 12px; }
    .setting-range { width: calc(100% - 44px); }
}

/* === Landscape phone === */
@media (max-height: 500px) and (orientation: landscape) {
    .speaking-area { padding: 8px; }
    .speaking-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
    .speaking-card { padding: 8px 6px; gap: 4px; }
    .avatar { width: 36px; height: 36px; font-size: 14px; }
    .speaking-name { font-size: 10px; }
    .chat-area { height: 80px; min-height: 60px; }
    .controls-bar { padding: 6px 10px; }
    .ctrl-btn { width: 40px; height: 40px; }
}

/* === Touch-friendly === */
@media (hover: none) and (pointer: coarse) {
    .btn-icon { width: 40px; height: 40px; }
    .ctrl-btn { width: 52px; height: 52px; }
    .ctrl-btn.small { width: 40px; height: 40px; }
    .channel-header { padding: 10px 12px; }
    .user-item { padding: 8px 12px; }
    .setting-range::-webkit-slider-thumb { width: 24px; height: 24px; }
    .setting-range::-moz-range-thumb { width: 24px; height: 24px; }
    .setting-checkbox-label input[type="checkbox"] { width: 20px; height: 20px; }
}

/* === High DPI === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .border, .sidebar { border-width: 0.5px; }
}
