/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #0f1117;
  --bg-card:       #1a1d27;
  --bg-card-hover: #1f2334;
  --border:        #2a2d3e;
  --border-focus:  #6366f1;
  --text:          #e8eaf0;
  --text-muted:    #6b7280;
  --text-dim:      #9ca3af;
  --accent:        #6366f1;
  --accent-hover:  #4f52d9;
  --accent-glow:   rgba(99, 102, 241, 0.35);
  --red:           #ef4444;
  --red-glow:      rgba(239, 68, 68, 0.4);
  --green:         #10b981;
  --green-hover:   #059669;
  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     20px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.55);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #1a1d27 0%, #12111e 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon { font-size: 1.75rem; }

.logo-text {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ── Main container ──────────────────────────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.card:hover { border-color: #3a3d52; }

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Record section ──────────────────────────────────────────────────────── */
.record-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.record-btn-wrap {
  position: relative;
  flex-shrink: 0;
}

.record-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.3s;
}

.record-ring.active {
  border-color: var(--red);
  animation: spin-ring 2s linear infinite;
  box-shadow: 0 0 20px var(--red-glow);
}

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

.btn-record-main {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 0 0 0 var(--accent-glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 1;
}

.btn-record-main:hover:not(:disabled) {
  transform: scale(1.07);
  box-shadow: 0 0 28px var(--accent-glow);
}

.btn-record-main:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-record-main.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  animation: record-pulse 1.4s ease-in-out infinite;
}

.btn-record-main.paused {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  animation: none;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.record-icon {
  font-size: 2rem;
  color: #fff;
  line-height: 1;
  display: block;
}

.btn-record-main.recording .record-icon {
  font-size: 1.3rem; /* square stop shape while recording */
}

@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--red-glow); }
  50%       { box-shadow: 0 0 0 14px transparent; }
}

.record-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.status-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-dim);
  min-height: 1.4em;
  transition: color 0.2s;
}

.status-text.active  { color: #a5b4fc; }
.status-text.error   { color: #f87171; }
.status-text.success { color: var(--green); }
.status-text.paused  { color: #fbbf24; }

/* ── Waveform animation ──────────────────────────────────────────────────── */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}

.waveform.active { opacity: 1; }

.waveform span {
  display: block;
  width: 4px;
  background: linear-gradient(to top, #6366f1, #a5b4fc);
  border-radius: 4px;
  height: 8px;
  animation: wave-bar 1.1s ease-in-out infinite;
}

.waveform span:nth-child(1)  { animation-delay: 0.0s; }
.waveform span:nth-child(2)  { animation-delay: 0.1s; }
.waveform span:nth-child(3)  { animation-delay: 0.2s; }
.waveform span:nth-child(4)  { animation-delay: 0.3s; }
.waveform span:nth-child(5)  { animation-delay: 0.15s; }
.waveform span:nth-child(6)  { animation-delay: 0.25s; }
.waveform span:nth-child(7)  { animation-delay: 0.05s; }
.waveform span:nth-child(8)  { animation-delay: 0.35s; }
.waveform span:nth-child(9)  { animation-delay: 0.18s; }
.waveform span:nth-child(10) { animation-delay: 0.08s; }

@keyframes wave-bar {
  0%, 100% { height: 6px; }
  50%       { height: 24px; }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }
.btn:not(:disabled):active { transform: scale(0.97); }

.btn-stop {
  background: #2a1f1f;
  color: #f87171;
  border: 1px solid #4a2020;
  align-self: flex-start;
}

.btn-stop:not(:disabled):hover {
  background: #3a2020;
  border-color: var(--red);
}

.btn-copy {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  box-shadow: 0 2px 12px rgba(16,185,129,0.3);
}

.btn-copy:not(:disabled):hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 18px rgba(16,185,129,0.45);
}

/* ── Textareas ───────────────────────────────────────────────────────────── */
.fancy-textarea {
  width: 100%;
  background: #12141f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-family: inherit;
  font-size: 0.975rem;
  line-height: 1.75;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 200px;
}

.fancy-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.fancy-textarea::placeholder { color: #3d4060; }

.fancy-textarea--output {
  background: #0d0f1a;
  color: #c7d2fe;
  cursor: default;
  border-color: #2a2d52;
}

/* ── Presets ─────────────────────────────────────────────────────────────── */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-preset {
  background: #12141f;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-preset:not(:disabled):hover {
  background: #1e2035;
  border-color: #6366f1;
  color: #a5b4fc;
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-preset:not(:disabled):active { transform: scale(0.96); }

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

.btn-preset.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border-color: #6366f1;
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.loading-presets {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Copy bar ────────────────────────────────────────────────────────────── */
.copy-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 2rem;
  color: #3d4060;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

/* ── Refined section fade-in ─────────────────────────────────────────────── */
.refined-section {
  animation: fade-up 0.4s ease;
}

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

/* ── Auth overlay ────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-up 0.3s ease;
}

.auth-overlay[hidden] { display: none; }

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.75rem;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.auth-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 0.5rem;
}

.auth-input {
  width: 100%;
  background: #12141f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-btn {
  width: 100%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  justify-content: center;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.auth-btn:not(:disabled):hover {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.auth-error {
  font-size: 0.875rem;
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
}

/* Logout button in header */
.btn-logout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}

.btn-logout:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: #3a3d52;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .record-controls { flex-direction: column; align-items: flex-start; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .card { padding: 1.25rem; }
}
