/* === Police système moderne === */
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

    :root {
      color-scheme: light dark;
    }

    html,
    body {
      height: 100%;
      margin: 0;
    }

    body {
      background: Canvas;
      color: CanvasText;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 2;
      display: flex;
      align-items: center;
      gap: .75rem;
      flex-wrap: wrap;
      padding: .6rem .75rem;
      background: color-mix(in oklab, Canvas, CanvasText 4%);
      border-bottom: 1px solid #8883;
    }

    .title {
      font-weight: 600;
      opacity: .9;
    }

    .spacer {
      flex: 1;
    }

    label,
    input,
    select {
      font-size: 14px;
    }

    #zoomVal {
      min-width: 3ch;
      display: inline-block;
      text-align: right;
    }

    .page {
      padding: 1rem clamp(.75rem, 3vw, 2rem);
    }

    /* Zone texte globale */
    #band-lyrics {
      --chord-color: currentColor;
      font-size: clamp(18px, 2.6vh, 22px);
      line-height: 1.42;
      white-space: normal;
    }

    /* Bloc de section : espace ENTRE parties même si titres masqués */
    .secBlock {
      margin-top: 0.9rem;
    }

    .secBlock:first-child {
      margin-top: 0;
    }

    /* Titre de section */
    .secTitle {
      margin: 0 0 .25rem 0;
      font-weight: 700;
      color: CanvasText;
      font-size: 0.95rem;
      letter-spacing: .01em;
      margin-left: -0.4rem;
    }

    /* Corps de section */
    .secBody {
      margin: 0;
      padding-left: .4rem;
    }

    /* Lignes accords/paroles */
    .lineMono {
      margin: .08rem 0;
    }

    .lineMono .chRowMono,
    .lineMono .lyRowMono {
      display: block;
      white-space: pre !important;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace !important;
      line-height: 1.15;
    }

    .lineMono .chRowMono {
      color: var(--chord-color);
    }

    /* Rangée "accords capo" (mode capo + option "accords originaux" activée) :
       teinte complémentaire (rotation de 180° sur le cercle chromatique) de la couleur
       d'accord choisie, pour rester nettement distincte de la rangée "accords originaux". */
    .lineMono .chRowCapoDim {
      color: var(--chord-color);
      filter: hue-rotate(180deg) saturate(1.3);
    }

    .chord-bold .chRowMono {
      font-weight: 700;
    }

    .chord-italic .chRowMono {
      font-style: italic;
    }

    /* Compact pour Band */
    #band-lyrics.compact .secBlock {
      margin-top: .5rem;
    }

    #band-lyrics.compact .secTitle {
      margin-bottom: .16rem;
      font-size: 0.9rem;
    }

    #band-lyrics.compact .lineMono {
      margin: .03rem 0;
    }

    #band-lyrics.compact .lineMono .chRowMono,
    #band-lyrics.compact .lineMono .lyRowMono {
      line-height: 1.08;
    }

    .light body,
    .light html {
      background: #fff;
      color: #111;
    }

    /* Masquer par défaut ce qui est réservé à l'impression */
    .print-only {
      display: none;
    }

    /* Footer infos — style Chantre */
    .band-footer {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: 8px;
      font-size: clamp(10px, 2vh, 14px);
      font-style: italic;
      opacity: .85;
      text-align: right;
      color: #444;
      text-align: right;
      background: transparent;
      border: none;
      padding: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* === Mode projecteur Band (barrette à gauche de chaque section) === */
    body.band-proj-on #band-lyrics .secBlock {
      position: relative;
      padding-left: 20px;
    }

    body.band-proj-on #band-lyrics .secBlock .proj-handle {
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 20px;
      border-radius: 4px;
      background: color-mix(in oklab, CanvasText 10%, Canvas 90%);
      cursor: pointer;
      opacity: .6;
      transition: background .15s ease, opacity .15s ease, box-shadow .15s ease;
    }


    body.band-proj-on #band-lyrics .secBlock .proj-handle:hover,
    body.band-proj-on #band-lyrics .secBlock .proj-handle:focus-visible {
      opacity: 1;
      box-shadow: 0 0 0 2px color-mix(in oklab, Highlight 50%, Canvas 50%);
      outline: none;
    }

    body.band-proj-on #band-lyrics .secBlock .proj-handle.live {
      background: color-mix(in oklab, #18a418 85%, Canvas 15%);
      opacity: 1;
    }

    /* Ajustement quand un titre est présent (comme Directeur) */
    body.band-proj-on #band-lyrics .secBlock.has-title .proj-handle {
      top: 1.2rem;
      border-top-left-radius: 0;
      border-top-right-radius: 0;
    }

    body.band-proj-on #band-lyrics .secBlock:not(.has-title) .proj-handle {
      top: 0;
    }

    /* Optionnel : fond léger sur la section live */
    body.band-proj-on #band-lyrics .secBlock.sec-live {
      background: color-mix(in oklab, Highlight 8%, Canvas 92%);
      border-radius: .35rem;
    }

    .toggle-btn {
      background: #eee;
      color: #222;
      border: 1px solid #ccc;
      border-radius: 4px;
      padding: 4px 10px;
      cursor: pointer;
      font-weight: 500;
      transition: all 0.15s;
    }

    .toggle-btn:hover {
      background: #ddd;
    }

    .toggle-btn.active {
      background: #007bff;
      color: #fff;
      border-color: #007bff;
    }

    .toggle-btn .icon {
      margin-right: .35rem;
      font-size: 1.05em;
      line-height: 1;
    }

    /* --- Mode capo (local, indépendant du Directeur) --- */
    .toggle-btn.capo-active {
      background: #ffb300;
      color: #1a1a1a;
      border-color: #cc8f00;
      font-weight: 700;
    }

    .capo-wrap {
      position: relative;
      display: inline-block;
    }

    .capo-popup {
      position: absolute;
      top: 100%;
      left: 0;
      z-index: 50;
      margin-top: .3rem;
      background: Canvas;
      color: CanvasText;
      border: 1px solid #8884;
      border-radius: .6rem;
      box-shadow: 0 6px 24px #0004;
      padding: .6rem;
      min-width: 220px;
    }

    .capo-frets {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: .35rem;
    }

    .capo-fret-btn {
      padding: .35rem .5rem;
      border: 1px solid #ccc;
      border-radius: 4px;
      background: #eee;
      color: #222;
      cursor: pointer;
    }

    .capo-fret-btn:hover {
      background: #ddd;
    }

    .capo-fret-btn.active {
      background: #ffb300;
      color: #1a1a1a;
      border-color: #cc8f00;
      font-weight: 700;
    }

    /* Légende des couleurs d'accords (visible seulement quand les 2 rangées sont affichées) :
       sans elle, on perd vite la correspondance entre couleur et rangée (originaux vs capo). */
    .capo-legend {
      display: inline-flex;
      align-items: center;
      gap: .3rem;
      margin-left: .4rem;
      font-size: .82rem;
      opacity: .85;
      white-space: nowrap;
    }

    .capo-legend[hidden] {
      display: none;
    }

    .capo-legend-dot {
      display: inline-block;
      width: .6rem;
      height: .6rem;
      border-radius: 50%;
      background: var(--chord-color, currentColor);
      margin-right: -.1rem;
    }

    .capo-legend-capo {
      filter: hue-rotate(180deg) saturate(1.3);
    }

    .band-pip {
      position: fixed;
      right: 0.9rem;
      top: 3.3rem;
      /* juste sous la topbar band */
      z-index: 30;
      max-width: 42ch;
      padding: 0.6rem 0.8rem;
      border-radius: 0.8rem;
      border: 1px solid #0003;
      background: color-mix(in oklab, Canvas 92%, CanvasText 8%);
      box-shadow: 0 6px 24px #0006;
      font-size: 0.8rem;
    }

    .band-pip h4 {
      margin: 0 0 0.25rem;
      font-size: 0.85rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      opacity: 0.8;
    }

    .band-pip-meta {
      font-size: 0.8rem;
      opacity: 0.9;
      margin-bottom: 0.35rem;
    }

    .band-pip-lines {
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
    }

    .band-pip-line-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      opacity: 0.7;
      margin-bottom: 0.05rem;
    }

    /* Réduire un peu les lignes acc/chants dans le PIP */
    .band-pip .lineMono {
      font-size: 0.8rem;
      margin: 0;
    }

    /* Pas de PIP à l'impression */
    @media print {
      .band-pip {
        display: none !important;
      }
    }


    /* Impression */
    @media print {
      @page {
        margin: 12mm;
      }

      .topbar {
        display: none !important;
      }

      html,
      body {
        background: #fff !important;
        color: #000 !important;
        height: auto;
      }

      .page {
        min-height: auto !important;
        padding: 0 !important;
      }

      #band-lyrics {
        font-size: 12pt !important;
        line-height: 1.35;
        margin: 0 0 8mm 0;
      }

      /* Grand titre centré en haut */
      .print-only {
        display: block !important;
      }

      .print-title {
        text-align: center;
        font-weight: 800;
        font-size: 18pt;
        margin: 0 0 8mm 0;
      }

      /* Footer dans le flux */
      .band-footer {
        position: static;
        margin-top: 0;
        text-align: right;
        background: transparent;
        border: none;
        padding: 0;
        font-size: 11pt;
        color: #444;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .secBlock {
        page-break-inside: avoid;
      }
    }

