/* =========================================
   SOAP CHORD PRO v7.1 | COMPTOIR ANALOGIQUE
   ========================================= */

/* Fontes embarquées localement (css/fonts/) : la WebView du plugin est
   hors ligne, un @import CDN y resterait mort. */
@font-face {
    font-family: 'Barlow Condensed';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/barlow-condensed-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Barlow Condensed';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/barlow-condensed-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Barlow Condensed';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('fonts/barlow-condensed-800.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/ibm-plex-sans-600.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/jetbrains-mono-500.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/jetbrains-mono-600.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('fonts/jetbrains-mono-800.woff2') format('woff2');
}


:root {
    /* Tokens de la charte SOAP (design-system/tokens/). Ne pas redéfinir une
       valeur en dur ailleurs : tout passe par ces variables. */
    --graphite: #131315;
    --ecru: #E2E0D8;
    --ecru-hi: #EDEBE3;
    --ink: #1C1C1E;
    --rust: #E6396B;
    /* Ni blanc (4,07:1) ni encre (4,18:1) ne passent l'AA sur un aplat de ce
       rust à la taille réelle d'un bouton -- même constat que sur le site
       (voir site/css/soap.css). Cette variante ~12% plus sombre, même teinte
       à 0,1° près, ramène le blanc à 5,1:1. */
    --rust-btn: #CA325E;
    --citron: #B7E23F;
    --teal: #33D6C0;
    --amber: #FFC857;

    --bg-canvas: var(--graphite);
    --bg-module: #191A1C;      /* plaque en relief */
    --bg-well: #0E0E10;        /* puits encastré (clavier, séquenceur) */
    --border-inverse: rgba(255, 255, 255, 0.14);

    --text-on-inverse: var(--ecru);
    --text-on-inverse-muted: rgba(226, 224, 216, 0.62);

    --radius-sm: 4px;
    --radius-md: 8px;

    --shadow-module: 0 1px 0 rgba(255,255,255,0.06) inset, 0 2px 0 rgba(0,0,0,0.35), 0 10px 24px rgba(0,0,0,0.35);
    --shadow-control-rest: 0 1px 0 rgba(255,255,255,0.35) inset, 0 1px 2px rgba(19,19,21,0.18);
    --shadow-control-press: 0 1px 3px rgba(19,19,21,0.28) inset;
    --shadow-knob: 0 2px 0 rgba(255,255,255,0.08) inset, 0 1px 1px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.45);
    --ease-standard: cubic-bezier(.2,.7,.3,1);
    --duration-fast: 100ms;
    --duration-standard: 160ms;

    --font-display: 'Barlow Condensed', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* --- Alias des anciens noms -------------------------------------------
       Le reste de la feuille et quelques styles inline en JS les lisent
       encore. On les fait pointer sur les tokens plutôt que de réécrire
       chaque occurrence : la charte reste l'unique source de vérité. */
    --bg-dark-main: var(--graphite);
    --panel-bg: var(--bg-module);
    --panel-bg-alt: var(--bg-module);
    --text-main: var(--ecru);
    --text-muted: var(--text-on-inverse-muted);
    --neon-pink: var(--rust);      /* fondamentale / note jouée */
    --neon-cyan: var(--teal);      /* tonique de la gamme, intervalles */
    --accent-gold: var(--citron);  /* valeurs vivantes, LEDs */
    --border-glass: 1px solid var(--border-inverse);
    --white-keys: #F2F0EA;
    --black-keys: #1A1A1C;

    /* Intervalles / séquenceur : ramenés dans la palette de la charte. */
    --accent-b3: var(--teal);
    --accent-3: var(--citron);
    --accent-5: var(--teal);
    --accent-b7: var(--amber);
    --accent-7: var(--rust);

    --glow-pink: 0 0 8px rgba(230, 57, 107, 0.45);
    --glow-cyan: 0 0 8px rgba(51, 214, 192, 0.45);
}

/* --- Fond & Vignette --- */
body {
    font-family: var(--font-body);
    background: var(--bg-canvas);
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-canvas);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Plus de vignette ni de grain : sur graphite la charte veut un aplat mat. */

/* --- Container Principal (châssis) --- */
.app-container {
    background: var(--bg-canvas);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-md);
    width: 97vw;
    height: 96vh;
    box-shadow: var(--shadow-module);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.main-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 15px;
    overflow: hidden;
    min-height: 0;
}

.central-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Le seul défilement de l'application, et seulement quand la fenêtre est
       vraiment trop courte pour la rangée haute + le plancher de la piste.
       Avant, chaque bloc portait son propre overflow et rognait son contenu
       dans son coin, sans jamais rien laisser défiler d'utile. */
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    min-height: 0;
}

header {
    border-bottom: var(--border-glass);
    margin-bottom: 25px;
    padding-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 12px;
    justify-content: space-between;
    align-items: center;
}

.panel-label {
    white-space: nowrap;
}

.instrument-selector {
    display: flex;
    background: var(--panel-bg-alt);
    border: 1px solid var(--border-inverse);
    border-radius: 20px;
    padding: 3px;
}

.exit-tool-btn {
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--panel-bg-alt);
    border: 1px solid var(--border-inverse);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s ease;
}

.exit-tool-btn:hover {
    color: var(--text-main);
    border-color: var(--text-main);
}

.soap-web-app .exit-tool-btn {
    display: inline-flex;
}

.inst-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 18px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 16px;
    transition: all 0.3s ease;
    font-family: var(--font-mono);
}

.inst-btn.active {
    background: rgba(230, 57, 107, 0.12);
    color: var(--neon-pink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

h1 {
    font-size: 1.1rem;
    color: var(--text-main);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
    font-weight: 800;
    margin: 0;
}

/* --- Clavier --- */
.piano-input {
    height: 96px;
    width: 100%;
    /* Filet de sécurité horizontal porté ici plutôt que sur toute la colonne
       (.merged-kb) : seul le clavier peut réellement dépasser en largeur, et
       un overflow sur la colonne rognait aussi tout ce qui est en dessous. */
    overflow-x: auto;
    overflow-y: hidden;
    /* Plancher pour ~14 touches blanches (2 octaves) à leur largeur minimale
       (28px, voir .key) : en dessous, .merged-kb prend le relais avec son
       overflow-x:auto plutôt que d'écraser les touches sous ce seuil. */
    min-width: 392px;
    display: flex;
    justify-content: center;
    margin-top: auto;
    margin-bottom: auto;
}

/* Bande réellement occupée par les touches (voir rebuildPianos) : les %
   des touches noires sont calculés relativement à SA largeur, pas à celle
   (plus large, centrée) de .piano-input. */
.piano-keys-inner {
    position: relative;
    display: flex;
    height: 100%;
    /* Doit occuper toute la largeur disponible, sinon les touches (flex-basis:0)
       n'ont rien à se répartir et retombent sur leur min-width : le clavier
       restait à 392 px, tassé au milieu d'une colonne de 900. Le plafond est
       porté ici, sur la bande, et non sur les touches : les positions des
       touches noires sont des pourcentages de CETTE largeur (voir
       rebuildPianos), donc la bande doit épouser exactement la somme des
       touches blanches, sans espace résiduel. */
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
}

.key {
    background: var(--white-keys);
    border: 1px solid var(--bg-well);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-standard);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 20px;
    /* Largeur fluide plutôt que fixée en dur : avant, un clavier de 280px
       fixe flottait dans un panneau qui peut en faire 900+, laissant tout
       l'espace inoccupé. flex-basis:0 répartit l'espace disponible à parts
       égales entre les touches blanches, borné par min/max-width. */
    flex: 1 1 0;
    min-width: 28px;
    /* Pas de max-width : le plafond du clavier est porté par .piano-keys-inner
       (voir sa règle). Un plafond par touche laissait un reliquat d'espace
       dans la bande, ce qui décalait les touches noires -- leurs positions
       sont exprimées en % de la largeur de la bande. */
    box-sizing: border-box; /* le filet de 1px ne doit pas s'ajouter par-dessus le plafond */
    height: 92px;
    margin-right: -1px;
    cursor: pointer;
    z-index: 1;
}

/* Lettre du clavier d'ordinateur : plus lisible (taille et espacement des
   lettres légèrement augmentés) mais plus discrète (graisse et opacité
   réduites) qu'avant -- elle n'a plus le repère de degré romain pour lui
   tenir compagnie (voir le retrait de .roman-label ci-dessous), elle seule
   doit donc rester lisible sans pour autant dominer la touche. */
.key::before {
    content: attr(data-key);
    position: absolute;
    bottom: 30px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: rgba(19, 19, 21, 0.4);
    font-weight: 500;
    z-index: 10;
}

/* Sélectionner une gamme ne doit rien changer aux couleurs des touches
   diatoniques (.in-scale reste donc sans style propre, identique à l'état
   "Aucune gamme") : seule l'opacité des touches hors-gamme baisse, pour ne
   faire que les estomper plutôt que de reteinter tout le clavier. */
.key.not-in-scale {
    opacity: 0.3;
    pointer-events: none;
}

.key::after {
    content: attr(data-octave-label);
    position: absolute;
    bottom: 5px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: rgba(19, 19, 21, 0.38);
    font-weight: 500;
    z-index: 10;
}

.key.black {
    background: var(--black-keys);
    border: 1px solid #0A0A0B;
    border-top: 0;
    border-radius: 0 0 2px 2px;
    padding-bottom: 10px;
    /* left et width en %, calculés en JS (rebuildPianos) proportionnellement
       à la largeur réelle des touches blanches -- fixes en px, ils
       dériveraient de leur position dès que le clavier redimensionne. */
    height: 60px;
    position: absolute;
    z-index: 2;
    top: 0;
    margin: 0;
}

.key.black::before {
    bottom: 15px;
    color: rgba(226, 224, 216, 0.42);
}
/* La position des touches noires est calculée dynamiquement en JS
   (rebuildPianos) car le clavier peut désormais démarrer sur n'importe
   quelle fondamentale de gamme, pas seulement Do. */

.key.selected-root,
.key.playing-note {
    background: var(--rust) !important;
    box-shadow: var(--glow-pink);
    border-color: var(--rust);
}

/* Repère permanent de la fondamentale de la GAMME (degré I), indépendant de
   l'accord sélectionné : un simple liseré qui peut donc coexister avec le
   remplissage rouge de .selected-root quand les deux coïncident. Le teal
   (--neon-cyan) tranche nettement sur le fond crème/doré des touches (le
   doré s'y fondait trop) et reste distinct du rouge de la racine d'accord.
*/
.key.scale-tonic {
    outline: 2px solid var(--teal);
    outline-offset: -2px;
    box-shadow: var(--glow-cyan);
}

.key.selected-root::before,
.key.selected-root::after,
.key.playing-note::before,
.key.playing-note::after {
    color: #FFFFFF;
}

/* Indicateurs d'intervalles */
.key[class*="interval-"] {
    border-bottom: 4px solid var(--citron);
}

/* --- Panneaux (plaques vissées) --- */
.cyber-panel {
    background: var(--bg-module);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    position: relative;
    padding: 16px;
}



.row {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

/* --- Bandeau bas : clavier + constructeur d'accord --------------------------
   Vivait auparavant en tête de .central-area (.row-top), au-dessus de la
   piste -- les deux se disputaient alors la hauteur, et la piste ne recevait
   que ce qu'il restait une fois ce bloc servi. Posé maintenant sous
   .main-layout, comme le clavier ancré en bas d'un sampler (Kontakt et
   consorts) : la piste récupère toute la zone du haut, ce bandeau garde une
   hauteur propre et prévisible.

   max-height + overflow-y:auto est le même filet que .central-area
   ailleurs : sans lui, ce bandeau (clavier + Octave + anatomie + palette +
   constructeur + glisser-déposer) peut dépasser la fenêtre entière à une
   petite taille de plugin -- mesuré : jusqu'à ~680px de bandeau pour une
   fenêtre de 600px de haut, ce qui écrasait .main-layout (donc la piste) à
   zéro pixel plutôt que de simplement la comprimer. */
.bottom-dock {
    flex: 0 0 auto;
    border-top: 1px solid var(--border-inverse);
    background: var(--bg-module);
}
.bottom-dock-full {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px 16px;
}
.bottom-dock.builder-collapsed { display: none; }

.row-3 {
    /* La piste encaisse la variation de hauteur : elle s'étire sur l'espace
       restant et se comprime jusqu'à son plancher avant que quoi que ce soit
       ne défile. C'est l'inverse de l'arbitrage précédent, qui affamait la
       rangée haute pour engraisser une piste déjà au-delà de son minimum.
       Plancher relevé à 480px : la piste est l'espace de travail central de
       l'outil, elle doit dominer par défaut plutôt que se contenter du
       reliquat une fois le clavier/constructeur d'accord servi. Si ça ne
       tient pas sur l'écran, .central-area défile (mécanisme déjà en place,
       sûr -- pas de flex-shrink en cascade à gérer) : mieux vaut faire
       défiler la page, ou dézoomer le navigateur, que rogner la piste. */
    flex: 1 1 auto !important;
    min-height: 480px;
    display: flex;
    padding: 14px 16px;
    gap: 20px;
    align-items: stretch;
}

/* --- CUSTOM DROPDOWNS & INPUTS --- */
.theme-popup {
    position: relative;
}
#custom-container-scale-root { width: 78px; }
#custom-container-scale-type { width: 230px; }
#custom-container-chord-type { width: 240px; height: 100%; }

.theme-popup__checkbox {
    display: none;
}
.theme-popup__button {
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    color: var(--text-main);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s;
    font-family: var(--font-mono);
    height: 100%;
}
.theme-popup__button .selected-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.theme-popup__button:hover {
    border-color: rgba(255, 255, 255, 0.28);
}
.theme-popup__list-container {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: var(--bg-module);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    z-index: 999;
    max-height: 250px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}
.theme-popup__checkbox:checked ~ .theme-popup__list-container {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.theme-popup__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.theme-popup__optgroup {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    padding: 6px 10px;
    font-weight: bold;
}
.theme-popup__option {
    padding: 8px 15px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}
.theme-popup__option:hover {
    background: rgba(230, 57, 107, 0.12);
    color: var(--text-main);
}
.theme-popup__option.active {
    background: rgba(230, 57, 107, 0.12);
    color: var(--neon-pink);
    border-left: 2px solid var(--neon-pink);
}

/* --- CUSTOM RANGE SLIDER --- */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--accent-gold);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* --- Boutons --- */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-inverse);
    background: transparent;
    color: var(--text-main);
    text-transform: uppercase;
    box-shadow: none;
    transition: transform var(--duration-fast) var(--ease-standard),
                background var(--duration-standard) var(--ease-standard);
}

