/* ==========================================================================
   MasterComp — styles communs (outil + guides)
   Mobile first, thème sombre par défaut, thème clair via [data-theme="light"]
   ========================================================================== */

/* --- Variables : thème sombre (par défaut) --- */
:root {
  --fond: #0d0f13;
  --surface: #161920;
  --surface-2: #1e222b;
  --bordure: #2a2f3a;
  --texte: #e8eaef;
  --texte-doux: #9aa1b0;
  --accent: #3ddc97;
  --accent-fort: #2bbd7f;
  --accent-texte: #06281a;
  --alerte: #ffb020;
  --danger: #ff5c5c;
  --onde: #3ddc97;
  --onde-inactive: #4a5263;
  --boucle: rgba(61, 220, 151, 0.14);
  --tete: #ffffff;

  --rayon: 12px;
  --rayon-petit: 8px;
  --largeur: 1080px;
  --transport-h: 72px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --police-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

/* --- Thème clair (choix système si l'utilisateur n'a rien forcé) --- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --fond: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --bordure: #d9dee6;
    --texte: #141821;
    --texte-doux: #5a6272;
    --accent: #0f9d63;
    --accent-fort: #0b844f;
    --accent-texte: #ffffff;
    --alerte: #b26b00;
    --danger: #d12f2f;
    --onde: #0f9d63;
    --onde-inactive: #a9b1be;
    --boucle: rgba(15, 157, 99, 0.12);
    --tete: #141821;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --fond: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --bordure: #d9dee6;
  --texte: #141821;
  --texte-doux: #5a6272;
  --accent: #0f9d63;
  --accent-fort: #0b844f;
  --accent-texte: #ffffff;
  --alerte: #b26b00;
  --danger: #d12f2f;
  --onde: #0f9d63;
  --onde-inactive: #a9b1be;
  --boucle: rgba(15, 157, 99, 0.12);
  --tete: #141821;
  color-scheme: light;
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.6 var(--police);
}
a { color: var(--accent); }
a:hover { color: var(--accent-fort); }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lien-evitement:not(:focus) { position: absolute; left: -9999px; }
.lien-evitement:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; margin: 0; clip: auto;
  padding: 8px 12px; background: var(--accent); color: var(--accent-texte); z-index: 20; border-radius: var(--rayon-petit);
}
.conteneur { max-width: var(--largeur); margin: 0 auto; padding: 0 16px; }
kbd {
  font-family: var(--police-mono); font-size: .8em; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--bordure); border-bottom-width: 2px; background: var(--surface-2); color: var(--texte);
}
.aide-clavier summary { cursor: pointer; color: var(--accent); }
.aide-clavier p { margin: 8px 0 0; line-height: 2; }

/* --- En-tête --- */
.entete { border-bottom: 1px solid var(--bordure); background: var(--surface); }
.entete .conteneur { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.marque {
  display: flex; align-items: center; gap: 10px;
  color: var(--texte); text-decoration: none; font-weight: 700; font-size: 1.1rem;
}
.marque img { width: 32px; height: 32px; border-radius: 8px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--texte-doux); text-decoration: none; font-size: .9rem;
  padding: 6px 10px; border-radius: var(--rayon-petit);
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--texte); background: var(--surface-2); }
.nav .lien-pro { color: var(--accent); font-weight: 600; }
.nav .masque-mobile { display: none; }
.bouton-theme {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--bordure); border-radius: var(--rayon-petit);
  background: var(--surface-2); color: var(--texte); cursor: pointer;
}
.bouton-theme svg { width: 18px; height: 18px; fill: currentColor; }

/* --- Hero --- */
.hero { padding-top: 28px; padding-bottom: 12px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--texte-doux); max-width: 680px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding: 0; list-style: none; }
.badges li {
  font-size: .8rem; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--bordure); color: var(--texte-doux);
}

/* --- Outil : pistes --- */
.outil { padding-top: 12px; padding-bottom: 24px; }
.barre-outil {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  margin-bottom: 12px; font-size: .9rem; color: var(--texte-doux);
}
.interrupteur { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--texte); }
.interrupteur input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interrupteur .piste-switch {
  width: 38px; height: 22px; border-radius: 999px; background: var(--bordure);
  position: relative; transition: background .2s; flex: none;
}
.interrupteur .piste-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.interrupteur input:checked + .piste-switch { background: var(--accent); }
.interrupteur input:checked + .piste-switch::after { transform: translateX(16px); }
.interrupteur input:focus-visible + .piste-switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.barre-outil .aide-clavier { margin-left: auto; }
.bouton-lien {
  background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}

