:root {
    --bg-primary: #f2f2f7;
    --bg-secondary: #fff;
    --text-primary: #000;
    --text-secondary: #8e8e93;
    --text-tertiary: #3c3c43;
    --border-color: #e5e5ea;
    --hover-bg: #f2f2f7;
    --active-bg: #e5e5ea;
    --accent-color: #007aff;
    --accent-bg: #f0f8ff;
    --shadow: rgba(0, 0, 0, 0.1);
    --dialog-overlay: rgba(0, 0, 0, 0.5);
    --success-color: #34c759;
    --error-color: #ff3b30;
    --warning-color: #ff9f0a;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
    --bg-primary: #000;
    --bg-secondary: #1c1c1e;
    --text-primary: #fff;
    --text-secondary: #98989d;
    --text-tertiary: #c7c7cc;
    --border-color: #38383a;
    --hover-bg: #2c2c2e;
    --active-bg: #3a3a3c;
    --accent-color: #0a84ff;
    --accent-bg: #1c3a52;
    --shadow: rgba(0, 0, 0, 0.5);
    --dialog-overlay: rgba(0, 0, 0, 0.7);
    --success-color: #30d158;
    --error-color: #ff453a;
    --warning-color: #ff9f0a;
}

[data-theme="dim"] {
    --bg-primary: #1a2332;
    --bg-secondary: #243447;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-tertiary: #bdc1c6;
    --border-color: #3c4859;
    --hover-bg: #2d3e52;
    --active-bg: #374a61;
    --accent-color: #5e9eff;
    --accent-bg: #2c4a6b;
    --shadow: rgba(0, 0, 0, 0.3);
    --dialog-overlay: rgba(0, 0, 0, 0.6);
    --success-color: #32d74b;
    --error-color: #ff375f;
    --warning-color: #ffb340;
}

@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
    }
    [data-theme="dark"] {
        --border-color: #fff;
        --text-secondary: #fff;
    }
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: inherit;
    color: inherit;
    margin: 0;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

input,
select,
textarea {
    -webkit-appearance: none;
    appearance: none;
}

*:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

#authScreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-container {
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 40px 30px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px var(--shadow);
    animation: slideUpFade 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-logo {
    font-size: 72px;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
    will-change: transform;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.auth-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 35px;
    font-weight: 500;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-btn {
    padding: 16px 24px;
    border-radius: 14px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
    min-height: 52px;
}

.auth-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    pointer-events: none;
}

.auth-btn:hover::before {
    width: 300px;
    height: 300px;
}

.auth-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px var(--shadow);
}

.auth-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.auth-btn.google {
    background: #fff;
    color: #333;
    border-color: #dadce0;
}

.auth-btn.metamask {
    background: linear-gradient(135deg, #f6851b, #e2761b);
    color: white;
    border-color: #f6851b;
}

.auth-btn.metamask:hover {
    background: linear-gradient(135deg, #e2761b, #d66512);
}

.auth-divider {
    margin: 25px 0;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.auth-info {
    margin-top: 25px;
    padding: 14px 18px;
    background: var(--accent-bg);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-tertiary);
    border: 1px solid var(--border-color);
}

#mainApp {
    display: none;
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-secondary);
    min-height: 100vh;
    box-shadow: 0 0 50px var(--shadow);
    position: relative;
    overflow-x: hidden;
    padding-bottom: var(--safe-area-bottom);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dialog-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    box-shadow: 4px 0 20px var(--shadow);
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.side-menu.active {
    left: 0;
}

.menu-header {
    padding: 25px 20px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-bg));
    color: white;
    padding-top: calc(25px + var(--safe-area-top));
}

.menu-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.menu-header p {
    font-size: 14px;
    opacity: 0.95;
    font-weight: 500;
}

