:root {
  --bg-0: #06061a;
  --bg-1: #0e0e2a;
  --surface: rgba(24, 24, 56, 0.7);
  --surface-2: rgba(40, 40, 80, 0.5);
  --border: rgba(150, 130, 255, 0.18);
  --border-strong: rgba(150, 130, 255, 0.45);
  --text: #e6e6f4;
  --text-dim: #9c9cc8;
  --accent: #a78bfa;
  --accent-2: #60a5fa;
  --accent-glow: rgba(167, 139, 250, 0.4);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --ring-glow: rgba(96, 165, 250, 0.5);
}

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

html, body {
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(120, 80, 255, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(80, 100, 255, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

.stars {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 13% 22%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 47% 8%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 78% 35%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 28% 62%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 67% 78%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1px 1px at 91% 14%, rgba(255,255,255,0.5), transparent),
    radial-gradient(2px 2px at 35% 88%, rgba(180,160,255,0.6), transparent);
  animation: twinkle 8s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.5; } to { opacity: 0.9; } }

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: rgba(8, 8, 28, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 12px;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 24px var(--accent-glow);
}
.brand h1 {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand p { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.back-link {
  color: var(--text-dim); text-decoration: none; font-size: 13px;
  padding: 6px 10px; border-radius: 8px;
  transition: all 0.2s ease;
}
.back-link:hover { color: var(--text); background: var(--surface); }

/* ─── Stage ──────────────────────────────────────────────────── */
.stage {
  flex: 1;
  position: relative; z-index: 1;
  width: 100%; max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex; flex-direction: column; gap: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 42px 32px 32px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  text-align: center;
  position: relative;
}

/* ─── Avatar with rings ──────────────────────────────────────── */
.avatar {
  width: 180px; height: 180px;
  position: relative;
  margin: 0 auto 20px;
}
.rings {
  position: absolute; inset: 0;
  pointer-events: none;
}
.rings .ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
}
.avatar.calling .ring {
  animation: ripple 2.4s ease-out infinite;
}
.avatar.calling .ring:nth-child(2) { animation-delay: 0.8s; }
.avatar.calling .ring:nth-child(3) { animation-delay: 1.6s; }
@keyframes ripple {
  0% { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

.avatar.speaking .ring {
  animation: pulse-ring 1.2s ease-in-out infinite;
}
.avatar.speaking .ring:nth-child(2) { animation-delay: 0.4s; }
.avatar.speaking .ring:nth-child(3) { animation-delay: 0.8s; }
@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0; }
  50% { transform: scale(1.18); opacity: 0.45; }
}

.avatar-icon {
  position: absolute; inset: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 50%;
  font-size: 60px;
  color: #fff;
  box-shadow: 0 8px 36px var(--accent-glow), inset 0 -4px 16px rgba(0,0,0,0.2);
  transition: transform 0.25s ease;
}
.avatar.connecting .avatar-icon { animation: connecting 1.5s ease-in-out infinite; }
@keyframes connecting {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

#title {
  font-size: 22px; font-weight: 600; margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.subtitle {
  color: var(--text-dim);
  max-width: 480px; margin: 0 auto 24px;
}

.status-line {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-dim);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
}
.status-dot.connecting { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: blink 1s ease-in-out infinite; }
.status-dot.connected { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse-dot 2s ease-in-out infinite; }
.status-dot.err { background: var(--err); box-shadow: 0 0 8px var(--err); }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.dot-sep { opacity: 0.45; }
#timer { font-variant-numeric: tabular-nums; }

/* ─── Buttons ────────────────────────────────────────────────── */
.actions {
  display: flex; gap: 12px; justify-content: center; align-items: center;
  margin-bottom: 22px; flex-wrap: wrap;
}
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; gap: 9px;
  border: none; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 500;
  padding: 13px 24px;
  border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 32px var(--accent-glow); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(248, 113, 113, 0.4);
}
.btn-danger:hover { transform: translateY(-1px); }

.btn-secondary {
  width: 46px; height: 46px; padding: 0;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  justify-content: center;
}
.btn-secondary:hover { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary.muted { background: rgba(248, 113, 113, 0.18); border-color: rgba(248, 113, 113, 0.5); color: var(--err); }

.hidden { display: none !important; }

.hint {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim);
  background: var(--surface-2);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border);
}
.hint i { color: var(--accent); }

/* ─── Transcript ─────────────────────────────────────────────── */
.transcript {
  margin-top: 28px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  max-width: 560px;
  margin-left: auto; margin-right: auto;
}
.transcript h3 {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.transcript h3 i { color: var(--accent); margin-right: 6px; }
.transcript-stream {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 260px; overflow-y: auto;
  padding-right: 4px;
}
.transcript-stream::-webkit-scrollbar { width: 6px; }
.transcript-stream::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tline {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 14px; line-height: 1.5;
  animation: slide-in 0.25s ease-out;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.tline .role {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  flex-shrink: 0; margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.tline.user .role { background: rgba(96, 165, 250, 0.18); color: var(--accent-2); }
.tline.agent .role { background: rgba(167, 139, 250, 0.18); color: var(--accent); }
.tline .body { color: var(--text); flex: 1; }

/* ─── Info grid ──────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.info-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  text-align: left;
  backdrop-filter: blur(12px);
}
.info-item i {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  background: rgba(167, 139, 250, 0.14);
  color: var(--accent);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}
.info-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.info-item p { font-size: 13px; color: var(--text-dim); line-height: 1.45; }

/* ─── Footer ─────────────────────────────────────────────────── */
.foot {
  position: relative; z-index: 1;
  text-align: center; padding: 18px;
  font-size: 12px; color: var(--text-dim);
  border-top: 1px solid var(--border);
}

@media (max-width: 540px) {
  .topbar { padding: 12px 16px; }
  .brand p { display: none; }
  .stage { padding: 20px 14px 32px; gap: 20px; }
  .card { padding: 28px 18px 22px; border-radius: 18px; }
  .avatar { width: 140px; height: 140px; }
  .avatar-icon { font-size: 46px; inset: 12px; }
  #title { font-size: 19px; }
  .btn-primary, .btn-danger { padding: 12px 18px; font-size: 14px; }
}
