:root {
  --bg: #000;
  --surface: #1a1a20;
  --border: #2a2a32;
  --text: #e8e8ec;
  --muted: #8888a0;
  --accent: #9c7c5c;
  --accent-hover: #b08c6c;
  --danger: #e85d5d;
  --success: #5de88a;
}

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

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

header {
  margin-bottom: 2rem;
  text-align: center;
}

.phone-receiver {
  margin-bottom: 1rem;
  width: 100%;
}

.phone-receiver img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem 0;
}

.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

.card {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

#talk-section.card {
  padding-bottom: 0.75rem;
}

#talk-section.card:has(.transcript-reply:not([hidden])) {
  padding-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.card p {
  margin: 0 0 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  min-height: 44px;
  min-width: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  background: var(--border);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin: 0.75rem 0 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

#talk-section .status {
  margin-top: 1.5rem;
}

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

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

.transcript-reply {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.transcript-reply p {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.reply-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.reply-row strong {
  flex-shrink: 0;
}

.reply-row #reply {
  flex: 1;
  min-width: 0;
}

.replay-btn {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.replay-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.change-voice-wrap {
  margin: 1rem 0 0 0;
  text-align: right;
}

.change-voice-btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  min-height: unset;
  margin-top: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.change-voice-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.reply-audio-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Big "Click to talk" / "Send" area */
.talk-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  min-height: 140px;
  padding: 1.5rem;
  margin: 0;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  background: var(--border);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.talk-trigger:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.talk-trigger:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.talk-trigger.recording {
  background: rgba(156, 124, 92, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.talk-trigger.recording:hover {
  background: rgba(156, 124, 92, 0.22);
}

.talk-trigger-label {
  pointer-events: none;
}

.voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 48px;
}

.voice-wave-bar {
  width: 6px;
  min-height: 4px;
  border-radius: 3px;
  background: var(--accent);
  transition: height 0.05s ease-out;
}

@keyframes wave-idle {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

.voice-wave.connecting .voice-wave-bar {
  animation: wave-idle 1.2s ease-in-out infinite;
}

/* Mobile */
@media (max-width: 600px) {
  .container {
    padding: 1rem 0.75rem;
  }

  header {
    margin-bottom: 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
  }

  .card p {
    font-size: 0.875rem;
  }

  .talk-trigger {
    min-height: 120px;
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
  }

  .phone-receiver img {
    max-height: 220px;
  }

  .voice-wave {
    height: 44px;
  }

  .replay-btn {
    min-height: 44px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .change-voice-btn {
    min-height: unset;
    padding: 0.25rem 0.5rem;
  }

  .reply-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .reply-row #reply {
    width: 100%;
  }
}
