:root {
  color-scheme: dark;
  color: #f3f1ec;
  background: #000;
  --font-interface: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-titre: Baskerville, "Palatino Linotype", Palatino, Georgia, serif;
  --font-code: "SFMono-Regular", Consolas, ui-monospace, monospace;
  --paper: #090909;
  --surface: #101010;
  --control: #171717;
  --edge: #373737;
  --edge-control: #555;
  --ink: #f3f1ec;
  --muted: #c4c1bb;
  --accent: #9ac7b0;
  --selected: #192d25;
  --error: #f0b4ad;
  --score-paper: #000;
  --score-ink: #fff;
  --score-lines: #a5a5a5;
  --score-selected: #202020;
  --score-label: #fff;
  font: 15px/1.45 var(--font-interface);
}
*{box-sizing:border-box}body{margin:0}.masthead,main{max-width:1420px;margin:auto;padding:24px clamp(15px,4vw,56px)}.masthead{display:flex;justify-content:space-between;align-items:end;gap:16px;flex-wrap:wrap;padding-bottom:8px}.brand{letter-spacing:.22em;font-size:12px;font-weight:750;color:var(--muted);margin:0 0 6px}h1,h2,h3{font-family:var(--font-titre);font-weight:500;margin:0;line-height:1.12}h1{font-size:clamp(32px,5vw,52px);line-height:1}h2{font-size:clamp(24px,2.4vw,31px)}.panel{background:var(--paper);border:1px solid var(--edge);border-radius:12px;margin-bottom:16px;overflow:hidden}.bar,.actions,.form{display:flex;align-items:center;flex-wrap:wrap;gap:9px}.bar{padding:13px 16px;justify-content:space-between;border-bottom:1px solid var(--edge)}.form,.inset{padding:12px 16px}.form article{display:flex;gap:6px;align-items:center;padding:7px;background:var(--surface);border:1px solid var(--edge);border-radius:8px}.form article.active{border-color:var(--accent)}.workspace{display:grid;grid-template-columns:1.3fr 1fr;gap:16px}.scroll,#score{overflow:auto}button,select,input{font:inherit;color:inherit;border:1px solid var(--edge-control);background:var(--control);border-radius:6px;padding:5px 8px}button{cursor:pointer}button:hover{border-color:var(--accent)}.primary{background:var(--ink);color:#111;border-color:var(--ink);padding:9px 14px}input[type=number]{width:78px}label{font-size:13px;color:var(--muted)}table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums;white-space:nowrap}td,th{text-align:left;padding:6px 10px;border-bottom:1px solid var(--edge)}th{font-size:12px;color:var(--muted)}tr.active{background:var(--selected)}tr:nth-child(3n+1).group td{border-top:2px solid var(--edge)}.details{display:grid;gap:9px}.detail-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.detail-row strong{min-width:24px}svg{display:block}svg text{font-family:var(--font-interface);fill:var(--score-label)}svg .note{cursor:pointer}svg .generator{touch-action:none}#status{color:var(--error)}@media(max-width:1020px){.workspace{grid-template-columns:1fr;gap:0}}

