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

html, body {
  width: 100%;
  height: 100%;
  background: #0a0a0f;
  color: #e8e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
}

/* ---------- Login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2a 0%, #0a0a0f 70%);
}

.login-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 40px 32px;
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  opacity: 0.5;
  font-size: 13px;
  margin-bottom: 12px;
}

.login-card input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: rgba(100, 150, 255, 0.5);
}

.login-card button {
  background: linear-gradient(135deg, #5566ff, #7788ff);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: transform 0.1s, box-shadow 0.2s;
}

.login-card button:active {
  transform: scale(0.98);
}

.error {
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ---------- Main ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  background: linear-gradient(180deg, rgba(10,10,15,0.7) 0%, transparent 100%);
}

.brand {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.7;
}

.controls {
  display: flex;
  gap: 8px;
}

.controls button {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #e8e8f0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}

.controls button:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Chat (fullscreen) ---------- */
.chat-screen {
  position: fixed;
  inset: 0;
  background: #0f0f18;
  z-index: 20;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.chat-screen.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: #141420;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 12px;
  flex-shrink: 0;
}

.chat-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #e8e8f0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close:active { transform: scale(0.94); }

.chat-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  text-align: center;
}

.chat-spacer { width: 36px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.38;
  word-wrap: break-word;
  position: relative;
}

.msg > * { margin: 0; }
.msg p { margin: 0; }

.msg.in {
  align-self: flex-end;
  background: linear-gradient(135deg, #4455cc, #5566ee);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.out {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: #e8e8f0;
  border-bottom-left-radius: 5px;
}

.msg.voice {
  cursor: pointer;
  padding: 8px 12px;
  line-height: 1.32;
}

.msg.voice .voice-icon {
  display: inline-block;
  margin-right: 5px;
  opacity: 0.7;
  font-size: 12px;
}

.msg.voice .voice-preview {
  font-style: italic;
  opacity: 0.85;
  margin: 0;
}

.msg.voice .voice-full {
  display: none;
  margin: 0;
  font-style: normal;
  opacity: 1;
}

.msg.voice.expanded .voice-preview { display: none; }
.msg.voice.expanded .voice-full { display: block; }

.msg.voice .voice-hint {
  display: block;
  font-size: 10px;
  opacity: 0.5;
  margin-top: 2px;
  font-style: normal;
}

.msg.voice.expanded .voice-hint::after { content: 'toque para recolher'; }
.msg.voice:not(.expanded) .voice-hint::after { content: 'toque para expandir'; }

/* Formatação WhatsApp */
.msg strong { font-weight: 700; }
.msg em { font-style: italic; }
.msg del { text-decoration: line-through; opacity: 0.7; }
.msg code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg.in code { background: rgba(0, 0, 0, 0.22); }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 18px 10px;
  font-size: 13px;
  opacity: 0.65;
  color: #cfd0e0;
  flex-shrink: 0;
}

.typing-indicator.hidden { display: none; }

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8899ee;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #141420;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 11px 16px;
  border-radius: 22px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  line-height: 1.35;
  overflow-y: auto;
}

.chat-input-row textarea:focus {
  border-color: rgba(100, 150, 255, 0.4);
}

.chat-input-row button {
  background: linear-gradient(135deg, #5566ff, #7788ff);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-input-row button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.chat-empty {
  text-align: center;
  opacity: 0.4;
  padding: 40px 20px;
  font-size: 14px;
}

.stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#blob-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: pointer;
  filter: drop-shadow(0 0 40px rgba(100, 130, 255, 0.35));
  transition: filter 0.6s ease-out;
}

#blob-canvas.recording {
  filter: drop-shadow(0 0 55px rgba(255, 90, 120, 0.55));
}

#blob-canvas.loading {
  filter: drop-shadow(0 0 50px rgba(80, 200, 255, 0.5));
}

#blob-canvas.playing {
  filter: drop-shadow(0 0 55px rgba(100, 220, 160, 0.55));
}

#blob-canvas.disabled {
  cursor: default;
}

body.chat-open #blob-canvas {
  display: none;
}

.status-text {
  position: absolute;
  bottom: calc(22vh + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  opacity: 0.6;
  letter-spacing: 0.02em;
  z-index: 3;
  transition: opacity 0.3s;
  text-align: center;
  padding: 0 20px;
  max-width: 80vw;
  pointer-events: none;
}
