.chat-screen {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 6px;
}

.chat-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.chat-logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.chat-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0;
}

.voice-state {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-screen .voice-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.chat-screen .voice-mode-badge.live {
  background: #dcfae6;
  color: #067647;
}

.chat-screen .voice-mode-badge.browser {
  background: #e0e7ff;
  color: #3730a3;
}

.chat-screen .voice-mode-badge.fallback,
.chat-screen .voice-mode-badge.upload {
  background: #fef0c7;
  color: #93370d;
}

.chat-screen .voice-mode-badge.processing,
.chat-screen .voice-mode-badge.connecting {
  background: #e0f2fe;
  color: #075985;
}

.chat-thread {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 2px 12px;
  -webkit-overflow-scrolling: touch;
}

.chat-turn {
  display: grid;
  gap: 8px;
}

.load-older-chat {
  justify-self: center;
  width: auto;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(24, 32, 42, 0.06);
}

.chat-message {
  max-width: min(86%, 560px);
  min-width: 0;
  padding: 11px 13px;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  font: inherit;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: left;
}

.user-message {
  justify-self: end;
  background: #e9eef6;
}

.assistant-message {
  justify-self: start;
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 8px;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  cursor: pointer;
}

.assistant-message.failed {
  background: #fff4f2;
  color: #7a271a;
}

.assistant-message.pending {
  grid-template-columns: 8px minmax(0, 1fr) auto;
  cursor: default;
  color: #344054;
  background: #f8fafc;
}

.assistant-message.pending.failed {
  color: #7a271a;
  background: #fff4f2;
}

.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #2563eb;
  animation: pendingPulse 1s ease-in-out infinite;
}

.pending-message {
  min-width: 0;
}

.pending-elapsed {
  justify-self: end;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

@keyframes pendingPulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-live-transcript {
  margin: 0;
  min-height: 0;
  max-height: 72px;
  padding: 8px 10px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(24, 32, 42, 0.08);
}

.chat-composer textarea,
.chat-message-input {
  min-height: 26px;
  max-height: 140px;
  padding: 9px 4px 8px 8px;
  border: 0;
  background: transparent;
  resize: none;
  line-height: 1.35;
  outline: none;
}

.chat-message-input {
  width: 100%;
  min-width: 0;
}

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

.chat-icon-button,
.chat-send-button {
  -webkit-appearance: none;
  appearance: none;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.chat-icon-button {
  background: #f2f4f7;
  color: #344054;
}

.chat-microphone-button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.chat-microphone-button.voice-motion {
  transition:
    background-color 130ms ease-out,
    box-shadow 130ms ease-out,
    color 130ms ease-out,
    transform 130ms ease-out;
}

.chat-microphone-button.voice-motion::before,
.chat-microphone-button.voice-motion::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  pointer-events: none;
}

.chat-microphone-button.voice-motion::before {
  z-index: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.92) 0 22%, transparent 23%),
    conic-gradient(from 210deg, #f04438, #f97316, #ef4444, #f04438);
  opacity: 0;
  transform: scale(0.36) rotate(-28deg);
  transition:
    opacity 90ms ease-out,
    transform 150ms cubic-bezier(0.2, 0.9, 0.22, 1.2);
}

.chat-microphone-button.voice-motion::after {
  z-index: 0;
  border: 2px solid rgba(180, 35, 24, 0.26);
  opacity: 0;
  transform: scale(0.62);
  transition:
    opacity 100ms ease-out,
    transform 150ms ease-out;
}

.chat-send-button {
  background: #111827;
  color: #ffffff;
}

.chat-send-button:disabled,
.chat-icon-button:disabled {
  opacity: 0.45;
}

.chat-icon-button.listening {
  background: #fee4e2;
  color: #b42318;
}

.chat-microphone-button.voice-motion.listening {
  box-shadow: inset 0 0 0 2px rgba(180, 35, 24, 0.16);
  transform: scale(1.02);
}

.chat-microphone-button.voice-motion.listening::before {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.chat-microphone-button.voice-motion.listening::after {
  opacity: 1;
  transform: scale(0.98);
}

.chat-icon-button .voice-record-icon {
  position: relative;
  z-index: 1;
  width: 19px;
  height: 19px;
  display: block;
  flex: 0 0 auto;
  line-height: 0;
  background: currentColor;
  -webkit-mask-image: url("./icons/mic.svg");
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-image: url("./icons/mic.svg");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.chat-microphone-button.voice-motion .voice-record-icon {
  transition:
    border-radius 110ms ease-out,
    height 110ms ease-out,
    transform 130ms ease-out,
    width 110ms ease-out;
}

.chat-icon-button.listening .voice-record-icon {
  width: 15px;
  height: 15px;
  border-radius: 5px;
  -webkit-mask-image: none;
  mask-image: none;
}

.chat-microphone-button.voice-motion.listening .voice-record-icon {
  transform: rotate(90deg) scale(0.92);
}

@media (prefers-reduced-motion: reduce) {
  .chat-microphone-button.voice-motion,
  .chat-microphone-button.voice-motion::before,
  .chat-microphone-button.voice-motion::after,
  .chat-microphone-button.voice-motion .voice-record-icon {
    transition: none;
  }
}

.send-icon {
  width: 19px;
  height: 19px;
  display: block;
  flex: 0 0 auto;
  line-height: 0;
  background: currentColor;
  -webkit-mask-image: url("./icons/send.svg");
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-image: url("./icons/send.svg");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}
