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

:root {
    --bg-base: #1a1a1a;
    --bg-elevated: #0f0f0f;
    --bg-surface: #0a0a0a;
    --bg-overlay: rgba(15, 15, 15, 0.85);
    --bg-hover: #2a2a2a;
    --bg-active: rgba(255, 255, 255, 0.1);
    
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-tertiary: rgba(255, 255, 255, 0.4);
    
    --border-subtle: #2a2a2a;
    --border-default: #2a2a2a;
    
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-glow: rgba(102, 126, 234, 0.3);
    
    --success: #43b581;
    --danger: #f04747;
    --warning: #faa61a;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    --bg-base: #ffffff;
    --bg-elevated: #f5f5f5;
    --bg-surface: #e5e5e5;
    --bg-overlay: rgba(255, 255, 255, 0.9);
    --bg-hover: #e0e0e0;
    --bg-active: rgba(0, 0, 0, 0.08);
    
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: rgba(0, 0, 0, 0.4);
    
    --border-subtle: #dddddd;
    --border-default: #dddddd;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

@supports (height: 100dvh) {
    html, body {
        height: 100dvh;
    }
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

.loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: loaderIn 0.6s ease-out;
}

@keyframes loaderIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.loader-logo {
    animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.loader-spinner {
    width: 40px;
    height: 40px;
    position: relative;
}

.spinner-ring {
    width: 100%;
    height: 100%;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loader-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.screen.hidden {
    display: none;
}

.auth-screen {
    display: flex;
    flex-direction: column;
}

.auth-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.auth-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.auth-shape-1 {
    width: 300px;
    height: 300px;
    background: var(--accent-primary);
    top: -100px;
    right: -100px;
    animation: float1 8s ease-in-out infinite;
}

.auth-shape-2 {
    width: 250px;
    height: 250px;
    background: var(--accent-secondary);
    bottom: 20%;
    left: -80px;
    animation: float2 10s ease-in-out infinite;
}

.auth-shape-3 {
    width: 200px;
    height: 200px;
    background: var(--accent-primary);
    bottom: -50px;
    right: 20%;
    animation: float3 12s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, 20px) rotate(10deg); }
    66% { transform: translate(-20px, 10px) rotate(-5deg); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(40px, -30px) rotate(15deg); }
}

@keyframes float3 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, -20px); }
}

.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
    padding-top: max(24px, var(--safe-top));
    padding-bottom: max(24px, var(--safe-bottom));
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 48px;
    animation: authHeaderIn 0.6s ease-out 0.2s both;
}

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

.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: white;
    box-shadow: 0 8px 32px var(--accent-glow);
}

.auth-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

.auth-form {
    max-width: 360px;
    margin: 0 auto;
    width: 100%;
    animation: authFormIn 0.6s ease-out 0.4s both;
}

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

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-group:focus-within .input-icon {
    color: var(--accent-primary);
}

.input {
    width: 100%;
    height: 56px;
    padding: 0 16px 0 52px;
    background: var(--bg-elevated);
    border: 2px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-fast);
}

.input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.input-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.error-message {
    min-height: 24px;
    padding: 4px 0;
    font-size: 14px;
    color: var(--danger);
    text-align: center;
    font-weight: 500;
}

.btn-primary {
    width: 100%;
    height: 56px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    position: relative;
    z-index: 10;
}

.main-header {
    height: 60px;
    padding: 0 20px;
    padding-top: var(--safe-top);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    transition: transform var(--transition-base);
}

.main-header.hidden {
    transform: translateY(calc(-100% - var(--safe-top)));
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.header-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-btn:active {
    background: var(--bg-active);
    transform: scale(0.95);
}

.content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    background: var(--bg-base);
    overflow: hidden;
}

.view.active {
    display: flex;
}

#chat-view,
#dm-chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

#chat-view.active,
#dm-chat-view.active {
    display: flex;
}

#chat-view .chat-header,
#dm-chat-view .chat-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}

#chat-view .messages-area,
#dm-chat-view .messages-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

#chat-view .composer,
#dm-chat-view .composer {
    flex-shrink: 0;
}


.servers-grid {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.server-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    animation: cardIn 0.4s ease-out both;
}

.server-card:active {
    transform: scale(0.98);
    background: var(--bg-surface);
}

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

.server-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

.server-details {
    flex: 1;
    min-width: 0;
}

.server-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.server-meta-dot {
    width: 4px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 50%;
}

