:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f24;
    --bg-card: rgba(18, 18, 42, 0.8);
    --accent: #e94560;
    --accent-hover: #ff5a75;
    --accent-glow: rgba(233, 69, 96, 0.35);
    --accent-dim: rgba(233, 69, 96, 0.15);
    --text-primary: #f0f0f5;
    --text-secondary: #8888b0;
    --text-muted: #555570;
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(18, 18, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --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%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 0% 50%, rgba(233, 69, 96, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 50%, rgba(100, 50, 200, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 50% 100%, rgba(50, 100, 200, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

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

/* ════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.6s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--accent-dim);
    border-radius: 18px;
    border: 1px solid var(--glass-border);
}

.login-logo svg {
    width: 32px;
    height: 32px;
    fill: var(--accent);
}

.login-card h1 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrap {
    position: relative;
}

.input-wrap .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    pointer-events: none;
    transition: fill 0.3s;
}

.glass-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(10, 10, 26, 0.6);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.glass-input:hover {
    border-color: var(--border-light);
}

.glass-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px rgba(233, 69, 96, 0.15);
}

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

.btn-primary {
    width: 100%;
    padding: 15px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #d63851);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(233, 69, 96, 0.35);
}

.btn-primary:active {
    transform: translateY(0) scale(0.99);
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.08) 50%, transparent 60%);
    transition: transform 0.5s;
    transform: translateX(-100%);
}

.btn-primary:hover::after {
    transform: translateX(100%);
}

/* ════════════════════════════════════════
   ROOM PAGE
   ════════════════════════════════════════ */
.room-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

#connectionBar {
    text-align: center;
    padding: 5px 16px;
    padding-top: calc(5px + var(--safe-top));
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.4s ease;
    flex-shrink: 0;
    z-index: 5;
}

#connectionBar.connected {
    background: linear-gradient(135deg, #0d4a2a, #0f5a30);
    color: #6fcf97;
}

#connectionBar.connecting {
    background: linear-gradient(135deg, #6a5010, #7a6018);
    color: #f2c94c;
}

#connectionBar.disconnected {
    background: linear-gradient(135deg, #6a1818, #8a2020);
    color: #ff8a80;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 4;
}

.room-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    letter-spacing: -0.2px;
}

.participant-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--accent-dim);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.participant-badge svg {
    width: 14px;
    height: 14px;
    fill: var(--text-secondary);
}

/* ─── Video Grid ─── */
#videoGrid {
    flex: 1;
    display: grid;
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    align-content: center;
    position: relative;
}

#videoGrid:empty::after {
    content: 'Ожидание участников...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    white-space: nowrap;
    animation: pulse 2s ease-in-out infinite;
}

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

