/* Style repris du planificateur web de Swell (swell-ios, design-system) :
   fond blanc cassé chaud, un seul accent, le noir en dégradé, une seule
   police, Instrument Sans. La couleur est réservée aux états : bleu pour les
   notes jouées, vert pour le plus court, orange pour « il y avait plus court ». */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(vendor/fonts/instrument-sans-latin-wght-normal.woff2) format("woff2-variations"); /* OFL : vendor/fonts/instrument-sans.LICENSE */
}

:root {
  --canvas: #FAF9F6;
  --surface: #FFFFFF;
  --ink: #111111;
  --ink-soft: #4A4741;
  --ink-muted: #6B6862;
  --ink-faint: #9A968F;
  --line: #E4E0D9;
  --line-strong: #DEDBD6;
  --line-soft: #EFECE6;
  --control-border: #BDB7AE;
  --primary: #111114;
  --on-primary: #FFFFFF;
  --wash: rgba(40, 30, 20, 0.05);
  --wash-strong: rgba(40, 30, 20, 0.07);
  --glass: rgba(255, 255, 255, 0.74);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warning: #B54708;
  --warning-soft: #FEF0E1;
  --ok: #34C759;
  --ok-ink: #1E6B3A;
  --ok-soft: #EAF6EE;
  --played: #1D4E89;        /* notes jouées (le bleu « scale » de Swell) */
  --played-soft: #EAF2FD;
  --good: #2E9D4F;          /* le plus court */
  --shadow-card: 0 1px 2px rgba(40, 30, 20, 0.05), 0 2px 8px rgba(40, 30, 20, 0.04);
  --shadow-card-selected: 0 0 0 2px #33333A, 0 6px 18px rgba(17, 17, 20, 0.22);
  --shadow-primary: 0 1px 2px rgba(40, 30, 20, 0.12), 0 4px 12px rgba(17, 17, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  --shadow-secondary: 0 1px 2px rgba(40, 30, 20, 0.06), inset 0 1px 0 #FFFFFF;
  --shadow-raised: 0 1px 3px rgba(40, 30, 20, 0.1);
  --shadow-float: 0 8px 24px rgba(40, 30, 20, 0.08), 0 0 0 1px rgba(40, 30, 20, 0.04);
  --shadow-drawer: 0 24px 60px rgba(40, 30, 20, 0.18), 0 0 0 1px rgba(40, 30, 20, 0.05);
  --gradient-primary: linear-gradient(180deg, #33333A, #111114);
  --gradient-secondary: linear-gradient(180deg, #FFFFFF, #F6F6F8);
  --glass-blur: blur(20px) saturate(180%);
  --radius-s: 8px;
  --radius-m: 9px;
  --radius-l: 12px;
  --radius-xl: 16px;
  --radius-2xl: 18px;
  --font-sans: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --rail: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* Place pour le rail du menu, à gauche (en haut sur écran étroit). */
  padding-left: calc(var(--rail) + 28px);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

:where(a, button, select, input, .grid .cell):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Menu : le rail des outils (nav.js), en verre comme dans Swell */
.nav {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  width: var(--rail);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-xl);
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-float);
}
.nav-logo {
  flex: none;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: var(--radius-s);
  background: var(--gradient-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(17, 17, 20, 0.22);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}
.nav-tools { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-tools a {
  width: 52px;
  padding: 7px 0 5px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-muted);
  font-size: 10.5px;
  font-weight: 500;
  text-decoration: none;
}
.nav-tools a:hover { color: var(--ink); background: var(--wash); }
.nav-tools a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-raised), 0 0 0 1px rgba(40, 30, 20, 0.04); color: var(--ink); }
.nav-lab {
  margin-top: 8px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 10px;
  font-weight: 600;
}
@media (max-width: 700px) {
  body { padding-left: 0; }
  .nav {
    position: static;
    width: auto;
    margin: 12px 12px 0;
    padding: 6px 8px;
    flex-direction: row;
    justify-content: center;
  }
  .nav-logo { margin: 0 6px 0 0; }
  .nav-tools { flex-direction: row; }
  .nav-lab { margin: 0 0 0 6px; }
}

/* En haut de page (nav.js) : la barre du son à gauche, l'état du clavier
   MIDI (keyboard.js) à droite */
.top-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.midi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-s);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(40, 30, 20, 0.04);
  font-size: 13px;
  color: var(--ink-muted);
  max-width: 100%;
}
.midi-chip b { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.midi-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-faint); }
.midi-chip[data-state="connected"] .midi-dot { background: var(--ok); }
.midi-chip[data-state="connecting"] .midi-dot { animation: pulse 1.2s ease-in-out infinite; }
.midi-chip:is([data-state="denied"], [data-state="unsupported"], [data-state="error"]) .midi-dot { background: var(--warning); }

/* La barre du son (soundbar.js) : l'instrument, qui ouvre le panneau des
   réglages, et le bourdon */
.sound-bar { position: relative; margin-right: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sound-bar > button { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.8); border-color: var(--line); box-shadow: 0 1px 2px rgba(40, 30, 20, 0.04); color: var(--ink-muted); }
.sound-bar > button:hover { color: var(--ink); }
.sound-open #sound-name { color: var(--ink); font-weight: 600; }
.sound-open[aria-expanded="true"] { border-color: var(--control-border); color: var(--ink); }
.sound-open[aria-expanded="true"] svg:last-child { transform: rotate(180deg); }
.drone-chip b { font-weight: 600; color: var(--ink); }
.drone-chip b:empty { display: none; }
.drone-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-faint); }
.drone-chip[aria-pressed="true"] { border-color: var(--played); background: var(--played-soft); color: var(--played); }
.drone-chip[aria-pressed="true"] .drone-dot { background: var(--played); animation: pulse 2.4s ease-in-out infinite; }
.drone-chip.waiting .drone-dot { background: var(--warning); animation-duration: 1.2s; }

.sound-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px 18px;
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sound-panel-head { display: flex; justify-content: space-between; align-items: center; }
.sound-panel h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.sound-group { display: flex; flex-direction: column; gap: 10px; }
.sound-group + .sound-group { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.sound-group-head { display: flex; justify-content: space-between; align-items: center; }
.sound-group .filter-label, .sound-group-head .filter-label { font-weight: 500; }
.sound-group .toggle { align-items: flex-start; }
.sound-group .toggle input { margin-top: 1px; }
.sound-panel .segmented { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; }
.sound-panel .segmented button { padding: 0 4px; }
.sound-panel .sound-choices { display: flex; flex-wrap: wrap; }
.sound-panel .sound-choices button { flex: 1 1 auto; padding: 0 10px; white-space: nowrap; }
.sound-reset { min-height: 26px; padding: 0 8px; font-size: 12px; }
.drone-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.sound-credit { margin: 0; font-size: 11.5px; color: var(--ink-faint); }
.sound-credit a { color: inherit; }

/* Curseurs : un trait, rempli jusqu'au bouton (--fill, posé par le JS) */
.sound-slider { display: grid; grid-template-columns: 104px minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 14px; }
.sound-slider output { font-size: 12px; color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }
.sound-slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; }
.sound-slider input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--ink) var(--fill, 0%), var(--line) var(--fill, 0%)); }
.sound-slider input::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--ink) var(--fill, 0%), var(--line) var(--fill, 0%)); }
.sound-slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; border: 1px solid var(--control-border); background: var(--surface); box-shadow: var(--shadow-raised); }
.sound-slider input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--control-border); background: var(--surface); box-shadow: var(--shadow-raised); }

/* Hors du labo (nav.js), ses options sont masquées */
html:not(.lab) [data-lab] { display: none; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Boutons et listes : secondaire en dégradé blanc, principal en dégradé noir */
button, select {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  background: var(--gradient-secondary);
  box-shadow: var(--shadow-secondary);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--control-border); }
