/* ═══════════════════════════════════════════════════
   QRecite — Design System
   Aesthetic: Sacred Digital — dark luxury + Islamic geometry
   ═══════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  --bg-base:     #080A12;
  --bg-surface:  #0E1019;
  --bg-elevated: #14172A;
  --bg-card:     #181B2E;
  --bg-input:    #1E2138;

  --gold:        #C8973A;
  --gold-light:  #E4B85A;
  --gold-dim:    #7A5B22;
  --gold-glow:   rgba(200, 151, 58, 0.18);

  --teal:        #2D7D6E;
  --teal-light:  #3FAF99;

  --green:       #4ADE80;
  --red:         #F87171;

  --text-primary:   #EDE8DC;
  --text-secondary: #8E96A8;
  --text-muted:     #4A5168;

  --border:       rgba(200, 151, 58, 0.12);
  --border-hover: rgba(200, 151, 58, 0.38);
  --border-focus: rgba(200, 151, 58, 0.7);

  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-sm:   0 2px 8px rgba(0,0,0,0.4);
  --shadow:      0 4px 24px rgba(0,0,0,0.6);
  --shadow-gold: 0 0 36px rgba(200, 151, 58, 0.14);
  --shadow-up:   0 -4px 24px rgba(0,0,0,0.5);

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'DM Sans', system-ui, sans-serif;
  --font-arabic:  'NotoNaskhArabic', 'Amiri', 'Traditional Arabic', serif;

  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t:  200ms;
  --ts: 380ms;
}

/* ─── Arabic Fonts ─── */
@font-face {
  font-family: 'ManzoorNaskh';
  src: url('/fonts/ManzoorNaskh.ttf') format('truetype');
  font-display: swap;
}

/* Font variant classes */
.font-noto { --font-arabic: 'NotoNaskhArabic', 'Amiri', 'Traditional Arabic', serif; }
.font-manzoor { --font-arabic: 'ManzoorNaskh', 'Amiri', 'Traditional Arabic', serif; }

/* Default is Noto */
:root { --font-arabic: 'NotoNaskhArabic', 'Amiri', 'Traditional Arabic', serif; }

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Atmospheric Background ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 50% at 15% 10%, rgba(200, 151, 58, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 90%, rgba(45, 125, 110, 0.06) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg width='64' height='64' viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C8973A' fill-opacity='0.028'%3E%3Cpath d='M32 0l4 4-4 4-4-4zM0 32l4-4 4 4-4 4zM64 32l-4 4-4-4 4-4zM32 64l-4-4 4-4 4 4zM32 16l8 8-8 8-8-8zM16 32l8-8 8 8-8 8zM48 32l-8 8-8-8 8-8z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── App Shell ─── */
#app { position: relative; z-index: 1; }

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
.app-header {
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo-lockup {
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}

.logo-name {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: linear-gradient(140deg, var(--gold-light) 0%, var(--gold) 55%, var(--gold-dim) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.logo-tagline {
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  color: var(--text-secondary);
  direction: rtl;
  line-height: 1;
}

/* ─── Breadcrumb ─── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.breadcrumb-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  min-height: auto;
  transition: opacity var(--t) var(--ease-out);
}
.breadcrumb-btn:hover { opacity: 0.75; }

.breadcrumb-sep { color: var(--text-muted); }

/* ─── Font Toggle ─── */
.font-toggle {
  background: rgba(200, 151, 58, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--t) var(--ease-out),
    border-color var(--t) var(--ease-out),
    color var(--t) var(--ease-out);
  white-space: nowrap;
}

.font-toggle:hover {
  background: rgba(200, 151, 58, 0.15);
  border-color: var(--border-hover);
  color: var(--gold-light);
}

.font-toggle:active {
  transform: scale(0.98);
}

.font-toggle-label {
  display: inline-block;
  font-weight: 600;
}

/* ─── View Headers ─── */
.view-header { margin-bottom: 2rem; }

.view-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 300;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}
.view-title em {
  color: var(--gold);
  font-style: italic;
}

.view-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* ─── Reciter Grid — V1 ─── */
.reciter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.125rem;
  padding-bottom: 3rem;
}

.reciter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--t) var(--ease-out),
    box-shadow   var(--t) var(--ease-out),
    transform    var(--t) var(--ease-out);
}

/* Gold shimmer reveal */
.reciter-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    125deg,
    rgba(200, 151, 58, 0.07) 0%,
    rgba(200, 151, 58, 0.0)  50%,
    rgba(200, 151, 58, 0.04) 100%
  );
  opacity: 0;
  transition: opacity var(--t) var(--ease-out);
  pointer-events: none;
}

.reciter-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-gold);
  transform: translateY(-3px);
}
.reciter-card:hover::after { opacity: 1; }
.reciter-card:active { transform: translateY(-1px); }