/* === Impression avec préservation des styles === */
@media print {
  @page {
    margin: 12mm;
    size: A4 portrait;
  }

  /* Masquer les UI */
  .topbar,
  .band-pip {
    display: none !important;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    height: auto;
  }

  .page {
    padding: 0 !important;
  }

  /* Titre d'impression */
  .print-only {
    display: block !important;
  }

  .print-title {
    text-align: center;
    font-weight: 800;
    font-size: 18pt;
    margin: 0 0 8mm 0;
  }

  /* CRITIQUE : Préserver les couleurs et styles des accords */
  .lineMono .chRowMono {
    color: var(--chord-color) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .chord-bold .chRowMono {
    font-weight: 700 !important;
  }

  .chord-italic .chRowMono {
    font-style: italic !important;
  }

  /* Typographie */
  #band-lyrics {
    font-size: 12pt !important;
    line-height: 1.35;
    margin: 0 0 8mm 0;
  }

  /* Footer dans le flux */
  .band-footer {
    position: static !important;
    margin-top: 0;
    text-align: right;
    font-size: 11pt;
    color: #444;
  }

  /* Éviter les coupures */
  .secBlock {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .lineMono {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* ========================================
   MODE GRILLE POUR LA VUE BAND - VERSION SIMPLE (comme Director)
   À ajouter à la fin de band.css
   ======================================== */

/* ✅ RÈGLE DE BASE ESSENTIELLE */
#band-lyrics {
  --chord-color: currentColor;
  font-size: clamp(18px, 2.6vh, 22px);
  line-height: 1.42;
  white-space: normal;
}

/* conteneur d'un chant */
#band-lyrics.song {
  display: block;
}

/* verticale (liste) */
#band-lyrics.song.list {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

/* grille responsive (auto-fit, min 320px) */
#band-lyrics.song.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: .9rem;
  align-items: start;
}