button:disabled { border-color: var(--line); background: rgba(40, 30, 20, 0.06); box-shadow: none; color: var(--ink-faint); cursor: not-allowed; }
select { padding-right: 8px; background: rgba(255, 255, 255, 0.9); box-shadow: inset 0 1px 2px rgba(40, 30, 20, 0.04); }

button.small, select.small { min-height: 28px; padding: 0 10px; font-size: 13px; }
button.primary {
  align-self: center;
  min-height: 42px;
  padding: 0 28px;
  font-size: 15px;
  font-weight: 600;
  border-color: var(--primary);
  background: var(--gradient-primary);
  box-shadow: var(--shadow-primary);
  color: var(--on-primary);
}
button.primary:hover { border-color: var(--primary); filter: brightness(1.15); }
button.primary:disabled { border-color: var(--line); background: rgba(40, 30, 20, 0.06); box-shadow: none; color: var(--ink-faint); filter: none; }

/* Écrans : réglages, session, fin */
.setup, .session, .end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.setup[hidden], .session[hidden], .end[hidden] { display: none; }
.preview-section { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-header { display: flex; align-items: center; gap: 12px; }
.setup-options { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 24px; }

/* Arrivée de la Grille : titre, état du clavier, grille, comment ça marche */
.setup { align-items: stretch; gap: 28px; }
.page-head { display: flex; flex-direction: column; gap: 8px; max-width: 680px; }
.page-head h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
.page-head p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }

.card {
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(40, 30, 20, 0.05), 0 4px 14px rgba(40, 30, 20, 0.04);
}
.midi-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 18px; }
.midi-card-text { flex: 1 1 360px; display: flex; flex-direction: column; gap: 4px; }
.midi-card-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.midi-card-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.midi-card.is-warning .midi-card-title::before { background: var(--warning); }
.midi-card-body { font-size: 14px; line-height: 1.5; color: var(--ink-muted); }
.midi-card ul { flex-basis: 100%; margin: 0 -18px -16px; padding: 0; list-style: none; }
.midi-card li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 18px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.midi-card li > span:nth-child(2) { flex: 1 1 320px; min-width: 0; }
.tag { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 5px; background: var(--wash); color: var(--ink-muted); }
.tag.warning { background: var(--warning-soft); color: var(--warning); font-weight: 600; }

.grid-section { display: flex; flex-direction: column; gap: 14px; }
.grid-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.grid-section-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.grid-section-title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.grid-section-actions { display: flex; gap: 8px; }
.meta { font-size: 13px; color: var(--ink-muted); }
.hint { margin: 0; display: flex; align-items: center; gap: 6px; }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.start-row button.primary { align-self: auto; }

.how { display: flex; flex-direction: column; gap: 14px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.how h2 { margin: 0; font-size: 16px; font-weight: 600; }
.how ol { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; counter-reset: step; }
.how li { display: flex; gap: 10px; counter-increment: step; font-size: 14px; line-height: 1.45; color: var(--ink-muted); }
.how li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; background: var(--wash-strong); color: var(--ink); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.how li strong { display: block; color: var(--ink); font-weight: 600; }

/* Réglages de la grille, dans un tiroir en verre par-dessus la page (Swell) */
.drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 30;
  width: 400px;
  max-width: calc(100% - 28px);
  overflow-y: auto;
  padding: 18px;
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.drawer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }
.drawer h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.drawer-group { display: flex; flex-direction: column; gap: 8px; }
.drawer-group > .filter-label { font-size: 13px; font-weight: 500; color: var(--ink-muted); }
.drawer-group.helps { gap: 12px; padding-top: 16px; border-top: 1px dashed rgba(40, 30, 20, 0.12); }
.drawer-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.drawer-foot .start-row button.primary { flex: 1 1 auto; }
.icon-btn { width: 30px; min-height: 30px; padding: 0; border: none; background: var(--wash); box-shadow: none; border-radius: var(--radius-s); color: var(--ink-muted); display: inline-flex; align-items: center; justify-content: center; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; border: 1px solid rgba(40, 30, 20, 0.1); background: var(--surface); box-shadow: 0 1px 0 rgba(40, 30, 20, 0.08); font-size: 11px; font-weight: 600; color: var(--ink-muted); }

