:root {
  --warm: #f59e0b;
  --warm-dark: #d97706;
  --cream: #fff7ed;
  --ink: #292524;
  --muted: #78716c;
  --green: #22c55e;
  --red: #ef4444;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #431407 0%, #7c2d12 40%, #92400e 70%, #b45309 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 30px;
}

.stage { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; justify-content: center; }

/* ================= PHONE ================= */
.phone {
  width: 390px;
  height: min(92vh, 820px);
  min-height: 640px;
  background: #fff;
  border-radius: 46px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 0 0 10px #1c1917, inset 0 0 0 13px #292524;
  overflow: hidden;
  position: relative;
}

.screen {
  position: absolute;
  inset: 13px;
  border-radius: 34px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hide { display: none; }

/* ---- Incoming call ---- */
.incoming {
  background: linear-gradient(170deg, #fbbf24, #d97706 80%);
  color: #431407;
  align-items: center;
  justify-content: space-between;
  padding: 60px 30px 40px;
  text-align: center;
}

.incoming-label {
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
  animation: fadeIn 0.6s;
}

.avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: #fff7ed;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  position: relative;
}
.avatar .sun {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7ed, #fde68a 60%, #f59e0b);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.9) inset, 0 3px 8px rgba(0, 0, 0, 0.15);
}
.avatar.ring { animation: ring 2s infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5), 0 8px 30px rgba(0,0,0,0.2); }
  50% { box-shadow: 0 0 0 22px rgba(255, 255, 255, 0), 0 8px 30px rgba(0,0,0,0.2); }
}

.incoming h2 { font-size: 26px; margin-top: 18px; }
.caller-number { font-size: 14px; opacity: 0.75; margin-top: 4px; }

.incoming-actions { display: flex; gap: 56px; align-items: center; }