.theme-section {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.theme-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.theme-options {
    display: flex;
    gap: 10px;
}

.theme-btn {
    flex: 1;
    padding: 11px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    will-change: transform, background-color;
    min-height: 44px;
}

.theme-btn:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.theme-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.theme-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--bg-secondary);
}

.menu-items {
    padding: 12px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    margin: 0 10px;
    border-radius: 10px;
    will-change: transform, background-color;
    min-height: 56px;
}

.menu-item:hover {
    background: var(--hover-bg);
    transform: translateX(5px);
}

.menu-item:active {
    background: var(--active-bg);
}

.menu-item-icon {
    width: 24px;
    height: 24px;
    margin-right: 16px;
    color: var(--accent-color);
    flex-shrink: 0;
}

.menu-item-text {
    font-size: 16px;
    font-weight: 500;
}

.header {
    background: var(--bg-secondary);
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: calc(20px + var(--safe-area-top));
}

.menu-button {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: var(--bg-primary);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s ease;
    will-change: transform, background-color;
}

.menu-button:hover {
    background: var(--hover-bg);
    transform: translateY(-50%) scale(1.05);
}

.menu-button:active {
    background: var(--active-bg);
    transform: translateY(-50%) scale(0.95);
}

.menu-button span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-button.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.menu-button.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.menu-button.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

#menuTitle {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-color);
    margin-top: 5px;
}

.user-section {
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.user-info-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-bg));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
    transition: transform 0.2s ease;
    will-change: transform;
}

.user-avatar:hover {
    transform: scale(1.02);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wallet-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.wallet-badge {
    padding: 7px 13px;
    background: linear-gradient(135deg, #f6851b, #e2761b);
    color: white;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(246, 133, 27, 0.3);
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-signout {
    padding: 7px 13px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    will-change: transform, box-shadow;
    min-height: 32px;
}

.btn-signout:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.btn-signout:active {
    transform: translateY(0);
}

#signOutContainer.hidden {
    display: none !important;
}

.content {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

#dialerSection {
    text-align: center;
}

#dialedNumber {
    min-height: 80px;
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 16px;
    border: 2px solid var(--border-color);
    word-break: break-all;
}

.dialpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 25px auto;
    max-width: 320px;
}

.dial-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 26px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--shadow);
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
}

.dial-btn:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px var(--shadow);
}

.dial-btn:active {
    background: var(--active-bg);
    transform: scale(0.92);
}

.dial-btn small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    margin-top: -2px;
    color: var(--text-secondary);
}

.call-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    background: var(--success-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 25px auto;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 32px;
    touch-action: manipulation;
    box-shadow: 0 8px 20px rgba(52, 199, 89, 0.4);
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
}

.call-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 28px rgba(52, 199, 89, 0.5);
}

.call-btn:active {
    transform: scale(0.95);
}

.call-btn.end {
    background: var(--error-color);
    box-shadow: 0 8px 20px rgba(255, 59, 48, 0.4);
}

.call-btn.end:hover {
    box-shadow: 0 12px 28px rgba(255, 59, 48, 0.6) !important;
}

#callingOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 20px;
}

.calling-icon {
    font-size: 80px;
    margin-bottom: 35px;
    animation: callPulse 1.5s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes callPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.15) rotate(5deg);
        opacity: 0.85;
    }
}

.calling-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.calling-number {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 50px;
    font-weight: 500;
    word-break: break-word;
    text-align: center;
    max-width: 90%;
}

#activeCallSection {
    display: none;
    text-align: center;
    padding: 30px 20px;
    animation: fadeIn 0.3s ease;
    position: relative;
    z-index: 1001;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.caller-info {
    margin: 25px 0;
}

.caller-avatar,
#activeCallerAvatar,
#incomingCallerAvatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-bg));
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: white;
    overflow: hidden;
    box-shadow: 0 8px 24px var(--shadow);
    animation: avatarGlow 2s ease-in-out infinite;
}