.btn:active { transform: translateY(1px); box-shadow: var(--shadow-control-press); }

/* Lecture : citron, la couleur de l'état vivant. */
.btn-green {
    background: var(--citron);
    border-color: var(--citron);
    color: var(--ink);
    box-shadow: var(--shadow-control-rest);
}

.btn-green:hover { background: var(--citron); }

.btn-remove {
    border-color: var(--border-inverse);
    color: var(--text-muted);
}

.btn-remove:hover { color: var(--rust); border-color: var(--rust); }

/* Export MIDI : action principale, donc rust, l'accent unique de la marque.
   Ni blanc (4,07:1) ni encre (4,18:1) ne passaient l'AA sur le rust brut à
   cette taille -- var(--rust-btn) est l'aplat assombri prévu pour ça. */
.btn-blue {
    background: var(--rust-btn);
    border-color: var(--rust-btn);
    color: #FFFFFF;
    box-shadow: var(--shadow-control-rest);
}

.btn-blue:hover { background: var(--rust-btn); }

.btn-clear:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--text-main) !important;
}

/* La progression est désormais persistée : "Vider" efface un vrai travail,
   pas juste une session volatile. Un deuxième clic dans les 3s confirme,
   plutôt qu'une boîte de dialogue native -- indisponible ou silencieusement
   ignorée dans certaines WebViews de plugin. */
.btn-clear.confirm-pending {
    background: var(--rust) !important;
    border-color: var(--rust) !important;
    color: #FFFFFF !important;
}

/* --- Séquenceur Piano Roll --- */
#sequencer-container {
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    /* Plancher de la grille : c'est l'espace de travail réel de l'outil, et
       il tombait à 102 px (deux notes empilées, l'aide de départ écrasée sur
       trois lignes illisibles). En dessous de ce seuil, mieux vaut laisser
       .central-area défiler que rendre la piste inutilisable. */
    min-height: 160px;
    flex: 1;
    min-width: 0;
}

.sequencer-body {
    flex: 1;
    display: flex;
    position: relative;
    min-height: 0;
}

/* Repère de premier lancement : centré sur la fenêtre visible de la piste
   (donc hors de #sequencer-timeline, qui défile -- un enfant positionné en
   absolute à l'intérieur d'un conteneur overflow:auto scrolle avec son
   contenu, il ne resterait pas au centre de l'écran). pointer-events:none
   pour ne jamais bloquer la colonne fantôme dessous. Affiché/masqué par
   renderDock() selon que la progression est vide, sans minuterie. */
.seq-empty-hint {
    position: absolute;
    inset: 0 0 0 44px; /* 44px = largeur de #sequencer-keys, comme .ruler-spacer */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
    z-index: 5;
}
.seq-empty-hint.visible { display: flex; }
.seq-empty-hint kbd { color: var(--text-main); }

#sequencer-keys {
    flex: 0 0 44px;
    border-right: 1px solid var(--border-inverse);
    position: relative;
    background: #141416;
    overflow-x: hidden;
    overflow-y: hidden;
}

#sequencer-timeline {
    position: relative;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;

    /* Quadrillage Musical (1 unité = 80px = 1 blanche = 2 temps à 120bpm) */
    /* 1 Mesure (4 temps) = 160px */
    background-color: var(--bg-well);
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px), /* 20px (croche) */
        linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px), /* 80px (blanche) */
        linear-gradient(to right, rgba(255, 255, 255, 0.16) 1px, transparent 1px); /* 160px (mesure) */
    background-size: 20px 100%, 80px 100%, 160px 100%;
}

/* --- Time Ruler : numéros de mesure, collée directement au-dessus de la
   piste (même bordure, pas de gap), régénérée par renderTimeRuler() --- */
#time-ruler {
    height: 20px;
    flex: 0 0 20px;
    display: flex;
    background: #121214;
    border-bottom: 1px solid var(--border-inverse);
    position: relative;
    overflow: hidden;
}
/* Aligne le début de la ruler avec le début réel de la piste (au-delà de la
   colonne des touches à gauche), pour que "1" ne se retrouve plus au-dessus
   du clavier vertical. */
.ruler-spacer {
    flex: 0 0 44px;
    border-right: 1px solid var(--border-inverse);
    background: #121214;
}
#ruler-track {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ruler-inner {
    position: relative;
    height: 100%;
}
.ruler-measure {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding-left: 6px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-muted);
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    box-sizing: border-box;
}
.ruler-beat-tick {
    position: absolute;
    top: 13px;
    bottom: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.28);
}

/* --- Bande d'accords : symbole + degré, collée sous la règle de mesures.
   Même mécanique que la règle (translateX synchronisé sur le scroll
   horizontal, voir renderChordRuler), pour rester lisible même quand la
   piste défile verticalement -- ce que .seq-chord-label, ancré en bas d'une
   grille de plusieurs centaines de pixels, ne permettait pas. --- */
#chord-ruler {
    height: 34px;
    flex: 0 0 34px;
    display: flex;
    background: #16171a;
    border-bottom: 1px solid var(--border-inverse);
    position: relative;
    overflow: hidden;
}
#chord-ruler-track {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.chord-ruler-inner {
    position: relative;
    height: 100%;
}
.chord-ruler-item {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0 4px;
    box-sizing: border-box;
    border-right: 1px dashed rgba(255, 255, 255, 0.16);
    overflow: hidden;
}
.chord-ruler-item .sym {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.76rem;
    color: var(--citron);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.chord-ruler-item .deg {
    font-family: var(--font-mono);
    font-size: 0.56rem;
    letter-spacing: 0.04em;
    color: var(--teal);
    white-space: nowrap;
}
.chord-ruler-item.hors-gamme .deg { color: var(--text-muted); }
.chord-ruler-item.editing .sym { color: var(--rust); }

#sequencer-grid {
    background-image:
        linear-gradient(to right, rgba(230, 57, 107, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, transparent 11px, rgba(255, 255, 255, 0.15) 12px);
    position: relative;
    height: 100%;
}

.seq-note {
    background: var(--accent-gold);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.35);
    position: absolute;
    height: 10px;
    border-radius: 2px;
}

/* Tête de lecture : le HTML et le JS existaient déjà (playhead.style.left
   déplacé à chaque accord dans playProgression), mais aucune règle ne la
   rendait visible -- ni couleur, ni largeur, ni position. */
#playhead {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--rust);
    box-shadow: 0 0 6px rgba(230, 57, 107, 0.6);
    z-index: 15;
    pointer-events: none;
}

.seq-key {
    position: absolute;
    width: 100%;
    height: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.55rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 5px;
    box-sizing: border-box;
}
.seq-key.black { background: var(--bg-well); border-bottom: 1px solid rgba(255, 255, 255, 0.05); color: rgba(226, 224, 216, 0.35); }
.seq-key.white { background: #141416; }
.seq-key.c-note { border-top: 1px solid var(--border-inverse); color: var(--text-main); }

.seq-chord-column {
    position: absolute;
    top: 0;
    height: 100%;
    border-right: 1px dashed rgba(255, 255, 255, 0.25);
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.2s;
}
.seq-chord-column:hover { background: rgba(255, 255, 255, 0.08); }
.seq-chord-column.selected { background: rgba(230, 57, 107, 0.14); border: 1px solid var(--rust); }

/* --- Nom de l'accord --- */
.seq-chord-label {
    position: absolute;
    bottom: 5px;
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: bold;
    pointer-events: none;
    font-family: var(--font-mono);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* --- Poignée de redimensionnement de l'accord : seul moyen d'éditer la durée,
   visible en permanence (pas juste au survol) pour l'affordance DAW --- */
.resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 20;
    background: rgba(255, 255, 255, 0.12);
    border-right: 2px solid rgba(255, 255, 255, 0.35);
    transition: background 0.2s, border-color 0.2s;
}
.resize-handle:hover,
.seq-chord-column.resizing .resize-handle {
    background: rgba(230, 57, 107, 0.4);
    border-right-color: var(--neon-cyan);
}
.seq-chord-column.selected .resize-handle {
    border-right-color: var(--neon-pink);
}

/* --- Contrôles Octave --- */
.oct-btn {
    background: transparent;
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    border-radius: 2px;
}

.oct-btn:hover {
    background: var(--neon-cyan);
    color: var(--ecru);
    box-shadow: var(--glow-cyan);
}

#octave-label {
    color: var(--neon-pink);
    text-shadow: none;
}