/* Permet aux tuiles de rétrécir même avec des lignes en white-space:pre */
#band-lyrics.song.grid>.secBlock,
#band-lyrics.song.grid>.secBlock .secBody {
  min-width: 0;
}

/* ✅ Style simple des sections - PAS de bordures ni fond */
.secBlock {
  margin: .1rem 0;
}

.secTitle {
  margin: 0 0 .25rem -0.4rem;
  font-weight: 700;
}

.secBody {
  padding-left: .4rem;
}

/* Masquer l'overflow horizontal */
#band-lyrics.song.grid .lineMono {
  overflow-x: hidden;
  text-overflow: clip;
}

/* Si une section est trop large, elle s'étend sur toute la ligne de la grille */
#band-lyrics.song.grid>.secBlock.wide {
  grid-column: 1 / -1;
}

/* Étendre une section sur 2 colonnes (moyennement large) */
#band-lyrics.song.grid>.secBlock.span-2 {
  grid-column: span 2;
}

/* Étendre une section sur toute la ligne (très large) */
#band-lyrics.song.grid>.secBlock.span-all {
  grid-column: 1 / -1;
}

/* ===== Bouton partition dans la topbar ===== */
.band-sheet-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.3rem;
  padding: .2rem .4rem;
  color: inherit;
}
.band-sheet-btn:hover { opacity: .7; }

