:root {
  --bg: #030516;
  --bg-elev: #0a1228;
  --bg-card: #0f1a3a;
  --text: #eaf4ff;
  --text-dim: #8aa4cc;
  --accent: #3b82f6;
  --accent-hot: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --error: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

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

/* ===== LOGIN ===== */
#login-screen {
  justify-content: center;
  align-items: center;
  padding: 32px;
  gap: 48px;
}

.brand {
  text-align: center;
}

.logo-orb {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-hot), var(--accent) 60%, #1e3a8a 100%);
  box-shadow: 0 0 60px var(--accent-glow), inset 0 0 20px rgba(255,255,255,0.2);
  animation: orb-breathe 3s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 60px var(--accent-glow); }
  50% { transform: scale(1.05); box-shadow: 0 0 80px var(--accent-glow); }
}

.brand h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.brand .subtitle {
  color: var(--text-dim);
  font-size: 14px;
}

.login-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form input {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-form input::placeholder {
  color: var(--text-dim);
}

#login-btn {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#login-btn:hover, #login-btn:focus {
  background: var(--accent-hot);
}

#login-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ===== OTP step (device novo) ===== */
#otp-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.3s ease;
  width: 100%;
}

.otp-hint {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
  margin: 0 4px;
}

#otp-code {
  padding: 18px 16px !important;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
  color: var(--text);
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.4em;
  padding-left: 0.4em !important; /* compensa letter-spacing do ultimo char */
  font-family: -apple-system, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#otp-code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#otp-code::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.35em;
}

#otp-submit-btn {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
#otp-submit-btn:hover:not(:disabled),
#otp-submit-btn:focus:not(:disabled) {
  background: var(--accent-hot);
}
#otp-submit-btn:active:not(:disabled) { transform: scale(0.98); }
#otp-submit-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

#otp-cancel-btn {
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#otp-cancel-btn:hover,
#otp-cancel-btn:focus {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
}

.error {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  padding: 8px;
}

.app-version {
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  margin-top: 16px;
  opacity: 0.5;
  letter-spacing: 0.02em;
  font-family: -apple-system, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ===== Cartao de confirmacao de identidade de voz ===== */
.voice-identify-card {
  align-self: stretch;
  background: linear-gradient(145deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02));
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 16px;
  padding: 16px;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideFadeIn 0.35s ease;
  box-shadow: 0 4px 24px rgba(59,130,246,0.15);
}