/* --- Barre d'Élévation / Inversions --- */
.inv-dot {
    width: 25px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.inv-dot:hover {
    background: rgba(230, 57, 107, 0.1);
    border-color: rgba(230, 57, 107, 0.5);
}
.inv-dot.active {
    background: rgba(230, 57, 107, 0.15);
    border-color: var(--neon-pink);
    box-shadow: 0 1px 3px rgba(230, 57, 107, 0.3);
}
.inv-dot-fill {
    width: 12px;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 1px;
    transition: all 0.3s ease;
    position: absolute;
    box-shadow: none;
}
.inv-dot.active .inv-dot-fill {
    background: var(--neon-pink);
    box-shadow: none;
}

/* --- Potard Humanize : "top hat" façon Les Paul, skirt sombre + capuchon laiton --- */
.lp-label-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.lp-dial {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    touch-action: none;
    outline: none;
}
.lp-dial:focus-visible .lp-knob {
    box-shadow: var(--shadow-knob), 0 0 0 2px var(--teal);
}
.lp-dial .ticks {
    position: absolute;
    inset: 0;
}
.lp-dial .ticks i {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    height: 8px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 1px;
    margin: -4px 0 0 -1px;
    transform-origin: 50% 50%;
}
.lp-knob {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #2A2A2C;
    box-shadow: var(--shadow-knob);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.15s ease;
}
.lp-knob .cap {
    border-radius: 50%;
    width: 64%;
    height: 64%;
    background: transparent;
    position: relative;
}
.lp-knob .pointer {
    position: absolute;
    top: 12%;
    left: 50%;
    width: 11%;
    height: 34%;
    background: var(--ecru);
    border-radius: 2px;
    transform-origin: 50% 155%;
    margin-left: -5.5%;
}
.lp-label {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: bold;
}
.lp-val {
    font-size: 0.75rem;
    color: var(--accent-gold);
    font-weight: bold;
}

/* --- Tempo : sélecteur en en-tête du séquenceur --- */
.tempo-ctrl {
    display: flex;
    align-items: center;
}
.tempo-ctrl .note-ic {
    font-size: 0.65rem;
    color: var(--accent-gold);
}
.tempo-ctrl .bpm-val {
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text-main);
    min-width: 20px;
    text-align: center;
}
.tempo-ctrl .bpm-unit {
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.tempo-ctrl button {
    background: transparent;
    border: 1px solid var(--border-glass);
    border-radius: 2px;
    width: 13px;
    height: 13px;
    line-height: 1;
    font-size: 0.6rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.tempo-ctrl button:hover {
    background: var(--neon-cyan);
    color: var(--ecru);
}

/* --- Progressions toutes faites --------------------------------------- */
/* Repliée par défaut (voir toggleProgressionPresets/renderDock) : un rang
   de pastilles groupées par longueur, plutôt que les blocs à en-tête pleine
   largeur d'origine -- plus proche des autres rangées compactes du panneau
   (grille, zoom) que d'une vraie section. */
.prog-presets-row {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 0 16px 12px;
}
.prog-presets-row.visible { display: flex; }
.prog-presets-row .prog-group-sep {
    width: 1px;
    align-self: stretch;
    background: var(--border-inverse);
    margin: 2px 2px;
}
.prog-wrapper {
    display: contents;
}
.prog-option {
    position: relative;
    display: inline-block;
}
.prog-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}
.prog-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border-inverse);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.64rem;
    font-weight: 500;
    font-family: var(--font-mono);
    white-space: nowrap;
    transition: background var(--duration-standard) var(--ease-standard),
                border-color var(--duration-standard) var(--ease-standard),
                color var(--duration-standard) var(--ease-standard);
}
.prog-input:hover ~ .prog-btn {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-main);
}
.prog-input:checked ~ .prog-btn {
    background: var(--citron);
    border-color: var(--citron);
    color: var(--ink);
    font-weight: 600;
}

/* --- Floating Button pour le Séquenceur --- */
.btn-floating {
    position: absolute;
    transform: translateX(-50%);
    z-index: 100;
    background: #f2e6cc;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    pointer-events: auto;
}

.btn-floating:hover {
    background: #e3cc9c;
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* --- Card Selector (Mood) --- */
.mood-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    /* Pas de plafond de hauteur : une grille de 6 bases ou de 8 extensions
       fait plus de 80 px, et le cap précédent la faisait défiler dans son
       coin -- d'où le « Renversement » qui semblait surgir au milieu des
       extensions. La colonne Accord prend sa hauteur naturelle. */
    width: 100%;
    justify-content: center;
    padding-right: 5px;
}
.mood-grid::-webkit-scrollbar { width: 4px; }
.mood-grid::-webkit-scrollbar-thumb { background: rgba(230, 57, 107, 0.3); border-radius: 4px; }

/* Sépare visuellement Sus2/Sus4 (pas de tierce, ni majeur ni mineur) des
   quatre vraies qualités de triade -- voir renderMoodCards(). */
.mood-sus-sep {
    /* Doit occuper toute la largeur. flex-basis ne suffisait pas : la grille
       des bases est un `display:grid` (voir .merged-mood .mood-grid), où
       flex-basis est ignoré -- le libellé se retrouvait dans une seule
       cellule, avec « Sus 2 » à côté de lui et « Sus 4 » seul en dessous. */
    grid-column: 1 / -1;
    flex-basis: 100%;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.7;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    padding-top: 6px;
    margin-top: 2px;
}

.mood-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 6px 4px;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1 1 30%;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Petit indicateur de raccourci clavier, discret, posé partout où une action
   a un équivalent au clavier : un badge en coin sur les cartes/boutons, ou
   un fragment de texte muet accolé à un libellé (variante .inline). */
.shortcut-hint {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    opacity: 0.55;
    pointer-events: none;
}
.mood-card .shortcut-hint {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.5rem;
}
.mood-card.active .shortcut-hint { color: var(--ecru); opacity: 0.65; }
.shortcut-hint.inline {
    margin-left: 5px;
    text-transform: none;
    font-weight: 500;
}
.mood-card:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.mood-card.active {
    border-color: #5c2424;
    color: var(--ecru);
    background: var(--neon-pink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
    font-weight: bold;
}

/* --- Desktop Layout Classes --- */
.header-main-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 10px;
    gap: 40px;
}

.scale-selector {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    position: relative;
}

.scale-dropdown-wrapper {
    display: flex;
    flex-direction: row;
    gap: 10px;
    position: relative;
    z-index: 100;
}

.keyboard-panel {
    display: flex;
    align-items: stretch;
    gap: 20px;
    flex: 1;
    padding: 15px;
}

/* --- Bloc fusionné : clavier (2/3) + mood (1/3) --- */
.merged-panel {
    display: flex;
    gap: 20px;
}

.merged-kb {
    flex: 2 1 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-width: 0;
    /* Surtout PAS d'overflow ici. `overflow-x: auto` seul suffisait à faire
       calculer `overflow-y: auto` par la spec CSS (dès qu'un axe n'est plus
       `visible`, l'autre passe de `visible` à `auto`) : cette colonne rognait
       donc verticalement, et c'est ce qui rendait l'anatomie d'accord et la
       palette de degrés invisibles sous le clavier. Le défilement horizontal
       de secours vit maintenant sur .piano-input seul (voir sa règle), qui
       est le seul élément réellement susceptible d'être trop large. */
}

.merged-mood {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    border-left: 1px dashed rgba(255, 255, 255, 0.25);
    padding-left: 18px;
}

#octave-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mood-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* --- Ligne compacte octave + élévation, sous le clavier --- */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
}

.ctrl-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ctrl-tag {
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: bold;
}

.ctrl-divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.25);
}

/* --- Bloc 2 fusionné : séquenceur (80%) + BPM/Humanize (20%), transport en pied --- */
.row-3.block2 {
    flex-direction: column;
    gap: 15px;
}

.block2-main {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.block2-side {
    flex: 0 0 20%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    padding-top: 6px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    padding-left: 20px;
    box-sizing: border-box;
}

.block2-side .tempo-ctrl {
    width: 100%;
    justify-content: center;
}

.block2-transport {
    display: flex;
    gap: 15px;
}

.block2-transport .btn {
    flex: 1;
    padding: 15px 10px;
    font-weight: bold;
    font-size: 0.8rem;
}

/* --- Zoom séquenceur : boutons intégrés en bas à droite de la piste --- */
.zoom-ctrl-float {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(245, 236, 214, 0.9);
    border: 1px solid var(--border-inverse);
    border-radius: 4px;
    padding: 3px 7px;
}
.zoom-ctrl-float button {
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: 3px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
}
.zoom-ctrl-float button:hover {
    background: var(--neon-cyan);
    color: var(--ecru);
}
.zoom-ctrl-float .zoom-val {
    font-size: 0.65rem;
    color: var(--text-muted);
    min-width: 32px;
    text-align: center;
}

/* --- Badge "accord en cours" : recentrage auto du séquenceur --- */
.seq-follow-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    text-align: center;
    font-size: 0.6rem;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--neon-cyan);
    background: rgba(230, 57, 107, 0.12);
    border: 1px solid rgba(230, 57, 107, 0.35);
    border-radius: 3px;
    padding: 1px 4px;
    pointer-events: none;
    z-index: 6;
}

/* --- Media Queries Responsives --- */
/* Bascule en colonne empilée abaissée de 1200 à 980 px : à 1100 px (la taille
   d'ouverture du plugin), la disposition côte à côte clavier / accord tient
   parfaitement -- l'empiler doublait la hauteur du bandeau bas pour rien. */
