/* ─── RHAPSODY SPEAK V2.1 ─── */

.sv2-wrap {
  padding: 24px 16px 120px;
  max-width: 540px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .sv2-wrap {
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
  }
}

/* ── Settings Toggles ── */
.sv2-settings {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.sv2-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 10px;
  font-size: 0.71rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
  color: #64748b;
  border: 1px solid rgba(255,255,255,0.08);
  font-family: inherit;
  transition: all 0.2s;
}

.sv2-toggle.on {
  background: rgba(124,58,237,0.15);
  color: #a78bfa;
  border-color: rgba(124,58,237,0.35);
  box-shadow: 0 0 8px rgba(124,58,237,0.25);
}

/* ── Stats Bar ── */
.sv2-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.74rem;
}

.sv2-stat { color: #64748b; }
.sv2-stat strong { color: #94a3b8; font-weight: 700; }
.sv2-stat-sep { color: rgba(255,255,255,0.12); }

/* ── Score panel top row ── */
.sv2-score-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

/* ── XP Badge ── */
.sv2-xp-badge {
  display: none;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(124,58,237,0.2);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.35);
  animation: sv2-xp-pop 0.4s ease-out;
}

@keyframes sv2-xp-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  65%  { transform: scale(1.15); }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── Playback Button ── */
.sv2-playback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(6,182,212,0.08);
  color: #06b6d4;
  border: 1px solid rgba(6,182,212,0.25);
  font-family: inherit;
  margin-bottom: 10px;
  transition: background 0.15s;
}

.sv2-playback-btn:hover { background: rgba(6,182,212,0.16); }

/* ── History Dots ── */
.sv2-hist { margin-bottom: 10px; }

.sv2-hist-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.sv2-hist-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.85;
}

/* ── Shadow status ── */
.sv2-s-shadow { color: #06b6d4; }

/* ── CEFR Level Pill (read-only) ── */
.sv2-cefr-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0.03em;
}

/* ── Sentence Card ── */
.sv2-card {
  background: rgba(13, 13, 26, 0.9);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
  min-height: 100px;
  transition: box-shadow 0.3s;
}

.sv2-sentence {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  line-height: 1.6;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  margin: 0;
}

.sv2-live {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #a78bfa;
  text-align: center;
  font-style: italic;
  min-height: 0;
}

/* ── Navigation ── */
.sv2-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.sv2-nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
}

.sv2-nav-btn:disabled {
  color: #334155;
  cursor: default;
}

.sv2-nav-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.08);
}

.sv2-counter {
  font-size: 0.85rem;
  color: #94a3b8;
}

/* ── Audio Buttons ── */
.sv2-audio-btns {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}

.sv2-audio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.sv2-audio-btn small {
  font-size: 0.7rem;
  color: #64748b;
  font-family: inherit;
}

.sv2-aico {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  transition: transform 0.15s;
}

.sv2-btn-play .sv2-aico {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
}

.sv2-btn-slow .sv2-aico {
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.2);
}

.sv2-btn-repeat .sv2-aico {
  background: rgba(236, 72, 153, 0.1);
  border: 1px solid rgba(236, 72, 153, 0.4);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.2);
}

.sv2-audio-btn:active .sv2-aico {
  transform: scale(0.91);
}

/* ── Mic Section ── */
.sv2-mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sv2-unsupported {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: #f59e0b;
  text-align: center;
}

/* ── Mic Button ── */
.sv2-mic-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv2-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.sv2-ring-a1 {
  border-color: rgba(124, 58, 237, 0.5);
  animation: sv2-ring 1.5s ease-out infinite;
}

.sv2-ring-a2 {
  border-color: rgba(124, 58, 237, 0.35);
  animation: sv2-ring 1.5s ease-out 0.3s infinite;
}

.sv2-ring-a3 {
  border-color: rgba(124, 58, 237, 0.2);
  animation: sv2-ring 1.5s ease-out 0.6s infinite;
}

@keyframes sv2-ring {
  0%   { transform: scale(1);   opacity: 0.8; }
  100% { transform: scale(2.0); opacity: 0;   }
}

.sv2-mic-btn {
  position: relative;
  z-index: 2;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4c1d95, #7c3aed);
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s;
}

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

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

.sv2-mic-btn.sv2-recording {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  box-shadow: 0 0 40px rgba(124, 58, 237, 0.8), 0 0 80px rgba(124, 58, 237, 0.4);
  animation: sv2-pulse 0.8s ease-in-out infinite;
}