/* ===== FASE C — CARD DE AUTORIZAÇÃO POR VOZ ===== */
.auth-card {
  align-self: stretch;
  background: linear-gradient(145deg, rgba(30, 58, 138, 0.18), rgba(15, 26, 58, 0.5));
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 16px;
  padding: 18px 18px 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideFadeIn 0.35s ease;
  box-shadow: 0 6px 32px rgba(59, 130, 246, 0.25),
              inset 0 1px 0 rgba(147, 197, 253, 0.15);
  position: relative;
}
.auth-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.5));
}
.auth-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  flex: 1;
}
.auth-category {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.auth-cat-emoji { font-size: 12px; }
.auth-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-description {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}
.auth-prompt {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 4px 0;
}
.auth-transcript {
  font-size: 13px;
  color: var(--accent-hot);
  background: rgba(59, 130, 246, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  font-style: italic;
  min-height: 20px;
  animation: auth-transcript-pulse 1.5s ease-in-out infinite;
}
@keyframes auth-transcript-pulse {
  0%, 100% { background: rgba(59, 130, 246, 0.08); }
  50%      { background: rgba(59, 130, 246, 0.18); }
}
.auth-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.auth-mic-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.auth-mic-btn:active { transform: scale(0.96); }
.auth-mic-btn.recording {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5),
              0 0 0 4px rgba(245, 158, 11, 0.25);
  animation: auth-mic-pulse 1s ease-in-out infinite;
}
@keyframes auth-mic-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5), 0 0 0 4px rgba(245, 158, 11, 0.25); }
  50%      { box-shadow: 0 6px 24px rgba(245, 158, 11, 0.6), 0 0 0 10px rgba(245, 158, 11, 0.08); }
}
.auth-mic-label { white-space: nowrap; }
.auth-cancel-btn {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.auth-cancel-btn:hover,
.auth-cancel-btn:focus {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
}
.auth-card-sent {
  opacity: 0.7;
  border-color: rgba(16, 185, 129, 0.45);
}
.auth-card-sent .auth-title::after {
  content: ' ✓';
  color: var(--ok);
}
.auth-sent-hint {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 6px;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 8px;
}
@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== FASE D — CARD DE CADASTRO DE VOZ DE TERCEIROS ===== */
.enroll-card {
  align-self: stretch;
  background: linear-gradient(145deg, rgba(96, 165, 250, 0.14), rgba(15, 26, 58, 0.45));
  border: 1px solid rgba(129, 140, 248, 0.4);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideFadeIn 0.3s ease;
  box-shadow: 0 6px 28px rgba(59, 130, 246, 0.18),
              inset 0 1px 0 rgba(147, 197, 253, 0.15);
}
.enroll-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.enroll-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.5));
}
.enroll-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.enroll-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.enroll-reason {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-hot);
}
.enroll-name-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.enroll-name-input {
  background: var(--bg-card);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.enroll-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.enroll-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  padding: 2px 0;
}
.enroll-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.enroll-btn-accept {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.enroll-btn-accept:active { transform: scale(0.96); }
.enroll-btn-accept:hover { box-shadow: 0 6px 18px var(--accent-glow); }
.enroll-btn-skip,
.enroll-cancel-btn {
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.enroll-btn-skip:hover,
.enroll-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
/* Estagio 2 */
.enroll-phrase-hint {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.enroll-phrase {
  font-size: 14px;
  font-style: italic;
  color: var(--accent-hot);
  background: rgba(59, 130, 246, 0.12);
  padding: 12px 14px;
  border-radius: 10px;
  text-align: center;
  line-height: 1.4;
}
.enroll-countdown {
  font-size: 12px;
  color: #f59e0b;
  text-align: center;
  animation: auth-transcript-pulse 1s ease-in-out infinite;
}
.enroll-mic-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 200ms ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.enroll-mic-btn:active { transform: scale(0.96); }
.enroll-mic-btn.recording {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  animation: auth-mic-pulse 1s ease-in-out infinite;
}
.enroll-card-done .enroll-done {
  text-align: center;
  font-size: 13px;
  color: var(--ok);
  font-weight: 600;
  padding: 10px;
}
.enroll-card-done {
  border-color: rgba(16, 185, 129, 0.5);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.14), rgba(15, 26, 58, 0.3));
}
.voice-identify-card.vi-saved {
  border-color: rgba(16,185,129,0.45);
  background: linear-gradient(145deg, rgba(16,185,129,0.12), rgba(16,185,129,0.04));
  transform: scale(1.02);
  transition: all 0.3s ease;
}
.voice-identify-card.vi-dismissed {
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.25s ease;
}
.vi-header { display: flex; align-items: center; gap: 10px; }
.vi-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,0.2);
  border-radius: 50%; font-size: 16px;
}
.vi-title { font-weight: 600; font-size: 15px; color: var(--text); }
.vi-body { padding: 0 4px; }
.vi-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.4; }
.vi-name-display {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 22px; font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-hot);
  min-width: 140px;
  margin-bottom: 10px;
}
.vi-name-display.hidden { display: none; }
.vi-confidence-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--warn);
  color: #000;
  font-size: 11px; font-weight: 700;
  cursor: help;
}
.vi-name-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(59,130,246,0.4);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 18px; font-weight: 500;
  letter-spacing: 0.01em;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.vi-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.vi-name-input.hidden { display: none; }
.vi-hint { font-size: 12px; color: var(--text-dim); }
.vi-actions {
  display: flex; gap: 8px;
  flex-wrap: wrap;
}
.vi-btn {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.vi-btn:active:not(:disabled) { transform: scale(0.97); }
.vi-btn:disabled { opacity: 0.55; cursor: wait; }
.vi-btn-yes {
  background: var(--ok);
  color: white;
}
.vi-btn-yes:hover:not(:disabled) {
  background: #0ea371;
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}
.vi-btn-edit {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.18);
}
.vi-btn-edit:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.3);
}
.vi-btn-no {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
}
.vi-btn-no:hover {
  background: rgba(239,68,68,0.08);
  color: var(--error);
  border-color: rgba(239,68,68,0.25);
}

.hidden {
  display: none !important;
}

/* ===== MAIN ===== */
#main-screen {
  padding: 0;
  height: 100%;
  min-height: 0;
  /* display eh controlado pela classe .active (em .screen) — sem isso,
     o id sobrescreveria o .screen { display: none } e o chat apareceria
     atras do login. */
  flex-direction: column;
  position: relative;
}

.main-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  z-index: 5;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}