@media (max-width: 980px) {
    /* L'app reste contenue dans la fenêtre plutôt que de basculer en page
       qui défile (body{height:auto;overflow-y:auto} auparavant) : sous ce
       seuil -- fenêtre de plugin étroite, ou zoom navigateur -- il fallait
       jusqu'ici faire défiler toute la fenêtre pour atteindre le transport.
       Clavier et accord passent en colonne compacte dans le bandeau bas
       (voir .bottom-dock-full, qui garde son propre plafond+défilement) ;
       la piste, elle, occupe toute .central-area -- même logique qu'en
       plein écran (voir .row-3 hors media query). */
    body {
        height: 100vh;
        overflow: hidden;
    }

    .app-container {
        width: 100%;
        height: 100vh;
        padding: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        margin-bottom: 20px;
    }

    .header-main-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    /* Ces règles empilaient l'ancien en-tête sur écran étroit. Dans la barre
       d'outils, un `width: 100%` sur la tonique la met seule sur sa ligne et
       étire son champ sur toute la largeur : on garde la largeur naturelle. */
    .scale-selector {
        flex-direction: column;
        align-items: flex-start;
        width: auto;
        gap: 6px;
    }

    .scale-dropdown-wrapper {
        width: auto;
        flex-wrap: nowrap;
    }

    #custom-container-scale-root {
        width: 70px !important;
    }

    #custom-container-scale-type {
        flex: 1;
        width: auto !important;
    }

    .instrument-selector {
        align-self: flex-start;
    }

    .main-layout {
        flex-direction: column;
        overflow: hidden;
    }

    /* .central-area garde sa règle de base (flex column, overflow-y:auto,
       min-height:0) : la piste (.row-3), seule occupante désormais, prend
       toute la hauteur disponible. Le bandeau clavier+accord (.bottom-dock)
       vit hors de .main-layout et garde son propre plafond+défilement (voir
       .bottom-dock-full hors media query) -- les deux colonnes internes
       (clavier, accord) passent juste en pile plutôt que côte à côte, sous
       ce seuil de largeur. */
    .merged-panel {
        flex-direction: column;
    }

    .merged-mood {
        border-left: 0;
        border-top: 1px dashed rgba(255, 255, 255, 0.25);
        padding-left: 0;
        padding-top: 12px;
    }

    .app-container .row-3 {
        /* Toute la hauteur de .central-area, comme hors media query -- le
           bandeau clavier+accord vit ailleurs (.bottom-dock) et ne lui
           dispute plus rien. Même plancher qu'en pleine largeur (voir sa
           règle) -- overflow retiré : hidden
           ici rognerait silencieusement le contenu de la piste (en-tête +
           presets + grille + transport) si leur somme dépasse ce que le
           flex lui alloue, exactement le genre de troncature déjà corrigé
           ailleurs. C'est .central-area qui défile en dernier recours. */
        flex: 1 1 auto !important;
        min-height: 480px;
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    .block2-main {
        flex: 1 1 auto;
        min-height: 0;
        flex-direction: column;
    }

    /* #sequencer-container (id, specificité 100) porte déjà flex:1 hors
       media query -- .block2-seq seul (specificité 10) ne l'emportait
       jamais, quel que soit l'ordre des règles. Hauteur fluide plutôt que
       fixée à 320px : elle remplit ce que .block2-main lui laisse une fois
       l'en-tête et le transport posés, comme en plein écran. */
    #sequencer-container.block2-seq {
        flex: 1 1 auto;
        height: auto;
        /* Même plancher qu'en pleine largeur : en dessous, la grille ne montre
           plus assez de rangées pour travailler. Mieux vaut laisser
           .central-area défiler. */
        min-height: 160px;
        width: 100%;
        box-sizing: border-box;
    }

    .block2-transport {
        flex: 0 0 auto;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
    }

    /* .app-container en préfixe : .block2-transport .btn (0,2,0) hors media
       query, plus loin dans le fichier (correctifs de la réorganisation),
       gagnerait sinon la bataille de specificité malgré la media query. */
    .app-container .block2-transport .btn {
        flex: 1 1 calc(50% - 10px);
        margin-top: 0 !important;
        padding: 12px 10px;
    }

}

/* =========================================================================
   RÉORGANISATION v8 — barre de titre, barre d'outils, lectures d'état
   Les réglages globaux quittent les panneaux pour une rangée unique ; le
   séquenceur récupère toute la largeur ; l'accord courant et la position de
   lecture, qui n'étaient affichés nulle part, ont maintenant un afficheur.
   ========================================================================= */

/* --- Vocabulaire commun -------------------------------------------------- */
.ctl-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-inverse);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge .led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--citron);
    box-shadow: 0 0 6px var(--citron);
    flex: none;
}

.badge.is-off .led { background: rgba(226, 224, 216, 0.25); box-shadow: none; }
.badge.is-alert .led { background: var(--rust); box-shadow: 0 0 6px var(--rust); }

kbd {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    border: 1px solid var(--border-inverse);
    border-radius: 3px;
    padding: 2px 5px;
    color: var(--text-main);
}

/* --- Barre de titre ------------------------------------------------------ */
.app-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-inverse);
    background: #111113;
    flex: 0 0 auto;
}

.tb-mark {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    background: var(--ecru);
    display: grid;
    place-items: center;
    flex: none;
}

.tb-mark img { width: 14px; height: 14px; display: block; }

.tb-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-main);
}

.tb-sep { width: 1px; height: 18px; background: var(--border-inverse); flex: none; }

.tb-doc {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-doc b { color: var(--text-main); font-weight: 400; }
.tb-doc em { font-style: normal; }

.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* --- Bandeau hôte (plugin / Max) ------------------------------------------ */
.host-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 16px;
    background: rgba(230, 57, 107, 0.10);
    border-bottom: 1px solid rgba(230, 57, 107, 0.35);
    flex: 0 0 auto;
}
.host-banner[hidden] { display: none; }
.host-banner span {
    font-family: var(--font-body);
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--text-main);
}
.host-banner button {
    margin-left: auto;
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    line-height: 1;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}
.host-banner button:hover { color: var(--text-main); border-color: var(--rust); }

/* Bandeau de suggestion de gamme : même charpente que .host-banner (classe
   dédiée plutôt que réutilisée, pour ne pas hériter de son teint "alerte"
   rouge -- une suggestion n'est pas un avertissement) accentuée en cyan
   (--neon-cyan, déjà la couleur de la tonique/des intervalles ailleurs dans
   l'app). La règle [hidden] explicite est nécessaire pour la même raison
   qu'ailleurs dans ce fichier : un sélecteur de classe avec `display` a la
   même spécificité que la règle UA [hidden], et gagnerait sinon le lien selon
   l'ordre du fichier plutôt que selon l'intention. */
.scale-suggestion-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    background: rgba(51, 214, 192, 0.10);
    border-bottom: 1px solid rgba(51, 214, 192, 0.35);
    flex: 0 0 auto;
}
.scale-suggestion-banner[hidden] { display: none; }
.scale-suggestion-banner span {
    font-family: var(--font-body);
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--text-main);
}
.scale-suggestion-banner #scale-suggestion-apply {
    margin-left: auto;
    flex: 0 0 auto;
    background: var(--neon-cyan);
    color: var(--bg-dark-main);
    border: 1px solid var(--neon-cyan);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    height: 22px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.scale-suggestion-banner #scale-suggestion-apply:hover { opacity: 0.85; }
.scale-suggestion-banner #scale-suggestion-dismiss {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    line-height: 1;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}
.scale-suggestion-banner #scale-suggestion-dismiss:hover { color: var(--text-main); border-color: var(--neon-cyan); }

/* --- Barre d'outils ------------------------------------------------------ */
.app-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-inverse);
    background: #151517;
    flex: 0 0 auto;
}

.ctl { display: flex; flex-direction: column; gap: 6px; }

.app-toolbar .tb-sep { height: 34px; align-self: flex-end; margin-bottom: 2px; }

.toolbar-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    padding-bottom: 8px;
}

/* Segmenté (instrument) : un seul puits, les segments ne flottent pas. */
.seg {
    display: flex;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.seg .inst-btn {
    border: 0;
    border-right: 1px solid var(--border-inverse);
    border-radius: 0;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    padding: 9px 16px;
    color: var(--text-muted);
    box-shadow: none;
}

.seg .inst-btn:last-child { border-right: 0; }

.seg .inst-btn.active {
    background: var(--ecru);
    color: var(--ink);
    font-weight: 500;
    box-shadow: none;
}

/* Écoute interne : même bouton segmenté que Piano/Synth, mais à deux états
   (actif/coupé) plutôt qu'à choix multiple -- le vert reprend le code couleur
   du reste de l'app pour "actif" (voir --led-active), le gris celui de
   "éteint" (voir .badge.is-off .led). */
#internal-listen-toggle .led {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(28, 28, 30, 0.25);
    margin-right: 5px;
    vertical-align: middle;
}
#internal-listen-toggle.active .led {
    background: var(--led-active, #B7E23F);
    box-shadow: 0 0 5px var(--led-active, #B7E23F);
}
#internal-listen-toggle:not(.active) { color: var(--text-muted); }

#internal-listen-volume {
    width: 64px;
    margin-left: 10px;
    vertical-align: middle;
    accent-color: var(--neon-pink, #E6396B);
}
/* Un sélecteur d'ID l'emporte sur [hidden] de la feuille UA (même
   spécificité de base, mais l'ID gagne) : sans la règle [hidden] explicite
   ci-dessous, ce bloc restait visible hors plugin malgré l'attribut. */
#internal-listen-selector { display: flex; align-items: center; gap: 4px; }
#internal-listen-selector[hidden] { display: none; }
#internal-listen-selector .ctl-label { margin-right: 6px; }

/* Incrémenteur (octave, tempo, zoom) : un puits avec deux flancs cliquables. */
.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.stepper button {
    width: 28px;
    height: 34px;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border-inverse);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.stepper button:last-child { border-right: 0; border-left: 1px solid var(--border-inverse); }
.stepper button:hover { background: rgba(255, 255, 255, 0.06); color: var(--citron); }

.stepper > span {
    padding: 0 12px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-main);
    min-width: 46px;
    text-align: center;
}

.stepper .bpm-unit {
    padding-left: 0;
    min-width: 0;
    font-size: 0.56rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stepper .bpm-val { padding-right: 4px; min-width: 30px; }

#octave-label { color: var(--citron); font-weight: 500; }

/* Le potard tient dans la rangée : plus petit qu'en colonne latérale. */
.app-toolbar .lp-label-wrap { gap: 3px; }
.app-toolbar .lp-dial { width: 44px; height: 44px; }
.app-toolbar .lp-label { font-size: 0.58rem; }
.app-toolbar .lp-val { font-size: 0.62rem; color: var(--citron); }

/* --- En-têtes de panneau ------------------------------------------------- */
.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-main);
    white-space: nowrap;
    flex-shrink: 0;
}

.panel-note {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Le résumé de la progression est la donnée la moins critique de l'en-tête :
   c'est elle qui cède la place (ellipsis) si la grille + le cadrage + le
   zoom ne tiennent plus tous sur une ligne, jamais l'inverse. */
#prog-meta {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* --- Octave, juste au-dessus du clavier ---------------------------------- */
/* Vivait dans la barre d'outils globale ; posé ici, au plus près des touches
   qu'il décale, maintenant que le clavier a rejoint le bandeau bas. */
.kb-octave-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 2px 0 4px;
}

/* --- Repère de tessiture ------------------------------------------------- */
.oct-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.oct-bar {
    flex: 1;
    height: 3px;
    background: var(--bg-well);
    border-radius: 2px;
    position: relative;
}

.oct-bar i {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--teal);
    border-radius: 2px;
    display: block;
    transition: left var(--duration-standard) var(--ease-standard),
                width var(--duration-standard) var(--ease-standard);
}

/* --- Afficheur de l'accord courant --------------------------------------- */
/* Barre fixe en tête de .central-area (voir index.html) : ne fait plus
   partie du bandeau clavier, qui vit ailleurs et défile en interne, donc
   jamais masquée. */
.chord-readout {
    width: 100%;
    flex: none;
    margin-bottom: 15px;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    box-sizing: border-box;
}

.btn-toggle-builder {
    margin-left: auto;
    align-self: center;
    flex: none;
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.02em;
    padding: 5px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-toggle-builder:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.3); }

.cr-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.7rem;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--citron);
    white-space: nowrap;
}

