:root {
  --bg: #101214;
  --panel: #15181b;
  --surface: #1a1d21;
  --line: #2c3138;
  --line-strong: #4a515b;
  --text: #f2f0ea;
  --muted: #a6abb3;
  --dim: #8a9099;
  --accent: #f5a524;
  --on-accent: #1a1205;
  --danger: #ff9b8a;
  --font: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p,
ul {
  margin: 0;
  padding: 0;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.desktop-only {
  display: none;
}

/* ---------- Éléments communs ---------- */

.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail {
  font-size: 15px;
  color: var(--muted);
}

.hint {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.input {
  height: 50px;
  min-width: 0;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 16px;
}

.input::placeholder {
  color: var(--dim);
}

.button {
  height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button-outline {
  background: transparent;
  border-color: var(--line-strong);
  font-size: 15px;
  font-weight: 500;
}

.button-danger {
  color: var(--danger);
}

.icon-button {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Liste des chansons ---------- */

.songs {
  min-height: 100dvh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.songs-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.songs-header h1 {
  flex-grow: 1;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.song-list {
  list-style: none;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.song {
  width: 100%;
  min-height: 76px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.song[aria-current='true'] {
  border-color: var(--accent);
}

.song-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.song-name {
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.song-meta {
  font-size: 14px;
  color: var(--muted);
}

.song-bpm {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
}

.song[aria-current='true'] .song-bpm {
  color: var(--accent);
}

.songs-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ---------- Lecture ---------- */

.player {
  min-height: 100dvh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-title {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-title h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stage,
.tune {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 24px 48px;
}

.tune > section {
  flex: 1 1 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tempo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tempo-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tempo-value {
  font-family: var(--mono);
  font-size: clamp(132px, 17vw, 220px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.tempo-unit {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
}

.beats-block {
  flex: 1 1 340px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.beat-status {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.beats {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 10px;
}

.beat {
  height: 96px;
  border-radius: 16px;
  background: transparent;
  border: 1.5px dashed #3a4048;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.beat-num {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
}

.beat-label {
  font-size: 12px;
}

.beat.is-on {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--text);
}

.beat.is-on .beat-label {
  color: var(--muted);
}

.beat.is-current {
  border: 1.5px solid var(--text);
  color: var(--text);
}

.beat.is-on.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.beat.is-on.is-current .beat-label {
  color: var(--on-accent);
  font-weight: 600;
}

.beats-small .beat {
  height: 72px;
  border-radius: 14px;
}

.beats-small .beat-num {
  font-size: 26px;
}

.beats-small .beat.is-on {
  background: var(--accent);
  color: var(--on-accent);
}

.beats-small .beat.is-on .beat-label {
  color: var(--on-accent);
  font-weight: 600;
}

.percents {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.percent {
  height: 46px;
  padding: 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

.percent[aria-pressed='true'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.elapsed {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.play {
  width: 96px;
  height: 96px;
  border-radius: 48px;
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.play .icon-stop,
.play.is-playing .icon-play {
  display: none;
}

.play.is-playing .icon-stop {
  display: block;
}

.play-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.volume {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--muted);
}

.volume input {
  flex-grow: 1;
  min-width: 0;
  height: 44px;
  accent-color: var(--accent);
}

.shortcuts {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Réglages ---------- */

.settings {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--bg);
  color: var(--text);
}

.settings::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.settings form {
  min-height: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-header h2 {
  flex-grow: 1;
  font-size: 22px;
  font-weight: 600;
}

.input-name {
  font-size: 18px;
  font-weight: 500;
}

.stepper {
  display: flex;
  gap: 8px;
}

.stepper-button {
  width: 50px;
  height: 50px;
  font-family: var(--mono);
  font-size: 22px;
}

.input-number {
  flex-grow: 1;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
}

.input-select {
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.signature {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 22px;
  color: var(--muted);
}

.signature select {
  flex: 1 1 0;
  color: var(--text);
}

.sounds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sound {
  height: 46px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 500;
}

.sound[aria-pressed='true'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.check {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.check input {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

/* ---------- Téléphone : une vue à la fois ---------- */

@media (max-width: 899px) {
  body[data-view='player'] .songs,
  body[data-view='songs'] .player {
    display: none;
  }
}

/* ---------- Ordinateur : liste et lecture côte à côte ---------- */

@media (min-width: 900px) {
  .mobile-only {
    display: none;
  }

  .desktop-only {
    display: block;
  }

  .app {
    display: flex;
  }

  .songs {
    position: sticky;
    top: 0;
    width: 340px;
    height: 100dvh;
    flex-shrink: 0;
    padding: 28px 24px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }

  .songs-header h1 {
    font-size: 24px;
  }

  .player {
    flex: 1 1 0;
    min-width: 0;
    padding: 32px clamp(24px, 4vw, 56px);
  }

  .player-title h2 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .beat {
    height: 140px;
    border-radius: 18px;
  }

  .beat-num {
    font-size: 48px;
  }

  .beats-small .beat {
    height: 72px;
  }

  .beats-small .beat-num {
    font-size: 26px;
  }

  .progress-block {
    padding-bottom: 20px;
  }

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .play {
    width: auto;
    height: 72px;
    padding: 0 36px;
    border-radius: 36px;
  }

  .play svg {
    width: 22px;
    height: 22px;
  }

  .play-label {
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
  }

  .volume {
    flex: 1 1 220px;
    width: auto;
  }

  .settings {
    width: 480px;
    height: auto;
    max-height: calc(100dvh - 48px);
    margin: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
  }

  .settings form {
    padding: 24px;
  }
}