.sv2-mic-btn.sv2-processing {
  background: linear-gradient(135deg, #374151, #4b5563);
  box-shadow: none;
  cursor: not-allowed;
  animation: none;
}

@keyframes sv2-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}

.sv2-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  animation: sv2-spin 0.8s linear infinite;
}

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

/* ── Waveform ── */
.sv2-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 48px;
}

.sv2-bar {
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  transition: height 0.08s linear;
}

/* ── Status ── */
.sv2-status {
  font-size: 0.85rem;
  text-align: center;
  min-height: 20px;
  color: #64748b;
}

.sv2-s-rec  { color: #a78bfa; }
.sv2-s-proc { color: #94a3b8; }
.sv2-s-err  { color: #ef4444; }

.sv2-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: sv2-blink 0.8s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 4px;
}

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

/* ── Score Panel ── */
.sv2-score-panel {
  width: 100%;
  display: none;
}

.sv2-score-panel.visible {
  display: block;
  animation: sv2-fadein 0.3s ease-out;
}

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

.sv2-score-card {
  background: rgba(13, 13, 26, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.sv2-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.sv2-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sv2-score-num {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.sv2-score-pct {
  font-size: 0.7rem;
  color: #64748b;
}

.sv2-score-info {
  flex: 1;
  min-width: 0;
}

.sv2-score-label {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.sv2-score-said {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv2-score-said em { color: #94a3b8; font-style: italic; }

/* ── Word Breakdown ── */
.sv2-word-breakdown {
  margin-bottom: 12px;
}

.sv2-bd-title {
  font-size: 0.72rem;
  color: #475569;
  margin: 0 0 8px;
}

.sv2-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.sv2-word {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  animation: sv2-wordin 0.2s ease-out both;
}

.sv2-word.ok {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sv2-word.no {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes sv2-wordin {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Result Buttons ── */
.sv2-result-btns {
  display: flex;
  gap: 12px;
}

.sv2-rbtn {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s;
}

.sv2-rbtn:active { transform: scale(0.97); }

.sv2-rbtn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sv2-rbtn-primary {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  border: none;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
}

/* ── Fluency + WPM Metrics (V2.2) ── */
.sv2-metrics {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sv2-metric-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sv2-metric-label {
  font-size: 0.7rem;
  color: #64748b;
  width: 46px;
  flex-shrink: 0;
}

.sv2-metric-bar-wrap {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.sv2-metric-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease-out;
}

.sv2-metric-val {
  font-size: 0.72rem;
  font-weight: 700;
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

.sv2-metric-wpm {
  font-size: 0.8rem;
  font-weight: 700;
  flex: 1;
}

.sv2-metric-wpm small {
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.7;
}

.sv2-metric-tag {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid;
  opacity: 0.85;
}

/* ── Portrait phone optimization ── */
@media (orientation: portrait) and (max-width: 500px) {
  .sv2-wrap {
    padding: 16px 12px calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 24px) !important;
  }
  .sv2-settings { margin-bottom: 8px !important; }
  .sv2-stats { margin-bottom: 8px !important; }
  .sv2-card {
    padding: 16px !important;
    margin-bottom: 10px !important;
    min-height: 70px !important;
    border-radius: 12px !important;
  }
  .sv2-sentence { font-size: 1rem !important; line-height: 1.45 !important; }
  .sv2-nav { margin-bottom: 12px !important; }
  .sv2-audio-btns { gap: 14px !important; margin-bottom: 16px !important; }
  .sv2-aico { width: 40px !important; height: 40px !important; border-radius: 11px !important; }
  .sv2-mic-section { gap: 12px !important; }
  .sv2-mic-wrap { width: 100px !important; height: 100px !important; }
  .sv2-mic-btn { width: 66px !important; height: 66px !important; }
  .sv2-waveform { height: 36px !important; }
  .sv2-score-card {
    padding: 12px !important;
    gap: 12px !important;
    margin-bottom: 8px !important;
    border-radius: 12px !important;
  }
  .sv2-result-btns { gap: 8px !important; }
}

/* ── Sentence History (V2.2) ── */
.sv2-sent-hist {
  margin-bottom: 10px;
}

.sv2-sh-title {
  font-size: 0.7rem;
  color: #475569;
  margin: 0 0 6px;
}

.sv2-sh-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sv2-sh-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 3px 8px;
}

.sv2-sh-date {
  font-size: 0.66rem;
  color: #475569;
}

.sv2-sh-score {
  font-size: 0.72rem;
  font-weight: 700;
}