.cr-detail {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.cr-detail em { font-style: normal; color: var(--teal); white-space: nowrap; }

/* Point rouille : l'accord posé contient une note hors gamme (dominante
   secondaire, emprunt...) -- le chiffrage romain seul ne le disait pas,
   voir la recette théorie musicale (audit-soap.html#recette). */
.cr-chromatic {
    color: var(--rust);
    font-size: 0.55rem;
    cursor: help;
    align-self: center;
}

/* --- Anatomie d'accord (légende couleurs) --------------------------------- */
/* Rappelle ce que chaque couleur de note dans la piste veut dire (voir
   anatomyLexicon / intervalColor dans renderDock) -- un seul vocabulaire
   de couleur pour toute l'appli, pas une légende avec ses propres teintes. */
.chord-anatomy-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 8px;
    padding: 6px 0 2px;
}
.anatomy-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: 999px;
}
.anatomy-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.anatomy-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Palette des degrés --------------------------------------------------- */
/* Sept (ou moins) cartes, une par degré de la gamme -- composer sans
   connaître les noms de notes. Vit sous le clavier, dans le bandeau bas
   (.bottom-dock) ; passe à la ligne plutôt que de s'écraser si la place
   manque (comme le reste de ce bandeau, voir .bottom-dock-full). */
.degree-palette-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 2px;
}
.degree-card {
    /* 78 px permet aux sept degrés de tenir sur une seule ligne dès ~600 px de
       colonne : à 92 px, le vii° basculait seul sur une deuxième rangée et
       coûtait 50 px de hauteur à la taille d'ouverture du plugin. */
    flex: 1 1 86px;
    min-width: 78px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 6px;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
}
.degree-card { cursor: pointer; position: relative; }
.degree-card:hover { border-color: var(--teal); background: rgba(255, 255, 255, 0.04); }

/* Degré dont la qualité a été personnalisée : il ne joue plus l'accord
   diatonique de la gamme, et ça doit se voir sans avoir à lire le nom.
   Rouille, la couleur que la charte réserve à « attention, pas la norme ». */
.degree-card.is-custom {
    border-color: var(--rust);
    background: rgba(230, 57, 107, 0.10);
}
.degree-card.is-custom:hover { border-color: var(--rust); background: rgba(230, 57, 107, 0.16); }

/* Degré actuellement joué. Anneau citron (la couleur « vivant/actif » de la
   charte) posé en box-shadow plutôt qu'en bordure : il se superpose au
   cerclage rouille d'un degré personnalisé au lieu de le remplacer, les deux
   informations restant lisibles ensemble. */
.degree-card.is-current { box-shadow: 0 0 0 2px var(--citron); }
.degree-card.is-current .deg-roman { color: var(--citron); }

.deg-reset {
    position: absolute;
    top: 2px;
    right: 3px;
    z-index: 3;
    width: 15px;
    height: 15px;
    padding: 0;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--rust);
    font-size: 0.68rem;
    cursor: pointer;
}
.deg-reset:hover { background: var(--rust); color: var(--ink); }
.deg-roman {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    color: var(--teal);
}
.deg-name {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-main);
}
/* Le sélecteur de qualité (custom dropdown) réutilise renderCustomDropdown --
   même mécanique que Tonique/Gamme, mais taillée pour une carte de ~100px
   plutôt que la barre d'outils. */
.degree-card .theme-popup { width: 100%; }
.degree-card .theme-popup__button {
    padding: 4px 6px;
    font-size: 0.58rem;
    height: auto;
}
.degree-card .theme-popup__list-container { font-size: 0.68rem; }

/* --- Transport ----------------------------------------------------------- */
.block2-transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.transport-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn-stop { color: var(--text-muted); }
.btn-stop:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.28); }

.pos-readout {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--citron);
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
}

.prog-badge { max-width: 340px; overflow: hidden; }
.prog-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Poignée de redimensionnement de la piste ----------------------------- */
/* .row-3 hérite déjà de position:relative (voir .cyber-panel) : la poignée
   s'ancre donc dans son coin bas-droit sans conteneur supplémentaire.
   Étire .row-3 en hauteur au-delà de ce que le flex lui donne naturellement
   -- utile pour voir plus de rangées de la grille sans agrandir la fenêtre,
   au prix d'un défilement de .central-area si ça dépasse l'écran. */
.seq-resize-handle {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 18px;
    height: 18px;
    cursor: ns-resize;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    z-index: 30;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
    padding: 2px;
    box-sizing: border-box;
}
.seq-resize-handle:hover { color: var(--teal); background: rgba(51, 214, 192, 0.12); }

/* Le zoom n'est plus une pastille flottante par-dessus la piste : il vit dans
   l'en-tête du bloc, avec les autres réglages de la progression. */
.zoom-ctrl-float {
    position: static;
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 0;
    padding: 0;
    box-shadow: none;
    /* Le bandeau grille+cadrage+zoom ne doit jamais perdre en lisibilité :
       s'il manque de place, c'est #prog-meta (moins critique) qui tronque. */
    flex-shrink: 0;
}

.zoom-ctrl-float .stepper button { height: 26px; width: 24px; }
.zoom-ctrl-float .zoom-val { min-width: 48px; font-size: 0.68rem; }

/* Grille d'aimantation : même puits que les autres contrôles du bandeau,
   trois segments plutôt qu'une valeur fixe -- avant, une poignée de durée
   n'aimantait jamais qu'à la croche (0.25 unité), sans réglage possible. */
.snap-grid {
    display: flex;
    flex-shrink: 0;
    background: var(--bg-well);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.snap-grid button {
    /* .zoom-ctrl-float button (plus haut, hérité de l'ancien widget de zoom
       flottant) impose 18x18px à specificité égale -- width/height:auto
       ici les rendent au contenu plutôt qu'à un carré taillé pour "−"/"+". */
    width: auto;
    height: auto;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border-inverse);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    padding: 6px 9px;
    cursor: pointer;
    line-height: 1;
}
.snap-grid button:last-child { border-right: 0; }
.snap-grid button:hover:not(.active) { background: rgba(255, 255, 255, 0.06); color: var(--text-main); }
.snap-grid button.active { background: var(--citron); color: var(--ink); font-weight: 500; }

/* Bouton "pilule" générique du bandeau de la piste (Cadrer/Vue complète,
   Progressions toutes faites...). .zoom-ctrl-float .btn-adjust-range (deux
   classes) plutôt que .btn-adjust-range seule : .zoom-ctrl-float button
   (une classe + un type, plus haut dans le fichier) a une specificité
   supérieure à une classe seule et imposerait sinon 18x18px, taillé pour
   les anciens boutons +/- du zoom flottant. */
.zoom-ctrl-float .btn-adjust-range {
    width: auto;
    height: auto;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.02em;
    padding: 6px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.zoom-ctrl-float .btn-adjust-range:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.28); }
.zoom-ctrl-float .btn-adjust-range.active {
    color: var(--citron);
    border-color: var(--citron);
}

/* --- Ajustements de la nouvelle grille ----------------------------------- */
.main-layout { padding: 16px; }

.merged-kb { gap: 12px; align-items: stretch; }
.merged-kb .piano-input { margin: 4px 0; }

.merged-mood {
    gap: 8px;
    border-left: 1px solid var(--border-inverse);
    padding-left: 18px;
}

.mood-grid { max-height: none; overflow: visible; justify-content: flex-start; }

.mood-card {
    background: transparent;
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 9px 6px;
    color: var(--text-main);
}

.mood-card:hover { background: rgba(255, 255, 255, 0.06); }

.row-3.block2 { gap: 12px; }
.block2-main { gap: 0; }

/* --- Éléments retirés par la réorganisation ------------------------------
   Le <header> et la colonne latérale du séquenceur n'existent plus dans le
   HTML ; leurs styles restaient utiles à personne. La barre de titre porte
   maintenant le bouton de sortie. */
.header-main-group, .controls-row, .ctrl-divider { display: none; }

.exit-tool-btn {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-inverse);
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* --- Correctifs de la réorganisation ------------------------------------- */

/* Le transport n'est plus une rangée de quatre pavés étirés : les actions
   reprennent leur largeur naturelle, l'export reste seul à droite. */
.block2-transport .btn {
    flex: 0 0 auto;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 0.72rem;
}

/* Déclencheur fixe "Ajouter / Valider" (remplace l'ancien bouton flottant de
   la piste, qui suivait la tessiture et pouvait sortir du cadre visible).
   Teal en mode édition : on modifie un accord déjà posé, pas un nouveau --
   même logique que le teal des extensions, réservé au "secondaire". */
#btn-add-chord.btn-editing {
    background: var(--teal);
    border-color: var(--teal);
}
#btn-add-chord.btn-editing:hover { background: var(--teal); }

/* États actifs : citron pour la base de l'accord, teal pour les extensions —
   la hiérarchie de la charte, où le citron dit « actif » et le teal
   « secondaire ». Le rust reste réservé à l'action principale et aux erreurs. */
.mood-card.active {
    background: var(--citron);
    border-color: var(--citron);
    color: var(--ink);
    box-shadow: var(--shadow-control-rest);
    font-weight: 500;
}

#mood-ext-wrapper .mood-card.active {
    background: var(--teal);
    border-color: var(--teal);
}

.mood-card.active .shortcut-hint { color: var(--ink); opacity: 0.5; }

/* Réserve la place de la plus grande grille d'extensions (4 rangées de 2)
   pour que la colonne ne saute pas quand on passe d'un accord à 8 extensions
   à un accord qui n'en prend aucune. En em plutôt qu'en px : suit le zoom
   et la taille de police, contrairement au min-height posé en JS auparavant. */
/* Réserve deux rangées d'extensions (grille à 4 colonnes) pour que la colonne
   ne saute pas entre un accord qui en propose huit et un qui n'en propose
   aucune. En em : suit le zoom, contrairement au min-height posé en JS avant. */
/* Réserve une seule rangée (pas les deux du cas le plus large, Majeur/Mineur
   à 8 extensions) : accepter un léger réajustement de hauteur en changeant
   de qualité d'accord coûte moins que garder en permanence une deuxième
   rangée vide pour Diminué/Augmenté/Sus, qui n'en proposent qu'une ou deux.
   La piste -- l'élément central de l'outil -- en profite directement : cette
   réserve valait à elle seule ~50 px pris sur elle en continu. */
.mood-ext-section { min-height: 2.8em; }

/* Deux colonnes régulières plutôt qu'un flex qui laisse des lignes bancales. */
.merged-mood .mood-grid {
    display: grid;
    /* Trois colonnes plutôt que deux : les six bases tiennent en deux rangées
       au lieu de trois, les huit extensions en trois au lieu de quatre. On
       récupère la hauteur qui manquait à la colonne Accord sans rapetisser
       un seul bouton -- les libellés sont courts (« Majeur », « Maj 7 »),
       c'est la place verticale qui manquait, pas la place horizontale.
       Quatre colonnes : les quatre qualités de triade tiennent exactement sur
       une ligne (elles forment un groupe, autant que ça se voie), le filet
       « suspensions » passe dessous, et Sus 2 / Sus 4 ferment. En trois
       colonnes, « Augmenté » se retrouvait seul sur sa rangée et le bloc
       gagnait deux rangées pour rien ; en deux, c'était trois rangées. Les
       huit extensions passent de même de quatre rangées à deux. */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.merged-mood .mood-card { flex: none; min-width: 0; }

/* Renversement : des pastilles, comme partout ailleurs dans la charte. */
.inv-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--border-inverse);
    background: transparent;
    align-items: center;
}

.inv-dot:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); }

.inv-dot.active {
    background: var(--citron);
    border-color: var(--citron);
    box-shadow: 0 0 8px var(--citron);
}

.inv-dot-fill { display: none; }