#score svg text { fill: var(--score-label); }
.display-menu {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  justify-content: end;
  padding: 18px clamp(16px, 4vw, 56px) 0;
  pointer-events: none;
}
.display-menu details {
  pointer-events: auto;
  position: relative;
  color: #f5f5f5;
  color-scheme: dark;
}
.display-menu summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid #494949;
  border-radius: 7px;
  background: #111;
  cursor: pointer;
  list-style: none;
}
.display-menu summary::-webkit-details-marker { display: none; }
.display-menu details[open] summary span { transform: rotate(180deg); }
.menu-content {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: grid;
  gap: 12px;
  width: min(280px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid #494949;
  border-radius: 9px;
  background: #141414;
  box-shadow: 0 12px 32px #0007;
}
.menu-content label { display: grid; gap: 4px; color: #dedede; }
.menu-content select, .menu-content button {
  background: #202020;
  border-color: #555;
  color: #f5f5f5;
}
.menu-content button { text-align: left; }
.score-only {
  color-scheme: dark;
  background: #000;
  color: #fff;
  --score-selected: transparent;
}
.score-only main > :not(.score-panel) { display: none; }

.block-controls { display: grid; gap: 10px; }
.block-controls fieldset { margin: 0; min-width: 0; border: 1px solid var(--edge); border-radius: 8px; }
.block-controls fieldset .actions + .actions { margin-top: 8px; }
.block-controls legend { font-size: 13px; padding: 0 6px; }
#matrix td.block-cell { background: var(--selected); }

#score .score-step { cursor: pointer; touch-action: manipulation; }
#score .score-step rect { fill: var(--score-paper); stroke: var(--score-lines); }
#score .score-step:hover rect,
#score .score-step:focus-visible rect { stroke: var(--score-ink); stroke-width: 2; }

.model-panel { scroll-margin-top: 70px; }
.model-panel p { margin: 0 0 10px; }
.model-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 12px; }
.model-fields label { display: grid; gap: 5px; }
.model-fields textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--edge); border-radius: 6px; background: var(--surface); color: var(--ink); font: 14px/1.5 var(--font-code); }
.model-actions { margin-top: 12px; }
#model-status { margin: 10px 0 0; font-size: 13px; }
.voice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.voice-row > strong { min-width: 80px; }
#composition textarea { min-height: 225px; }
#composition { grid-template-columns: 1fr; }
#composition .actions { align-self: start; }
#wav-player { margin: 12px; width: min(500px, calc(100% - 24px)); }

#script-panel { scroll-margin-top: 70px; }
#composition-code { min-height: 340px; line-height: 1.55; tab-size: 2; font-size: 16px; }
#composition-status { margin: 0; }
#script-result { min-width: 0; border-top: 1px solid var(--edge); }
#script-matrix tbody tr.group td { border-top: 2px solid var(--edge); }
#script-score svg text { fill: var(--score-label); }
.script-help { color: var(--muted); }
.script-help summary { cursor: pointer; }

.sequence-columns { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.sequence-columns h3 { margin: 0 0 8px; font-size: 17px; }
.sequence-columns .scroll { margin-top: 10px; }
.sequence-columns td input { width: 72px; }
.sequence-columns td select { margin-right: 4px; }
#dictionary-code { margin: 10px 0; }
#dictionary-status:empty { display: none; }
@media (max-width: 850px) { .sequence-columns { grid-template-columns: 1fr; } }
.note-parameters { display: grid; gap: 6px 10px; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); margin-top: 8px; }
.note-parameters label { display: grid; gap: 3px; }

[hidden] { display: none !important; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--surface);
}
.preset-card h3 { margin: 0; font: 500 24px var(--font-titre); }
.preset-card p { flex: 1; margin: 8px 0 14px; color: var(--muted); }
#preset-status { padding-top: 0; margin: 0; }
#preset-status:empty { display: none; }

body {
  min-height: 100vh;
  background: #000;
}
main { max-width: none; padding-block: 0; }
.score-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-block: 72px;
  margin: 0;
  background: #000;
  border: 0;
  border-radius: 0;
}
#panels { padding-bottom: 24px; }
#panels > [data-pane] { scroll-margin-top: 72px; }
.score-panel > .bar { display: none; }
.menu-content { max-height: calc(100dvh - 80px); overflow-y: auto; }
.menu-group { display: grid; gap: 6px; border-top: 1px solid #444; padding-top: 9px; }
.menu-group > span { color: #ddd; font-size: 13px; }
.menu-panes { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px; }
.menu-panes button[aria-pressed="true"] { background: #dce9e0; color: #18382a; }
body:not(.score-only) #status { color: #f0b4ad; }
#script-score { background: #000; }
#show-all[aria-pressed="true"] { background: #dce9e0; color: #18382a; }
#score input.score-coefficient {
  width: 100%;
  height: 24px;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--score-ink);
  font: 700 13px var(--font-interface);
  text-align: center;
  appearance: textfield;
}
#score input.score-coefficient:hover,
#score input.score-coefficient:focus { border-color: var(--score-lines); background: var(--score-paper); }
#score input.score-coefficient::-webkit-inner-spin-button,
#score input.score-coefficient::-webkit-outer-spin-button { appearance: none; margin: 0; }
#score .score-values {
  width: max-content;
  min-width: 100%;
  color: var(--score-ink);
  background: var(--score-paper);
}
#score .score-values th,
#score .score-values td { min-width: 85px; text-align: right; border-color: #242424; }
#score .score-values th { color: #ddd; }
#score .score-values th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 138px;
  text-align: left;
  background: var(--score-paper);
}
#score .score-values-result th,
#score .score-values-result td { border-top: 1px solid #777; font-weight: 700; }
#score .score-values-coefficient th { font-weight: 400; color: #bcbcbc; }
#score .score-values .score-selected { background: #202020; }
#score .score-values button { padding: 2px 7px; background: transparent; border-color: #555; }
#score .score-values input.score-coefficient { width: 64px; text-align: right; font-weight: 400; }
.values-operation { margin-bottom: 12px; gap: 8px 12px; }
.values-operation label, .values-operation small { color: #ddd; }
.values-operation button, .values-operation select, .values-operation input {
  color-scheme: dark;
  background: #171717;
  color: #f5f5f5;
  border-color: #555;
}
#score .score-values .score-block { background: #19382c; }
#score .score-matrices {
  display: flex;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
  gap: 12px;
  color: var(--score-ink);
}
#score .score-matrix { flex: 0 0 auto; padding: 10px; border: 1px solid #444; border-radius: 8px; }
#score .score-matrix th, #score .score-matrix td { padding: 4px 6px; border-color: #333; color: #f5f5f5; text-align: right; }
#score .score-matrix th:first-child { text-align: left; }
#score .score-matrix button { color: #f5f5f5; background: #181818; border-color: #444; }
#score .score-matrix td button { min-width: 44px; text-align: right; }
#score .score-matrix button[aria-pressed="true"],
#score .score-matrix button[aria-pressed="mixed"] { background: #19382c; border-color: #78b59a; }
#score .score-matrix input.score-coefficient { width: 54px; text-align: right; }
#score .score-matrix td.score-block { background: #19382c; }
#score .score-matrix tfoot th,
#score .score-matrix tfoot td { border-top: 1px solid #666; font-weight: 700; }

#panels { color: var(--ink); }
#panels > [data-pane] { min-width: 0; }
#panels .bar { padding-block: 16px; }
#panels h2, #panels h3 { text-wrap: balance; }
#panels :is(code, kbd) { font-family: var(--font-code); }
#panels kbd { border: 1px solid var(--edge-control); border-radius: 4px; padding: 1px 5px; }
#panels ::placeholder { color: #a8a8a8; opacity: 1; }
#panels :focus-visible, .display-menu :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#panels button:disabled { opacity: 0.55; cursor: default; }

