/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:           #080810;
  --surface:      #0f0f1a;
  --surface-2:    #161625;
  --border:       rgba(255,255,255,0.06);

  --violet:       #7c3aed;
  --violet-dim:   rgba(124,58,237,0.18);
  --violet-glow:  rgba(124,58,237,0.35);
  --violet-ring:  rgba(124,58,237,0.5);

  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.18);
  --red-glow:     rgba(239,68,68,0.4);
  --red-ring:     rgba(239,68,68,0.55);

  --amber:        #f59e0b;
  --amber-dim:    rgba(245,158,11,0.15);
  --amber-ring:   rgba(245,158,11,0.5);

  --text:         rgba(255,255,255,0.9);
  --text-mid:     rgba(255,255,255,0.45);
  --text-dim:     rgba(255,255,255,0.2);

  --font-display: 'Syne', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --orb-size: 180px;
  --orb-radius: calc(var(--orb-size) / 2);
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Noise texture overlay ─────────────────────────────────────────────── */
.noise-overlay {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── Radial glow (shifts on state) ─────────────────────────────────────── */
.radial-glow {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: background 0.8s ease;
  background: radial-gradient(ellipse 60% 45% at 50% 42%, var(--violet-dim) 0%, transparent 70%);
}
.radial-glow.recording {
  background: radial-gradient(ellipse 60% 45% at 50% 42%, var(--red-dim) 0%, transparent 70%);
}
.radial-glow.processing {
  background: radial-gradient(ellipse 60% 45% at 50% 42%, var(--amber-dim) 0%, transparent 70%);
}

/* ─── Reload overlay ────────────────────────────────────────────────────────── */
.reload-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.reload-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.reload-spinner {
  width: 48px; height: 48px;
  animation: spin 1s linear infinite;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 28px 24px 0;
}

.logo-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.logo-btn:active { opacity: 0.4; }

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.app-logo {
  width: 40vw;
  max-width: 180px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--violet);
  opacity: 0.6;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.recording {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: dot-blink 1s ease-in-out infinite;
}
.status-dot.processing {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ─── Main layout ───────────────────────────────────────────────────────── */
.app-main {
  position: relative; z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 32px;
  gap: 0;
}

/* ─── Orb zone ──────────────────────────────────────────────────────────── */
.orb-zone {
  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 64px;
  flex-shrink: 0;
}

/* ─── Pulse rings (idle) ────────────────────────────────────────────────── */
.pulse-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--violet-ring);
  opacity: 0;
  pointer-events: none;
  transition: border-color 0.5s;
}

.idle .pulse-ring { animation-play-state: running; }
.recording .pulse-ring,
.processing .pulse-ring { animation-play-state: paused; opacity: 0; }

.ring-1 { width: 220px; height: 220px; animation: pulse-expand 2.5s ease-out 0s infinite; }
.ring-2 { width: 260px; height: 260px; animation: pulse-expand 2.5s ease-out 0.7s infinite; }
.ring-3 { width: 300px; height: 300px; animation: pulse-expand 2.5s ease-out 1.4s infinite; }

.recording .ring-1,
.recording .ring-2,
.recording .ring-3 {
  border-color: var(--red-ring);
  animation: pulse-expand-red 2.5s ease-out infinite;
}