.server-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.skeleton-card {
    height: 80px;
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-lg);
    animation: skeleton 1.5s ease-in-out infinite;
}

.skeleton-item {
    height: 64px;
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-md);
    animation: skeleton 1.5s ease-in-out infinite;
    margin-bottom: 8px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.subheader {
    height: 64px;
    padding: 0 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.back-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.back-btn:active {
    background: var(--bg-active);
    transform: scale(0.95);
}

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

.subheader-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

.subheader-text {
    min-width: 0;
}

.subheader-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subheader-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.channels-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.channels-section {
    margin-bottom: 20px;
}

.channels-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 8px 12px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.channel-item:active {
    background: var(--bg-active);
    transform: scale(0.98);
}

.channel-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.channel-icon.voice {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.channel-name {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
}

.chat-header {
    height: 64px;
    min-height: 64px;
    padding: 0 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    z-index: 100;
    position: sticky;
    top: 0;
}

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

.chat-hash {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.chat-header-title {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    position: relative;
}

.chat-header-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--text-tertiary);
    border: 2px solid var(--bg-elevated);
    border-radius: 50%;
}

.chat-header-avatar.online::after {
    background: var(--success);
}

.chat-header-user-info {
    min-width: 0;
}

.chat-header-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-header-status.online {
    color: var(--success);
}

.chat-header-status.typing {
    color: var(--primary);
    font-style: italic;
}

.messages-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.messages-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 100%;
}

.message-group {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    animation: messageIn 0.3s ease-out;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    align-self: flex-start;
}

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

.message-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-size: 15px;
    font-weight: 600;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.message-content {
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    color: var(--text-primary);
}

.message-continuation {
    padding: 2px 0 2px 52px;
}

.message-continuation .message-content {
    font-size: 15px;
}

.messages-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.messages-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.messages-empty-text {
    font-size: 15px;
    color: var(--text-secondary);
}

.composer {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    z-index: 50;
}

.composer-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

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

.composer-input-wrap {
    flex: 1;
    min-width: 0;
}

.composer-input {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

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

.composer-input::placeholder {
    color: var(--text-tertiary);
}

.composer-send {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.composer-send:active {
    transform: scale(0.92);
}

.friends-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.friends-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 12px 4px 8px;
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    animation: cardIn 0.4s ease-out both;
}

.friend-card:active {
    background: var(--bg-active);
    transform: scale(0.98);
}

.friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    position: relative;
}

.friend-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-tertiary);
    border: 3px solid var(--bg-base);
    border-radius: 50%;
}

.friend-avatar.online::after {
    background: var(--success);
}

.friend-details {
    flex: 1;
    min-width: 0;
}

.friend-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.friend-status.online {
    color: var(--success);
}

.profile-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.profile-card {
    background: var(--bg-elevated);
    margin: 16px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
}

.profile-banner {
    height: 100px;
    background: var(--accent-gradient);
    position: relative;
}

.profile-banner-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
}

.profile-avatar-wrap {
    position: relative;
    width: 88px;
    height: 88px;
    margin: -44px auto 12px;
}

.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    border: 4px solid var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: white;
    background-size: cover;
    background-position: center;
    text-transform: uppercase;
}

.profile-status-dot {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--success);
    border: 4px solid var(--bg-elevated);
    border-radius: 50%;
}

.profile-username {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}

.profile-tag {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    padding-bottom: 20px;
}

.settings-section {
    padding: 0 16px;
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 12px 4px 8px;
}

.settings-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row:active {
    background: var(--bg-hover);
}

.settings-row.danger {
    color: var(--danger);
}

.settings-row.danger .settings-row-icon {
    color: var(--danger);
}

.settings-row-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.settings-row-content {
    flex: 1;
    min-width: 0;
}

.settings-row-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-row.danger .settings-row-title {
    color: var(--danger);
}

.settings-row-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.toggle {
    position: relative;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-base);
}

.toggle-track::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    left: 4px;
    top: 4px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-track {
    background: var(--accent-gradient);
}

.toggle input:checked + .toggle-track::before {
    transform: translateX(20px);
}

.app-version {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 20px;
}

.voice-bar {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(76px + var(--safe-bottom));
    padding: 12px 16px;
    background: var(--bg-overlay);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% + 20px));
    opacity: 0;
    transition: all var(--transition-base);
}

.voice-bar:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
}

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