.status-dot.connected { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.listening { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulse-dot 1s infinite; }
.status-dot.thinking { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse-dot 0.6s infinite; }
.status-dot.speaking { background: var(--accent-hot); box-shadow: 0 0 10px var(--accent-hot); }
.status-dot.error { background: var(--error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.icon-btn:hover { color: var(--text); background: var(--bg-elev); }
.icon-btn:active { transform: scale(0.95); transition: transform 0.1s; }
.icon-btn.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--accent-glow);
}
.icon-btn.active svg {
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
}
.icon-btn.active::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-hot);
  box-shadow: 0 0 6px var(--accent-hot);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.conversation {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 85%;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;  /* preserva quebras de linha (Shift+Enter) e espacos */
  animation: bubble-in 0.25s ease;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Preview em tempo real da transcrição (Web Speech API).
   Aparece com opacidade reduzida e pontinho piscando enquanto o usuario fala;
   ao soltar o botao, a classe .interim e removida e vira bolha definitiva. */
.bubble.user.interim {
  background: rgba(59, 130, 246, 0.55);
  color: rgba(255, 255, 255, 0.92);
  position: relative;
  animation: bubble-in 0.25s ease, interim-pulse 1.8s ease-in-out infinite;
}
.bubble.user.interim::after {
  content: '▊';
  display: inline-block;
  margin-left: 2px;
  animation: interim-cursor 1s steps(2, jump-none) infinite;
  opacity: 0.7;
}
@keyframes interim-cursor {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0; }
}
@keyframes interim-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.18); }
}

.bubble.bubble-image {
  padding: 6px;
  max-width: 70%;
}

.bubble-image-thumb {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 380px;
  object-fit: cover;
  border-radius: 12px;
  cursor: zoom-in;
}

.bubble-image-caption {
  padding: 6px 8px 2px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
}

/* ===== OVERLAY DE ENVIO (imagem em upload) ===== */
.bubble.bubble-image.sending {
  position: relative;
}

.bubble.bubble-image.sending .bubble-image-thumb {
  filter: brightness(0.5);
}

.bubble-sending-overlay {
  position: absolute;
  inset: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 2;
}

.sending-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sending-spin 0.8s linear infinite;
}

@keyframes sending-spin {
  to { transform: rotate(360deg); }
}

.sending-label {
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sending-size {
  font-size: 11px;
  opacity: 0.75;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble.system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ===== APPROVAL BUTTONS ===== */
.bubble-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  animation: bubble-in 0.25s ease;
}

.bubble-container.user {
  align-items: flex-end;
}

.bubble-container.assistant {
  align-items: flex-start;
}

.approval-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.approval-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  flex: 0 0 auto;
}

.approval-btn:hover {
  transform: scale(1.1);
}

.approval-btn:active {
  transform: scale(0.95);
}

.approval-btn svg {
  width: 24px;
  height: 24px;
}

.approval-yes {
  background: var(--ok);
  color: white;
  border-radius: 8px;
  border: 2px solid var(--ok);
}

.approval-yes:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  border-color: var(--ok);
}

.approval-analyze {
  background: var(--warn);
  color: white;
  border-radius: 8px;
  border: 2px solid var(--warn);
}

.approval-analyze:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  border-color: var(--warn);
}

.approval-no {
  background: var(--error);
  color: white;
  border-radius: 8px;
  border: 2px solid var(--error);
}

.approval-no:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  border-color: var(--error);
}

.rating-stars {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  padding-left: 4px;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.rating-stars:hover {
  opacity: 1;
}

.rating-stars.submitted {
  opacity: 0.9;
  pointer-events: none;
}

.rating-star {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.25);
  transition: color 0.15s ease, transform 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.rating-star:hover {
  transform: scale(1.25);
}

.rating-star.filled {
  color: #fbbf24;
}

/* ===== ACTIONS BAR (mic + stars abaixo do balao) ===== */
.bubble-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding-left: 4px;
}

.bubble-mic-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex: 0 0 auto;
}

.bubble-mic-btn:hover {
  background: rgba(59, 130, 246, 0.3);
  color: #fff;
  transform: scale(1.1);
}

.bubble-mic-btn.played {
  color: #60a5fa;
}

/* ===== BOTAO DE FEEDBACK DE VOZ (mic + ?) ===== */
.voice-feedback {
  position: relative;
  margin-left: auto;  /* empurra pra direita */
}

.bubble-voice-fb-btn {
  position: relative;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex: 0 0 auto;
}

