:root {
  --bg: #0b1220;
  --bg-soft: #111a2e;
  --card: #16213a;
  --card-border: #24334f;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --gold: #fbbf24;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --danger: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding: 0 14px calc(190px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Header ------------------------------------------------------------------ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(var(--bg) 70%, rgba(11, 18, 32, 0));
  padding: 12px 2px 8px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.app-header h1 {
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

.ghost-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Filters ----------------------------------------------------------------- */
.filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0 12px;
}

.filter-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 10px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-btn.active {
  background: var(--accent);
  color: #07131f;
  border-color: var(--accent);
}

/* Chapters ---------------------------------------------------------------- */
.chapters { margin-bottom: 14px; }

.chapter-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.chapter-chip {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: left;
  min-width: 104px;
}

.chapter-chip.active {
  border-color: var(--accent);
  background: var(--bg-soft);
}

.chapter-chip .ch-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.chapter-chip .ch-range {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.chapter-chip .ch-progress {
  font-size: 0.72rem;
  color: var(--accent);
  margin-top: 3px;
  font-weight: 600;
}

/* Word card --------------------------------------------------------------- */
.word-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.word-top {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  background: var(--accent);
  color: #07131f;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-muted {
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--card-border);
}

.french-word {
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 6px 0 2px;
}

.english-word {
  font-size: 1.15rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 34ch;
}

.master-btn {
  margin-top: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.master-btn.mastered {
  background: var(--gold);
  color: #3b2a06;
  border-color: var(--gold);
}

/* Player bar -------------------------------------------------------------- */
.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-soft);
  border-top: 1px solid var(--card-border);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  z-index: 10;
}

.player-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.player-now {
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.player-toggles {
  display: flex;
  gap: 6px;
}

.chip-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.chip-btn.active {
  background: var(--accent);
  color: #07131f;
  border-color: var(--accent);
}

#seekBar {
  width: 100%;
  margin: 10px 0 2px;
  accent-color: var(--accent);
  height: 26px;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.ctrl-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  width: 52px;
  height: 52px;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.ctrl-btn.play {
  background: var(--accent);
  color: #07131f;
  border-color: var(--accent);
  font-size: 1.5rem;
}

.ctrl-btn.speed {
  font-size: 0.85rem;
  font-weight: 700;
  width: auto;
  padding: 0 14px;
}

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

/* Empty state ------------------------------------------------------------- */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 0.95rem;
  line-height: 1.5;
}