.call-btn {
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn:active { transform: scale(0.94); }
.call-btn.decline { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 6px 18px rgba(220, 38, 38, 0.5); }
.call-btn.answer { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 6px 18px rgba(22, 163, 74, 0.5); }
.call-btn.end { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 6px 18px rgba(220, 38, 38, 0.5); width: 70px; height: 70px; }

.incoming-hint { font-size: 13px; opacity: 0.85; }

/* ---- In-call ---- */
.call {
  background: linear-gradient(180deg, #1c1917, #292524);
  color: #fff;
  align-items: center;
}

.call-top { text-align: center; padding: 40px 20px 10px; }
.call-status { color: #fbbf24; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }

.avatar.speaking { background: #1c1917; }
.wave { position: absolute; bottom: -10px; display: flex; gap: 4px; height: 34px; align-items: flex-end; }
.wave i {
  width: 4px;
  height: 8px;
  border-radius: 3px;
  background: #fbbf24;
  animation: wave 0.9s ease-in-out infinite;
}
.wave i:nth-child(2) { animation-delay: 0.1s; }
.wave i:nth-child(3) { animation-delay: 0.2s; }
.wave i:nth-child(4) { animation-delay: 0.3s; }
.wave i:nth-child(5) { animation-delay: 0.4s; }
.wave.paused i { animation-play-state: paused; height: 6px; opacity: 0.35; }
@keyframes wave {
  0%, 100% { height: 6px; }
  50% { height: 30px; }
}

.call h2 { margin-top: 22px; font-size: 21px; }

/* Transcript */
.transcript {
  flex: 1;
  width: 100%;
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  margin-top: 16px;
}

.t-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  animation: fadeIn 0.3s;
}
.t-bubble.sunny {
  align-self: flex-start;
  background: #3f3a36;
  color: #ffedd5;
  border-bottom-left-radius: 4px;
}
.t-bubble.sunny::before { content: "☀ Sunny · "; color: #fbbf24; font-weight: 700; font-size: 11.5px; }
.t-bubble.you {
  align-self: flex-end;
  background: #fbbf24;
  color: #431407;
  border-bottom-right-radius: 4px;
  font-weight: 600;
}
.t-bubble.you::before { content: "You · "; opacity: 0.65; font-weight: 700; font-size: 11.5px; }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #fbbf24; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* Call actions */
.text-fallback {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 12px 16px 0;
}
.text-fallback input {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid #57534e;
  border-radius: 12px;
  font-size: 13px;
  outline: none;
  background: #3f3a36;
  color: #ffedd5;
}
.text-fallback input:focus { border-color: #fbbf24; }
.text-fallback button {
  width: 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, #fbbf24, #f59e0b);
  color: #431407;
  font-size: 15px;
  cursor: pointer;
}
.text-fallback button:hover { filter: brightness(1.05); }

.call-actions {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 16px 0 10px;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #a8a29e;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
  width: 56px;
  text-align: center;
}
.action:hover { color: #fff; }
.action.on { color: #fbbf24; }

.talk-btn {
  border: none;
  background: none;
  font-family: inherit;
  width: 70px;
  gap: 6px;
  color: #fbbf24;
}
.talk-btn.listening { color: #ef4444; transform: scale(1.15); }

.push-status { padding: 0 0 26px; font-size: 12px; color: #a8a29e; }

/* ---- Ended screen ---- */
.ended {
  background: linear-gradient(180deg, #431407, #7c2d12);
  color: #fff;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 30px;
  text-align: center;
}
.ended .avatar { background: #fff7ed; }
.ended h2 { margin-top: 14px; }

.summary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 18px;
  padding: 16px;
  max-width: 300px;
}
.summary h3 { color: #fbbf24; font-size: 14px; margin-bottom: 8px; letter-spacing: 1px; text-transform: uppercase; }
.summary p { font-size: 13.5px; line-height: 1.5; color: #ffedd5; }

.again-btn {
  background: linear-gradient(120deg, #fbbf24, #f59e0b);
  color: #431407;
  border: none;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  transition: transform 0.15s;
}
.again-btn:hover { transform: translateY(-2px); }
.again-btn.small { font-size: 12.5px; padding: 10px 18px; margin-top: 16px; }
.again-btn.ghost {
  background: none;
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.5);
  box-shadow: none;
  margin-top: 10px;
}
.again-btn.ghost:hover { background: rgba(251, 191, 36, 0.12); }
.side-links { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ================= SIDE PANEL ================= */
.side-panel { max-width: 380px; }
.side-card {
  background: rgba(255, 251, 235, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 22px;
  padding: 26px;
  color: #ffedd5;
  backdrop-filter: blur(6px);
}
.side-card h3 { color: #fbbf24; margin-bottom: 14px; font-size: 17px; }
.side-card ol { margin-left: 18px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.5; }
.side-card em { color: #fde68a; }
.side-note { margin-top: 16px; font-size: 12.5px; color: #d6d3d1; border-top: 1px dashed rgba(251, 191, 36, 0.3); padding-top: 14px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.transcript::-webkit-scrollbar { width: 5px; }
.transcript::-webkit-scrollbar-thumb { background: #57534e; border-radius: 3px; }

/* ---- Phone network link bar ---- */
.phone-stack { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.phone-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: rgba(28, 25, 23, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fed7aa;
  font-size: 12px;
  border-radius: 999px;
}
.phone-link-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #78716c;
}
.phone-link.on .phone-link-dot { background: #22c55e; box-shadow: 0 0 8px #22c55e; }

.connector-box {
  margin-top: 14px;
  border-top: 1px dashed rgba(251, 191, 36, 0.3);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.connector-title { color: #fbbf24; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.local-url {
  font-size: 11.5px;
  color: #a5f3fc;
  font-family: Consolas, monospace;
  word-break: break-all;
  text-align: center;
  margin: 4px 0 0;
  background: rgba(6, 182, 212, 0.08);
  border: 1px dashed rgba(6, 182, 212, 0.3);
  border-radius: 8px;
  padding: 6px 8px;
}

/* ================= DISPATCH BRIDGE OVERLAY ================= */
.bridge-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.bridge-panel {
  background: #1a1d27;
  border: 1px solid #333;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.bridge-header {
  margin-bottom: 16px;
  position: relative;
}
.bridge-header h2 { font-size: 1.2rem; color: #facc15; margin-bottom: 2px; }
.bridge-header p { font-size: 0.75rem; color: #999; }
.bridge-close {
  position: absolute;
  top: 0; right: 0;
  background: none; border: none; color: #999;
  font-size: 1.5rem; cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.bridge-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.bridge-card {
  background: #22263a;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.bridge-card h3 { font-size: 0.85rem; color: #facc15; margin-bottom: 8px; }
.bridge-hint { font-size: 0.75rem; color: #999; margin-bottom: 10px; }
.bridge-empty { font-size: 0.8rem; color: #999; font-style: italic; }
.bridge-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.bridge-btn {
  background: #1a1d27; color: #e8e8e8; border: 1px solid #333;
  border-radius: 8px; padding: 8px 14px; font-size: 0.8rem;
  cursor: pointer; transition: all 0.2s; font-weight: 500;
}
.bridge-btn:hover:not(:disabled) { background: #facc15; color: #000; border-color: #facc15; }
.bridge-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.bridge-btn.primary { background: #facc15; color: #000; border-color: #facc15; font-weight: 700; }
.bridge-btn.primary:hover { background: #fb923c; border-color: #fb923c; }
.bridge-status { font-size: 0.75rem; color: #999; min-height: 20px; }
.bridge-status.error { color: #ef4444; }
.bridge-status.success { color: #22c55e; }
.bridge-field-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; margin-bottom: 4px;
  cursor: pointer; transition: background 0.15s;
}
.bridge-field-row:hover { background: rgba(250, 204, 21, 0.08); }
.bridge-field-label { font-size: 0.7rem; color: #999; min-width: 110px; }
.bridge-field-value { font-size: 0.8rem; flex: 1; word-break: break-word; }
.bridge-field-actions { display: flex; gap: 4px; }
.bridge-field-actions button {
  background: none; border: 1px solid #333; color: #e8e8e8;
  border-radius: 4px; padding: 2px 6px; font-size: 0.65rem;
  cursor: pointer; transition: all 0.15s;
}
.bridge-field-actions button:hover { background: #facc15; color: #000; border-color: #facc15; }
.bridge-field-row.mapped { border-left: 3px solid #22c55e; background: rgba(34,197,94,0.08); }
.bridge-field-row.missing { border-left: 3px solid #ef4444; background: rgba(239,68,68,0.08); }
.bridge-app-detected { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.bridge-app-icon { color: #22c55e; font-size: 1.1rem; font-weight: 700; }
.bridge-app-missing { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.2); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.bridge-app-msg { font-size: 0.85rem; color: #fbbf24; margin-bottom: 10px; }
.bridge-app-add { display: flex; flex-wrap: wrap; gap: 8px; }
.bridge-input { background: #1a1d27; border: 1px solid #333; border-radius: 6px; padding: 6px 10px; color: #e8e8e8; font-size: 0.8rem; flex: 1; min-width: 140px; }
.bridge-input:focus { border-color: #facc15; outline: none; }
.bridge-custom-list { margin-top: 8px; }
.bridge-custom-app { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-radius: 4px; margin-bottom: 2px; font-size: 0.75rem; }
.bridge-custom-app:hover { background: rgba(255,255,255,0.05); }
.bridge-btn-small { background: none; border: 1px solid #555; color: #999; border-radius: 4px; padding: 2px 8px; font-size: 0.65rem; cursor: pointer; }
.bridge-btn-small:hover { border-color: #ef4444; color: #ef4444; }
.bridge-app-list { margin-top: 8px; }
.bridge-app-item { display: flex; gap: 8px; padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; }
.bridge-app-item:hover { background: rgba(255,255,255,0.05); }
.bridge-app-name { color: #e8e8e8; min-width: 100px; }
.bridge-app-title { color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }