:root {
  --bg: #F2EDE2;
  --surface: #FBF7EE;
  --surface-elevated: #F7F0E0;
  --text: #1F1A12;
  --text-muted: #6B5D49;
  --text-faint: #A19378;
  --accent: #B8521A;
  --accent-soft: #EFDCC2;
  --border: #D9CAB1;
  --border-strong: #B5A284;
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Schibsted Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-width: 260px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* === App shell : grid 2 colonnes === */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease-out;
}
body:not(.sidebar-open) .app-shell {
  grid-template-columns: 0 1fr;
}

/* === Sidebar === */
.sidebar {
  background: var(--surface-elevated);
  border-right: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease-out, opacity 0.2s;
}
body:not(.sidebar-open) .sidebar {
  transform: translateX(-100%);
  pointer-events: none;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 18px 16px 56px;
  border-bottom: 0.5px solid var(--border);
}
.sidebar-header h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}
.new-song-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.new-song-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.song-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  flex: 1;
  overflow-y: auto;
}
.song-item {
  display: flex;
  align-items: stretch;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.song-item:hover { background: rgba(184, 82, 26, 0.04); }
.song-item.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.song-item-main {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-ui);
  min-width: 0;
}
.song-item-main:hover { color: var(--text); border: none; }
.song-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-item.active .song-item-title { color: var(--accent); }
.song-item-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.song-item-delete {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  padding: 0 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  font-family: var(--font-ui);
}
.song-item:hover .song-item-delete,
.song-item.active .song-item-delete { opacity: 0.5; }
.song-item-delete:hover {
  opacity: 1 !important;
  color: var(--accent);
  border: none;
}
@media (hover: none) {
  /* Écrans tactiles : ✕ toujours visible, sinon il est introuvable */
  .song-item-delete { opacity: 0.45; }
}

/* === Main area === */
.main-area {
  padding: 0 32px calc(96px + env(safe-area-inset-bottom));
  min-width: 0; /* permet au grid de respecter la largeur */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.5) 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(184,82,26,0.04) 0%, transparent 60%);
}
.container { max-width: 940px; margin: 0 auto; padding-top: 28px; }

/* === Header principal === */
header.main {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 20px;
  margin-left: -32px;
  margin-right: -32px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-bottom: 10px;
  padding-left: 32px;
  padding-right: 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: #F2EDE2;
  transition: box-shadow 0.2s ease;
}
header.main.scrolled {
  box-shadow: 0 4px 12px rgba(42, 32, 26, 0.08);
}
.title-block {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  flex: 1;
}
.title-block h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 36px;
  line-height: 1;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.wordmark {
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.035em;
}
.wordmark .accent { color: var(--accent); }
/* === Titre du morceau en fade-in dans la sticky bar === */
.sticky-song-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 400px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  cursor: default;
}
.sticky-song-title.sticky-title-visible {
  opacity: 1;
}
.header-controls { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; flex: 0 0 auto; }
.control-group label {
  display: none;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
  font-weight: 500;
}
/* Compact controls scoped to sticky header */
header.main select {
  padding: 7px 24px 7px 10px;
  min-width: 110px;
  font-size: 13px;
  background-position: calc(100% - 10px) 50%, calc(100% - 6px) 50%;
}
header.main .seg-group button { padding: 7px 10px; font-size: 13px; }
header.main #print-btn {
  font-size: 0;
  width: 34px;
  padding: 7px;
  line-height: 1;
}
header.main #print-btn::before {
  content: '⎙';
  font-size: 16px;
  font-family: var(--font-ui);
  display: block;
}
/* === Champ titre du morceau === */
.song-title-bar {
  margin-bottom: 40px;
}
.song-title-input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.02em;
  padding: 8px 8px 18px 8px;
  margin-left: -4px;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
  outline: none;
}
.song-title-input:hover { border-bottom-color: var(--border); }
.song-title-input:focus { border-bottom-color: var(--accent); }
.song-title-input::placeholder { color: var(--text-faint); font-style: italic; }

/* === Form controls === */
select {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 9px 14px;
  cursor: pointer;
  min-width: 130px;
  transition: border-color 0.15s;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
select:hover { border-color: var(--accent); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,82,26,0.15); }
button {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }

/* === Segmented controls (mode, pentatonique) === */
.seg-group { display: inline-flex; }
.seg-group button {
  border-radius: 0;
  background: var(--surface);
  border-right: 0;
  padding: 9px 14px;
}
.seg-group button:first-child { border-radius: 2px 0 0 2px; }
.seg-group button:last-child { border-radius: 0 2px 2px 0; border-right: 1px solid var(--border-strong); }
.seg-group button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.seg-group button:not(.active):hover { background: var(--accent-soft); color: var(--text); border-color: var(--border-strong); }

/* === Sections === */
section.part { margin-bottom: 48px; }
section.part > header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--border);
  flex-wrap: wrap;
}
.part-collapse {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s, color 0.15s;
  align-self: center;
  border-radius: 3px;
}
.part-collapse:hover { color: var(--accent); border: none; }
section.part.is-collapsed .part-collapse { transform: rotate(-90deg); }
section.part.is-collapsed > header {
  border-bottom-style: dashed;
  margin-bottom: 0;
  padding-bottom: 16px;
}
section.part.is-collapsed { margin-bottom: 24px; }
section.part.is-collapsed .part-content { display: none; }
section.part h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  margin: 0;
  letter-spacing: -0.015em;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.roman-numeral {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.part-meta {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-width: 280px;
}
.part-progression {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  white-space: nowrap;
  flex-shrink: 0;
}
.part-actions { display: flex; gap: 8px; align-items: center; }
.part-actions select, .part-actions button {
  font-size: 12.5px;
  padding: 6px 12px;
  min-width: auto;
}
.part-actions select { padding-right: 24px; min-width: 140px; }
.part-actions button { background: transparent; }

/* === Chord cards === */
.chord-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.chord-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 3px;
  padding: 14px 8px 10px;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
  animation: chordIn 0.3s ease-out backwards;
  display: flex;
  flex-direction: column;
}
.chord-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.chord-card:nth-child(1) { animation-delay: 0ms; }
.chord-card:nth-child(2) { animation-delay: 45ms; }
.chord-card:nth-child(3) { animation-delay: 90ms; }
.chord-card:nth-child(4) { animation-delay: 135ms; }
@keyframes chordIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chord-degree {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--accent);
  letter-spacing: 0.18em;
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
}
.chord-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  margin-bottom: 8px;
  line-height: 1;
  letter-spacing: -0.01em;
}
.capo-shape {
  display: block;
  font-family: var(--font-ui);
  font-style: italic;
  font-size: 14px;
  font-weight: 400;
  color: var(--accent);
  margin-top: 3px;
}
.chord-card svg { width: 100%; max-width: 108px; height: auto; color: var(--text); display: block; margin: 0 auto; }
.chord-card svg text { font-family: var(--font-ui); }
.chord-card svg text.fret-num { font-family: var(--font-mono); }

/* === Variante piano : SVG plus large, chevrons plus courts === */
.chord-card-piano .chord-diagram svg { max-width: 190px; }
.chord-card-piano .voicing-nav { height: 60px; }
.chord-card-piano .voicing-nav-spacer { height: 60px; }