.bubble-voice-fb-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #fbbf24;
  transform: scale(1.1);
}

.bubble-voice-fb-btn.submitted {
  background: rgba(59, 130, 246, 0.35);
  color: #fbbf24;
}

.voice-fb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  background: #fbbf24;
  color: #000;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 1.5px #18182a;
}

.voice-fb-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: #1c1c2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 50;
  min-width: 120px;
}

.voice-fb-popover.open {
  display: flex;
}

.voice-fb-popover button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s ease;
}

.voice-fb-popover button:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* ===== BALAO COLAPSADO (> 50 palavras) ===== */
.bubble.collapsed {
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}

.bubble.collapsed::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5em;
  background: linear-gradient(to bottom, transparent, var(--panel, #1f1f2e) 85%);
  pointer-events: none;
}

.bubble.collapsed:hover {
  background: rgba(59, 130, 246, 0.12);
}

.bubble.collapsed::before {
  content: 'Ler tudo ↗';
  position: absolute;
  right: 8px;
  bottom: 4px;
  font-size: 11px;
  color: #60a5fa;
  font-weight: 500;
  z-index: 1;
}

/* ===== MODAL DE RESPOSTA LONGA ===== */
.response-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  /* safe-area pra iPhone notch + barra inferior; evita overflow da viewport */
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  overflow: hidden;
  animation: modalFadeIn 0.15s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.response-modal-box {
  background: #18182a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  /* Usa 100% do espaco disponivel no overlay (overlay ja tem padding com safe-area) */
  max-height: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;  /* garante bordas arredondadas no body scroll */
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.2s ease-out;
}

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

.response-modal-header {
  flex: 0 0 auto;  /* nao encolhe, nao cresce */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.response-modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 16px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex: 0 0 auto;
  transition: all 0.15s ease;
}

.response-modal-close:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.3);
}

.response-modal-body {
  flex: 1 1 auto;       /* ocupa o espaco central e faz scroll se precisar */
  min-height: 0;        /* permite encolher dentro do flex container */
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  /* Scrollbar custom pra ficar visivel em dark */
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.4) transparent;
}

.response-modal-body::-webkit-scrollbar {
  width: 6px;
}
.response-modal-body::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.4);
  border-radius: 3px;
}

.response-modal-footer {
  flex: 0 0 auto;  /* nao encolhe, fica fixo embaixo */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
  background: #14142a;  /* diferencia visualmente do body */
}

/* Dentro do modal, estrelas ficam centrais, voice-feedback na direita */
.response-modal-footer .rating-stars {
  margin: 0 4px;
}
.response-modal-footer .voice-feedback {
  margin-left: auto;
}
.response-modal-footer .approval-buttons {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.mic-area {
  flex: 0 0 auto;
  padding: 18px 0 calc(4px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.05);
  /* Suaviza qualquer reposicionamento quando alterna text/mic ou quando
     botoes internos mudam (evita "pulo" do mic pra direita) */
  transition: padding 180ms ease, gap 180ms ease;
  will-change: transform;
}

.mic-row {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  justify-content: center;
  position: relative;
}

/* Attach-btn (camera/anexo) SAI da mic-row e vai pro canto da mic-area,
   liberando totalmente o espaco horizontal pros hints laterais do mic. */
.mic-area .mic-row > .attach-btn {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.mic-area .mic-row > .attach-btn-spacer {
  display: none;
}

.mic-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px var(--accent-glow), inset 0 2px 4px rgba(255,255,255,0.15);
  /* Transition suave em TODAS as propriedades que podem mudar ao alternar
     entre text-form e mic-area (evita "pulo" lateral). Durante drag, o
     transform fica a cargo do JS (rAF coalesce — ver updateDragVisual). */
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 200ms ease,
              background 200ms ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  flex: 0 0 auto;
  will-change: transform;
}

.attach-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex: 0 0 auto;
  padding: 0;
}

.attach-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.05);
}

.attach-btn:active {
  transform: scale(0.95);
}

.attach-btn-spacer {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  visibility: hidden;
}

.attach-btn-text {
  width: 42px;
  height: 42px;
  align-self: flex-end;
  margin-bottom: 1px;
  flex: 0 0 42px;
}

.mic-btn:active,
.mic-btn.recording {
  transform: scale(0.95);
}

.mic-btn.recording {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.4);
}

/* Pontinho de status — centrado no pe do botao (amarelo/verde/vermelho).
   Substitui popups que apareciam acima do mic. */