.session-bar { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.session-title { font-size: 15px; font-weight: 600; }
.session-count { font-size: 14px; color: var(--ink-muted); }
.session-progress { display: flex; align-items: baseline; gap: 12px; }
.session-time { font-size: 14px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.session-time.running { color: var(--ink); font-weight: 600; }
.session-time.over { color: var(--danger); }
.target { text-align: center; min-height: 170px; }
.target-label { font-size: 14px; color: var(--ink-muted); }
.target-chord { font-size: 92px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.target-info { font-size: 16px; color: var(--ink-soft); }
.target-next { font-size: 14px; color: var(--ink-muted); margin-top: 8px; }
.session .piano { width: 100%; }
.session-midi { width: 100%; }

.end { padding-top: 40px; text-align: center; }
.end-title { font-size: 16px; color: var(--ink-muted); }
.score { font-size: 64px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.score-label { font-size: 14px; color: var(--ink-muted); margin-bottom: 12px; }
.end-stats { font-size: 18px; font-variant-numeric: tabular-nums; }
.end-best { font-size: 14px; color: var(--ink-muted); min-height: 20px; }
.end-best.record { color: var(--ok-ink); font-weight: 600; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 16px; }

/* Historique des grilles jouées, sous la grille */
.history { display: flex; flex-direction: column; gap: 10px; width: 100%; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.history .filter-label { font-size: 16px; font-weight: 600; color: var(--ink); }
.history-scroll { width: 100%; overflow-x: auto; }
.history table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th { font-weight: 500; color: var(--ink-muted); text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.history td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.history .num { text-align: right; font-variant-numeric: tabular-nums; }
.history .history-title { white-space: normal; min-width: 160px; }
.history [data-more] { align-self: flex-start; }
@media (max-width: 600px) {
  .history .optional { display: none; }
  .history .history-title { min-width: 0; }
}

/* Grille : chaque accord sur une carte */
.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 1000px; /* 12 accords par ligne */
}
.grid .cell {
  width: 76px; /* même largeur pour tous : C comme C♯m */
  padding: 14px 4px;
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}

.grid .cell .degree { display: block; font-size: 12px; font-weight: 500; color: var(--ink-muted); margin-top: 2px; }

.grid .cell.current { box-shadow: var(--shadow-card-selected); }
.grid .cell.start,
.grid .cell.perfect { background: var(--ok-soft); border-color: #8CC79C; color: var(--ok-ink); }
.grid .cell.ok { background: var(--warning-soft); border-color: #F0B37E; color: var(--warning); }

/* Aperçu et bande de progression : cartes plus petites */
.grid.preview { justify-content: flex-start; max-width: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
.grid.preview .cell { width: auto; }
.grid.preview, .grid.strip { gap: 8px; }
.grid.strip { max-width: 760px; }
.grid.preview .cell, .grid.strip .cell { padding: 10px 2px; font-size: 17px; }
.grid.strip .cell { width: 58px; }
.grid.preview .cell .degree, .grid.strip .cell .degree { font-size: 11px; }
.grid.strip .cell.upcoming { border-style: dashed; background: transparent; box-shadow: none; min-height: 44px; cursor: default; }

/* Filtres de la grille : contrôles segmentés de Swell */
.grid-filters { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 24px; }
.drawer .grid-filters { display: contents; }
.filter { display: flex; align-items: center; gap: 8px; }
.drawer .filter { flex-wrap: wrap; }
.filter-label { font-size: 13px; color: var(--ink-muted); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--wash); }
.segmented button {
  min-height: 28px;
  padding: 0 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  color: var(--ink-muted);
  font-size: 13px;
}
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--surface); box-shadow: var(--shadow-raised); color: var(--ink); }
.filter[hidden] { display: none; }
.filter[data-mode="progression"] { flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: 6px; }
.progression-list { display: flex; flex-wrap: wrap; gap: 6px; }
.progression-list button { min-height: 30px; padding: 0 10px; font-size: 13px; }
.progression-list button.on { border-color: var(--primary); background: var(--gradient-primary); box-shadow: var(--shadow-primary); color: var(--on-primary); }
.progression-label { color: var(--ink-faint); }
.progression-list button.on .progression-label { color: #C9C7CF; }

/* Carte de la tonalité : les 7 degrés, bordure selon la fonction */
.key-map { display: flex; justify-content: center; gap: 8px; width: 100%; max-width: 820px; }
.degree-card {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 2px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.degree-card.T { border-color: #8CC79C; }
.degree-card.S { border-color: #B3AEE6; }
.degree-card.D { border-color: #F0B37E; }
.degree-card.playing { background: var(--played); color: #fff; }
.degree-card .roman { font-size: 12px; color: var(--ink-muted); }
.degree-card .symbol { font-size: 20px; font-weight: 600; }
.degree-card .card-notes { font-size: 12px; color: var(--ink-muted); }
.degree-card .function { font-size: 11px; color: var(--ink-faint); }
.degree-card.playing .roman, .degree-card.playing .card-notes, .degree-card.playing .function { color: #C6DAF4; }
.grid .cell { cursor: pointer; }
@media (max-width: 600px) {
  .grid.strip { gap: 4px; }
  .grid.strip .cell { width: 40px; padding: 5px 1px; font-size: 15px; }
  .grid.strip .cell.upcoming { min-height: 34px; }
  .target-chord { font-size: 72px; }
  .key-map { flex-wrap: wrap; }
  .degree-card { flex: 0 0 calc(25% - 6px); }
}

/* Cases à cocher rondes (Swell) */
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.toggle input, input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--control-border);
  background: var(--surface);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(40, 30, 20, 0.06);
}
input[type="checkbox"]:checked { background: var(--gradient-primary); border-color: var(--primary); }
input[type="checkbox"]:checked::after { content: ""; width: 7px; height: 3.5px; border-left: 1.5px solid var(--on-primary); border-bottom: 1.5px solid var(--on-primary); transform: translateY(-1px) rotate(-45deg); }
input[type="checkbox"]:disabled { opacity: 0.5; cursor: default; }
.drawer .toggle { align-items: flex-start; }
.drawer .toggle input { margin-top: 1px; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }
.toggle-text small { font-size: 13px; color: var(--ink-muted); }

.feedback { font-size: 16px; text-align: center; min-height: 24px; max-width: 720px; }
.feedback.good { color: var(--ok-ink); }
.feedback.ok { color: var(--warning); }
.reference { font-size: 14px; color: var(--ink-muted); min-height: 20px; }
.warning { font-size: 14px; color: var(--danger); min-height: 20px; }

/* MIDI */
.status { font-size: 14px; }
.status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status.on::before { background: var(--ok); }
.status.off::before { background: var(--ink-faint); }
.pedal { font-size: 12px; padding: 2px 8px; border-radius: 5px; background: var(--played); color: #fff; }

/* Analyse */
.analysis {
  text-align: center;
  min-height: 190px;
}
.chord { font-size: 48px; font-weight: 600; letter-spacing: -0.02em; }
.chord.muted { color: var(--ink-faint); font-weight: 400; font-size: 32px; }
.position { font-size: 20px; margin-top: 6px; color: var(--ink-soft); min-height: 28px; }
.alternatives { font-size: 15px; margin-top: 4px; color: var(--ink-muted); min-height: 22px; }
.notes {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 22px;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  min-height: 48px;
}
.notes .note { display: flex; flex-direction: column; align-items: center; }
.notes small { font-size: 13px; color: var(--ink-muted); }

/* Clavier */
.piano {
  position: relative;
  height: 140px;
  display: flex;
  overflow-x: auto;
  border-radius: 0 0 var(--radius-s) var(--radius-s);
  box-shadow: var(--shadow-card);
}
.key.white {
  position: relative;
  flex: 1 0 22px;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: none;
  border-radius: 0 0 4px 4px;
}
.key.white:first-child { border-left: 1px solid var(--line-strong); }
.key.black {
  position: absolute;
  top: 0;
  width: 60%;
  height: 62%;
  right: -30%;
  z-index: 2;
  background: var(--gradient-primary);
  border-radius: 0 0 3px 3px;
}
/* Notes jouées en bleu ; vert et orange réservés au correcteur. */
.key.white.on { background: var(--played); }
.key.black.on { background: #163B68; }
.key.white.kept { background: #9FC0EA; }
.key.black.kept { background: #4F79AE; }
.key.white.good { background: var(--good); }
.key.black.good { background: #237A3D; }
.key.white.ok { background: #D4791F; }
.key.black.ok { background: var(--warning); }
.key.white.tone { background: var(--line); }
.key.black.tone { background: #77746D; }
.key .label {
  position: absolute;
  bottom: 6px;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: var(--ink-muted);
}
/* Point sur les touches de l'accord de départ */
.key > .dot {
  display: none;
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--ink);
  pointer-events: none;
}
.key.white > .dot { bottom: 38px; }
.key.black > .dot { bottom: 18px; background: #fff; }
.key.prev > .dot { display: block; }
.key .note-name {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  pointer-events: none;
}
.key.black .note-name { bottom: 4px; font-size: 9px; }

/* Légende du clavier (mode correcteur) */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-top: -8px;
  font-size: 13px;
  color: var(--ink-muted);
}
.legend[hidden] { display: none; }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(40, 30, 20, 0.15); }
.swatch.on { background: var(--played); }
.swatch.good { background: var(--good); }
.swatch.ok { background: #D4791F; }
.swatch.tone { background: var(--line); }
.swatch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); margin: 0 3px; }

/* Énoncer les notes (voice.js) */
[hidden] { display: none !important; }
.voice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.voice-bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; }
.voice-mic.on::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.voice-hint { font-size: 13px; color: var(--ink-muted); }
.voice-error:empty { display: none; }
.voice-raw { font-size: 16px; color: var(--ink-soft); min-height: 24px; }
.voice-raw .interim { color: var(--ink-faint); }
.feedback.bad { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 48px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  font-size: 22px;
  font-weight: 600;
}
.chip.good { background: var(--ok-soft); border-color: #8CC79C; color: var(--ok-ink); }
.chip.enh { background: var(--warning-soft); border-color: #F0B37E; color: var(--warning); }
.chip.bad { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.chip.unknown { font-size: 14px; font-weight: 400; color: var(--ink-faint); background: transparent; border-style: dashed; }

.voice-history { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.voice-try { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-muted); }
.voice-try .chips { min-height: 0; gap: 6px; }
.voice-try .chip { font-size: 15px; padding: 3px 10px; }

.toggle:has(input:disabled) { color: var(--ink-faint); cursor: default; }

.privacy { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; font-size: 12px; line-height: 1.6; color: var(--ink-muted); text-align: center; }
.privacy a { color: inherit; }

/* Métronome (metronome.js) */
.metronome-option { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 20px; }
.drawer .metronome-option { flex-direction: column; align-items: flex-start; }
.metronome { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }
.drawer .metronome { justify-content: flex-start; }
.metronome-play { min-width: 36px; }
.metronome-play.on { border-color: var(--primary); background: var(--gradient-primary); color: var(--on-primary); }
.metronome-dots { display: inline-flex; align-items: center; gap: 6px; }
.metronome-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.metronome-dots i:first-child { width: 16px; height: 16px; }
.metronome-dots i.on { background: var(--played); }
.metronome-dots i.on:first-child { background: #D4791F; }
.metronome-tempo { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.metronome-tempo input {
  width: 58px;
  min-height: 32px;
  padding: 0 4px;
  font: inherit;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  background: rgba(255, 255, 255, 0.9);
}
.metronome-hint { font-size: 13px; color: var(--ink-muted); }
.session .metronome-dots i { width: 16px; height: 16px; }
.session .metronome-dots i:first-child { width: 22px; height: 22px; }