/* --- Glisser-déposer + Play, sous Renversement --------------------------- */
/* Remplace l'ancienne barre native fixée tout en bas de la fenêtre du plugin
   (MidiDragHandle, hors WebView) : ce bouton EST maintenant la zone de
   glisser-déposer -- côté plugin, le natif superpose une zone de prise
   invisible exactement sur ses bornes (voir dragHandleBoundsChanged dans
   app.js et PluginEditor::handleDragHandleBoundsEvent), parce qu'une WebView
   ne peut pas fiablement démarrer un glisser-déposer de fichier OS toute
   seule. Côté outil web, il n'y a rien à glisser : seul l'aspect visuel
   reste, "Exporter MIDI" (dans le pied de piste) fait le travail. */
.drag-play-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}
.drag-handle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px dashed rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.02em;
    cursor: grab;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; background: rgba(255, 255, 255, 0.07); }
.drag-handle .grip { color: var(--teal); flex: none; display: flex; }
.drag-play-row .play-btn { flex: none; min-width: 84px; }

/* Le potard se passe des graduations à cette taille : à 44px elles forment
   une couronne d'épines plutôt qu'une échelle lisible. Même règle qu'il vive
   dans la barre d'outils ou, désormais, dans l'en-tête de la piste. */
.app-toolbar .lp-dial .ticks,
.panel-head .lp-dial .ticks { display: none; }
/* Le potard d'Humanize, à côté du titre "Progression" : même gabarit compact
   que dans l'ancienne barre d'outils, pas la taille par défaut (64px) prévue
   pour une colonne latérale. */
.panel-head .lp-label-wrap { flex: none; gap: 3px; }
.panel-head .lp-dial { width: 44px; height: 44px; }
.panel-head .lp-label { font-size: 0.58rem; }
.panel-head .lp-val { font-size: 0.62rem; color: var(--citron); }

/* Le clavier ne doit pas être étiré par les marges auto héritées de l'ancienne
   colonne centrée. */
/* Hauteur du clavier ramenée de 118 à 96 px : les touches blanches font
   maintenant ~66 px de large (au lieu de 28), la proportion reste juste, et
   les 22 px récupérés vont à la piste -- qui n'avait plus que 102 px de
   grille utile, soit deux notes empilées. */
.merged-kb .piano-input { margin: 4px 0; height: 96px; }

/* Les noms d'accords gardent leur casse : « Am » n'est pas « AM ». */
.prog-badge span { text-transform: none; font-size: 0.62rem; letter-spacing: 0.02em; }

/* Les contrôles de la barre gardent leur largeur naturelle : sans ça, un
   contrôle seul sur une ligne (après passage à la ligne, ou en fenêtre
   étroite) voyait son champ s'étirer sur toute la largeur. */
.app-toolbar .ctl {
    flex: 0 0 auto;
    align-items: flex-start;
}

.app-toolbar .scale-dropdown-wrapper { width: auto; }
.app-toolbar .lp-label-wrap { flex: 0 0 auto; }

/* En fenêtre étroite (petite WebView de plugin), la barre se resserre plutôt
   que de passer à la ligne dès le premier réglage. */
@media (max-width: 1280px) {
    .app-toolbar { gap: 12px; padding: 10px 12px; }
    .app-toolbar .toolbar-end { display: none; }
}

/* =========================================================================
   MISE EN PAGE v9 — tout visible d'un coup d'oeil
   Trois zones empilées, sans défilement de page : barre de titre + réglages,
   la piste (qui prend toute la place restante), puis le bandeau clavier +
   accord, dont la hauteur se règle au séparateur. Chaque bloc est resserré
   (une ligne d'en-tête, des boutons plus bas) : à 1100x800, taille
   d'ouverture du plugin, la piste montre sa grille ET son transport, là où
   elle était auparavant écrasée sous le clavier.
   ========================================================================= */

/* En hôte, la fenêtre EST l'application : pas de cadre flottant à 97 %. */
html.is-hosted .app-container {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* --- Barre de titre ------------------------------------------------------ */
.app-titlebar { padding: 7px 14px; gap: 10px; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-doc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: text;
    min-width: 0;
}
.tb-doc:hover { border-color: var(--border-inverse); }
.tb-doc b { color: var(--text-main); font-weight: 500; outline: none; overflow: hidden; text-overflow: ellipsis; }
.tb-doc-pen { flex: none; opacity: 0.6; }

/* Son du plug-in ON/OFF : l'état se lit à la couleur ET au mot. */
.sound-ctl { display: flex; align-items: center; gap: 8px; }
.sound-ctl[hidden] { display: none; }
.sound-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-inverse);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
}
.sound-toggle b {
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}
.sound-toggle .spk-on { display: none; }
.sound-toggle.is-on { color: var(--text-main); border-color: var(--citron); }
.sound-toggle.is-on b { background: var(--citron); color: var(--ink); }
.sound-toggle.is-on .spk-on { display: block; color: var(--citron); }
.sound-toggle.is-on .spk-off { display: none; }
.sound-toggle:hover { border-color: var(--text-main); }
#internal-listen-volume { width: 72px; }
#internal-listen-volume[hidden] { display: none; }

.midi-input-selector { display: flex; align-items: center; gap: 6px; }
.midi-input-selector[hidden] { display: none; }
.midi-input-selector select {
    max-width: 170px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    background: var(--bg-well);
    color: var(--text-main);
    border: 1px solid var(--border-inverse);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
}

/* --- Barre de réglages --------------------------------------------------- */
.app-toolbar { padding: 7px 14px; gap: 14px; align-items: flex-end; }
.app-toolbar .ctl { gap: 4px; }
.app-toolbar .theme-popup__button { padding: 6px 10px; }
.app-toolbar .stepper button { height: 30px; }
.app-toolbar .seg .inst-btn { padding-top: 7px; padding-bottom: 7px; }
.app-toolbar .tb-sep { height: 28px; }

/* --- Zone piste ---------------------------------------------------------- */
.main-layout { padding: 8px 14px 0; min-height: 0; }
.central-area { overflow: hidden; }
.row-3,
.app-container .row-3 {
    min-height: 0 !important;
    padding: 8px 12px 10px;
    gap: 8px;
}
.row-3.block2 { gap: 8px; }
#sequencer-container,
#sequencer-container.block2-seq { min-height: 90px; }

/* En-tête de piste sur une seule ligne : Humanize en potard compact. */
.row-3 .panel-head { min-height: 32px; gap: 10px; }
.panel-head .lp-label-wrap {
    display: grid;
    grid-template-columns: 28px auto;
    grid-template-rows: auto auto;
    column-gap: 6px;
    row-gap: 0;
    align-items: center;
}
.panel-head .lp-dial { width: 28px; height: 28px; grid-row: 1 / 3; }
.panel-head .lp-label { font-size: 0.54rem; line-height: 1.1; }
.panel-head .lp-val { font-size: 0.6rem; line-height: 1.1; }
.row-3 .panel-head .tb-sep { height: 22px; }
.zoom-ctrl-float .stepper button { height: 26px; }
.zoom-ctrl-float .btn-adjust-range,
.zoom-ctrl-float .snap-grid button { padding-top: 4px; padding-bottom: 4px; }

/* Transport : une ligne basse, jamais poussée hors de la fenêtre. */
.block2-transport { gap: 8px; flex-wrap: nowrap; }
.block2-transport .btn { padding: 7px 12px; font-size: 0.66rem; white-space: nowrap; }
.pos-readout { padding: 6px 10px; font-size: 0.7rem; }
.btn-play { border-color: var(--citron); color: var(--citron); min-width: 92px; }
.btn-play:hover { background: rgba(183, 226, 63, 0.1); }
.btn-play.is-playing { background: var(--citron); color: var(--ink); }
.transport-end { min-width: 0; }

/* Glisser-déposer : à côté de la progression qu'il glisse. */
.drag-handle[hidden] { display: none; }
.transport-end .drag-handle {
    flex: none;
    padding: 7px 12px;
    border-color: var(--teal);
    color: var(--text-main);
    font-size: 0.64rem;
}
.transport-end .drag-handle.is-empty { opacity: 0.4; border-color: var(--border-inverse); }

/* --- Séparateur piste / clavier ------------------------------------------ */
.dock-splitter {
    flex: 0 0 auto;
    position: relative;
    height: 16px;
    margin-top: 6px;
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--border-inverse);
    background: var(--bg-module);
    touch-action: none;
    user-select: none;
}
.dock-grip {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
}
.dock-splitter:hover .dock-grip,
.dock-splitter.dragging .dock-grip { background: var(--teal); }
.dock-splitter .btn-toggle-builder {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 8px;
    font-size: 0.56rem;
    cursor: pointer;
}

/* --- Bandeau clavier + accord -------------------------------------------- */
.bottom-dock { border-top: 0; }
/* Par défaut, le bandeau épouse son contenu (plafonné pour laisser sa place
   à la piste) ; une fois réglé au séparateur, il garde la hauteur choisie. */
.bottom-dock-full {
    height: var(--dock-h, auto);
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    padding: 4px 14px 10px;
    box-sizing: border-box;
}
.merged-panel { gap: 16px; }
.merged-kb { gap: 6px; }
.merged-mood { gap: 6px; padding-left: 14px; }
.merged-mood .panel-head { min-height: 0; }

/* Accord courant + octave : une ligne au-dessus des touches. */
.kb-head { display: flex; align-items: center; gap: 12px; min-height: 34px; }
.kb-head .chord-readout {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    align-items: baseline;
    gap: 12px;
}
.kb-head .cr-name { font-size: 1.55rem; }
.kb-head .kb-octave-row { padding: 0; flex: none; }
.kb-head .stepper button { height: 26px; }

.merged-kb .piano-input { height: 88px; margin: 0; }
.merged-kb .key { height: 86px; }
.merged-kb .key.black { height: 54px; }

/* Notes de l'accord : chaque touche prend la couleur de sa fonction et porte
   son étiquette (1, 3, ♭7...) -- lisible sans connaître le code couleur. */
.key.chord-tone {
    background: var(--tone-color) !important;
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 10px color-mix(in srgb, var(--tone-color) 55%, transparent);
}
.key.chord-tone::before { color: rgba(19, 19, 21, 0.55); }
.key.chord-tone::after {
    content: attr(data-tone);
    bottom: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink);
}
.key.black.chord-tone::before { bottom: 22px; }
.key.black.chord-tone::after { bottom: 5px; font-size: 0.62rem; }
/* Tonique de la gamme : un liseré citron en haut de la touche plutôt qu'un
   contour teal, qui se confondait avec la couleur de la quinte. */
.key.scale-tonic {
    outline: 0;
    box-shadow: inset 0 4px 0 var(--citron);
}
.key.scale-tonic.chord-tone {
    box-shadow: inset 0 4px 0 var(--citron), 0 0 10px color-mix(in srgb, var(--tone-color) 55%, transparent);
}

/* Légende : pastille numérotée + fonction + note. */
.chord-anatomy-row { gap: 4px 6px; padding: 2px 0 0; }
.anatomy-chip { padding: 2px 8px 2px 3px; gap: 6px; border-color: color-mix(in srgb, var(--tone-color) 45%, transparent); }
.anatomy-tag {
    min-width: 18px;
    height: 18px;
    padding: 0 3px;
    box-sizing: border-box;
    border-radius: 9px;
    background: var(--tone-color);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}
.anatomy-label { color: var(--text-main); }
.anatomy-note { font-family: var(--font-mono); font-size: 0.62rem; color: var(--tone-color); font-weight: 600; }

/* Degrés : cartes plus basses, sur une ligne. */
.degree-palette-row { gap: 5px; }
.degree-card { padding: 3px 5px; min-width: 70px; flex-basis: 76px; }