/* === Voicing nav === */
.voicing-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
}
.chord-diagram { flex: 0 1 auto; min-width: 0; }
.chord-diagram svg { max-width: 100px; }
.voicing-nav {
  flex: 0 0 auto;
  width: 16px;
  height: 100px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voicing-nav:hover {
  color: var(--accent);
  opacity: 1;
  transform: scale(1.25);
  border: none;
}
.voicing-nav-spacer { flex: 0 0 auto; width: 16px; }
.voicing-counter {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.15em;
  margin-top: 4px;
  text-align: center;
  opacity: 0.65;
}

/* === Lyrics === */
.lyrics-container { margin-top: 18px; }
.add-lyrics {
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
}
.add-lyrics:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.lyrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
}
.lyric-block {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 3px;
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s, border-color 0.15s, box-shadow 0.15s;
}
.lyric-block.dragging {
  opacity: 0.4;
  cursor: grabbing;
  transform: scale(0.98);
  transition: opacity 0.15s, transform 0.15s;
}
.lyric-block.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
  transition: outline 0.1s, background 0.1s;
}
.lyric-drag-handle {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  letter-spacing: -0.25em;
  padding-right: 8px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.lyric-drag-handle:hover {
  opacity: 1;
  color: var(--accent);
}
.lyric-block:hover .lyric-drag-handle { opacity: 0.8; }
.lyric-block.dragging .lyric-drag-handle { cursor: grabbing; }
.lyric-drag-handle:active,
.lyric-drag-handle.is-grabbing {
  color: var(--accent);
  transform: scale(1.3);
  opacity: 1 !important;
}
.lyric-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border);
}
.lyric-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.lyric-actions { display: flex; gap: 4px; }
.lyric-actions button {
  font-size: 10.5px;
  padding: 4px 9px;
  background: transparent;
  border: 0.5px solid var(--border);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.lyric-actions button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.lyric-edit {
  width: 100%;
  min-height: 130px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  background: transparent;
  border: none;
  color: var(--text);
  resize: vertical;
  padding: 4px 0;
  outline: none;
}
.lyric-edit::placeholder { color: var(--text-faint); font-style: italic; }
.lyric-preview {
  min-height: 130px;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 2.4;
  padding: 4px 0;
}
.lyric-preview:empty::before {
  content: 'Aperçu vide — bascule en édition pour écrire';
  color: var(--text-faint);
  font-style: italic;
  font-size: 13px;
  font-family: var(--font-ui);
}
.cp-line { display: block; margin-bottom: 0.2em; }
.cp-line:empty { height: 1.5em; }
.cp-seg { display: inline-block; vertical-align: top; }
.cp-chord {
  display: block;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.7em;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.3em;
  height: 1.3em;
  min-width: 0.5em;
}
.cp-lyric { display: block; white-space: pre; }
.add-lyric-col {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-radius: 3px;
  min-height: 100px;
  cursor: pointer;
  transition: all 0.15s;
}
.add-lyric-col:hover { color: var(--accent); border-color: var(--accent); }

/* === Mode libre === */
.free-mode-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.free-chord-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 10px 14px;
  outline: none;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.free-chord-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,82,26,0.15);
}
.free-chord-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
  letter-spacing: 0.1em;
}
.free-chord-hint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.part-progression--free {
  font-style: italic;
}
.free-degree {
  min-height: 14px; /* même hauteur que .chord-degree pour aligner les noms */
}
.chord-card--unknown {
  background: var(--surface-elevated);
  border-style: dashed;
  opacity: 0.8;
}
.chord-card--no-guitar .chord-diagram {
  opacity: 0.5;
}
.free-chord-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  padding: 28px 0;
  text-align: center;
  letter-spacing: 0.12em;
  grid-column: 1 / -1;
}

/* === Scale === */
.scale-toggle { text-align: center; margin: 56px 0 24px; }
.scale-toggle button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  transition: all 0.15s;
}
.scale-toggle button:hover { color: var(--accent); border-bottom-color: var(--accent); }
.scale-section {
  background: var(--surface);
  border: 0.5px solid var(--border);
  padding: 28px 32px 32px;
  border-radius: 3px;
  animation: scaleIn 0.3s ease-out;
}
.scale-section[hidden] { display: none; }
@keyframes scaleIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.scale-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.scale-header h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 26px;
  margin: 0;
}
.scale-notes {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}
.penta-toggle { margin-bottom: 18px; }
.penta-toggle .seg-group button { font-size: 11.5px; padding: 7px 12px; }
.scale-legend {
  display: flex;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.legend-dot.root { background: var(--accent); }
.legend-dot.scale { background: var(--accent-soft); border: 0.5px solid var(--border-strong); }
#fretboard svg { width: 100%; height: auto; color: var(--text); display: block; }
#fretboard svg text { font-family: var(--font-ui); }
#fretboard svg text.fret-label { font-family: var(--font-mono); }

/* === Bouton roue dentée (settings) === */
.settings-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-btn:hover { border-color: var(--accent); color: var(--accent); }
.settings-btn.is-open {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* === Settings backdrop === */
.settings-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 18, 0.4);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s;
}
body.settings-open .settings-backdrop {
  display: block;
  opacity: 1;
}

