:root {
  --bg: #080a12;

  --surface-1: rgba(18, 21, 35, 0.82);
  --surface-2: rgba(27, 30, 47, 0.78);

  --border: rgba(255, 255, 255, 0.10);
  --border-active: rgba(104, 112, 255, 0.35);

  --text-primary: #f4f5fb;
  --text-secondary: #a5a8bb;
  --text-muted: #74788d;

  --primary: #5964ff;
  --primary-light: #7b82ff;
  --violet: #6656e8;

  --success: #67dc8b;
  --warn: #e8a33d;
  --danger: #e2554f;

  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 30px;
  --radius-pill: 999px;

  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.28);
  --shadow-primary: 0 8px 34px rgba(76, 84, 255, 0.32);

  --blur: blur(22px);
}

* { box-sizing: border-box; }

/* Any component rule that sets `display` (e.g. `.control-button { display:
   flex }`) otherwise silently overrides the browser's default
   `[hidden] { display: none }` UA style, since author rules always beat UA
   rules regardless of selector specificity — so `hidden` alone stops
   working the moment a class/id also declares `display`. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #05060a;
  color: var(--text-primary);
  font-family: Geist, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* ---------- Login ---------- */

#login-view {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  padding: 28px 26px;
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur);
}

.login-card h1 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(8, 10, 18, 0.6);
  color: var(--text-primary);
  font-size: 16px;
}

#login-form input:focus {
  border-color: var(--border-active);
}

#login-form button {
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(100deg, var(--primary), var(--violet));
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
}

.error { color: #ff8a85; font-size: 14px; }

/* ---------- Page shell ---------- */

#call-view {
  width: 100%;
  display: flex;
  justify-content: center;
}

.live-voice-page {
  min-height: 100dvh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;

  padding: 24px 24px 20px;
  gap: 18px;

  background:
    radial-gradient(circle at 50% 15%, rgba(78, 70, 220, 0.16), transparent 34%),
    var(--bg);
}

/* ---------- Connection status ---------- */

.connection-status {
  align-self: flex-end;

  display: inline-flex;
  align-items: center;
  gap: 9px;

  height: 38px;
  padding: 0 16px;

  border-radius: var(--radius-pill);

  background: rgba(18, 23, 33, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: var(--blur);

  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(103, 220, 139, 0.8);
}

.connection-status[data-status="connecting"] .status-dot {
  background: var(--warn);
  box-shadow: 0 0 10px rgba(232, 163, 61, 0.8);
}

.connection-status[data-status="error"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(226, 85, 79, 0.8);
}

.connection-status[data-status="idle"] .status-dot {
  background: var(--text-muted);
  box-shadow: none;
}

/* ---------- Voice hero / orb ---------- */

.voice-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.voice-orb-container {
  width: 220px;
  height: 220px;
  position: relative;
  margin: 6px auto 0;
  display: grid;
  place-items: center;
}

.voice-orb-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px dotted rgba(109, 105, 255, 0.7);
  animation: rotateOrb 16s linear infinite;
}

@keyframes rotateOrb {
  to { transform: rotate(360deg); }
}

.voice-orb {
  width: 165px;
  height: 165px;
  border-radius: 50%;

  background: radial-gradient(
    circle at 35% 25%,
    rgba(180, 190, 255, 0.95),
    rgba(94, 102, 235, 0.92) 42%,
    rgba(58, 61, 158, 0.95) 75%
  );

  box-shadow:
    0 0 30px rgba(93, 101, 255, 0.35),
    0 0 80px rgba(92, 78, 255, 0.18),
    inset 0 0 35px rgba(255, 255, 255, 0.15);

  transition: filter 0.3s ease;
}

.voice-orb[data-state="idle"] {
  animation: orbBreathe 4s ease-in-out infinite;
}

.voice-orb[data-state="connecting"] {
  animation: orbBreathe 1s ease-in-out infinite;
}

