:root {
  --ink: #081b14;
  --forest: #0e3327;
  --moss: #1c5c41;
  --sand: #e9e2ce;
  --gold: #c8a24d;
  --ember: #cc1e00;

  --font-display: "Reem Kufi", "Segoe UI", sans-serif;
  --font-ui: "IBM Plex Sans Arabic", "Tahoma", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--ink);
  color: var(--sand);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  height: 10px;
  background: repeating-linear-gradient(
    -45deg,
    var(--moss) 0 6px,
    transparent 6px 12px
  );
  opacity: 0.4;
  z-index: 0;
}

body::before {
  top: 0;
}

body::after {
  bottom: 0;
}

#app {
  width: 100%;
  max-width: 640px;
  padding: 48px 28px;
  position: relative;
  z-index: 1;
}

.screen {
  position: relative;
  background: var(--forest);
  border-radius: 28px 4px 28px 4px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
  animation: rise 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

.screen[hidden] {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Home screen ---------- */

.logo {
  display: block;
  width: 55%;
  max-width: 220px;
  height: auto;
  margin: 0 auto 32px;
  border-radius: 6px;
}

.headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.5;
  margin: 0 0 36px;
  color: var(--sand);
}

.home-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 0.95rem;
  color: rgba(233, 226, 206, 0.75);
}

input[type="email"] {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  padding: 12px 4px;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(233, 226, 206, 0.3);
  color: var(--sand);
  transition: border-color 200ms ease;
  direction: ltr;
  text-align: left;
}

input[type="email"]:focus {
  outline: none;
  border-bottom-color: var(--gold);
}

input[type="email"]::placeholder {
  color: rgba(233, 226, 206, 0.35);
}

.error {
  margin: 0;
  color: var(--ember);
  background: rgba(138, 51, 36, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: bold;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 16px 24px;
  border: none;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}

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

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--gold);
  color: var(--ink);
  border-radius: 999px 8px 999px 8px;
}

.btn-ghost {
  background: rgba(233, 226, 206, 0.08);
  color: var(--sand);
  border-radius: 14px;
  flex: 1 1 140px;
  font-size: 0.95rem;
  padding: 14px 16px;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(233, 226, 206, 0.16);
}

.btn-danger {
  color: #e8b8ac;
}

/* ---------- Recording screen ---------- */

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--forest);
  border-radius: inherit;
  z-index: 5;
}

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

.countdown-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.5rem, 18vw, 6rem);
  color: var(--gold);
}

.countdown-number.pulse {
  animation: countdown-pulse 800ms ease-out;
}

@keyframes countdown-pulse {
  0% {
    opacity: 0;
    transform: scale(1.4);
  }
  30%, 80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

.progress-track {
  height: 3px;
  background: rgba(233, 226, 206, 0.15);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 200ms linear;
}

.equalizer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin-bottom: 8px;
}

.equalizer span {
  width: 6px;
  height: 16px;
  border-radius: 3px;
  background: var(--gold);
  animation: pulse 900ms ease-in-out infinite;
}

.equalizer span:nth-child(1) { animation-delay: 0ms; }
.equalizer span:nth-child(2) { animation-delay: 120ms; }
.equalizer span:nth-child(3) { animation-delay: 240ms; }
.equalizer span:nth-child(4) { animation-delay: 360ms; }
.equalizer span:nth-child(5) { animation-delay: 480ms; }

.equalizer.is-paused span {
  animation-play-state: paused;
  height: 6px;
}

@keyframes pulse {
  0%, 100% { height: 10px; }
  50% { height: 38px; }
}

.lyric-stage {
  min-height: 8.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  margin-bottom: 40px;
}

.lyric-line {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  line-height: 1.6;
  margin: 0;
  color: var(--gold);
  transition: opacity 260ms ease, transform 260ms ease;
}

.lyric-line.is-leaving {
  opacity: 0;
  transform: translateY(-14px);
}

.lyric-line.is-entering {
  animation: breathe-in 500ms ease both;
}

@keyframes breathe-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Submit screen ---------- */

.ring {
  width: 64px;
  height: 64px;
  margin: 0 auto 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 1.6rem;
  font-weight: 600;
}

.ring.is-loading {
  border: 3px solid rgba(233, 226, 206, 0.2);
  border-top-color: var(--gold);
  animation: spin 900ms linear infinite;
}

.ring.is-success {
  border: 3px solid var(--gold);
  color: var(--gold);
}

.ring.is-success::after {
  content: "✓";
}

.ring.is-error {
  border: 3px solid var(--ember);
  color: var(--ember);
}

.ring.is-error::after {
  content: "!";
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.submit-status {
  font-size: 1.15rem;
  line-height: 1.7;
  margin: 0 0 28px;
  color: var(--sand);
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  #app {
    padding: 24px 16px;
  }

  .screen {
    padding: 32px 20px;
  }

  .controls {
    flex-direction: column;
  }

  .btn-ghost {
    flex: 1 1 auto;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .screen,
  .lyric-line.is-entering,
  .equalizer span,
  .ring.is-loading,
  .countdown-number.pulse {
    animation: none !important;
  }

  .lyric-line {
    transition: none;
  }
}
