/* ─── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg-app: #FDF6EE;
  --violet: #9F8FCE;
  --violet-shadow: #8272B3;
  --title-1: #6B5B8E;
  --title-2: #5D4E7B;
  --text-story: #4A3E63;
  --text-sec-1: #B3A4C9;
  --text-sec-2: #8B7BA8;
  --chip-inactive: #F0E8F7;
  --timer-active: #FFE1A8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Baloo 2", system-ui, -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--text-story);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: transform 0.08s ease;
}

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ─── Écran ──────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ─── Accueil ────────────────────────────────────────────────────────── */
.home {
  gap: 20px;
  padding: 24px 20px 40px;
  position: relative;
}

.settings-fab {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #F0E8F7;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(107, 91, 142, 0.12);
  z-index: 2;
}

.settings-fab:active {
  transform: scale(0.92);
}

.home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
}

.moon {
  font-size: 56px;
  line-height: 1;
  animation: floaty 3s ease-in-out infinite;
}

.app-title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  color: var(--title-1);
}

.app-subtitle {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-sec-1);
}

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

.chip {
  border-radius: 30px;
  padding: 12px 22px;
  font-size: 18px;
  font-weight: 700;
  background: var(--chip-inactive);
  color: var(--text-sec-2);
}

.chip-active {
  background: var(--violet);
  color: #fff;
}

.chip:active {
  transform: scale(0.95);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.story-card {
  border-radius: 28px;
  padding: 22px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  box-shadow: 0 4px 0 rgba(107, 91, 142, 0.12);
}

.story-card:active {
  transform: scale(0.95);
}

.story-emoji {
  font-size: 54px;
  line-height: 1;
}

.story-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--title-2);
  line-height: 1.2;
  text-align: center;
}

/* ─── Lecteur ────────────────────────────────────────────────────────── */
.player {
  min-height: 100vh;
  min-height: 100dvh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}

.home-btn {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 26px;
  box-shadow: 0 3px 0 rgba(107, 91, 142, 0.15);
}

.home-btn:active {
  transform: scale(0.94);
}

.timer-btn {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 30px;
  height: 56px;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--title-2);
  box-shadow: 0 3px 0 rgba(107, 91, 142, 0.15);
}

.timer-btn:active {
  transform: scale(0.96);
}

.timer-active {
  background: var(--timer-active);
}

.identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 24px 0;
}

.player-emoji {
  font-size: 76px;
  line-height: 1;
}

.player-emoji.pulsing {
  animation: pulse 2s ease-in-out infinite;
}

.player-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--title-2);
  text-align: center;
  line-height: 1.15;
}

.karaoke-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 28px;
}

.karaoke-card {
  background: rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  padding: 28px 24px;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-shadow: 0 4px 0 rgba(107, 91, 142, 0.08);
}

.sentence {
  margin: 0;
  font-size: 23px;
  font-weight: 600;
  color: var(--text-story);
  text-align: center;
  line-height: 1.45;
  text-wrap: pretty;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 0 28px 36px;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--violet);
  border-radius: 8px;
  transition: width 0.4s ease;
}

.buttons {
  display: flex;
  align-items: center;
  gap: 24px;
}

.skip-btn {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  font-size: 26px;
  box-shadow: 0 4px 0 rgba(107, 91, 142, 0.15);
}

.skip-btn:active {
  transform: scale(0.94);
}

.play-btn {
  background: var(--violet);
  border-radius: 50%;
  width: 92px;
  height: 92px;
  font-size: 40px;
  color: #fff;
  box-shadow: 0 5px 0 var(--violet-shadow);
}

.play-btn:active {
  transform: scale(0.94);
}

/* ─── Panneau réglages ───────────────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(74, 62, 99, 0.35);
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.settings-card {
  width: 100%;
  max-width: 448px;
  background: var(--bg-app);
  border-radius: 28px;
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: 0 -8px 30px rgba(74, 62, 99, 0.25);
  animation: slide-up 0.24s ease;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--title-1);
}

.settings-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #F0E8F7;
  color: var(--text-sec-2);
  font-size: 18px;
  font-weight: 700;
}

.settings-close:active {
  transform: scale(0.92);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.settings-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--title-2);
}

.rate-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--violet);
  font-variant-numeric: tabular-nums;
}

.settings-note {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-sec-2);
  line-height: 1.4;
}

.rate-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rate-icon {
  font-size: 24px;
  line-height: 1;
}

.rate-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  border-radius: 8px;
  background: #F0E8F7;
  outline: none;
}

.rate-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 3px 0 var(--violet-shadow);
  cursor: pointer;
}

.rate-slider::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 3px 0 var(--violet-shadow);
  cursor: pointer;
}

.rate-slider:focus-visible {
  box-shadow: 0 0 0 3px rgba(159, 143, 206, 0.5);
}

.voice-select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--title-2);
  background: #fff;
  border: 2px solid #F0E8F7;
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.voice-select:focus-visible {
  border-color: var(--violet);
  outline: none;
}

.test-btn {
  align-self: stretch;
  height: 56px;
  border-radius: 30px;
  background: var(--violet);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--violet-shadow);
}

.test-btn:active {
  transform: scale(0.97);
}

.test-btn:disabled {
  background: #CFC5E4;
  box-shadow: none;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .settings-overlay,
  .settings-card {
    animation: none;
  }
}
