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

:root {
    --bg: #0b0f1a;
    --bg-elev: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.08);
    --text: #e8eaed;
    --muted: #8b93a7;
    --brand: #6366f1;
    --brand-2: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warn: #f59e0b;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(139,92,246,0.25), transparent 60%),
        radial-gradient(900px 500px at -10% 100%, rgba(99,102,241,0.22), transparent 60%),
        var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.phone-container {
    width: 100%;
    max-width: 460px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 28px 28px 24px;
    backdrop-filter: blur(20px);
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
}

.top-bar .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    display: inline-block;
    margin-right: 6px;
    transition: background 0.3s, box-shadow 0.3s;
}

.top-bar .dot.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.call-timer {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--muted);
}

.avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
}

.avatar {
    position: relative;
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-ring {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.08);
    transition: all 0.3s;
}

.avatar-ring::before,
.avatar-ring::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Idle */
.avatar-ring.idle { border-color: rgba(255,255,255,0.1); }

/* User speaking - green pulse */
.avatar-ring.user-speaking { border-color: rgba(16,185,129,0.6); }
.avatar-ring.user-speaking::before {
    border-color: rgba(16,185,129,0.5);
    opacity: 1;
    animation: ring 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
.avatar-ring.user-speaking::after {
    border-color: rgba(16,185,129,0.35);
    opacity: 1;
    animation: ring 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite 0.6s;
}

/* AI thinking - yellow glow */
.avatar-ring.ai-thinking { border-color: rgba(245,158,11,0.5); }
.avatar-ring.ai-thinking::before {
    border-color: rgba(245,158,11,0.3);
    opacity: 1;
    animation: ring 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

/* AI speaking - purple pulse */
.avatar-ring.ai-speaking { border-color: rgba(99,102,241,0.6); }
.avatar-ring.ai-speaking::before {
    border-color: rgba(99,102,241,0.5);
    opacity: 1;
    animation: ring 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
.avatar-ring.ai-speaking::after {
    border-color: rgba(99,102,241,0.35);
    opacity: 1;
    animation: ring 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) infinite 0.75s;
}

@keyframes ring {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.5); opacity: 0; }
}

.avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(99,102,241,0.4);
    transition: background 0.3s;
}

.avatar-inner.user-mode {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 10px 40px rgba(16,185,129,0.4);
}

.avatar-inner.thinking-mode {
    background: linear-gradient(135deg, var(--warn), #d97706);
    box-shadow: 0 10px 40px rgba(245,158,11,0.4);
}

.avatar-inner svg { width: 52px; height: 52px; color: white; }

.status-text {
    font-size: 14px;
    color: var(--muted);
    text-align: center;
    letter-spacing: 0.02em;
    min-height: 20px;
    transition: color 0.2s;
}

.status-text.speaking { color: var(--success); font-weight: 500; }
.status-text.thinking { color: var(--warn); font-weight: 500; }
.status-text.ai-reply { color: var(--brand-2); font-weight: 500; }
.status-text.error { color: var(--danger); }

.metrics-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    margin: 0 16px 10px 16px;
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: space-between;
}
.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 70px;
}
.metric-label {
    color: #8892a6;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric-value {
    color: var(--brand-2);
    font-weight: 600;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s;
}
.metric-value.good { color: #10b981; }
.metric-value.warn { color: #f59e0b; }
.metric-value.bad { color: var(--danger); }
.metric-target {
    color: #4a5162;
    font-size: 9px;
}

.subtitle-box {
    min-height: 120px;
    max-height: 180px;
    overflow-y: auto;
    padding: 14px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
}

.subtitle-box::-webkit-scrollbar { width: 4px; }
.subtitle-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.subtitle-box:empty::before {
    content: '字幕会显示在这里...';
    color: #4a5162;
    font-style: italic;
}

.subtitle-line { margin-bottom: 6px; }
.subtitle-line:last-child { margin-bottom: 0; }

.subtitle-line .tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 11px;
    margin-right: 8px;
    font-weight: 600;
    vertical-align: 1px;
}

.subtitle-line.user { color: var(--muted); }
.subtitle-line.user .tag {
    background: rgba(16,185,129,0.15);
    color: var(--success);
}
.subtitle-line.user.pending { font-style: italic; opacity: 0.7; }

.subtitle-line.ai { color: var(--text); }
.subtitle-line.ai .tag {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: white;
    font-weight: 700;
}

.waveform {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
}

#waveCanvas { width: 100%; height: 100%; max-width: 340px; }

.controls {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 4px 0;
}

.btn-action {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s, box-shadow 0.2s;
    color: white;
}

.btn-action svg { width: 26px; height: 26px; }

.btn-call {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 8px 24px rgba(16,185,129,0.4);
}
.btn-call:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(16,185,129,0.5);
}

.btn-hangup {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 8px 24px rgba(239,68,68,0.4);
}
.btn-hangup:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(239,68,68,0.5);
}

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

.text-input-area {
    display: flex;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.text-input-area input {
    flex: 1;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.text-input-area input::placeholder { color: #4a5162; }
.text-input-area input:focus {
    border-color: var(--brand);
    background: rgba(99,102,241,0.06);
}

.text-input-area button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.text-input-area button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99,102,241,0.45);
}

.text-input-area button svg { width: 18px; height: 18px; }
