:root {
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --secondary: #334155;
  --secondary-hover: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --success: #10b981;
  --recording: #ef4444;
  --idle: #64748b;
  --radius: 16px;
  --shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  color: var(--text);
  background: radial-gradient(
      circle at 20% 0%,
      rgba(239, 68, 68, 0.15),
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 100%,
      rgba(59, 130, 246, 0.12),
      transparent 40%
    ),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 3vw, 2rem);
  min-height: 100vh;
}

.header {
  text-align: center;
}

.title {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-icon {
  display: inline-flex;
  width: clamp(1.5rem, 4vw, 2rem);
  height: clamp(1.5rem, 4vw, 2rem);
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.title-icon svg {
  width: 100%;
  height: 100%;
}

.subtitle {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--idle);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.status-dot[data-status="recording"] {
  background: var(--recording);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.transcript-wrap {
  position: relative;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  min-height: 180px;
  max-height: 50vh;
  overflow-y: auto;
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  line-height: 1.7;
}

.transcript-wrap::-webkit-scrollbar {
  width: 8px;
}

.transcript-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.transcript-wrap::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}

.message {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.placeholder {
  position: absolute;
  inset: 1rem 1.1rem;
  margin: 0;
  color: var(--text-muted);
  pointer-events: none;
  font-style: italic;
  transition: opacity 0.2s ease;
}

.transcript-wrap.has-content .placeholder {
  opacity: 0;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  transition: background 0.18s ease, transform 0.08s ease,
    box-shadow 0.18s ease;
  min-height: 44px;
  flex: 1 1 140px;
}

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

.control:focus-visible {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
}

.control:active {
  transform: scale(0.97);
}

.control.pause {
  background: #2563eb;
}

.control.pause:hover {
  background: #1d4ed8;
}

.control.pause:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

.control.secondary {
  background: var(--secondary);
  flex: 0 0 auto;
}

.control.secondary:hover {
  background: var(--secondary-hover);
}

.control.secondary:focus-visible {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.4);
}

.control:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.control.record.is-recording,
.control.pause {
  position: relative;
}

.control.pause .btn-icon::after {
  content: "";
  position: absolute;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.5);
}

@media (max-width: 480px) {
  .actions {
    flex-direction: column;
  }

  .control,
  .control.secondary {
    flex: 1 1 auto;
    width: 100%;
  }

  .card-header {
    flex-direction: row;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot[data-status="recording"] {
    animation: none;
  }

  .control,
  .toast,
  .placeholder {
    transition: none;
  }
}