@keyframes avatarGlow {
    0%, 100% {
        box-shadow: 0 8px 24px var(--shadow);
    }
    50% {
        box-shadow: 0 8px 32px rgba(0, 122, 255, 0.4);
    }
}

.caller-avatar img,
#activeCallerAvatar img,
#incomingCallerAvatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.caller-number,
#activeCallerName {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

#incomingCallModal #incomingCallerName {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #ffffff !important;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#incomingCallModal #incomingCallerNumber {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.95) !important;
    margin-bottom: 8px;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#incomingCallModal .incoming-caller-number {
    font-size: 24px;
    margin: 25px 0;
    font-weight: 400;
    letter-spacing: 1px;
    word-break: break-word;
    color: #ffffff !important;
}

.wallet-address {
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    transition: color 0.2s ease;
}

.wallet-address:hover {
    color: var(--accent-color);
}

#callDuration {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

#networkQualityIndicator {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

#networkQualityIndicator.poor {
    color: var(--error-color);
}

#networkQualityIndicator.good {
    color: var(--warning-color);
}

#networkQualityIndicator.excellent {
    color: var(--success-color);
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 24px;
    touch-action: manipulation;
    box-shadow: 0 4px 12px var(--shadow);
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px var(--shadow);
}

.control-btn:active {
    transform: scale(0.92);
}

.control-btn.active {
    background: var(--error-color) !important;
    color: white !important;
    border-color: var(--error-color) !important;
}

.control-btn#speakerBtn.active {
    background: var(--success-color) !important;
    color: white !important;
    border-color: var(--success-color) !important;
}

.numbers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.numbers-header h3 {
    font-size: 20px;
    color: var(--text-primary);
    font-weight: 700;
}

.btn-small {
    padding: 8px 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
    min-height: 36px;
}

.btn-small:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-small:active {
    transform: scale(0.95);
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: var(--error-color);
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.phone-item {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    border: 2px solid transparent;
    will-change: transform, box-shadow;
}

.phone-item:hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.phone-item:active {
    transform: scale(0.98);
}

.phone-item.selected {
    background: var(--accent-bg);
    border-color: var(--accent-color);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.2);
}

.phone-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.phone-details {
    flex: 1;
    min-width: 0;
}

.phone-number {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.primary-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--success-color);
    color: white;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 5px;
}

.secondary-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.btn-delete {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    flex-shrink: 0;
    touch-action: manipulation;
    opacity: 0.6;
    transition: all 0.2s ease;
    border-radius: 8px;
    min-width: 38px;
    min-height: 38px;
}

.btn-delete:hover {
    opacity: 1;
    background: var(--hover-bg);
    transform: scale(1.1);
}

.btn-delete:active {
    transform: scale(0.9);
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: 25px;
    line-height: 1.6;
}

.btn-primary {
    padding: 14px 28px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.btn-primary:active {
    transform: scale(0.97);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--dialog-overlay);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 28px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px var(--shadow);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
    -webkit-overflow-scrolling: touch;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 22px;
    color: var(--text-primary);
    font-weight: 700;
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    color: var(--text-primary);
    transition: all 0.2s ease;
    will-change: transform, background-color;
}

.close-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

.close-btn:active {
    transform: scale(0.9);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: all 0.2s ease;
    min-height: 48px;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 14px;
}

#incomingCallModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#incomingCallTimer {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 15px;
    text-align: center;
}

.incoming-call-content {
    text-align: center;
    color: white;
    padding: 50px 30px;
    animation: incomingPulse 1.5s ease-in-out infinite;
}

@keyframes incomingPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.incoming-actions {
    display: flex;
    gap: 50px;
    justify-content: center;
    margin-top: 40px;
}

.accept-btn,
.decline-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: all 0.2s ease;
    will-change: transform, box-shadow;
    -webkit-tap-highlight-color: transparent;
}

.accept-btn {
    background: var(--success-color);
    box-shadow: 0 10px 30px rgba(52, 199, 89, 0.5);
}