/* ===== Modale partition PDF ===== */
.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-modal[hidden] { display: none; }
.sheet-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  cursor: pointer;
}
.sheet-modal-box {
  position: relative;
  z-index: 1;
  width: 90vw;
  height: 90vh;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sheet-modal-close-btn {
  position: absolute;
  top: .4rem;
  right: .6rem;
  z-index: 2;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}
.sheet-modal-close-btn:hover { background: rgba(0,0,0,.8); }
.sheet-modal-box iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ===== Menu Réglages flottant ===== */
.settings-btn {
  position: relative;
}

.settings-panel {
  position: fixed;
  z-index: 100;
  min-width: 230px;
  padding: .6rem .75rem;
  background: color-mix(in oklab, Canvas, CanvasText 5%);
  border: 1px solid #8884;
  border-radius: .6rem;
  box-shadow: 0 6px 20px #0003;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.settings-panel[hidden] { display: none; }

.settings-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.settings-row label {
  display: flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  white-space: nowrap;
}

.settings-row--slider label {
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  width: 100%;
}

.settings-slider-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
}

.settings-slider-wrap input[type="range"] {
  flex: 1;
}

.settings-slider-wrap span {
  min-width: 3.5ch;
  text-align: right;
  font-size: .85em;
  opacity: .8;
}

/* Séparateur avec label de groupe */
.settings-separator {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .2rem 0 .1rem;
}

.settings-separator::before,
.settings-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #8882;
}

.settings-separator:empty::after {
  display: none;
}

.settings-group-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .55;
  white-space: nowrap;
}

/* Boutons du drawer mobile : masqués par défaut (bureau) */
.mobile-menu-btn,
.mobile-menu-close {
  display: none;
}

/* ========================================
   MODE SMARTPHONE : drawer plein écran + paroles/accords maximisés
   ======================================== */
@media (max-width: 600px), (max-height: 600px) {
  /* Empêche les lignes monospace (accords/paroles) trop longues d'élargir
     toute la page : elles défilent horizontalement dans leur propre zone. */
  html, body {
    overflow-x: hidden;
  }
  #band-lyrics {
    overflow-x: auto;
  }

  /* Bouton ☰ flottant, toujours visible (sauf drawer ouvert) */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 60;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 1px solid #8886;
    background: color-mix(in oklab, Canvas, CanvasText 6%);
    color: CanvasText;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    opacity: .85;
  }
  body.mobile-menu-open .mobile-menu-btn {
    display: none;
  }

  /* Topbar masquée par défaut, devient le drawer "Menu" une fois ouverte */
  body:not(.mobile-menu-open) .topbar {
    display: none;
  }
  body.mobile-menu-open .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    inset: 0;
    z-index: 200;
    height: 100vh;
    overflow-y: auto;
    padding: 3rem 1rem 1rem;
    gap: .6rem;
    background: Canvas;
  }
  body.mobile-menu-open .topbar > * {
    width: 100%;
  }
  body.mobile-menu-open .topbar .spacer {
    display: none;
  }

  body.mobile-menu-open .mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: .6rem;
    right: .6rem;
    z-index: 260;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 1px solid #8886;
    background: Canvas;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
  }

  /* Panneaux flottants (Réglages / Capo) repris dans le flux du drawer */
  body.mobile-menu-open .settings-panel,
  body.mobile-menu-open .capo-popup {
    position: static !important;
    width: 100%;
    margin-top: .5rem;
    box-sizing: border-box;
    inset: auto !important;
  }

  /* Maximiser l'espace pour les paroles/accords (3.4rem de marge en haut pour ne pas passer sous le bouton ☰) */
  .page {
    padding: 3.4rem .6rem 2.2rem;
  }
  #band-lyrics {
    font-size: clamp(20px, 4.2vw, 26px);
  }
  /* Forcer l'affichage en liste verticale, même si la grille est sélectionnée */
  #band-lyrics.song.grid {
    display: flex;
    flex-direction: column;
  }

  /* PIP "prochain chant" repositionné/réduit (pas de topbar visible au-dessus) */
  .band-pip {
    left: .6rem;
    right: .6rem;
    top: 3.4rem;
    width: auto;
    max-width: none;
    max-height: 35vh;
    overflow-y: auto;
    box-sizing: border-box;
    font-size: .75rem;
  }
}