.mic-status-dot {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  transition: background 200ms ease, box-shadow 200ms ease;
  pointer-events: none;
}
.mic-btn.status-loading .mic-status-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.75);
  animation: mic-status-blink 1s ease-in-out infinite;
}
.mic-btn.status-ready .mic-status-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.85);
}
.mic-btn.status-error .mic-status-dot {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.85);
}
@keyframes mic-status-blink {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50%      { opacity: 0.45; transform: translateX(-50%) scale(0.75); }
}

/* Pulse duplo defasado — box-shadow em vez de border (repaint 50% menor).
   Usa 2 elementos (o .mic-pulse real + pseudo ::before) com delay entre eles
   pra criar ondas orgânicas em vez de uma só. */
.mic-btn.recording .mic-pulse,
.mic-btn.recording .mic-pulse::before {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 3px var(--warn);
  animation: pulse-ring 1.3s infinite ease-out;
  will-change: transform, opacity;
}
.mic-btn.recording .mic-pulse::before {
  content: '';
  animation-delay: 0.65s;
}

@keyframes pulse-ring {
  0%   { transform: scale(1);    opacity: 0.9; }
  70%  { opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* Flash rápido ao soltar o botão — simula envio (feedback físico).
   Aplicado por JS via classList.add('sent') + remove em 320ms. */
.mic-btn.sent {
  animation: mic-sent-flash 320ms ease-out;
}
@keyframes mic-sent-flash {
  0%   { box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 0 rgba(59, 130, 246, 0.55); }
  60%  { box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 24px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 0 rgba(59, 130, 246, 0); }
}

.mic-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.mic-hint {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Estado de aviso: aos 4:30 de gravacao (30s antes do corte) fica vermelho */
.mic-hint.warn {
  color: #ef4444;
  font-weight: 600;
}

/* ===== PUSH-TO-TALK LOCK (arraste direita = trava, arraste esquerda = descarta) ===== */
.mic-row {
  position: relative;
}

/* Icone alternativo "enviar" (seta pra cima) dentro do mic-btn — aparece quando locked */
.mic-btn .mic-icon-send {
  display: none;
}
.mic-btn.locked .mic-icon-default {
  display: none;
}
.mic-btn.locked .mic-icon-send {
  display: block;
}

/* Estado locked: verde + anel pulsando (pronto pra enviar com 1 clique) */
/* Transform fica a cargo do JS (mantem o botao preso na direita via inline style) */
.mic-btn.locked {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.mic-btn.locked .mic-pulse {
  position: absolute;
  inset: -8px;
  border: 3px solid #10b981;
  border-radius: 50%;
  animation: pulse-ring 1.2s infinite;
}

/* Estados "hot" durante drag */
.mic-btn.drag-cancel-hot {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.5);
}
.mic-btn.drag-lock-hot {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.5);
}

/* ===== HINTS LATERAIS DE DRAG (descartar / travar) =====
   Pill horizontal com icone + texto. Posicionados FORA do botao de 72px
   (raio 36 + gap 14 = 50px do centro). Ícones e fundo ficam visiveis
   em qualquer tema/plano de fundo. */
.mic-drag-hint {
  position: absolute;
  top: 50%;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  will-change: transform, opacity;
}
.mic-drag-hint svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}
/* ESQUERDA (descartar): seta APONTA pra esquerda (sugere "joga fora").
   Alinhada pelo lado DIREITO, que fica 14px antes do botao. */
.mic-drag-hint-left {
  right: calc(50% + 50px);
  left: auto;
  transform: translateY(-50%);
}
/* DIREITA (travar): cadeado + texto.
   Alinhada pelo lado ESQUERDO, que fica 14px depois do botao. */
.mic-drag-hint-right {
  left: calc(50% + 50px);
  right: auto;
  transform: translateY(-50%);
}

.mic-drag-hint.visible {
  opacity: 0.85;
}
.mic-drag-hint.active {
  opacity: 1;
  transform: translateY(-50%) scale(1.12);
}
.mic-drag-hint-left.active {
  background: #ef4444;
  color: white;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.55);
}
.mic-drag-hint-right.active {
  background: #10b981;
  color: white;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
}

/* Em telas muito estreitas (<360px), textos colapsam e fica só o icone */
@media (max-width: 360px) {
  .mic-drag-hint span { display: none; }
  .mic-drag-hint { padding: 7px 9px; }
  .mic-drag-hint svg { width: 16px; height: 16px; }
}

/* ===== TOGGLE + TEXTO (OCULTO, ACIONADO PELO HEADER) ===== */
.toggle-text-btn {
  display: none !important;
}