/* Colonne Accord resserrée. */
.merged-mood .mood-grid { gap: 5px; }
.merged-mood .mood-card { padding: 6px 4px; font-size: 0.66rem; }
.mood-sus-sep { margin: 0; font-size: 0.54rem; }
.mood-ext-section { min-height: 0; }
.mood-ext-section .panel-title { font-size: 0.72rem; }

/* Fenêtre étroite (plugin à 800 px) : le clavier et l'accord restent côte à
   côte -- empilés, ils demandaient deux fois la hauteur du bandeau. */
@media (max-width: 980px) {
    .merged-panel { flex-direction: row; }
    .merged-mood { border-left: 1px solid var(--border-inverse); border-top: 0; padding-left: 12px; padding-top: 0; flex: 0 0 300px; }
    .merged-mood .mood-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .block2-transport { flex-wrap: nowrap; }
    .app-container .block2-transport .btn { flex: 0 0 auto; padding: 7px 10px; }
    #host-badge { display: none; }
    .sound-toggle #internal-listen-toggle-text { display: none; }
}
@media (max-width: 900px) {
    #btn-remove-edit { display: none; }
    .midi-input-selector .ctl-label { display: none; }
    #internal-listen-volume { width: 56px; }
}

/* Touche noire hors gamme : pleine et sombre plutôt que transparente -- à
   30 % d'opacité, elle laissait voir la couleur de la touche blanche
   voisine en dessous, et le clavier devenait illisible. */
.key.black.not-in-scale { opacity: 1; background: #3b3b40; border-color: #2c2c30; }
.key.black.not-in-scale::before { color: rgba(226, 224, 216, 0.18); }

/* Le nom de chaque accord posé se lit dans la bande au-dessus de la grille :
   le répéter en bas de chaque colonne doublait l'information. Seul l'accord
   proposé (colonne fantôme, pas encore dans la bande) garde son étiquette,
   en haut, là où l'oeil la cherche. */
.seq-chord-column:not(.placeholder) .seq-chord-label { display: none; }
.seq-chord-label.seq-draft-label {
    position: absolute;
    top: 4px;
    white-space: nowrap;
    bottom: auto;
    display: block;
    color: var(--citron);
    text-shadow: none;
    font-size: 0.66rem;
    z-index: 6;
}

/* Petite fenêtre (plugin à sa taille minimale) : la piste garde sa grille et
   son transport, le bandeau cède en premier et défile en interne. */
.bottom-dock-full { max-height: calc(100vh - 380px); min-height: 150px; }
@media (max-width: 980px) {
    .zoom-ctrl-float .ctl-label,
    .zoom-ctrl-float .tb-sep { display: none; }
    .zoom-ctrl-float { gap: 5px; }
    .zoom-ctrl-float .zoom-val { min-width: 36px; padding: 0 4px; }
    .degree-card { min-width: 50px; flex-basis: 56px; padding: 3px 3px; }
    .degree-card .theme-popup__button { padding: 3px 4px; font-size: 0.54rem; }
    .row-3 .panel-head .lp-label { display: none; }
    .app-toolbar .ctl-label { font-size: 0.56rem; }
}
@media (max-height: 700px) {
    .app-toolbar { padding-top: 5px; padding-bottom: 5px; }
    .app-toolbar .ctl { flex-direction: row; align-items: center; gap: 8px; }
    .app-toolbar .ctl-label { font-size: 0.56rem; }
    .app-toolbar .tb-sep { height: 22px; align-self: center; margin: 0; }
    .app-titlebar { padding-top: 5px; padding-bottom: 5px; }
    #prog-presets-row { padding-top: 0; padding-bottom: 0; }
}

/* =========================================================================
   MISE EN PAGE v10 — proposition B validée : une seule barre, façon DAW
   Identité + tonalité à gauche, transport au centre, sortie son / entrée
   MIDI / réglages à droite. L'ancienne barre d'outils (tonique, gamme,
   instrument, tempo) et l'en-tête de piste (humanize, grille, zoom) ont
   disparu : les réglages de début de session sont dans le popover ⚙, ceux
   de la piste flottent sur elle. La piste récupère ~200 px de hauteur.
   ========================================================================= */
.app-titlebar { height: 52px; box-sizing: border-box; padding: 0 14px; gap: 10px; }
.tb-spacer { flex: 1 1 0; min-width: 8px; }
.tb-right { margin-left: 0; gap: 8px; }
.tb-doc { max-width: 220px; }

.tb-chip {
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--border-inverse);
    background: var(--bg-well);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    white-space: nowrap;
    cursor: pointer;
}
.tb-chip:hover, .tb-chip.is-open { border-color: var(--citron); }
.tb-chip.active { border-color: var(--citron); color: var(--citron); }

.tb-icon {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border-radius: 6px;
    border: 1px solid var(--border-inverse);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
}
.tb-icon:hover, .tb-icon.is-open { border-color: var(--citron); color: var(--citron); }

/* Transport : un bloc unique au centre, toujours au même endroit. */
.tb-transport {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px;
    border-radius: 8px;
    background: var(--bg-module);
    border: 1px solid var(--border-inverse);
}
.tb-transport .btn { height: 32px; padding: 0 14px; font-size: 0.68rem; white-space: nowrap; }
.tb-transport #btn-play-main { width: 44px; min-width: 0; padding: 0; font-size: 0.9rem; }
.tb-transport .pos-readout { min-width: 44px; text-align: center; padding: 0 8px; border: 0; background: transparent; font-size: 0.78rem; }

/* --- Popover Réglages ----------------------------------------------------- */
.settings-pop {
    position: fixed;
    z-index: 900;
    width: 460px;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #1C1C20;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.settings-pop[hidden] { display: none; }
.sp-head { display: flex; align-items: center; justify-content: space-between; }
.sp-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.06em; text-transform: uppercase; }
.sp-row { display: flex; align-items: flex-end; gap: 16px; }
.sp-row .ctl { display: flex; flex-direction: column; gap: 6px; }
.sp-row .ctl[hidden] { display: none; }
.sp-grow { flex: 1 1 0; min-width: 0; }
.settings-pop #custom-container-scale-type { width: 100%; }
.settings-pop .theme-popup__button { padding: 7px 10px; }
.settings-pop .stepper button { height: 30px; }
.settings-pop .seg .inst-btn { padding-top: 7px; padding-bottom: 7px; }
.settings-pop #internal-listen-volume { width: 100%; }
.settings-pop .lp-label-wrap {
    display: grid;
    grid-template-columns: 32px auto;
    column-gap: 8px;
    align-items: center;
}
.settings-pop .lp-dial { width: 32px; height: 32px; grid-row: 1 / 3; }
.settings-pop .lp-dial .ticks { display: none; }
.settings-pop .lp-label { font-size: 0.56rem; }
.settings-pop .lp-val { font-size: 0.66rem; color: var(--citron); }
.sp-actions { justify-content: space-between; align-items: center; }
.sp-actions .btn { padding: 7px 12px; font-size: 0.64rem; }
.sp-foot {
    padding-top: 12px;
    border-top: 1px solid var(--border-inverse);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    line-height: 1.9;
}
.sp-foot kbd { margin: 0 1px; }

/* --- Piste sans en-tête : outils flottants -------------------------------- */
.row-3, .app-container .row-3 { padding: 8px 12px; gap: 6px; }
.seq-float,
.seq-float.zoom-ctrl-float {
    position: absolute;
    bottom: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 6px;
    background: rgba(24, 24, 27, 0.94);
    border: 1px solid var(--border-inverse);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.seq-float-left { left: 56px; }
.seq-float-right, .seq-float.zoom-ctrl-float { right: 18px; left: auto; }
.seq-float:empty { display: none; }
.sf-sep { width: 1px; height: 18px; background: var(--border-inverse); }
.seq-float .stepper button { height: 26px; width: 26px; }
.seq-float .zoom-val { min-width: 40px; padding: 0 2px; font-size: 0.68rem; }
.seq-float .snap-grid button, .seq-float .btn-adjust-range { padding-top: 4px; padding-bottom: 4px; }
.seq-float .drag-handle { padding: 6px 12px; border-color: var(--teal); color: var(--text-main); font-size: 0.64rem; }
.seq-float .drag-handle.is-empty { opacity: 0.45; border-color: var(--border-inverse); }
.seq-float .btn { padding: 6px 12px; font-size: 0.64rem; }

/* Action sur l'accord sélectionné, posée sur lui. */
.seq-col-del {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 6;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #1C1C20;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.56rem;
    white-space: nowrap;
    cursor: pointer;
}
.seq-col-del:hover { border-color: var(--rust); color: var(--rust); }

.bottom-dock-full { max-height: calc(100vh - 320px); }

/* --- Barre du haut aux petites largeurs ----------------------------------- */
@media (max-width: 1280px) {
    #internal-listen-toggle-text { display: none; }
}
@media (max-width: 1100px) {
    .midi-input-selector .ctl-label { display: none; }
    .midi-input-selector select { max-width: 120px; }
    .tb-doc { max-width: 150px; }
}
@media (max-width: 900px) {
    .tb-doc { max-width: 100px; }
    .tb-transport .shortcut-hint { display: none; }
    .app-titlebar { gap: 6px; padding: 0 10px; }
    .tb-right { gap: 6px; }
    .midi-input-selector select { max-width: 96px; }
}
@media (max-width: 900px) {
    .seq-float #drag-handle-label, .seq-float .sf-lbl { display: none; }
    .seq-float .snap-grid button { padding-left: 6px; padding-right: 6px; }
    .seq-float-left { left: 50px; }
}

/* --- Correctifs après essai réel (app autonome Mac) ------------------------ */

/* Menus déroulants fermés : opacity:0 ne suffisait pas, la liste (250 px)
   restait dans le flux de défilement de son conteneur. Sous les cartes de
   degré, elle rendait le bandeau du bas défilable vers une zone vide : la
   molette faisait « disparaître » le clavier. Fermée, elle n'existe plus. */
.theme-popup__list-container { display: none; }
.theme-popup__checkbox:checked ~ .theme-popup__list-container { display: block; }
/* Les cartes de degré sont en bas de la fenêtre : leur menu s'ouvre vers le haut. */
.degree-card .theme-popup__list-container { top: auto; bottom: calc(100% + 5px); }

/* Popover : une seule partie à la fois. */
.settings-pop [data-sp][hidden] { display: none; }
.settings-pop.sp-compact { width: 380px; }
.sp-note { margin: 0; font-family: var(--font-mono); font-size: 0.64rem; color: var(--text-muted); line-height: 1.5; max-width: 220px; }
.sp-note[hidden] { display: none; }

/* La zone de glisser-déposer ne sélectionne jamais son texte. */
.drag-handle, .drag-handle * { user-select: none; -webkit-user-select: none; }
.sf-label { font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 0 4px 0 6px; white-space: nowrap; }
@media (max-width: 1100px) { .sf-label { display: none; } }

/* Plugin : le .mid se glisse depuis la bande native en pied de fenêtre (voir
   plugin/Source/MidiDragHandle.h). La pastille de gauche (glisser / exporter)
   n'a rien à montrer ici. */
html.is-hosted .seq-float-left { display: none; }

/* Un geste de glisser sur la piste surlignait toute la grille comme une
   sélection de texte (constaté dans Ableton). Rien à y sélectionner. */
#sequencer-container, .bottom-dock, .app-titlebar { user-select: none; -webkit-user-select: none; }
#session-name { user-select: text; -webkit-user-select: text; }

/* =========================================================================
   MISE EN PAGE v11 — proposition C validée : séquenceur en haut, Lab en bas
   La piste garde son fond. Le Lab (tonalité, progressions, degrés, clavier,
   qualité d'accord) devient un panneau teinté et encadré, moitié-moitié par
   défaut avec la piste (séparateur réglable). Le tempo se règle dans la
   barre du haut ; le bouton « Ajouter » vit au-dessus de l'accord en
   préparation, dans la piste.
   ========================================================================= */
:root {
    --lab-bg: #15201F;
    --lab-border: rgba(51, 214, 192, 0.38);
    --lab-well: rgba(0, 0, 0, 0.28);
}

/* --- Barre du haut ---------------------------------------------------------- */
.tb-tempo { height: 32px; border-radius: 6px; }
.tb-tempo button { height: 30px; width: 28px; }
.tb-tempo .bpm-val { min-width: 34px; padding: 0 2px 0 8px; }
.tb-tempo .bpm-unit { padding-right: 8px; }
.tb-daw {
    font-style: normal;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    color: var(--teal);
    border: 1px solid rgba(51, 214, 192, 0.5);
    border-radius: 3px;
    padding: 0 4px;
    margin-right: 8px;
}
.tb-daw[hidden] { display: none; }
.tb-history { display: inline-flex; gap: 4px; }
.tb-history .tb-icon { font-size: 1rem; line-height: 1; }
.tb-icon:disabled { opacity: 0.35; cursor: default; border-color: var(--border-inverse); color: var(--text-main); }
.tb-right .tb-transport { margin-right: 4px; }
.tb-transport #btn-play-main { width: 48px; }
.tb-loop {
    height: 32px;
    width: 32px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid var(--border-inverse);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
}
.tb-loop.is-on { border-color: var(--citron); color: var(--citron); }
.tb-loop[hidden] { display: none; }

/* --- Séparateur : un simple espace entre deux blocs ------------------------- */
.dock-splitter {
    height: 16px;
    margin-top: 0;
    border-top: 0;
    background: transparent;
}

/* --- Le Lab ------------------------------------------------------------------ */
.bottom-dock.lab {
    margin: 0 10px 10px;
    border-radius: 12px;
    background: var(--lab-bg);
    border: 1px solid var(--lab-border);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.bottom-dock-full.lab {
    height: var(--dock-h, 50vh);
    max-height: none;
    min-height: 150px;
    padding: 10px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.bottom-dock.lab.builder-collapsed { display: none; }

.lab-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; min-height: 32px; }
.lab-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--teal);
    line-height: 1;
}
.lab-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.14); }
.lab .lab-ctl { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 0; }
.lab-ctl .ctl-label { font-size: 0.58rem; }
.lab .theme-popup__button { padding: 5px 10px; background: var(--lab-well); }
.lab #custom-container-scale-type { min-width: 220px; }
.lab .lab-head .theme-popup__list-container { z-index: 60; }