.pistes { display: grid; gap: 10px; }
/* Réserve la place des 4 pistes avant leur création en JS (évite le décalage de mise en page / CLS) */
.pistes:empty { min-height: 606px; }
.piste {
  position: relative;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon);
  padding: 10px; display: grid; gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.piste.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.piste.survol { border-style: dashed; border-color: var(--accent); }
.piste-tete { display: flex; align-items: center; gap: 10px; min-width: 0; }
.piste-num {
  flex: none; width: 30px; height: 30px; border-radius: var(--rayon-petit);
  display: grid; place-items: center; font-weight: 700; font-family: var(--police-mono);
  background: var(--surface-2); color: var(--texte-doux); border: 1px solid var(--bordure);
  cursor: pointer; padding: 0; font-size: .95rem;
}
.piste.active .piste-num { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.piste-nom {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: .95rem;
}
.piste-nom.vide { color: var(--texte-doux); font-weight: 400; }
.bouton-icone {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--bordure); border-radius: var(--rayon-petit);
  background: transparent; color: var(--texte-doux); cursor: pointer;
}
.bouton-icone:hover { color: var(--texte); background: var(--surface-2); }
.bouton-icone svg { width: 16px; height: 16px; fill: currentColor; }

/* Zone de dépôt (piste vide) */
.depot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 84px; border: 1.5px dashed var(--bordure); border-radius: var(--rayon-petit);
  color: var(--texte-doux); font-size: .9rem; text-align: center; cursor: pointer; padding: 8px;
}
.depot:hover { border-color: var(--accent); color: var(--texte); }
.depot strong { color: var(--accent); font-weight: 600; }
.depot small { font-size: .75rem; }

/* Forme d'onde */
.onde {
  position: relative; height: 84px; border-radius: var(--rayon-petit);
  background: var(--surface-2); overflow: hidden; cursor: crosshair; touch-action: none;
}
.onde canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.onde .chargement {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--texte-doux); font-size: .85rem;
}

/* Mesures */
.mesures {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  margin: 0; font-size: .8rem;
}
.mesure { background: var(--surface-2); border-radius: var(--rayon-petit); padding: 5px 8px; min-width: 0; }
.mesure dt { color: var(--texte-doux); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.mesure dd { margin: 0; font-family: var(--police-mono); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mesure.alerte dd { color: var(--alerte); }
.mesure.danger dd { color: var(--danger); }

/* --- Barre de transport (fixée en bas) --- */
.transport {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.transport .conteneur { display: flex; align-items: center; gap: 10px; min-height: var(--transport-h); }
.bouton-transport {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--bordure); background: var(--surface-2);
  color: var(--texte); cursor: pointer;
}
.bouton-transport svg { width: 20px; height: 20px; fill: currentColor; }
.bouton-transport.principal { width: 52px; height: 52px; background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.bouton-transport.principal:hover { background: var(--accent-fort); }
.bouton-transport[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.bouton-transport:disabled { opacity: .4; cursor: not-allowed; }
.transport .zone-temps { margin-left: auto; display: flex; align-items: center; gap: 16px; min-width: 0; }
.temps {
  font-family: var(--police-mono); font-variant-numeric: tabular-nums; font-size: .9rem;
  margin-left: auto; text-align: right; line-height: 1.3;
}
.temps small { display: block; color: var(--texte-doux); font-size: .75rem; }
.ecoute-actuelle { display: none; color: var(--texte-doux); font-size: .85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecoute-actuelle strong { color: var(--texte); }

/* --- Contenu éditorial --- */
.bandeau-pro {
  margin: 8px 0 32px; padding: 18px; border-radius: var(--rayon);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface));
  border: 1px solid var(--bordure);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
}
.bandeau-pro p { margin: 0; flex: 1 1 280px; }
.bouton {
  display: inline-block; padding: 10px 18px; border-radius: var(--rayon-petit);
  background: var(--accent); color: var(--accent-texte); text-decoration: none; font-weight: 600;
  border: 0; cursor: pointer; font: 600 1rem var(--police);
}
.bouton:hover { background: var(--accent-fort); color: var(--accent-texte); }

.contenu { padding-bottom: 40px; }
.contenu h2 { font-size: 1.45rem; line-height: 1.3; margin: 40px 0 12px; letter-spacing: -0.01em; }
.contenu h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.contenu p, .contenu li { color: var(--texte); }
.contenu .chapo { font-size: 1.1rem; color: var(--texte-doux); }
.etapes { display: grid; gap: 12px; padding: 0; list-style: none; counter-reset: etape; }
.etapes li {
  counter-increment: etape; background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); padding: 14px 14px 14px 56px; position: relative;
}
.etapes li::before {
  content: counter(etape); position: absolute; left: 14px; top: 14px;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-texte); font-weight: 700; font-size: .9rem;
}
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.tableau th, .tableau td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
.tableau th { color: var(--texte-doux); font-weight: 600; }
.faq details {
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon);
  padding: 12px 14px; margin-bottom: 8px;
}
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; color: var(--texte-doux); }
.encadre {
  border-left: 3px solid var(--accent); background: var(--surface);
  padding: 12px 16px; border-radius: 0 var(--rayon-petit) var(--rayon-petit) 0;
}
.fil-ariane { font-size: .85rem; color: var(--texte-doux); padding-top: 20px; }
.fil-ariane a { color: var(--texte-doux); }

