:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #16202c;
  --muted: #667085;
  --accent: #12a150;
  --danger: #d92d20;
  --me: #e7f6ee;
  --ai: #eef1f6;
  --border: #e3e7ee;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --card: #171e28; --text: #e8edf3; --muted: #93a0b0;
    --me: #173526; --ai: #222b37; --border: #2a3441;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; justify-content: center; align-items: center;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 16px;
}
.phone {
  width: 100%; max-width: 420px; height: min(720px, calc(100vh - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  display: flex; flex-direction: column; overflow: hidden;
}
header { display: flex; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
header h1 { margin: 0; font-size: 17px; }
header p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; transition: box-shadow .15s;
}
.avatar.listening { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 30%, transparent); }
.avatar.speaking { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent); } }
.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; }
.msg.user { align-self: flex-end; background: var(--me); }
.msg.ai { align-self: flex-start; background: var(--ai); }
.msg.sys { align-self: center; font-size: 12px; color: var(--muted); background: none; }
.msg.handoff { align-self: center; font-size: 12px; color: #fff; background: #f79009; }
.controls { padding: 12px 16px 4px; display: flex; gap: 8px; }
.controls select {
  padding: 0 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.call {
  flex: 1; padding: 14px; border: 0; border-radius: 999px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer;
}
.call.active { background: var(--danger); }
.text-form { display: flex; gap: 8px; padding: 8px 16px 16px; }
.text-form input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.text-form button {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
}