.voice-orb[data-state="listening"] {
  animation: orbPulse 1.7s ease-in-out infinite;
}

.voice-orb[data-state="thinking"] {
  background: radial-gradient(
    circle at 35% 25%,
    rgba(200, 190, 255, 0.95),
    rgba(102, 86, 232, 0.92) 42%,
    rgba(58, 61, 158, 0.95) 75%
  );
  animation: orbPulse 0.9s ease-in-out infinite;
}

.voice-orb[data-state="speaking"] {
  box-shadow:
    0 0 44px rgba(93, 101, 255, 0.55),
    0 0 100px rgba(92, 78, 255, 0.3),
    inset 0 0 35px rgba(255, 255, 255, 0.2);
  animation: orbPulse 0.5s ease-in-out infinite;
}

.voice-orb[data-state="error"] {
  filter: grayscale(0.6) brightness(0.85);
  animation: none;
}

/* A call or a meeting in progress tints the orb green regardless of its
   per-turn state (idle/connecting/listening/thinking/speaking), so it reads
   at a glance as "session active" — set via orb.dataset.session in app.js's
   setActiveSession(), never on the error state (setActiveSession(null) is
   always called before an error is shown, see the ws.onclose handler). */
.voice-orb[data-session="call"],
.voice-orb[data-session="meeting"] {
  background: radial-gradient(
    circle at 35% 25%,
    rgba(190, 255, 214, 0.95),
    rgba(52, 199, 118, 0.92) 42%,
    rgba(24, 110, 66, 0.95) 75%
  );

  box-shadow:
    0 0 30px rgba(103, 220, 139, 0.4),
    0 0 80px rgba(52, 199, 118, 0.2),
    inset 0 0 35px rgba(255, 255, 255, 0.15);
}

.voice-orb[data-session="call"][data-state="thinking"],
.voice-orb[data-session="meeting"][data-state="thinking"] {
  background: radial-gradient(
    circle at 35% 25%,
    rgba(210, 255, 227, 0.95),
    rgba(70, 209, 138, 0.92) 42%,
    rgba(24, 110, 66, 0.95) 75%
  );
}

.voice-orb[data-session="call"][data-state="speaking"],
.voice-orb[data-session="meeting"][data-state="speaking"] {
  box-shadow:
    0 0 44px rgba(103, 220, 139, 0.6),
    0 0 100px rgba(52, 199, 118, 0.35),
    inset 0 0 35px rgba(255, 255, 255, 0.2);
}

@keyframes orbBreathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.045); filter: brightness(1.12); }
}

.voice-state {
  text-align: center;
}

.voice-state-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--primary-light);
}

