:root {
  --bg: #111111;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --muted: #8a8a8a;
  --accent: #4a9eff;
  --accent-hover: #6bb0ff;
  --error: #ff5a5a;
  --bubble-customer: #2a3a5c;
  --bubble-agent: #2c2c2c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.mouth-wrap {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
}

.mouth {
  width: 64%;
  height: 64%;
  object-fit: contain;
  transition: opacity 40ms linear;
  user-select: none;
  -webkit-user-drag: none;
}

.speech {
  min-height: 96px;
  width: 100%;
  line-height: 1.5;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  word-break: break-word;
  white-space: pre-wrap;
}

.speech .cursor {
  display: inline-block;
  width: 8px;
  margin-left: 1px;
  animation: blink 1s steps(1) infinite;
  color: var(--accent);
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 80ms ease;
}

.btn:hover {
  background: #2c2c2c;
  border-color: #3a3a3a;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  text-align: center;
}

.status.error {
  color: var(--error);
}

/* Chat section */
.chat-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-messages {
  width: 100%;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  scroll-behavior: smooth;
}

.chat-messages:empty::before {
  content: "No messages yet. Say hi!";
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  animation: bubbleIn 200ms ease;
}

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

.chat-bubble.customer {
  align-self: flex-end;
  background: var(--bubble-customer);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.agent {
  align-self: flex-start;
  background: var(--bubble-agent);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble .time {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

.chat-form {
  display: flex;
  gap: 8px;
  width: 100%;
}

.chat-input {
  flex: 1;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 160ms ease;
}

.chat-input:focus {
  border-color: var(--accent);
}

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

.chat-send {
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, transform 80ms ease;
  white-space: nowrap;
}

.chat-send:hover {
  background: var(--accent-hover);
}

.chat-send:active {
  transform: scale(0.96);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (min-width: 480px) {
  .buttons {
    flex-direction: row;
  }
  .btn {
    flex: 1;
  }
}