/* === Settings panel (slide-in depuis la droite) === */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: var(--surface-elevated);
  border-left: 0.5px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
}
body.settings-open .settings-panel {
  transform: translateX(0);
}
.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 18px 16px 24px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.settings-panel-header h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}
.settings-close-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.settings-close-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.settings-panel-body {
  flex: 1;
  overflow-y: auto;
}
.settings-section {
  padding: 20px 24px;
  border-bottom: 0.5px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section-title {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  margin: 0 0 14px;
}
.settings-section--future {
  opacity: 0.4;
  pointer-events: none;
}
.settings-section--future .settings-section-title {
  margin-bottom: 0;
}

/* === Footer === */
footer {
  text-align: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 0.5px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* === État "armed" du bouton suppression (1er clic = arme, 2e clic = confirme) === */
.song-item.delete-armed {
  background: rgba(184, 82, 26, 0.08);
}
.song-item.delete-armed .song-item-main { color: var(--text); }
.song-item.delete-armed .song-item-meta {
  color: var(--accent);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.05em;
  font-style: italic;
}
.song-item-delete.is-armed {
  opacity: 1 !important;
  color: var(--bg) !important;
  background: var(--accent);
  border-radius: 3px;
  margin: 6px 8px 6px 0;
  width: 24px;
  padding: 0;
  font-weight: 500;
}
.song-item-delete.is-armed:hover {
  background: var(--text);
  color: var(--bg) !important;
}

/* === Bouton hamburger (toujours visible) === */
header.main .menu-toggle { margin-right: 8px; }
.menu-toggle {
  display: flex;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  cursor: pointer;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 18, 0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.25s;
}

/* ============================== */
/* Splash "écran trop petit"      */
/* ============================== */
.too-narrow-splash {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
body.too-narrow .too-narrow-splash {
  display: flex;
}
body.too-narrow .app-shell,
body.too-narrow .settings-panel,
body.too-narrow .settings-backdrop,
body.too-narrow .sidebar-backdrop {
  display: none !important;
}
.too-narrow-content {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.too-narrow-content h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 52px;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.025em;
}
.too-narrow-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.too-narrow-icon svg {
  width: 100%;
  height: 100%;
}
.too-narrow-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  margin: 0;
  color: var(--text);
  line-height: 1.3;
}
.too-narrow-sub {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  max-width: 400px;
}

/* === Print === */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-elevated: #fff;
    --text: #000;
    --text-muted: #444;
    --text-faint: #666;
    --accent: #000;
    --accent-soft: #ececec;
    --border: #d0d0d0;
    --border-strong: #999;
  }
  body { background: #fff !important; font-size: 11pt; margin: 0.8cm !important; }

  /* Layout : flow block pour Safari iOS print (le grid/flex du shell cause le bug "demi-page") */
  .app-shell,
  body.sidebar-open .app-shell {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
  }
  .sidebar, .menu-toggle, .sidebar-backdrop { display: none !important; }
  .main-area {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    background-image: none !important;
  }
  .container {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding-top: 0 !important;
  }
  header.main { display: block !important; position: static !important; box-shadow: none !important; margin-left: 0 !important; margin-right: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
  .title-block { display: block !important; }

  /* Éléments cachés à l'impression */
  .header-controls, .part-actions, .part-collapse, .scale-toggle, .lyric-actions,
  .lyric-drag-handle, .add-lyrics, .add-lyric-col, .lyric-edit, .penta-toggle,
  .voicing-nav, .voicing-counter, .scale-legend, footer,
  .free-mode-bar, .settings-panel, .settings-backdrop,
  .sticky-song-title { display: none !important; }

  .lyric-preview { display: block !important; min-height: 0; }
  .lyric-block.is-empty { display: none !important; }

  /* Déplier toutes les sections à l'impression */
  section.part.is-collapsed .part-content { display: block !important; }
  section.part.is-collapsed .part-collapse { display: none !important; }

  /* Grille d'accords : toujours 4 colonnes (évite l'héritage 2-col du breakpoint mobile) */
  .chord-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
  }
  /* Paroles : une variante par ligne */
  .lyrics-grid { grid-template-columns: 1fr !important; }

  .chord-card { animation: none !important; transform: none !important; padding-bottom: 6px; }
  section.part { page-break-inside: avoid; break-inside: avoid; margin-bottom: 18pt; }

  /* Tonique piano : fond blanc + bordure épaisse pour distinguer des touches noires */
  svg.piano .piano-key-root {
    fill: white !important;
    stroke: #000 !important;
    stroke-width: 2 !important;
  }

  /* Gamme : layout block pour éviter les bugs flex de Safari iOS print */
  .scale-section { page-break-before: always; }
  .scale-section[hidden] { display: none !important; }
  .scale-header { display: block !important; }
  .scale-notes { display: block !important; white-space: nowrap !important; margin-top: 6pt; }

  .title-block h1 { font-size: 30pt; }
  .title-block h1::first-letter { color: #000; }
  .song-title-input { font-size: 28pt; border-bottom: none !important; }
  .chord-degree, .roman-numeral, .cp-chord, .wordmark .accent { color: #000; }

  /* Impression : cacher contrôles section */
  .section-drag-handle, .section-key-controls, .section-delete,
  .add-section-bar, .key-detect-hint, .section-type-hint { display: none !important; }

  /* Tonalité à l'impression : remplace le nom éditable par nom · tonalité */
  .section-name[contenteditable] { display: none !important; }
  .section-print-key {
    display: block !important;
    font-family: var(--font-display);
    font-size: 20pt;
    font-weight: 400;
    color: #000;
  }

  /* Splash masqué à l'impression — l'app reste imprimable quelle que soit la taille de fenêtre */
  .too-narrow-splash { display: none !important; }
  body.too-narrow .app-shell { display: block !important; }
}

/* ===== v0.14 — Sections dynamiques ===== */

/* Poignée de drag section */
.section-drag-handle {
  flex: 0 0 auto;
  cursor: grab;
  color: var(--text-faint);
  font-size: 16px;
  letter-spacing: -1px;
  padding: 2px 4px;
  border-radius: 3px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.15s;
  align-self: center;
}
section.part:hover .section-drag-handle { opacity: 0.7; }
.section-drag-handle:hover { opacity: 1 !important; color: var(--accent); }
section.part.dragging {
  opacity: 0.4;
  transform: scale(0.98);
  transition: opacity 0.15s, transform 0.15s;
}
section.part.drag-over {
  outline: 3px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
  transition: outline 0.1s, background 0.1s;
}
.section-drag-handle:active,
.section-drag-handle.is-grabbing {
  color: var(--accent);
  transform: scale(1.3);
  opacity: 1 !important;
}

/* Sur touch devices (pas de hover possible), les poignées doivent être visibles en permanence */
@media (hover: none) {
  .section-drag-handle { opacity: 0.7 !important; }
  .lyric-drag-handle   { opacity: 0.7 !important; }
}

/* === Ghost flottant pendant un drag tactile === */
.touch-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  padding: 8px 16px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translate(-50%, -120%);
  transition: opacity 0.1s;
  opacity: 0.95;
}
.touch-drag-ghost--lyric {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 13px;
}

/* === Section active (focus pédale BT) === */
section.part.is-active {
  position: relative;
}
section.part.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: -16px;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: activeSectionPulse 0.4s ease-out;
}
@keyframes activeSectionPulse {
  from { opacity: 0; transform: scaleY(0.6); }
  to   { opacity: 1; transform: scaleY(1); }
}
@media print {
  section.part.is-active::before { display: none !important; }
}

/* === Solo mode panel === */
.lyrics-container {
  transition: opacity 0.25s ease;
}
.lyrics-container.solo-hidden {
  display: none;
}
.solo-panel {
  margin-top: 18px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 3px;
  padding: 18px 24px 22px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.solo-panel.solo-panel-visible {
  opacity: 1;
}
.solo-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.solo-panel-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 18px;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}
.solo-key {
  color: var(--accent);
}
.solo-mode-toggle button {
  font-size: 11.5px;
  padding: 6px 12px;
}
.solo-fretboard svg {
  width: 100%;
  height: auto;
  color: var(--text);
  display: block;
}
@media print {
  .solo-panel { display: none !important; }
  .lyrics-container.solo-hidden { display: block !important; }
}

/* Titre de section éditable */
.section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  margin: 0;
  letter-spacing: -0.015em;
  flex: 0 1 auto;
}
.section-name[contenteditable] {
  border-bottom: 1.5px dotted transparent;
  border-radius: 2px;
  transition: border-color 0.15s, background 0.15s;
  padding: 0 2px;
  outline: none;
  cursor: text;
  min-width: 4ch;
}
.section-name[contenteditable]:hover {
  border-bottom-color: var(--border-strong);
}
.section-name[contenteditable]:focus {
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}
.section-type-hint {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  opacity: 0.65;
  margin-top: 1px;
  line-height: 1.3;
}
.section-print-key {
  display: none;
}

