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

:root {
  --bg: #1f1108;
  --bg2: #241309;
  --surface: #2e1a0e;
  --surface2: #361f10;
  --accent: #e87d2e;
  --accent-glow: rgba(232, 125, 46, 0.35);
  --accent-light: #fb923c;
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.35);
  --yellow: #f59e0b;
  --text: #fff7ed;
  --text-muted: #9e6840;
  --radius: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Subtle radial glow in center */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 45%, rgba(232,125,46,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 28px 20px 36px;
  gap: 0;
  position: relative;
}

/* ── Header ── */
header {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 32px;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(232,125,46,0.4);
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Main layout ── */
main {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  flex: 1;
}

/* ── Mic area ── */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 0 20px;
  flex: 1;
  justify-content: center;
}

.mic-ring {
  position: relative;
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Outer glow ring — hidden by default */
.mic-ring::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.3s;
}

.mic-ring.recording::before {
  background: radial-gradient(circle, var(--red-glow) 0%, transparent 70%);
  animation: ring-pulse 1.4s ease-in-out infinite;
}

.mic-ring.processing::before {
  background: radial-gradient(circle, rgba(245,158,11,0.3) 0%, transparent 70%);
}

@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.12); opacity: 0.7; }
}

#record-btn {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 2px solid rgba(232,125,46,0.3);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  touch-action: none;
  position: relative;
}

#record-btn::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(232,125,46,0.15) 0%, transparent 60%);
  pointer-events: none;
}

#record-btn:hover:not(.recording):not(.processing) {
  border-color: rgba(232,125,46,0.6);
  box-shadow: 0 4px 28px rgba(0,0,0,0.4), 0 0 0 4px var(--accent-glow);
}

#record-btn.recording {
  background: #7f1d1d;
  border-color: var(--red);
  transform: scale(0.96);
  box-shadow: 0 0 0 6px var(--red-glow), inset 0 1px 0 rgba(255,255,255,0.05);
}

#record-btn.processing {
  background: #451a03;
  border-color: var(--yellow);
  box-shadow: 0 0 0 6px rgba(245,158,11,0.25);
  cursor: wait;
}

#record-btn svg {
  width: 52px;
  height: 52px;
  color: var(--text);
  pointer-events: none;
  transition: color 0.2s;
}

#record-btn.processing svg {
  color: var(--yellow);
  animation: spin-slow 2s linear infinite;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Status text ── */
#status-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.5em;
  transition: color 0.25s;
  font-weight: 500;
}

#status-text.recording  { color: #f87171; }
#status-text.processing { color: var(--yellow); }
#status-text.success    { color: var(--accent-light); }
#status-text.error      { color: #f87171; }

/* ── Result card ── */
.result-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: none;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
  animation: slide-up 0.2s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-card.visible { display: flex; }

.result-card.success {
  border-left: 3px solid var(--accent-light);
  border-color: rgba(251,146,60,0.3);
}
.result-card.error {
  border-left: 3px solid var(--red);
  border-color: rgba(239,68,68,0.25);
}

.result-message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.result-transcript {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}

/* ── History ── */
.history-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  background: var(--surface2);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.04);
  animation: slide-up 0.18s ease;
}

.history-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-item.ok .dot   { background: var(--accent-light); box-shadow: 0 0 6px var(--accent-light); }
.history-item.fail .dot { background: var(--red); box-shadow: 0 0 6px var(--red); }

.history-item .msg  { flex: 1; color: var(--text); line-height: 1.3; }
.history-item .time { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Responsive ── */
@media (min-width: 480px) {
  .mic-ring { width: 168px; height: 168px; }
  #record-btn { width: 150px; height: 150px; }
  #record-btn svg { width: 60px; height: 60px; }
}