/* Suggestion de gamme : une pastille à côté du sélecteur, plus un bandeau. */
.lab .scale-suggestion-banner {
    padding: 3px 4px 3px 12px;
    gap: 8px;
    border: 1px solid rgba(183, 226, 63, 0.4);
    border-radius: 999px;
    background: rgba(183, 226, 63, 0.10);
}
.lab .scale-suggestion-banner[hidden] { display: none; }
.lab .scale-suggestion-banner span { font-size: 0.7rem; }
.lab .scale-suggestion-banner #scale-suggestion-apply {
    margin-left: 4px;
    background: var(--citron);
    border-color: var(--citron);
    border-radius: 999px;
    height: 22px;
}
.lab .scale-suggestion-banner #scale-suggestion-dismiss { border-radius: 999px; }

.lab-presets { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lab-label {
    flex: none;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.lab .prog-presets-row,
.lab .prog-presets-row.visible { display: flex; padding: 0; gap: 6px; flex-wrap: wrap; }
.lab .prog-btn { padding: 4px 10px; border-radius: 999px; background: var(--lab-well); border-color: rgba(255, 255, 255, 0.16); color: var(--text-main); }

.lab .merged-panel { flex: 0 0 auto; }
.lab .merged-mood { border-left: 1px solid rgba(255, 255, 255, 0.10); }
.lab .degree-card,
.lab .mood-card:not(.active),
.lab .stepper { background: var(--lab-well); }
.lab .degree-palette-row { padding-top: 0; }

/* --- Bande des noms d'accord : bouton Ajouter, déplacement ----------------- */
#chord-ruler { height: 40px; flex-basis: 40px; }
.chord-ruler-item { cursor: grab; touch-action: none; }
.chord-ruler-item.reordering {
    z-index: 5;
    cursor: grabbing;
    background: rgba(183, 226, 63, 0.12);
    border: 1px solid var(--citron);
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.chord-ruler-item.draft { cursor: default; border-right: 0; overflow: visible; }
.btn-add-chord {
    height: 26px;
    max-width: 100%;
    padding: 0 10px;
    border-radius: 5px;
    border: 1px solid var(--citron);
    background: var(--citron);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(183, 226, 63, 0.25);
}
.btn-add-chord:hover { filter: brightness(1.08); }
.btn-add-chord .shortcut-hint { opacity: 0.6; margin-left: 6px; }
.btn-add-chord.btn-editing { height: 18px; padding: 0 8px; font-size: 0.6rem; background: transparent; color: var(--citron); box-shadow: none; }

/* --- Accord en préparation : pas encore sur la piste ----------------------- */
.seq-chord-column.placeholder {
    border: 1.5px dashed rgba(183, 226, 63, 0.7);
    background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 6px, transparent 6px 12px);
}
.seq-chord-column.placeholder:hover { background-color: rgba(183, 226, 63, 0.05); }
.seq-note.draft {
    background: color-mix(in srgb, var(--tone-color) 18%, transparent) !important;
    border: 1.5px dashed var(--tone-color);
    box-shadow: none;
}
.seq-chord-label.seq-draft-label {
    width: 100%;
    text-align: center;
    font-size: 0.56rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--citron);
    opacity: 0.85;
}

/* Actions de l'accord sélectionné : dupliquer, retirer. */
/* Ancrées à gauche, la colonne sélectionnée passant au-dessus de ses
   voisines : sur un accord court, elles débordent vers la droite plutôt que
   sur la colonne des notes. */
.seq-chord-column.selected { z-index: 4; }
.seq-col-actions {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 6;
    display: flex;
    gap: 4px;
}
.seq-col-actions .seq-col-del { position: static; }
.seq-col-dup:hover { border-color: var(--citron); color: var(--citron); }

/* --- Rangées de la gamme dans la piste ------------------------------------- */
.seq-lane {
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    background: rgba(183, 226, 63, 0.045);
    pointer-events: none;
}
.seq-lane.tonic { background: rgba(183, 226, 63, 0.10); }
.seq-key.in-scale { box-shadow: inset 3px 0 0 rgba(183, 226, 63, 0.55); color: var(--text-main); }

/* --- Lettres du clavier d'ordinateur : au survol, ou toujours si demandé --- */
.piano-input .key::before { opacity: 0; transition: opacity var(--duration-standard) var(--ease-standard); }
.piano-input:hover .key::before,
html.kb-letters-always .piano-input .key::before { opacity: 1; }

.sp-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-main);
    cursor: pointer;
}
.sp-check input { accent-color: var(--citron); }

/* Fenêtre étroite : la barre se resserre. */
@media (max-width: 1100px) {
    .lab #custom-container-scale-type { min-width: 170px; }
}
@media (max-width: 900px) {
    .tb-history { display: none; }
    .tb-tempo .bpm-unit { display: none; }
    .lab-presets .lab-label { display: none; }
}

/* =========================================================================
   v12 — Fond de piste dynamique + édition des notes d'un accord
   ========================================================================= */
/* Le fond est dessiné par la grille elle-même (rangées + quadrillage), qui
   défile avec les accords. Le conteneur ne garde que la couleur de fond. */
#sequencer-timeline { background-image: none; }
#sequencer-grid { background-image: none; }

.seq-lane {
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    background: transparent;
    pointer-events: none;
}
.seq-lane.black { background: rgba(0, 0, 0, 0.22); }
.seq-lane.c-row { border-bottom-color: rgba(255, 255, 255, 0.14); }
.seq-lane.in-scale { background: rgba(183, 226, 63, 0.045); }
.seq-lane.in-scale.black { background: rgba(183, 226, 63, 0.035); }
.seq-lane.tonic { background: rgba(183, 226, 63, 0.10); }

.seq-beats {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(to right, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px var(--bar-w)),
        repeating-linear-gradient(to right, rgba(255, 255, 255, 0.075) 0 1px, transparent 1px var(--beat-w)),
        repeating-linear-gradient(to right, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px var(--sub-w));
}

/* Notes hors de la gamme de l'accord : hachurées, comme dans Hookpad. */
.seq-note.out-of-scale {
    background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(14, 14, 16, 0.72) 3px 6px);
    border: 1px solid var(--tone-color);
}

/* Accord sélectionné : ses notes s'attrapent. */
.seq-chord-column.selected { cursor: cell; }
.seq-note.editable { cursor: ns-resize; z-index: 5; }
.seq-note.editable:hover { filter: brightness(1.15); }
.seq-note.note-selected { box-shadow: 0 0 0 2px #FFFFFF, 0 0 12px rgba(255, 255, 255, 0.45); z-index: 6; }
.seq-note.dragging { opacity: 0.95; }

/* Bande des noms : ✎ accord retouché, ● notes hors gamme. */
.chord-ruler-item .sym-row { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0; }
.chord-ruler-item .custom-badge {
    flex: none;
    font-size: 0.56rem;
    color: var(--citron);
    border: 1px solid rgba(183, 226, 63, 0.5);
    border-radius: 7px;
    padding: 0 4px;
    line-height: 12px;
}
.chord-ruler-item .off-dot { color: var(--rust); font-size: 0.5rem; }
.seq-col-reset { border-color: rgba(183, 226, 63, 0.55); color: var(--citron); }
.seq-col-reset:hover { border-color: var(--citron); }

/* Lab : pastille « notes perso ». */
.cr-custom {
    margin-left: 8px;
    height: 20px;
    padding: 0 8px;
    border-radius: 10px;
    border: 1px solid rgba(183, 226, 63, 0.5);
    background: transparent;
    color: var(--citron);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    white-space: nowrap;
    cursor: pointer;
}
.cr-custom[hidden] { display: none; }
.cr-custom:hover { border-color: var(--citron); background: rgba(183, 226, 63, 0.08); }

/* « ✓ Valider » dans la bande des noms : contour citron lisible (une règle
   plus ancienne sur .btn-editing le remplissait en teal, texte illisible). */
.chord-ruler-item #btn-add-chord.btn-editing,
.chord-ruler-item #btn-add-chord.btn-editing:hover {
    background: rgba(183, 226, 63, 0.12);
    border-color: var(--citron);
    color: var(--citron);
}

/* Barre d'actions de l'accord sélectionné : flottante, en haut de la partie
   visible de la piste, bornée au cadre (voir positionChordActions). */
#seq-chord-actions {
    top: 6px;
    z-index: 22;
    padding: 3px;
    border-radius: 6px;
    background: rgba(24, 24, 27, 0.94);
    border: 1px solid var(--border-inverse);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
#seq-chord-actions[hidden] { display: none; }