@keyframes pulse-expand {
  0%   { transform: scale(0.85); opacity: 0.5; }
  100% { transform: scale(1.2);  opacity: 0; }
}
@keyframes pulse-expand-red {
  0%   { transform: scale(0.9); opacity: 0.4; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ─── Spinner SVG (processing) ──────────────────────────────────────────── */
.spinner-svg {
  position: absolute;
  width: calc(var(--orb-size) + 20px);
  height: calc(var(--orb-size) + 20px);
  top: -10px; left: -10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.spinner-track { stroke: rgba(255,255,255,0.05); }
.spinner-arc   { stroke: var(--amber); }

.processing .spinner-svg {
  opacity: 1;
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  from { transform: rotate(-90deg); transform-origin: center; }
  to   { transform: rotate(270deg); transform-origin: center; }
}

/* ─── Record button ─────────────────────────────────────────────────────── */
.record-btn {
  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  border-radius: 50%;
  border: 2px solid var(--violet-ring);
  background: var(--violet-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.5s ease,
    border-color 0.5s ease,
    box-shadow 0.5s ease;
  box-shadow:
    0 0 40px rgba(124,58,237,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
  -webkit-user-select: none; user-select: none;
  outline: none;
  overflow: hidden;
}

.record-btn:active {
  transform: scale(0.92);
}

/* Idle (default) */
.idle .record-btn {
  border-color: var(--violet-ring);
  background: var(--violet-dim);
  box-shadow:
    0 0 40px rgba(124,58,237,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Recording */
.recording .record-btn {
  border-color: var(--red-ring);
  background: var(--red-dim);
  transform: scale(1.05);
  box-shadow:
    0 0 60px var(--red-glow),
    0 0 120px rgba(239,68,68,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Processing */
.processing .record-btn {
  border-color: var(--amber-ring);
  background: var(--amber-dim);
  box-shadow:
    0 0 40px rgba(245,158,11,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
  cursor: not-allowed;
}

/* ─── Mic icon ──────────────────────────────────────────────────────────── */
.mic-icon {
  width: 40px; height: 40px;
  color: rgba(255,255,255,0.85);
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: absolute;
  flex-shrink: 0;
}

.idle .mic-icon      { opacity: 1; transform: scale(1); }
.recording .mic-icon { opacity: 0; transform: scale(0.6); }
.processing .mic-icon {
  opacity: 0.3;
  transform: scale(0.9);
}

/* ─── Equalizer bars (recording) ────────────────────────────────────────── */
.eq-bars {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 50px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.recording .eq-bars { opacity: 1; }

.eq-bar {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  transform-origin: bottom center;
}

.bar-1 { height: 18px; animation: eq 0.8s ease-in-out 0.0s infinite alternate; }
.bar-2 { height: 32px; animation: eq 0.6s ease-in-out 0.1s infinite alternate; }
.bar-3 { height: 44px; animation: eq 0.7s ease-in-out 0.2s infinite alternate; }
.bar-4 { height: 28px; animation: eq 0.9s ease-in-out 0.05s infinite alternate; }
.bar-5 { height: 14px; animation: eq 0.5s ease-in-out 0.3s infinite alternate; }

@keyframes eq {
  from { transform: scaleY(0.25); }
  to   { transform: scaleY(1); }
}

/* Pause animations when not recording */
.idle .eq-bar,
.processing .eq-bar { animation-play-state: paused; }

/* ─── Timer ─────────────────────────────────────────────────────────────── */
.rec-timer {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--red);
  margin-top: 28px;
  opacity: 0;
  transition: opacity 0.3s ease;
  height: 20px;
}
.recording .rec-timer { opacity: 1; }

/* ─── State label ───────────────────────────────────────────────────────── */
.state-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-mid);
  margin-top: 12px;
  text-align: center;
  transition: opacity 0.3s ease;
  min-height: 18px;
}

/* ─── Transcriptions section ────────────────────────────────────────────── */
.transcriptions-section {
  width: 100%;
  max-width: 420px;
  margin-top: 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.empty-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 300;
  color: var(--text-dim);
  text-align: center;
  margin-top: 48px;
  letter-spacing: 0.06em;
}
.empty-hint.hidden { display: none; }

.transcriptions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Transcription card ────────────────────────────────────────────────── */
.t-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  animation: card-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.t-card-text {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
  padding-right: 28px;
}

.t-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.t-card-time,
.t-card-lang {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.t-card-lang {
  text-transform: uppercase;
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.t-card-delete {
  position: absolute;
  top: 10px; right: 10px;
  width: 22px; height: 22px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.t-card-delete:hover,
.t-card-delete:active {
  color: var(--red);
  background: rgba(239,68,68,0.1);
}

/* ─── State wrapper on <body> ───────────────────────────────────────────── */
body.idle      { }
body.recording { }
body.processing { }

/* ─── Splash / install banner (iOS) ─────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mid);
  letter-spacing: 0.05em;
  text-align: center;
  width: max-content;
  max-width: 280px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: banner-in 0.4s 1.5s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