/* --- Formulaire (page Pro) --- */
.formulaire { display: grid; gap: 12px; max-width: 480px; }
.formulaire label { font-weight: 600; font-size: .9rem; }
.formulaire input[type="email"], .formulaire select {
  width: 100%; padding: 11px 12px; border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure); background: var(--surface); color: var(--texte); font: inherit;
}
.formulaire .erreur { color: var(--danger); font-size: .85rem; margin: 0; }
.formulaire .piege { position: absolute; left: -9999px; }
.message { padding: 12px 14px; border-radius: var(--rayon-petit); border: 1px solid var(--bordure); }
.message.ok { border-color: var(--accent); }
.message.ko { border-color: var(--danger); }

/* --- Pied de page --- */
.pied {
  border-top: 1px solid var(--bordure); padding: 24px 0;
  font-size: .85rem; color: var(--texte-doux);
}
.pied .conteneur { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.pied a { color: var(--texte-doux); }
.pied a:hover { color: var(--texte); }
body.avec-transport .pied { padding-bottom: calc(var(--transport-h) + 24px + env(safe-area-inset-bottom)); }

/* --- Écrans plus larges --- */
@media (min-width: 640px) {
  .mesures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav .masque-mobile { display: inline-block; }
  .ecoute-actuelle { display: block; }
  .temps { margin-left: 0; }
}
@media (min-width: 900px) {
  .piste { grid-template-columns: 260px 1fr; grid-template-rows: auto 1fr; column-gap: 14px; }
  .piste-tete { grid-column: 1; }
  .mesures { grid-column: 1; grid-row: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: end; }
  .onde, .depot { grid-column: 2; grid-row: 1 / span 2; height: 100%; min-height: 104px; }
  .pistes:empty { min-height: 534px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- Titres des pages éditoriales --- */
.contenu h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 12px; padding-top: 12px; }
.formulaire .case { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.formulaire .case input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
/* Largeur de lecture confortable pour les textes longs */
article.contenu { max-width: 820px; }

/* --- Administration (/pro/admin/) --- */
.formulaire input[type="password"] {
  width: 100%; padding: 11px 12px; border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure); background: var(--surface); color: var(--texte); font: inherit;
}
.form-inline { display: inline; margin: 0; }
.bouton-lien.danger { color: var(--danger); }
.stats-admin { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.stats-admin .mesure { min-width: 140px; }
.stats-admin dd { font-size: 1.3rem; }
.tableau-admin td { vertical-align: middle; }
.code-copie {
  background: var(--surface-2); border: 1px solid var(--bordure); border-radius: var(--rayon-petit);
  padding: 12px; overflow-x: auto; font-family: var(--police-mono); font-size: .85rem;
}