.video-container {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    min-height: 150px;
    box-shadow: var(--shadow-sm);
    animation: tileIn 0.4s ease-out;
    border: 1px solid var(--border);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.video-container:hover {
    border-color: var(--border-light);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

@keyframes tileIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-container.speaking {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.video-element {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-element.hidden {
    display: none;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    border-radius: var(--radius-md);
    z-index: 1;
    user-select: none;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 4px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.video-mic-off {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: rgba(233, 69, 96, 0.2);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.video-mic-off.visible {
    display: flex;
}

.video-mic-off svg {
    width: 14px;
    height: 14px;
    fill: var(--accent);
}

/* ─── Controls ─── */
.room-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 4;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    min-width: 72px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.6rem;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-light);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0) scale(0.96);
}

.control-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    transition: fill 0.2s;
}

.control-btn.active {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.control-btn.inactive {
    background: rgba(233, 69, 96, 0.2);
    border-color: rgba(233, 69, 96, 0.3);
    color: var(--accent);
}

.control-btn.inactive:hover {
    background: rgba(233, 69, 96, 0.3);
}

.control-btn.danger {
    background: rgba(200, 40, 40, 0.2);
    border-color: rgba(200, 40, 40, 0.3);
    color: #ff6b6b;
}

.control-btn.danger:hover {
    background: rgba(200, 40, 40, 0.35);
    color: #ff8a8a;
}

/* ════════════════════════════════════════
   GRID LAYOUTS
   ════════════════════════════════════════ */
.participants-1 { grid-template-columns: minmax(auto, 720px); justify-content: center; align-content: center; }
.participants-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.participants-3,
.participants-4 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.participants-5,
.participants-6 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.participants-7,
.participants-8,
.participants-9,
.participants-10 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 1024px) {
    #videoGrid { gap: 6px; padding: 8px; }
    .video-container { min-height: 130px; }
    .login-card { padding: 40px 32px 36px; }
}

@media (max-width: 896px) and (orientation: landscape) {
    .room-header { padding: 8px 16px; }
    .header-logo { font-size: 0.9rem; }
    #videoGrid { padding: 4px; gap: 4px; }
    .video-container { min-height: 100px; }
    .video-placeholder { font-size: 2rem; }
    .room-controls { padding: 8px 12px; padding-bottom: calc(8px + var(--safe-bottom)); gap: 8px; }
    .control-btn { min-width: 56px; padding: 8px 10px; border-radius: 10px; }
    .control-btn svg { width: 18px; height: 18px; }
    .control-btn span { font-size: 0.5rem; }
    .participants-1 { grid-template-columns: 1fr; }
    .participants-2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .login-card { padding: 32px 24px 28px; border-radius: 20px; }
    .login-logo { width: 52px; height: 52px; border-radius: 14px; }
    .login-logo svg { width: 26px; height: 26px; }
    .login-card h1 { font-size: 1.4rem; }
    .glass-input { padding: 12px 14px 12px 40px; font-size: 0.95rem; }
    .btn-primary { padding: 13px 20px; }

    .room-header { padding: 10px 14px; }
    .header-logo { font-size: 0.9rem; }
    .participant-badge { font-size: 0.7rem; padding: 3px 10px; }
    .participant-badge svg { width: 12px; height: 12px; }

    #videoGrid { padding: 4px; gap: 4px; }
    .video-container { min-height: 120px; }
    .video-placeholder { font-size: 2.2rem; }
    .video-label { font-size: 0.7rem; bottom: 6px; left: 6px; padding: 3px 10px; }
    .video-mic-off { width: 24px; height: 24px; top: 6px; right: 6px; }
    .video-mic-off svg { width: 12px; height: 12px; }

    .room-controls { padding: 12px 10px; padding-bottom: calc(12px + var(--safe-bottom)); gap: 8px; }
    .control-btn { min-width: 60px; padding: 8px 12px; border-radius: 12px; gap: 3px; }
    .control-btn svg { width: 20px; height: 20px; }
    .control-btn span { font-size: 0.55rem; }
    #videoGrid:empty::after { font-size: 0.9rem; }
}

@media (max-width: 374px) {
    .control-btn { min-width: 48px; padding: 6px 8px; }
    .control-btn svg { width: 16px; height: 16px; }
    .control-btn span { font-size: 0.5rem; }
    .room-controls { gap: 4px; padding: 8px 6px; }
}

@supports (padding: max(0px)) {
    .room-header { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
    .room-controls { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}

@media (prefers-color-scheme: light) {
    :root { --bg-primary: #0a0a1a; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ════════════════════════════════════════
   FORM HELPERS
   ════════════════════════════════════════ */
.form-error {
    color: var(--accent);
    font-size: 0.82rem;
    margin-bottom: 16px;
    min-height: 20px;
    text-align: center;
}

.form-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 16px;
    line-height: 1.4;
}

.btn-small {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-small:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

/* ════════════════════════════════════════
   CONTACTS PAGE
   ════════════════════════════════════════ */
.contacts-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

.contacts-header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    padding-top: calc(12px + var(--safe-top));
    flex-shrink: 0;
    z-index: 4;
}

.contacts-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.search-wrap {
    position: relative;
}

.search-input {
    padding: 12px 16px !important;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 10;
    box-shadow: var(--shadow);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(255,255,255,0.03);
}

.search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

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

.search-result-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.search-result-nick {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.search-result-action {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
}

.search-result-action:hover:not(:disabled) {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.search-result-action:disabled {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.6;
}

/* ─── Section ─── */
.section-title {
    padding: 16px 20px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.pending-section {
    flex-shrink: 0;
}

.pending-section .section-title {
    color: var(--accent);
}

/* ─── Friend List ─── */
.friend-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px 20px;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    position: relative;
}

.friend-item:hover {
    background: rgba(255,255,255,0.03);
}

.friend-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.online-dot {
    position: absolute;
    left: 42px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #555;
    border: 2px solid var(--bg-primary);
    transition: background 0.3s;
    z-index: 2;
}

.online-dot.online {
    background: #2ecc71;
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.5);
}

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

.friend-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.friend-nick {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.friend-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.friend-call-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.friend-call-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.friend-call-btn:hover {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.friend-call-btn.accept-req:hover {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.friend-call-btn.reject-req:hover {
    background: rgba(233, 69, 96, 0.2);
    border-color: rgba(233, 69, 96, 0.3);
    color: var(--accent);
}

/* ─── Empty State ─── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    gap: 8px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    fill: currentColor;
    opacity: 0.4;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.empty-state span {
    font-size: 0.82rem;
    text-align: center;
    max-width: 280px;
    line-height: 1.4;
}

/* ─── Connection Status ─── */
.conn-status {
    text-align: center;
    padding: 6px 16px;
    padding-bottom: calc(6px + var(--safe-bottom));
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.conn-status.online {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.08);
}

.conn-status.offline {
    color: var(--accent);
    background: rgba(233, 69, 96, 0.08);
}

/* ════════════════════════════════════════
   INCOMING CALL OVERLAY
   ════════════════════════════════════════ */
.call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.call-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 32px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: fadeUp 0.4s ease-out;
    max-width: 340px;
    width: 90%;
}

.caller-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 0 24px rgba(233, 69, 96, 0.3);
}

.caller-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.caller-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    animation: pulse 1.5s ease-in-out infinite;
}

.call-actions {
    display: flex;
    gap: 24px;
    margin-top: 12px;
}

.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.65rem;
    font-family: inherit;
    font-weight: 500;
    color: #fff;
    transition: all 0.2s;
}

.call-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.call-btn.accept {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.4);
}

.call-btn.accept:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(46, 204, 113, 0.5);
}

.call-btn.reject {
    background: linear-gradient(135deg, var(--accent), #c0392b);
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
}

.call-btn.reject:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(233, 69, 96, 0.5);
}

/* ════════════════════════════════════════
   CONTACTS RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 480px) {
    .contacts-header { padding: 8px 14px; padding-top: calc(8px + var(--safe-top)); }
    .contacts-header-top { margin-bottom: 8px; }
    .search-input { padding: 10px 14px !important; font-size: 0.9rem; }

    .friend-avatar { width: 38px; height: 38px; font-size: 0.95rem; }
    .online-dot { left: 36px; top: 6px; width: 10px; height: 10px; }
    .friend-name { font-size: 0.85rem; }
    .friend-item { padding: 10px 12px; }
    .friend-call-btn { width: 34px; height: 34px; }
    .friend-call-btn svg { width: 16px; height: 16px; }

    .call-overlay-content { padding: 32px 24px; }
    .caller-avatar { width: 60px; height: 60px; font-size: 1.6rem; }
    .caller-name { font-size: 1.1rem; }
    .call-btn { width: 56px; height: 56px; }
    .call-btn svg { width: 24px; height: 24px; }
}

@media (max-width: 374px) {
    .friend-avatar { width: 32px; height: 32px; font-size: 0.85rem; }
    .online-dot { left: 30px; width: 8px; height: 8px; }
    .friend-call-btn { width: 30px; height: 30px; }
    .friend-call-btn svg { width: 14px; height: 14px; }
}

@supports (padding: max(0px)) {
    .contacts-header { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
    .conn-status { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* ════════════════════════════════════════
   PENDING LIST IN CONTACTS
   ════════════════════════════════════════ */
#pendingList {
    padding: 0 12px 4px;
}

#pendingList .friend-item {
    background: rgba(233, 69, 96, 0.04);
    border: 1px solid rgba(233, 69, 96, 0.1);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

#pendingList .friend-item:last-child {
    margin-bottom: 0;
}

/* ─── Audio/Video call buttons ─── */
.friend-call-btn.audio-call:hover {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.friend-call-btn.video-call:hover {
    background: rgba(52, 152, 219, 0.15);
    border-color: rgba(52, 152, 219, 0.3);
    color: #3498db;
}

/* ─── Outgoing call overlay ─── */
#outgoingCallOverlay .caller-status {
    animation: pulse 1.5s ease-in-out infinite;
}

#outgoingCallOverlay .call-btn.reject {
    background: linear-gradient(135deg, var(--accent), #c0392b);
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
}

#outgoingCallOverlay .call-btn.reject:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(233, 69, 96, 0.5);
}

/* ─── Outgoing call status text ─── */
#outgoingCallOverlay .caller-status {
    animation: outgoingPulse 1.2s ease-in-out infinite;
}

@keyframes outgoingPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ─── Header actions ─── */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Ringtone selector ─── */
.ringtone-panel {
    flex-shrink: 0;
}

.ringtone-list {
    padding: 0 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ringtone-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.ringtone-item:hover {
    background: rgba(255,255,255,0.04);
}

.ringtone-item.active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.ringtone-item-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.ringtone-item-check {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

.ringtone-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ringtone-play-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .ringtone-item { padding: 10px 12px; }
    .ringtone-play-btn { width: 28px; height: 28px; }
}