/* Contrôles clé/mode par section */
.section-key-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.seg-group--xs button {
  font-size: 11px;
  padding: 4px 8px;
  min-width: auto;
}
.section-key-select {
  font-size: 14px;
  font-family: var(--font-ui);
  font-weight: 500;
  padding: 4px 20px 4px 8px;
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
}
.section-key-select option { font-family: var(--font-ui); font-weight: 500; }
.section-key-select:hover { border-color: var(--border-strong); }
.capo-select {
  font-size: 12.5px;
  padding: 4px 20px 4px 8px;
  min-width: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-ui);
  cursor: pointer;
}
.capo-select:hover { border-color: var(--border-strong); }

/* === Contrôle transposition (sticky bar) === */
.transpose-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}
.transpose-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-size: 13px;
  padding: 3px 8px;
  cursor: pointer;
  font-family: var(--font-ui);
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}
.transpose-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.transpose-btn:disabled { opacity: 0.28; cursor: default; }
#transpose-offset-display {
  font-family: 'Schibsted Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  min-width: 28px;
  text-align: center;
  display: inline-block;
  color: var(--text);
}
.transpose-reset {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--accent);
  font-size: 13px;
  padding: 3px 5px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.transpose-reset:hover { opacity: 1; }
.transpose-reset:disabled { opacity: 0.3; }

/* Bouton de suppression section */
.section-delete {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-faint);
  font-size: 12px;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
}
.section-delete:hover { color: var(--accent); border-color: var(--border); }
.section-delete.is-armed {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 11px;
  padding: 5px 10px;
}
.section-delete.is-disabled, .section-delete:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Bannière de détection de tonalité */
.key-detect-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 2px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  animation: chordIn 0.25s ease-out;
}
.key-detect-hint[hidden] { display: none; }
.key-detect-hint strong { color: var(--text); font-weight: 500; }
.key-detect-adopt {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: opacity 0.15s;
}
.key-detect-adopt:hover { opacity: 0.85; color: #fff; }

/* Barre "Ajouter une section" */
.add-section-bar {
  margin-top: 12px;
  margin-bottom: 32px;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.add-section-btn {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 9px 20px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.add-section-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.add-section-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}
.add-section-picker[hidden] { display: none; }
.section-type-option {
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  padding: 10px 16px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.1s;
}
.section-type-option:last-child { border-bottom: none; }
.section-type-option:hover { background: var(--accent-soft); color: var(--accent); }