.transport {
  position: fixed;
  z-index: 3;
  top: 18px;
  left: clamp(16px, 4vw, 56px);
  display: flex;
  gap: 6px;
}
.transport button { width: 44px; height: 40px; padding: 0; font-size: 19px; }
.transport button[aria-pressed="true"] { background: var(--ink); color: #111; }
#workshop-link { color: var(--ink); text-underline-offset: 3px; }
#bounds-registers label { color: var(--muted); }
#bounds-registers input { width: 58px; }
#chords-link { color: var(--ink); text-underline-offset: 3px; }
.chord-note { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 8px; border-top: 1px solid var(--edge); }
.chord-note label { display: flex; align-items: center; gap: 4px; }
.chord-editor { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chord-editor label { color: var(--muted); }
.chord-editor input { width: min(210px, 45vw); font-family: var(--font-code); }

#print-partition { display: none; }
@media print {
  @page { size: A4 landscape; margin: 13mm; }
  body.printing-score { color-scheme: light; background: #fff; color: #000; }
  body.printing-score > :not(#print-partition) { display: none !important; }
  body.printing-score #print-partition {
    display: block;
    --score-paper: #fff;
    --score-ink: #000;
    --score-lines: #333;
    --score-label: #000;
  }
  #print-partition section { break-inside: avoid; margin-bottom: 4mm; }
  #print-partition h1 { font-size: 24pt; }
  #print-partition h2 { font-size: 15pt; margin: 5mm 0 2mm; }
  #print-partition h3 { font-size: 12pt; margin: 2mm 0; }
  #print-partition h2, #print-partition h3 { break-after: avoid; }
  #print-partition p { margin: 2mm 0 6mm; }
  #print-partition svg { width: 100%; height: auto; }
}

#cma-link { color: var(--ink); text-underline-offset: 3px; }
.cma-dialog { width: min(1080px,96vw); max-height: 90dvh; background: var(--paper); color: var(--ink); border: 1px solid var(--edge-control); border-radius: 12px; padding: 0; }
.cma-dialog::backdrop { background: #000b; }
.cma-dialog nav button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.cma-selection { display: flex; flex-wrap: wrap; gap: 7px 12px; max-height: 25vh; overflow: auto; }
.cma-selection label { display: inline-flex; gap: 4px; align-items: center; }
.cma-form p { color: var(--muted); }
.cma-apply { margin-top: 12px; }
.cma-status { margin: 0; }
.cma-status:empty { display: none; }
.cma-matrix { overflow: auto; }
.cma-form input[type="text"] { width: min(120px,30vw); }
#composition-live { border-bottom: 1px solid var(--edge); }
#composition-live > summary { cursor: pointer; font-weight: 650; }
#composition-live > p, #composition-live-status { color: var(--muted); }
#composition-live-form { grid-template-columns: minmax(0,1fr); }
#composition-live-code { min-height: 270px; line-height: 1.5; tab-size: 2; }
#composition-live-status:empty { display: none; }
#chords-v2-link { color: var(--ink); text-underline-offset: 3px; }
.chords-v2:not(.score-only) .score-panel { min-height: 0; padding-block: 76px 20px; }
.chords-cartes { display: flex; gap: 8px; overflow: auto; padding: 5px 1px 12px; }
.chords-carte { display: grid; flex: 0 0 auto; gap: 3px; min-width: 140px; text-align: left; padding: 10px; }
.chords-carte[aria-pressed="true"] { background: var(--selected); border-color: var(--accent); }
.chords-carte small, .chords-outils span { color: var(--muted); }
.chords-edition { border-top: 1px solid var(--edge); padding-top: 14px; }
.chords-outils { margin-bottom: 12px; }
.chords-piano { position: relative; display: grid; grid-template-columns: repeat(14,minmax(0,1fr)); max-width: 900px; height: clamp(92px,19vw,145px); margin-bottom: 18px; }
#chords-grid .piano-blanche { border: 1px solid #222; border-radius: 0 0 6px 6px; background: #f1eee7; color: #171717; padding: 0 0 8px; display: grid; align-content: end; }
#chords-grid .piano-noire { position: absolute; z-index: 1; top: 0; left: calc((var(--place) - .32)*100%/14); width: calc(.64*100%/14); height: 61%; border-radius: 0 0 5px 5px; background: #161616; border-color: #3b3b3b; padding: 0; }
#chords-grid .chords-piano button[aria-pressed="true"] { background: #9ac7b0; color: #12271e; box-shadow: inset 0 -4px #416954; }
.chords-cma { max-width: 550px; }
.chords-cma th, .chords-cma td { text-align: right; }