.card-name-en {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.card-name-ar {
  font-family: var(--font-arabic);
  font-size: 1.05rem;
  color: var(--text-secondary);
  direction: rtl;
  text-align: right;
  margin-bottom: 1rem;
}

.style-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  background: rgba(200, 151, 58, 0.07);
  border: 1px solid rgba(200, 151, 58, 0.18);
  border-radius: 100px;
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.02em;
}

/* ─── Loading Skeletons ─── */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.125rem;
}

.skeleton-card {
  height: 160px;
  background: linear-gradient(
    90deg,
    var(--bg-card)     25%,
    var(--bg-elevated) 50%,
    var(--bg-card)     75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Search Bar ─── */
.search-wrap {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 1rem;
  height: 1rem;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--t) var(--ease-out), box-shadow var(--t) var(--ease-out);
  -webkit-appearance: none;
  min-height: 48px;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(200, 151, 58, 0.1);
}

/* ─── Surah List — V2 ─── */
.surah-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.surah-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-bottom: 3rem;
}

.surah-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.125rem;
  cursor: pointer;
  transition:
    border-color var(--t) var(--ease-out),
    background   var(--t) var(--ease-out),
    transform    var(--t) var(--ease-out);
}
.surah-row:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  transform: translateX(3px);
}

.surah-num {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 151, 58, 0.07);
  border: 1px solid rgba(200, 151, 58, 0.14);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--gold);
  flex-shrink: 0;
}

.surah-info { min-width: 0; }

.surah-en {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.surah-meaning {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.surah-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.surah-ar {
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.surah-ayahs {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ─── Ayah Picker — V3 ─── */
.reciter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem 0.3rem 0.5rem;
  background: rgba(200, 151, 58, 0.07);
  border: 1px solid rgba(200, 151, 58, 0.18);
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.v3-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding-bottom: 3rem;
}

@media (min-width: 680px) {
  .v3-grid {
    grid-template-columns: 1fr 1fr;
  }
  .v3-span { grid-column: 1 / -1; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem 1.5rem;
}

.panel-title {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1.1rem;
  font-weight: 500;
}

/* Range controls */
.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.range-lbl {
  font-size: 0.78rem;
  color: var(--text-secondary);
  width: 2rem;
  flex-shrink: 0;
}

.ayah-select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 2rem 0.625rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--t) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23C8973A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  min-height: 44px;
}
.ayah-select:focus { border-color: var(--border-focus); }
.ayah-select option { background: var(--bg-elevated); color: var(--text-primary); }

.range-info {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.range-info strong { color: var(--gold); font-weight: 500; }

/* Audio player */
.audio-wrap {
  margin-top: 1rem;
}

.audio-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.audio-wrap audio {
  width: 100%;
  height: 38px;
  border-radius: var(--radius-sm);
  accent-color: var(--gold);
}

/* Ayah text panel */
.ayah-text-container {
  direction: rtl;
  text-align: right;
}

.ayah-verse {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.ayah-verse:first-child { padding-top: 0; }
.ayah-verse:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.verse-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  direction: rtl;
}

.ayah-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.25rem;
  background: rgba(200, 151, 58, 0.09);
  border: 1px solid rgba(200, 151, 58, 0.18);
  border-radius: 50%;
  font-size: 0.65rem;
  color: var(--gold);
  font-family: var(--font-ui);
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.ayah-text {
  font-family: var(--font-arabic);
  font-size: 1.45rem;
  line-height: 2.1;
  color: var(--text-primary);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  direction: ltr;
}

.ayah-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  direction: ltr;
  animation: pulse 1.8s ease-in-out infinite;
}

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.9rem 2rem;
  background: linear-gradient(140deg, var(--gold-light) 0%, var(--gold) 55%, #9F6B1E 100%);
  border: none;
  border-radius: var(--radius);
  color: #080A12;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    opacity   var(--t) var(--ease-out),
    transform var(--t) var(--ease-out),
    box-shadow var(--t) var(--ease-out);
  min-height: 50px;
}
.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(200, 151, 58, 0.28);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
  min-height: 44px;
}
.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ─── View Transitions ─── */
.fade-enter-active {
  animation: fadeSlideIn 280ms var(--ease-out);
}
.fade-leave-active {
  animation: fadeSlideOut 180ms var(--ease-out);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ═══════════════════════════════════════════════════
   V4 — PRACTICE VIEW
   ═══════════════════════════════════════════════════ */

.practice-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 3rem;
  max-width: 640px;
  margin: 0 auto;
}

/* Sticky reference audio bar */
.ref-audio-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.ref-audio-bar audio {
  width: 100%;
  height: 36px;
  accent-color: var(--gold);
}

/* Live pitch visualization panel */
.live-pitch-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  animation: fadeIn 300ms var(--ease-out);
}

.live-chart-container {
  position: relative;
  height: 200px;
  margin-top: 0.75rem;
}

.live-chart-container canvas {
  width: 100% !important;
  max-height: 200px;
}