.voice-bar-pulse {
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.voice-bar-details {
    min-width: 0;
}

.voice-bar-channel {
    display: block;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-bar-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.voice-bar-controls {
    display: flex;
    gap: 8px;
}

.voice-control-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.voice-control-btn:active {
    transform: scale(0.92);
}

.voice-control-btn.muted {
    background: var(--danger);
    color: white;
}

.voice-control-btn.disconnect {
    background: var(--danger);
    color: white;
}

.tab-bar {
    height: 64px;
    padding: 0 8px;
    padding-bottom: var(--safe-bottom);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    transition: transform var(--transition-base);
}

.tab-bar.hidden {
    transform: translateY(100%);
}

.tab-item {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.tab-item:active {
    transform: scale(0.95);
}

.tab-item.active {
    color: var(--accent-primary);
}

.tab-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-label {
    font-size: 11px;
    font-weight: 500;
}

.toast {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: all var(--transition-base);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.typing-indicator {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    min-height: 36px;
    position: sticky;
    bottom: 68px;
    z-index: 49;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    pointer-events: none;
}

.typing-indicator.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.pull-to-refresh {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-60px);
    transition: transform var(--transition-base);
    z-index: 100;
}

.pull-to-refresh.pulling {
    transform: translateY(0);
}

.pull-to-refresh-icon {
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    transition: transform var(--transition-base);
}

.pull-to-refresh.ready .pull-to-refresh-icon {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.pull-to-refresh.refreshing .pull-to-refresh-icon {
    animation: spin 0.8s linear infinite;
}

.message-context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-default);
    min-width: 200px;
    z-index: 9999;
    opacity: 0;
    transform: scale(0.9);
    transition: all var(--transition-fast);
    pointer-events: none;
}

.message-context-menu.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:active {
    background: var(--bg-hover);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.connection-status {
    position: fixed;
    top: calc(var(--safe-top) + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 8px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    opacity: 0;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-status.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.connection-status.reconnecting {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.connection-status.connected {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.connection-status.disconnected {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.connection-status-dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.members-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.members-modal.hidden {
    display: none;
}

.members-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.members-modal-content {
    position: relative;
    width: 100%;
    max-height: 70vh;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

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

.members-modal-title {
    font-size: 18px;
    font-weight: 600;
}

.members-modal-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.members-modal-close:active {
    background: var(--bg-hover);
}

.members-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
}

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    position: relative;
}

.member-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--text-tertiary);
    border: 2px solid var(--bg-elevated);
    border-radius: 50%;
}

.member-avatar.online::after {
    background: var(--success);
}

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

.member-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.call-modal,
.incoming-call-modal {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-modal.hidden,
.incoming-call-modal.hidden {
    display: none;
}

.call-modal-content,
.incoming-call-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.call-avatar,
.incoming-call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: white;
    background-size: cover;
    background-position: center;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px var(--accent-glow);
}

.call-username,
.incoming-call-username {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.call-status,
.incoming-call-status {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.call-timer {
    font-size: 20px;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 40px;
    font-variant-numeric: tabular-nums;
}

.call-timer.hidden {
    display: none;
}

.call-controls {
    display: flex;
    gap: 20px;
    margin-top: 40px;
}

.call-control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.call-control-btn:active {
    transform: scale(0.95);
}

.call-control-btn.muted {
    background: var(--danger);
    color: white;
}

.call-control-btn.hangup {
    background: var(--danger);
    color: white;
    width: 72px;
    height: 72px;
}

.incoming-call-actions {
    display: flex;
    gap: 40px;
    margin-top: 40px;
}

.incoming-call-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.incoming-call-btn:active {
    transform: scale(0.95);
}

.incoming-call-btn.decline {
    background: var(--danger);
    color: white;
}

.incoming-call-btn.accept {
    background: var(--success);
    color: white;
}

@keyframes pulse-call {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(67, 181, 129, 0.4);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(67, 181, 129, 0);
    }
}

.incoming-call-btn.accept {
    animation: pulse-call 2s infinite;
}

.call-message {
    background: linear-gradient(135deg, rgba(67, 181, 129, 0.15) 0%, rgba(46, 204, 113, 0.15) 100%);
    border: 1px solid rgba(67, 181, 129, 0.3);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin: 8px 0;
}

.call-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.call-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43b581 0%, #2ecc71 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.call-icon svg {
    stroke: white;
    width: 18px;
    height: 18px;
}

.call-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.call-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.call-duration {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.call-duration svg {
    width: 12px;
    height: 12px;
}
