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

:root {
    --bg-primary: #0a0d14;
    --bg-secondary: #11141f;
    --bg-tertiary: #1a1f2e;
    --bg-hover: #1e2436;
    --bg-surface: #181d2b;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-dim: rgba(59,130,246,0.10);
    --accent-glow: rgba(59,130,246,0.20);
    --accent-gradient: linear-gradient(135deg, #3b82f6, #2563eb);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #1e293b;
    --border-light: #263348;
    --message-outgoing-start: #1d4ed8;
    --message-outgoing-end: #2563eb;
    --message-incoming: #181d2b;
    --message-incoming-border: rgba(255,255,255,0.04);
    --online: #22c55e;
    --offline: #475569;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(59,130,246,0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --glass-bg: rgba(17,20,31,0.88);
    --glass-border: rgba(255,255,255,0.06);
    --pattern-alpha: 0.025;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    font-size: 14px;
    line-height: 1.5;
}

.app {
    height: 100%;
    display: flex;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

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

.icon-btn:active {
    transform: scale(0.94);
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    pointer-events: none;
    animation: rippleAnim 0.5s ease-out forwards;
}

@keyframes rippleAnim {
    from { transform: scale(0); opacity: 1; }
    to { transform: scale(4); opacity: 0; }
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.hidden { display: none !important; }
.danger-btn svg { color: var(--danger); }
.danger-btn:hover svg { color: var(--danger-hover); }
.select-count { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.select-mode-header { display: none !important; align-items: center; gap: 8px; }
.select-mode-active .select-mode-header { display: flex !important; }
.select-mode-active .normal-mode-header { display: none !important; }
.normal-mode-header { display: flex; }
.chat-item.muted { opacity: 0.5; }
.edited-mark { font-size: 11px; color: var(--text-muted); margin-left: 2px; }
.forwarded-mark { font-size: 11px; color: var(--accent); margin-left: 2px; }

.message-image { max-width: 260px; border-radius: var(--radius-md); cursor: pointer; }
.message-file { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.message-file-icon { 
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--accent);
}
.message-file-icon svg {
    width: 20px;
    height: 20px;
}
.message-input-container.hidden { display: none; }

.avatar-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    user-select: none;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--glass-border);
    animation: notificationIn 0.25s ease;
    border: none;
}

@keyframes notificationIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.96); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-circle {
    border-radius: 50%;
    aspect-ratio: 1;
}

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

.skeleton-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 1px;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.long {
    width: 85%;
}

.skeleton-messages {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-msg {
    display: flex;
    gap: 8px;
    max-width: 75%;
}

.skeleton-msg.outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.skeleton-bubble {
    height: 40px;
    width: 180px;
    border-radius: var(--radius-md);
}

.skeleton-msg.outgoing .skeleton-bubble {
    background: var(--accent-dim);
    width: 140px;
}
