:root {
  /* Dr. Lang brand — navy + gold */
  --navy: #0e2745;
  --navy-dark: #0a1c33;
  --gold: #c9a24b;
  --gold-hover: #b08d3a;
  --gold-soft: #fbf7ec;
  --ink: #1c2733;
  --bg: #f4f6f9;
  --bg-warm: #fbf7ec;
  --card: #ffffff;
  --text: var(--ink);
  --muted: #5a6776;
  --primary: var(--gold);
  --primary-light: var(--gold-soft);
  --primary-hover: var(--gold-hover);
  --accent: var(--navy);
  --border: #e6eaf0;
  --assistant: #f4f6f9;
  --patient: var(--gold-soft);
  --emergency: #fef2f2;
  --emergency-border: #dc2626;
  --emergency-text: #991b1b;
  --call-green: #059669;
  --call-blue: #2563eb;
  --call-amber: #d97706;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(165deg, var(--bg-warm) 0%, var(--bg) 45%, #f1f5f9 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.header, .footer {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
  margin-top: auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.brand-logo {
  flex-shrink: 0;
  height: 40px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  background: transparent;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: var(--navy);
}

.hint, .consent-text, .greeting {
  color: var(--muted);
  line-height: 1.5;
}

.greeting {
  color: var(--text);
  margin-bottom: 1rem;
}

.test-banner {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  color: #92400e;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  background: #ffffff;
  color: var(--text);
}

input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 3rem; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
}

.btn.primary {
  background: var(--gold);
  color: var(--navy-dark);
  border: 2px solid var(--gold);
}

.btn.primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
}

.btn.secondary {
  background: var(--card);
  color: var(--navy);
  border: 2px solid var(--navy);
}

.btn.secondary:hover {
  background: var(--gold-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.error, .call-error {
  color: var(--emergency-border);
  margin-top: 0.75rem;
  font-size: 0.9rem;
  text-align: center;
}

/* ── Phone-call surface ─────────────────────────────────────────────────── */

.call-card {
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.phone-surface {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.phone-avatar {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff1f2, #fce7f3);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 16px rgba(190, 18, 60, 0.12);
}

.phone-avatar-icon {
  font-size: 2.25rem;
  color: var(--primary);
  z-index: 1;
}

.call-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--call-green);
  animation: call-ring 2s ease-out infinite;
  opacity: 0;
}

.call-pulse.active {
  opacity: 1;
}

.call-pulse.speaking {
  border-color: var(--call-blue);
  animation: call-ring 1.4s ease-out infinite;
}

@keyframes call-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

.phone-contact {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.phone-role {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.call-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  min-width: 12rem;
  transition: background 0.25s, color 0.25s;
}

.call-status-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.call-status.connecting {
  background: #fffbeb;
  color: var(--call-amber);
  border: 1px solid #fde68a;
}

.call-status.active {
  background: #ecfdf5;
  color: var(--call-green);
  border: 1px solid #a7f3d0;
}

.call-status.listening {
  background: #ecfdf5;
  color: var(--call-green);
  border: 1px solid #6ee7b7;
}

.call-status.speaking {
  background: #eff6ff;
  color: var(--call-blue);
  border: 1px solid #bfdbfe;
}

.call-status.processing {
  background: #fffbeb;
  color: var(--call-amber);
  border: 1px solid #fde68a;
}

.call-status.ended {
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--border);
}

.call-hint {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.25rem 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  width: 100%;
}

.end-call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #fff;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  min-width: 14rem;
}

.end-call-btn:hover {
  background: var(--primary-hover);
}

.end-call-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
}

.text-fallback-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-top: 1.25rem;
  padding: 0.25rem;
}

.text-fallback-link:hover {
  color: var(--text);
}

.voice-panel {
  margin-top: 1rem;
  text-align: center;
}

/* Hidden internal transcript */
.transcript-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  padding: 0;
  margin: -1px;
}

/* Text fallback panel */
.fallback-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.fallback-label {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.emergency {
  background: var(--emergency);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: var(--emergency-text);
  text-align: left;
  font-size: 0.9rem;
}

.done-card {
  text-align: center;
}

.done-card h2 {
  color: var(--navy);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 600px) {
  .chat-form {
    flex-direction: row;
    align-items: flex-end;
  }
  .chat-form textarea { flex: 1; margin-bottom: 0; }
}

@media (max-width: 380px) {
  .phone-avatar {
    width: 4.5rem;
    height: 4.5rem;
  }
  .end-call-btn {
    min-width: 100%;
  }
}
