:root {
    --bg-dark: #08090d;
    --bg-panel: #14161d;
    --glass: rgba(255, 255, 255, 0.045);
    --glass-border: rgba(255, 255, 255, 0.09);
    --accent: #6d6af2;
    --accent-2: #d6549e;
    --accent-hover: #8482f5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #f3f4f6;
    --text-muted: #92959f;
    --success: #22c55e;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Ambient background: three soft gradient blobs drifting slowly behind
   everything. This is what gives the page life at rest - it never touches
   layout, and it is the ONLY thing that moves when nothing else is
   happening. Every other motion on the page is tied to a real event. */
.bg-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.bg-orbs span {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
    will-change: transform;
}

.bg-orbs span:nth-child(1) {
    width: 480px;
    height: 480px;
    left: -160px;
    top: -120px;
    background: radial-gradient(circle, var(--accent), transparent 70%);
    animation: driftA 26s ease-in-out infinite;
}

.bg-orbs span:nth-child(2) {
    width: 420px;
    height: 420px;
    right: -140px;
    bottom: -100px;
    background: radial-gradient(circle, var(--accent-2), transparent 70%);
    animation: driftB 32s ease-in-out infinite;
}

.bg-orbs span:nth-child(3) {
    width: 320px;
    height: 320px;
    left: 45%;
    top: 55%;
    background: radial-gradient(circle, #3fd6c8, transparent 70%);
    opacity: 0.2;
    animation: driftC 38s ease-in-out infinite;
}

@keyframes driftA {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.12); }
}
@keyframes driftB {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-50px, -30px) scale(1.08); }
}
@keyframes driftC {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-40%, -60%) scale(1.15); }
}

.app-container {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 800px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 30%),
                var(--bg-panel);
    position: relative;
    z-index: 1;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
}

@media (min-width: 450px) {
    .app-container {
        height: 90vh;
        border-radius: 32px;
        border: 1px solid var(--glass-border);
        overflow: hidden;
    }
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Dial Screen */
#dial-screen {
    justify-content: center;
}

.brand {
    text-align: center;
    margin-bottom: 72px;
}

.brand .logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 30px rgba(109, 106, 242, 0.4);
}

.brand h1 {
    font-weight: 600;
    font-size: 25px;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff, #b8bad0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand p {
    color: var(--text-muted);
    font-size: 14px;
}

.btn-dial {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success), #16a34a);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45), 0 10px 30px rgba(34, 197, 94, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: dialPulse 2.6s ease-out infinite;
}

.btn-dial:hover {
    transform: scale(1.05);
}

.dial-text {
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    font-weight: 500;
}

/* Call Screen */
#call-screen {
    justify-content: space-between;
}

.call-header {
    text-align: center;
    margin-top: 32px;
}

/* The agent orb replaces a static profile photo. Its glow and scale are
   driven every animation frame from real audio: the caller's own mic level
   while listening, the synthesized speech level while the agent talks. At
   rest it holds a slow, low-amplitude breathing motion so it never looks
   frozen - but that idle motion is capped low enough that it reads as
   "alive", not "animating for no reason". */
.agent-orb {
    width: 108px;
    height: 108px;
    margin: 0 auto 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-orb .ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(109, 106, 242, 0.35), transparent 72%);
    transform: scale(var(--level, 0));
    opacity: var(--level, 0);
    transition: transform 0.05s linear, opacity 0.05s linear;
}

.agent-orb .core {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: linear-gradient(150deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 8px 26px rgba(109, 106, 242, 0.4);
    transform: scale(calc(1 + var(--level, 0) * 0.14));
    transition: transform 0.05s linear;
}

.call-header h2 {
    font-size: 19px;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.call-status {
    color: var(--text-muted);
    font-size: 13.5px;
}

/* Waveform: bar heights are set inline, per frame, from JS - driven by the
   same real audio levels as the orb. No canned CSS keyframe loops. */
.audio-waves {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 56px;
    margin: 32px 0;
    opacity: 0.35;
    transition: opacity 0.3s;
}

.audio-waves.listening,
.audio-waves.speaking,
.audio-waves.thinking {
    opacity: 1;
}

.wave {
    width: 5px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 3px;
    transition: height 0.06s ease-out, background-color 0.2s ease;
}

.audio-waves.listening .wave { background-color: var(--success); }
.audio-waves.thinking .wave { background-color: var(--text-muted); }

.transcript-box {
    width: 100%;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 20px;
    min-height: 116px;
    max-height: 190px;
    overflow-y: auto;
    margin-bottom: 32px;
    border: 1px solid var(--glass-border);
}

.transcript-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-main);
    text-align: center;
}

.transcript-text.system,
.transcript-text.agent {
    color: #a5a3ff;
}

.transcript-text.user {
    color: var(--success);
}

.transcript-text.interim {
    opacity: 0.55;
    font-style: italic;
}

.call-controls {
    margin-bottom: 28px;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.btn-control {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.2s ease;
}

.end-call {
    background: linear-gradient(135deg, var(--danger), var(--danger-hover));
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.35);
}

.end-call:hover {
    transform: scale(1.05);
}

@keyframes dialPulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45), 0 10px 30px rgba(34, 197, 94, 0.25); }
    70% { box-shadow: 0 0 0 16px rgba(34, 197, 94, 0), 0 10px 30px rgba(34, 197, 94, 0.25); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0), 0 10px 30px rgba(34, 197, 94, 0.25); }
}

/* Countdown */
.call-timer {
    margin-top: 10px;
    font-size: 12.5px;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.call-timer.warning { color: #f59e0b; }

/* Mute control */
.btn-mute {
    background-color: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--glass-border);
    width: 54px;
    height: 54px;
    color: var(--text-main);
}
.btn-mute:hover { background-color: rgba(255, 255, 255, 0.13); }
.btn-mute.muted {
    background-color: var(--danger);
    border-color: var(--danger);
}

/* Notices: quota messages, connection errors */
.notice {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 16px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(109, 106, 242, 0.15);
    border: 1px solid rgba(109, 106, 242, 0.35);
    backdrop-filter: blur(10px);
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 5;
}
.notice.visible { opacity: 1; transform: translateY(0); }
.notice.error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.btn-dial:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

.mic-hint {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    max-width: 260px;
    line-height: 1.5;
}

/* Respect users who asked their OS for less motion. */
@media (prefers-reduced-motion: reduce) {
    .bg-orbs span,
    .btn-dial {
        animation: none !important;
    }
    .agent-orb .ring,
    .agent-orb .core,
    .wave {
        transition: none !important;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
