.page {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

/* Word display */
.word-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 28px 220px;
}
.word-counter {
  position: absolute;
  top: 20px; left: 0; right: 0;
  font-size: 15px; font-weight: 700; color: #7a7872;
  text-align: center;
  letter-spacing: 0.5px;
}
.word-arabic {
  font-family: 'Amiri', serif;
  font-size: 72px; font-weight: 700;
  direction: rtl; text-align: center;
  color: #2C2C2A; line-height: 1.2;
}
.word-translit {
  margin-top: 12px;
  font-size: 32px; font-weight: 600; color: #888780;
  text-align: center; font-style: italic;
}

/* Waveform */
.waveform {
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
  height: 36px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
.waveform.active { opacity: 1; }
.waveform .bar {
  width: 4px;
  border-radius: 2px;
  background: var(--green);
  height: 6px;
  animation: none;
}
.waveform.speaking .bar { animation: wave 0.7s ease-in-out infinite; }
.waveform.speaking .bar:nth-child(1) { animation-delay: 0s;    --h: 14px; }
.waveform.speaking .bar:nth-child(2) { animation-delay: 0.1s;  --h: 28px; }
.waveform.speaking .bar:nth-child(3) { animation-delay: 0.2s;  --h: 36px; }
.waveform.speaking .bar:nth-child(4) { animation-delay: 0.1s;  --h: 24px; }
.waveform.speaking .bar:nth-child(5) { animation-delay: 0.05s; --h: 18px; }

@keyframes wave {
  0%, 100% { height: 6px; }
  50%       { height: var(--h, 20px); }
}

/* Bottom card */
.bottom-card {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 390px;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 210px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.10);
  overflow: hidden;
  transition: background 0.3s;
}
.bottom-card.flash-green { animation: cardflash 0.6s ease-out; }
@keyframes cardflash {
  0%   { background: #d4f5e8; }
  100% { background: var(--bg); }
}

/* Badr — left column */
.card-badr {
  width: 32%;
  flex-shrink: 0;
  background: #e8f4ef;
  overflow: hidden;
  position: relative;
}
.card-badr {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-badr .badr {
  animation: badrFloat 3s ease-in-out infinite;
  width: clamp(90px, 26vw, 120px);
  height: clamp(99px, 28vw, 132px);
}

/* Right column */
.card-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px 24px;
}
.card-msg {
  font-size: 17px; font-weight: 600; color: #2C2C2A;
  line-height: 1.5;
  background: #f0ece4;
  border-radius: 14px;
  padding: 8px;
  margin-bottom: 8px;
  animation: badrPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes badrPop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.card-msg .name {
  color: var(--green);
  font-weight: 800;
}

/* Controls row */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
}

/* Mic indicator */
.mic-indicator {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
  position: relative;
}
.mic-indicator.idle      { background: #C8C6BE; }
.mic-indicator.listening { background: #e05050; }
.mic-indicator.listening::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid #e05050;
  animation: pulse-ring 1s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0;   }
}

.skip-btn {
  background: #f0ece4; border: none;
  border-radius: 16px; padding: 10px 20px;
  font-size: 15px; font-weight: 800; color: #888780;
  cursor: pointer;
  box-shadow: 0 3px 0 #ddd9d0;
  transition: transform 0.1s, box-shadow 0.1s;
  white-space: nowrap;
}
.skip-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #ddd9d0; }

.start-btn {
  width: 100%;
  background: var(--green); color: #fff; border: none;
  border-radius: 16px; padding: 14px;
  font-size: 18px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 0 var(--green-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}
.start-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }

.hidden { display: none !important; }

.loading-audio {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: #888780;
}
.loading-audio::before {
  content: '';
  width: 18px; height: 18px;
  border: 2px solid #C8C6BE;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