.decline-btn {
    background: var(--error-color);
    box-shadow: 0 10px 30px rgba(255, 59, 48, 0.5);
}

.accept-btn:hover,
.decline-btn:hover {
    transform: scale(1.1);
}

.accept-btn:active,
.decline-btn:active {
    transform: scale(0.95);
}

.list-item {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    will-change: transform, box-shadow;
}

.list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.call-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.call-details,
.contact-details {
    flex: 1;
    min-width: 0;
}

.call-number,
.contact-number {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.contact-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.call-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-bg));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 18px;
}

.contact-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.blocked-badge {
    padding: 5px 10px;
    background: var(--error-color);
    color: white;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

.copy-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 15px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    will-change: transform, opacity;
}

.copy-feedback.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.audio-levels {
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.audio-level {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin: 10px 0;
    overflow: hidden;
}

.audio-level-bar {
    height: 100%;
    width: 0%;
    max-width: 100%;
    background: var(--success-color);
    transition: width 0.1s ease, background-color 0.2s ease;
    border-radius: 3px;
    will-change: width, background-color;
}

.audio-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.info-banner {
    padding: 14px 16px;
    background: var(--accent-bg);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 18px;
    border: 1px solid var(--border-color);
}

.search-box {
    margin-bottom: 18px;
}

.search-box input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: all 0.2s ease;
    min-height: 48px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.search-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

@media (max-width: 480px) {
    #mainApp {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    .content {
        padding: 16px;
    }

    .auth-container {
        padding: 30px 20px;
    }

    .side-menu {
        width: 85%;
        left: -85%;
    }

    .side-menu.active {
        left: 0;
    }

    .dialpad {
        gap: 10px;
    }

    .dial-btn {
        font-size: 24px;
    }

    .incoming-actions {
        gap: 40px;
    }

    .accept-btn,
    .decline-btn {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }

    .user-section {
        flex-direction: column;
        align-items: stretch;
    }

    .user-info-container {
        width: 100%;
    }

    .wallet-section {
        width: 100%;
        justify-content: space-between;
    }

    .contact-actions {
        flex-direction: column;
        width: 100%;
    }

    .contact-actions .btn-small {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .header h1 {
        font-size: 22px;
    }

    .auth-title {
        font-size: 28px;
    }

    .dial-btn {
        font-size: 22px;
    }

    .call-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .user-section {
        padding: 12px 16px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-height: 500px) {
    .incoming-actions {
        margin-top: 20px;
        gap: 30px;
    }

    .accept-btn,
    .decline-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .incoming-call-content {
        padding: 30px 20px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    #mainApp {
        max-width: 600px;
    }

    .dialpad {
        max-width: 450px;
        gap: 16px;
    }

    .dial-btn {
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-primary: #000;
        --bg-secondary: #1c1c1e;
        --text-primary: #fff;
        --text-secondary: #98989d;
        --text-tertiary: #c7c7cc;
        --border-color: #38383a;
        --hover-bg: #2c2c2e;
        --active-bg: #3a3a3c;
        --accent-color: #0a84ff;
        --accent-bg: #1c3a52;
        --shadow: rgba(0, 0, 0, 0.5);
        --dialog-overlay: rgba(0, 0, 0, 0.7);
        --success-color: #30d158;
        --error-color: #ff453a;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-secondary) inset;
    -webkit-text-fill-color: var(--text-primary);
    transition: background-color 5000s ease-in-out 0s;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
    border: 0;
    padding: 0;
}

select::-ms-expand {
    display: none;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
    
    #mainApp {
        min-height: -webkit-fill-available;
    }
}

@supports not (backdrop-filter: blur(5px)) {
    .menu-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .modal {
        background: rgba(0, 0, 0, 0.8);
    }
    
    #incomingCallModal {
        background: rgba(0, 0, 0, 0.95);
    }
}