.text-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.05);
  animation: fadeIn 0.2s ease;
}

/* Caixa da mensagem: barra fina de enviar no topo + textarea embaixo,
   tudo dentro de um container arredondado, borda unica */
.text-wrap {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.text-top-bar {
  display: flex;
  justify-content: space-between;  /* camera esquerda, enviar direita */
  align-items: center;
  padding: 3px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  min-height: 26px;
}

.send-btn-mini {
  width: 26px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s;
}

.send-btn-mini:hover:not(:disabled),
.send-btn-mini:focus-visible:not(:disabled) {
  color: #fff;
  background: var(--accent);
  outline: none;
}

.send-btn-mini:active:not(:disabled) {
  transform: scale(0.9);
}

.send-btn-mini:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.text-area textarea {
  flex: 1;
  /* 4 linhas: padding vertical (16) + 4 * line-height (4 * 22 = 88) = ~104 */
  min-height: 104px;
  max-height: 220px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.text-area textarea::placeholder {
  color: var(--text-dim);
}

.attach-btn-mini {
  width: 26px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s;
}

.attach-btn-mini:hover {
  color: #fff;
  background: rgba(59, 130, 246, 0.25);
}

.attach-btn-mini:active {
  transform: scale(0.9);
}

/* Toast =============================================
   Antes ficava fixo no bottom center. Agora e um balao azul claro,
   inline logo abaixo do header, alinhado a direita (em cima do chat,
   nao cobre mensagens importantes). */
.toast {
  position: fixed;
  top: calc(52px + env(safe-area-inset-top, 0px));  /* logo abaixo do header */
  right: 12px;
  left: auto;
  bottom: auto;
  max-width: min(78%, 340px);
  transform: translateY(-6px);
  background: linear-gradient(145deg, rgba(96, 165, 250, 0.22), rgba(59, 130, 246, 0.32));
  color: #eaf4ff;
  padding: 10px 14px;
  border-radius: 14px;
  border-top-right-radius: 4px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.45),
              inset 0 1px 0 rgba(147, 197, 253, 0.25);
  border: 1px solid rgba(96, 165, 250, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Ajustes finos */
.icon-btn {
  padding: 12px; /* 22 icon + 24 padding = 46px, acima dos 44 recomendados */
}

/* Botao flutuante "novas mensagens" */
.new-msg-btn {
  position: absolute;
  bottom: 140px;
  left: 50%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.new-msg-btn.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* ===== MODO SAFYRA (tela cheia imersiva) ===== */
.safyra-mode {
  position: fixed;
  inset: 0;
  z-index: 10500;          /* acima de toasts e modals regulares, abaixo de sheet critica */
  background:
    radial-gradient(ellipse at 50% 45%, rgba(46, 52, 140, 0.55) 0%, rgba(10, 8, 26, 0.95) 55%, #03030a 100%);
  overflow: hidden;
  display: block;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.safyra-mode.hidden {
  display: none !important;
}

.safyra-mode.entering {
  opacity: 0;
  animation: safyra-mode-fade-in 0.5s ease forwards;
}

@keyframes safyra-mode-fade-in {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}

#safyra-mode-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Canvas cuida de tudo — gema, sinapses e nos orbitando */
}

.safyra-mode-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;    /* so os filhos com pointer-events:auto interagem */
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.safyra-mode-status {
  pointer-events: none;
  color: rgba(190, 220, 255, 0.8);
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(100, 140, 255, 0.4);
  font-weight: 500;
  min-height: 18px;
  transition: color 0.2s ease;
}

.safyra-mode-status.listening { color: #7dd3fc; text-shadow: 0 0 16px rgba(56, 189, 248, 0.7); }
.safyra-mode-status.thinking  { color: #93c5fd; text-shadow: 0 0 16px rgba(96, 165, 250, 0.7); }
.safyra-mode-status.speaking  { color: #93c5fd; text-shadow: 0 0 18px rgba(96, 165, 250, 0.7); }

.safyra-mode-exit {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 10, 30, 0.5);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: all 0.2s ease;
}

.safyra-mode-exit:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.6);
}

.safyra-mode-hint {
  pointer-events: none;
  color: rgba(138, 164, 204, 0.45);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .logo-orb,
  .status-dot,
  .mic-btn,
  .toast,
  .new-msg-btn,
  .screen {
    animation: none !important;
    transition: none !important;
  }
  .conversation {
    scroll-behavior: auto;
  }
}
