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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3348;
  --text: #e8eaf0;
  --text-muted: #8b90a5;
  --accent: #4f8cff;
  --accent-glow: rgba(79, 140, 255, 0.35);
  --success: #3ecf8e;
  --recording: #ff4f6a;
  --recording-glow: rgba(255, 79, 106, 0.4);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

header {
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.brand-logo {
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.brand-text {
  text-align: left;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Call panel */
.call-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  position: relative;
}

.status {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  min-height: 1.25em;
}

.status.processing { color: var(--accent); }
.status.recording { color: var(--recording); }
.status.ready { color: var(--success); }

.mic-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  z-index: 2;
}

.mic-btn:not(:disabled):hover {
  background: var(--border);
  transform: scale(1.04);
}

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

.mic-btn.on-call {
  background: var(--success);
  box-shadow: 0 0 0 8px rgba(62, 207, 142, 0.25);
}

.mic-btn.on-call.recording {
  background: var(--recording);
  box-shadow: 0 0 0 8px var(--recording-glow);
  animation: pulse-btn 1.5s ease-in-out infinite;
}

.mic-btn.speaking {
  background: var(--accent);
  box-shadow: 0 0 0 8px var(--accent-glow);
}

.mic-icon {
  width: 36px;
  height: 36px;
}

.mic-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  position: absolute;
  bottom: -28px;
  white-space: nowrap;
}

.pulse-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--recording);
  animation: ring-pulse 1.2s ease-out infinite;
  z-index: 1;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 8px var(--recording-glow); }
  50% { box-shadow: 0 0 0 16px transparent; }
}

@keyframes ring-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Messages */
.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.msg {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 90%;
}

.msg.user {
  background: var(--surface2);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.msg.agent {
  background: #1e2d4a;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.msg .role {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Extracted fields */
.fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 3px solid var(--border);
  transition: border-color 0.3s;
}

.field.filled {
  border-left-color: var(--success);
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.field-value {
  font-size: 0.9rem;
  text-align: right;
  word-break: break-word;
}

/* Summary */
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.summary-header h2 {
  margin-bottom: 0;
}

.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.copy-btn:hover { opacity: 0.85; }
.copy-btn.copied { background: var(--success); }

.summary-text {
  background: var(--surface2);
  border-radius: 8px;
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: inherit;
  color: var(--text);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 8px;
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

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

@media (max-width: 480px) {
  .field {
    flex-direction: column;
    gap: 4px;
  }
  .field-value { text-align: left; }
}