.live-pitch-info {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

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

/* Reference pitch controls */
.ref-pitch-control {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.ref-pitch-loaded {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ref-pitch-status {
  font-size: 0.8rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Record button centrepiece */
.record-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem 0;
}

.record-btn {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: rgba(200, 151, 58, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  transition:
    background var(--t) var(--ease-out),
    border-color var(--t) var(--ease-out),
    transform var(--t) var(--ease-out),
    box-shadow var(--t) var(--ease-out);
}

.record-btn:hover {
  background: rgba(200, 151, 58, 0.14);
  box-shadow: 0 0 40px rgba(200, 151, 58, 0.2);
  transform: scale(1.05);
}
.record-btn:active { transform: scale(0.98); }

/* Recording active state */
.record-btn.is-recording {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  box-shadow: 0 0 48px rgba(248, 113, 113, 0.2);
}

/* Pulsing ring when recording */
.record-btn.is-recording::before {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: recordPulse 1.6s ease-out infinite;
}

@keyframes recordPulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.record-btn svg { width: 28px; height: 28px; }

.record-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
}

.record-timer {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--red);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

/* Divider */
.or-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* File upload drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(200, 151, 58, 0.04);
}

.drop-zone-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}
.drop-zone-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Audio preview after recording */
.audio-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.audio-preview audio {
  width: 100%;
  height: 36px;
  accent-color: var(--gold);
}
.preview-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Mic permission error */
.mic-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--red);
  font-size: 0.82rem;
}

/* Comparing spinner */
.comparing-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.comparing-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* V4 action bar */
.v4-actions {
  display: flex;
  gap: 0.75rem;
}
.v4-actions .btn-primary { flex: 1; }
.v4-actions .btn-ghost { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════
   V5 — RESULTS VIEW
   ═══════════════════════════════════════════════════ */

.results-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 3rem;
  max-width: 720px;
  margin: 0 auto;
}

/* Tier badge hero */
.tier-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1rem;
  position: relative;
}

.tier-badge {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.tier-score {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.tier-score-pct {
  font-size: 1.2rem;
  opacity: 0.6;
}

.tier-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Glow behind tier badge */
.tier-hero::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  filter: blur(60px);
  opacity: 0.15;
  pointer-events: none;
}

/* Audio panels (side-by-side) */
.audio-panels {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.audio-panels > .panel {
  min-width: 280px;
}

@media (max-width: 600px) {
  .audio-panels {
    flex-direction: column;
  }
  .audio-panels > .panel {
    min-width: 100%;
  }
}

/* Chart panel */
.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

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

.chart-mode-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem;
}

.chart-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: calc(var(--radius-sm) - 2px);
  padding: 0.32rem 0.6rem;
  min-height: auto;
  cursor: pointer;
  transition: color var(--t) var(--ease-out), background-color var(--t) var(--ease-out);
}

.chart-mode-btn:hover {
  color: var(--text-primary);
}

.chart-mode-btn.active {
  background: rgba(200, 151, 58, 0.2);
  color: var(--gold-light);
}

.chart-panel canvas {
  width: 100% !important;
  max-height: 300px;
}

/* Match proportion bar */
.match-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.match-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
}

.match-bar-good {
  height: 100%;
  background: var(--green);
  border-radius: 4px 0 0 4px;
  transition: width 600ms var(--ease-out);
}

.match-bar-bad {
  height: 100%;
  background: var(--red);
  transition: width 600ms var(--ease-out);
}

.match-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Raw scores expandable */
.raw-scores-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color var(--t);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: auto;
}
.raw-scores-toggle:hover { color: var(--text-primary); }

.raw-scores-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.raw-score-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  text-align: center;
}

.raw-score-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.raw-score-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Results action buttons */
.results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.results-actions > * { flex: 1; min-width: 120px; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* iOS bottom safe area */
.safe-bottom { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }

/* Prevent iOS font bump on focus */
input, select, textarea { font-size: 16px; }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .app-header {
    padding: 1.25rem 0 1rem;
    margin-bottom: 1.5rem;
  }
  .reciter-grid {
    grid-template-columns: 1fr;
  }
  .surah-row {
    padding: 0.7rem 0.875rem;
    gap: 0.75rem;
  }
  .raw-scores-grid {
    grid-template-columns: 1fr;
  }
  .tier-score {
    font-size: 2.8rem;
  }
  .record-btn {
    width: 100px;
    height: 100px;
  }
  .v4-actions {
    flex-direction: column;
  }
  .v4-actions .btn-ghost {
    width: 100%;
  }
  .results-actions {
    flex-direction: column;
  }
}

/* ─── Pulse animation ─── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Focus-visible outline for keyboard nav ─── */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Hide outline for mouse clicks */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Touch action hints for mobile ─── */
@media (pointer: coarse) {
  .record-btn {
    width: 100px;
    height: 100px;
  }
  .surah-row { padding: 0.9rem 1rem; }
  .drop-zone { padding: 2.5rem 1rem; }
}