.voice-state-description {
  margin: 5px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

.call-timer {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.banner {
  width: 100%;
  background: var(--danger);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Transcript preview (latest messages) ---------- */

.transcript-panel {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(12, 15, 27, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: var(--blur);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-row {
  display: flex;
}

.message-row.user-row {
  justify-content: flex-end;
}

.message-row.assistant-row {
  align-items: flex-start;
  gap: 10px;
}

.assistant-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(102, 86, 232, 0.35);
  font-size: 13px;
}

.message-bubble {
  max-width: 78%;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
}

.message-bubble.message-user {
  border-radius: 18px 18px 4px 18px;
  background: linear-gradient(135deg, rgba(60, 64, 145, 0.9), rgba(40, 43, 103, 0.9));
}

.message-bubble.message-ai {
  border-radius: 18px 18px 18px 5px;
  background: rgba(31, 34, 50, 0.9);
}

/* ---------- Full transcript ---------- */

.transcript-mode-full {
  margin-top: 4px;
}

.transcript-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(12, 15, 27, 0.55);
}

.bubble {
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 80%;
  font-size: 14px;
}

.bubble.user { align-self: flex-end; background: rgba(89, 100, 255, 0.25); }
.bubble.assistant { align-self: flex-start; background: rgba(255, 255, 255, 0.08); }

/* ---------- Primary call button ---------- */

.primary-call-button {
  width: 100%;
  min-height: 88px;

  border: 0;
  border-radius: var(--radius-lg);
  padding: 0 18px;

  display: flex;
  align-items: center;
  gap: 18px;

  color: white;
  cursor: pointer;

  background: linear-gradient(100deg, #65d58b 0%, #5b82d8 48%, #5045ff 100%);
  box-shadow: var(--shadow-primary);

  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.primary-call-button:hover {
  transform: translateY(-1px);
}

.primary-call-button-start {
  background: linear-gradient(100deg, #65d58b 0%, #5b82d8 48%, #5045ff 100%);
}

.primary-call-button-end {
  background: linear-gradient(100deg, #e2554f 0%, #c94a63 100%);
  box-shadow: 0 8px 34px rgba(226, 85, 79, 0.3);
}

.primary-call-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(20, 35, 46, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.primary-call-title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 18px;
  font-weight: 650;
}

.primary-call-arrow {
  font-size: 22px;
  opacity: 0.85;
}

.primary-actions-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.primary-actions-row .primary-call-button {
  flex: 1 1 0;
  width: auto;
}

.primary-actions-row .meeting-button {
  flex: 1 1 0;
  width: 100%;
  min-height: 88px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-lg);

  display: flex;
  align-items: center;
  gap: 18px;

  color: white;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.primary-actions-row .meeting-button:hover {
  transform: translateY(-1px);
}

/* ---------- Typed text input (during a call) ---------- */

.text-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 13px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-1);
  backdrop-filter: var(--blur);
  color: var(--text-primary);
  font-size: 15px;
}

.text-input-row input:focus {
  border-color: var(--border-active);
}

.text-input-row input::placeholder {
  color: var(--text-muted);
}

.text-input-row button {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(100deg, var(--primary), var(--violet));
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  transition: transform 0.16s ease;
}

.text-input-row button:hover {
  transform: translateY(-1px);
}

/* ---------- Secondary controls ---------- */

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.control-button {
  min-height: 100px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  backdrop-filter: var(--blur);

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;

  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.control-button:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
  border-color: var(--border-active);
}

.control-button:disabled {
  opacity: 0.45;
  filter: grayscale(0.3);
  cursor: not-allowed;
}

.control-button:disabled:hover {
  transform: none;
  background: var(--surface-1);
  border-color: var(--border);
}

.control-icon {
  font-size: 20px;
}

.control-title {
  font-size: 13px;
  font-weight: 600;
}

.control-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

#mute-call.is-muted {
  border-color: rgba(232, 163, 61, 0.4);
  background: rgba(232, 163, 61, 0.12);
}

/* ---------- Meeting transcript result ---------- */

#meeting-transcript {
  width: 100%;
  margin-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 13px;
  text-align: left;
  background: rgba(12, 15, 27, 0.55);
}

.meeting-button {
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: white;
}

.meeting-button-start {
  background: linear-gradient(100deg, #f6c667 0%, #e8a33d 55%, #d9782a 100%);
  box-shadow: 0 8px 34px rgba(232, 163, 61, 0.3);
}

/* ---------- Privacy footer ---------- */

.privacy-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 0 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .live-voice-page {
    padding: 18px 16px 16px;
    gap: 14px;
  }

  .voice-orb-container {
    width: 175px;
    height: 175px;
  }

  .voice-orb {
    width: 135px;
    height: 135px;
  }

  .control-button {
    min-height: 92px;
  }

  .primary-actions-row {
    flex-direction: column;
  }

  .primary-actions-row .primary-call-button,
  .primary-actions-row .meeting-button {
    flex: 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .voice-orb[data-state="idle"],
  .voice-orb[data-state="connecting"],
  .voice-orb[data-state="listening"],
  .voice-orb[data-state="thinking"],
  .voice-orb[data-state="speaking"],
  .voice-orb-ring {
    animation: none;
  }
}
