:root {
  /* Palette Yellow Leaf Music : fond blanc, ambre du logo et déclinaisons */
  --bg: #ffffff;
  --card: #fff6e3;
  --card-2: #fde7b3;
  --line: #f3d78c;
  --text: #1a1408;
  --muted: #6f5f3c;
  --accent: #fdb833;
  --accent-hover: #f0a514;
  --accent-ink: #1a1408;
  --accent-2: #946000;
  --ok: #2a8a4a;
  --bad: #c8402e;
  --radius: 16px;
  --gutter: max(16px, env(safe-area-inset-left));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--gutter);
  max-width: 960px; margin: 0 auto;
}
.brand { font-size: 1.3rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; font-size: 1.3rem; }

main { max-width: 960px; margin: 0 auto; padding: 0 var(--gutter) 32px; }
.lead { color: var(--muted); margin: 4px 0 20px; }

/* Modes */
.modes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mode {
  display: flex; gap: 14px; align-items: center; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-height: 84px; color: var(--text);
  transition: border-color .15s, transform .1s;
}
.mode:hover { border-color: var(--accent); }
.mode:active { transform: scale(.98); }
.mode-icon { font-size: 2rem; }
.mode-title { font-weight: 700; font-size: 1.1rem; display: block; }
.mode-desc { color: var(--muted); font-size: .9rem; }
.mode-best { color: var(--accent-2); font-size: .8rem; }

/* Boutons */
.primary, .secondary, .ghost {
  border: 0; border-radius: 12px; padding: 12px 20px; min-height: 48px; font-weight: 600;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--card-2); }
.ghost { background: transparent; color: var(--muted); }
.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .4; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 16px 0; }

/* Session */
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.session-title { font-weight: 700; }
.score { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 6px 16px; font-weight: 700; min-width: 64px; text-align: center; }
.stage {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 24px 16px;
  text-align: center; min-height: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.qcount { color: var(--muted); font-size: .9rem; }
.instrument { font-size: 1rem; color: var(--accent-2); min-height: 1.5em; }
.phase { font-size: 1.5rem; font-weight: 700; }
.countdown { font-size: clamp(4rem, 18vw, 7rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.phase.listen { color: var(--ok); }
.phase.hear { color: var(--accent-2); }
.bar { width: min(420px, 100%); height: 8px; background: var(--card-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); }
.prompt { color: var(--muted); }
.targets { display: flex; gap: 10px; min-height: 22px; }
.dot { width: 20px; height: 20px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); transition: background .2s, transform .2s; }
.dot.on { background: var(--ok); transform: scale(1.15); }
.live { font-size: 1.8rem; font-weight: 700; min-height: 2.4rem; color: var(--accent-2); }
.meter { width: min(240px, 60%); height: 6px; background: var(--card-2); border-radius: 3px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--ok); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform .05s linear; }
.feedback { font-size: 1.2rem; font-weight: 600; min-height: 3.2em; max-width: 36em; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.feedback small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }

/* Grille rythmique */
.rhythm-grid { display: grid; gap: 4px; width: 100%; max-width: 640px; }
.rhythm-grid .cell { aspect-ratio: 1; border-radius: 6px; background: var(--card-2); }
.rhythm-grid .cell.beat { background: #f3cf7e; }
.rhythm-grid .cell.exp { background: #1a1408; }
.rhythm-grid .cell.hit { background: var(--ok); }
.rhythm-grid .cell.miss { background: var(--bad); }
.rhythm-grid .cell.now { outline: 3px solid var(--accent-2); }

/* Soutien */
.support { background: linear-gradient(135deg, #fff1cc, #fdd88a); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 28px; }
.support h2 { margin: 0 0 4px; font-size: 1.15rem; }
.support p { margin: 0 0 12px; color: var(--muted); }
.support iframe { width: 100%; height: 560px; border: 0; border-radius: 12px; background: #fff; }
.support-link { display: inline-block; padding: 10px 18px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.support-link:hover { background: var(--accent-hover); }
.support-placeholder { border: 2px dashed #c9962e; border-radius: 12px; padding: 28px 16px; text-align: center; color: var(--muted); }

/* Fin */
.end-card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 32px 16px; text-align: center; margin-top: 8px; }
.end-score { font-size: 3.5rem; font-weight: 800; }
.end-best { color: var(--accent-2); min-height: 1.5em; }

/* Réglages */
dialog { border: 0; border-radius: 20px; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: 90dvh; padding: 0; }
dialog::backdrop { background: #1a140866; }
.settings-form { padding: 20px; }
.settings-form h2 { margin-top: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 8px 14px 12px; }
legend { padding: 0 6px; color: var(--accent-2); font-weight: 700; }
label { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
label.check { justify-content: flex-start; }
input[type=number], select { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 8px 10px; min-height: 40px; }
input[type=number] { width: 90px; text-align: center; }
input[type=range] { width: 50%; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.group-label { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; user-select: none; border: 2px solid transparent; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { border-color: var(--accent-hover); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent-2); }
.chip { justify-content: flex-start; }

@media (max-width: 520px) {
  .stage { min-height: 380px; padding: 16px 8px; }
  .support iframe { height: 520px; }
  label { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Accueil par familles */
.group-title { font-size: 1.1rem; margin: 22px 0 4px; }
.group-title small { color: var(--muted); font-weight: 400; margin-left: 8px; }

/* Réponses à choix */
.answer-panel { width: 100%; max-width: 680px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; width: 100%; }
.choice { min-height: 56px; font-size: 1.05rem; padding: 8px 6px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--text); font-weight: 600; }
.choice:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--card-2); }
.choice.sel { background: var(--accent); border-color: var(--accent-hover); color: var(--accent-ink); }
.choice.good { background: var(--ok); border-color: var(--ok); color: #fff; opacity: 1; }
.choice.bad { background: var(--bad); border-color: var(--bad); color: #fff; opacity: 1; }
.choice:disabled { cursor: default; opacity: .55; }
