/* Studio Louve — thème sombre inspiré des consoles de studio */
:root {
  --fond: #1b1d22; --fond2: #23262d; --fond3: #2c3038; --fond4: #363b45;
  --ligne: #3d424d; --texte: #e8e9ec; --doux: #9aa0ab; --accent: #f2b33d; --accent2: #5ab0ff;
  --rouge: #ff4d4d; --vert: #46d17a; --jaune: #ffd23f;
  --entete: 210px; --hauteur-piste: 88px;
  --rayon: 6px;
  color-scheme: dark;
}
body.clair { --fond: #e9eaee; --fond2: #f6f6f8; --fond3: #ffffff; --fond4: #dfe1e6; --ligne: #c7cad2; --texte: #1c1e23; --doux: #5d6370; color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond); color: var(--texte);
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--fond3); border: 1px solid var(--ligne); border-radius: var(--rayon);
  padding: 6px 10px; cursor: pointer; min-height: 34px; white-space: nowrap;
}
button:hover { background: var(--fond4); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
button.actif, button.bascule.on { background: var(--accent); color: #1b1d22; border-color: var(--accent); }
button.danger:hover { background: var(--rouge); color: #fff; }
button.principal-btn { background: var(--accent); color: #1b1d22; border-color: var(--accent); font-weight: 600; }
select, input[type=number], input[type=text], input[type=search], textarea {
  background: var(--fond); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 5px 7px; min-height: 32px;
}
input[type=range] { accent-color: var(--accent); }
.rouge { color: var(--rouge); }
[hidden] { display: none !important; }
body.mode-simple .pro { display: none !important; }

/* Barre de menus */
.menus { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--fond2); border-bottom: 1px solid var(--ligne); }
.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .3px; }
.logo img { width: 26px; height: 26px; }
.menu { background: transparent; border-color: transparent; }
.menu:hover { background: var(--fond3); }
.espace { flex: 1; }
.bascule-fenetre { display: flex; border: 1px solid var(--ligne); border-radius: var(--rayon); overflow: hidden; }
.bascule-fenetre button { border: 0; border-radius: 0; background: var(--fond3); }
.bascule-fenetre button.actif { background: var(--accent); }
.interrupteur { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--doux); }
.interrupteur input { display: none; }
.interrupteur i { width: 38px; height: 22px; border-radius: 11px; background: var(--fond4); position: relative; transition: .2s; }
.interrupteur i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--texte); transition: .2s; }
.interrupteur input:checked + i { background: var(--accent); }
.interrupteur input:checked + i::after { left: 19px; background: #1b1d22; }

/* Transport */
.transport { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--fond2); border-bottom: 1px solid var(--ligne); flex-wrap: wrap; }
.transport .groupe { display: flex; gap: 4px; align-items: center; }
.transport .gros { font-size: 18px; min-width: 46px; }
.transport .rec { color: var(--rouge); }
body.enregistre .transport .rec { background: var(--rouge); color: #fff; animation: clign 1s infinite; }
body.lit #tLecture { background: var(--vert); color: #102; }
@keyframes clign { 50% { opacity: .55; } }
.compteur { background: #0e1013; color: #7dffb0; border-radius: var(--rayon); padding: 3px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; display: flex; flex-direction: column; align-items: flex-end; min-width: 120px; cursor: pointer; line-height: 1.15; }
.compteur b { font-size: 19px; }
.compteur small { color: #9fb; opacity: .7; }
body.clair .compteur { background: #1c1e23; }
.tempo label { display: flex; align-items: center; gap: 2px; }
#iBpm { width: 70px; }
.vu-master canvas { display: block; border-radius: 3px; background: #0e1013; }
.etat-micro { font-size: 12px; color: var(--doux); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etat-micro.ok { color: var(--vert); }

/* Zone principale */
.principal { flex: 1; display: flex; min-height: 0; }
.vue-edition, .vue-mixage { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Barre du clip sélectionné */
.barre-clip { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--fond3); border-bottom: 1px solid var(--ligne); flex-wrap: wrap; font-size: 13px; }
.barre-clip button { min-height: 30px; padding: 3px 8px; }
.barre-clip input[type=number] { width: 58px; min-height: 28px; }
#infoClip { color: var(--doux); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Timeline */
.tl { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; }
.tl-contenu { position: relative; min-height: 100%; }
.tl-regle { position: sticky; top: 0; z-index: 6; display: flex; height: 40px; background: var(--fond2); border-bottom: 1px solid var(--ligne); }
.tl-regle .coin { position: sticky; left: 0; z-index: 7; width: var(--entete); flex: none; display: flex; gap: 4px; padding: 4px; background: var(--fond2); border-right: 1px solid var(--ligne); }
.tl-regle .coin button { flex: 1; padding: 2px 4px; min-height: 30px; font-size: 12.5px; }
#regle { position: sticky; left: var(--entete); display: block; cursor: pointer; touch-action: none; }
.piste { display: flex; height: var(--hauteur-piste); border-bottom: 1px solid var(--ligne); }
.piste.sel .entete { background: var(--fond4); }
.piste.inactive { opacity: .45; }
.piste.cible-depot .couloir { background: rgba(242,179,61,.12); }
.entete { position: sticky; left: 0; z-index: 4; width: var(--entete); flex: none; background: var(--fond2); border-right: 1px solid var(--ligne); padding: 5px 6px 5px 10px; display: flex; flex-direction: column; gap: 4px; }
.entete::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.entete .l1 { display: flex; align-items: center; gap: 4px; }
.entete .icone { font-size: 16px; cursor: pointer; }
.entete .nom { flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; padding: 2px 4px; min-height: 26px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.entete .nom:focus { border-color: var(--ligne); background: var(--fond); }
.entete .l2 { display: flex; gap: 3px; align-items: center; }
.entete .l2 button, .entete .l1 button { min-height: 26px; min-width: 28px; padding: 1px 5px; font-size: 12px; font-weight: 700; }
.b-m.on { background: #ffcf3f; color: #222; border-color: #ffcf3f; }
.b-s.on { background: #4cd07d; color: #111; border-color: #4cd07d; }
.b-r { color: var(--rouge); }
.b-r.on { background: var(--rouge); color: #fff; border-color: var(--rouge); }
.b-r.on.clignote { animation: clign .8s infinite; }
.entete .l3 { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--doux); }
.entete .l3 input[type=range] { flex: 1; min-width: 0; height: 18px; }
.entete .vu { width: 6px; height: 100%; position: absolute; right: 2px; top: 0; }
.couloir { position: relative; flex: none; }
.grille { position: absolute; inset: 0; pointer-events: none; }
.clip {
  position: absolute; top: 4px; bottom: 4px; border-radius: 5px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 35%, #15171b); border: 1px solid color-mix(in srgb, var(--c) 80%, #000);
  cursor: grab; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none;
}
.clip.sel { outline: 2px solid #fff; outline-offset: -1px; touch-action: none; z-index: 2; }
.clip.deplace { opacity: .75; cursor: grabbing; }
.clip canvas { position: absolute; left: 0; top: 16px; width: 100%; height: calc(100% - 16px); }
.clip .titre { position: absolute; left: 0; right: 0; top: 0; height: 16px; padding: 0 5px; font-size: 11px; line-height: 16px; background: color-mix(in srgb, var(--c) 70%, #000); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip .poignee { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 3; }
.clip .poignee.g { left: 0; } .clip .poignee.d { right: 0; }
.clip .poignee:hover { background: rgba(255,255,255,.18); }
.clip.enregistrement { background: rgba(255,77,77,.25); border-color: var(--rouge); }
.tete { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; z-index: 5; box-shadow: 0 0 6px var(--accent); }
.tl-vide { position: absolute; left: var(--entete); right: 0; top: 60px; text-align: center; color: var(--doux); padding: 30px 16px; pointer-events: none; }
.tl-vide p { display: inline-block; border: 2px dashed var(--ligne); border-radius: 12px; padding: 24px; max-width: 520px; }
body.depot .tl { outline: 3px dashed var(--accent); outline-offset: -3px; }

/* Mixage */
.vue-mixage { flex-direction: row; overflow-x: auto; overflow-y: auto; gap: 2px; padding: 6px; background: var(--fond); align-items: stretch; }
.tranche { width: 112px; flex: none; background: var(--fond2); border: 1px solid var(--ligne); border-radius: var(--rayon); display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 6px 5px; position: relative; min-height: 460px; }
.tranche::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--c); border-radius: var(--rayon) var(--rayon) 0 0; }
.tranche.master { width: 128px; border-color: var(--accent); }
.tranche .t-nom { font-weight: 600; font-size: 12.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.tranche .t-sec { font-size: 10.5px; color: var(--doux); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.inserts { display: flex; flex-direction: column; gap: 2px; }
.inserts button { min-height: 22px; padding: 1px 4px; font-size: 11px; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.inserts button.on { background: color-mix(in srgb, var(--accent2) 45%, var(--fond3)); border-color: var(--accent2); }
.tranche label { font-size: 11px; display: flex; align-items: center; gap: 3px; }
.tranche label input[type=range] { flex: 1; min-width: 0; }
.tranche .fader-zone { flex: 1; display: flex; gap: 6px; justify-content: center; align-items: stretch; min-height: 180px; }
.fader { writing-mode: vertical-lr; direction: rtl; width: 30px; flex: none; min-height: 170px; }
.vu-v { width: 10px; background: #0e1013; border-radius: 3px; display: block; }
.tranche .db { text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.tranche .boutons { display: flex; gap: 3px; justify-content: center; }
.tranche .boutons button { min-height: 26px; min-width: 28px; padding: 1px 5px; font-size: 12px; font-weight: 700; }
.tranche select { font-size: 11px; min-height: 26px; padding: 1px 3px; }

/* Panneau latéral */
.cote { display: flex; flex: none; border-left: 1px solid var(--ligne); background: var(--fond2); }
.onglets { display: flex; flex-direction: column; gap: 2px; padding: 4px; border-right: 1px solid var(--ligne); }
.onglets button { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 18px; border: 0; background: transparent; padding: 6px 4px; min-width: 58px; }
.onglets button span { font-size: 10.5px; color: var(--doux); }
.onglets button.actif { background: var(--fond4); color: inherit; }
.onglets button.actif span { color: var(--accent); }
.panneau { width: 360px; overflow-y: auto; padding: 12px; }
.panneau h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.panneau h2 .fermer { margin-left: auto; min-height: 28px; padding: 2px 9px; }
.panneau h3 { font-size: 13px; margin: 16px 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.panneau p.aide { color: var(--doux); font-size: 12.5px; margin: 4px 0 8px; }
.champ { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.champ > span { font-size: 12.5px; color: var(--doux); }
.ligne { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.ligne > * { flex: none; }
.ligne .etire { flex: 1; min-width: 0; }
.curseur { display: grid; grid-template-columns: 92px 1fr 56px; gap: 6px; align-items: center; margin: 5px 0; font-size: 12.5px; }
.curseur output { text-align: right; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--doux); }
.carte { background: var(--fond3); border: 1px solid var(--ligne); border-radius: 8px; padding: 10px; margin: 8px 0; }
.vu-h { height: 12px; background: #0e1013; border-radius: 3px; overflow: hidden; position: relative; }
.vu-h i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--vert) 0 70%, var(--jaune) 70% 88%, var(--rouge) 88%); transition: width .05s; }
.liste-sons { display: flex; flex-direction: column; gap: 4px; }
.son { display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; align-items: center; background: var(--fond3); border: 1px solid var(--ligne); border-radius: 6px; padding: 5px; cursor: grab; }
.son button { min-height: 28px; padding: 2px 7px; }
.son .infos { min-width: 0; }
.son .infos b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.son .infos small { color: var(--doux); font-size: 11px; }
.son .actions { display: flex; gap: 3px; }
.etiquette { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 8px; background: var(--fond4); color: var(--doux); margin-right: 3px; }
.filtres { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.filtres button { min-height: 26px; padding: 2px 8px; font-size: 12px; border-radius: 13px; }
textarea.paroles { width: 100%; min-height: 220px; resize: vertical; font-size: 15px; line-height: 1.5; }
.lignes-paroles { max-height: 200px; overflow-y: auto; border: 1px solid var(--ligne); border-radius: 6px; margin: 6px 0; font-size: 13px; }
.lignes-paroles div { padding: 3px 8px; cursor: pointer; display: flex; gap: 8px; }
.lignes-paroles div small { color: var(--doux); font-family: ui-monospace, monospace; min-width: 44px; }
.lignes-paroles div.courante { background: var(--accent); color: #1b1d22; }
.lignes-paroles div.courante small { color: #1b1d22; }
.etat { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 8px; font-weight: 600; }
.etat.ok { background: rgba(70,209,122,.2); color: var(--vert); }
.etat.dev { background: rgba(242,179,61,.18); color: var(--accent); }
.etat.bureau { background: rgba(90,176,255,.18); color: var(--accent2); }

/* Fenêtres flottantes (effets) */
.fenetre { position: fixed; z-index: 40; background: var(--fond2); border: 1px solid var(--ligne); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); width: 380px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 90px); display: flex; flex-direction: column; }
.fenetre .barre { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--fond3); border-radius: 10px 10px 0 0; cursor: move; touch-action: none; font-weight: 600; }
.fenetre .barre .c { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.fenetre .barre button { margin-left: auto; min-height: 28px; padding: 2px 9px; }
.fenetre .corps { overflow-y: auto; padding: 10px 12px; }
.bloc-fx { border: 1px solid var(--ligne); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.bloc-fx > header { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.bloc-fx > header label { margin-left: auto; font-weight: 400; font-size: 12px; display: flex; gap: 4px; align-items: center; }
.bloc-fx.off .curseur { opacity: .45; }

/* Toasts, modale */
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 20px)); }
.toast { background: #0e1013; color: #fff; border: 1px solid var(--ligne); border-left: 4px solid var(--accent2); padding: 9px 12px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); pointer-events: auto; display: flex; gap: 10px; align-items: center; width: 100%; }
.toast.erreur { border-left-color: var(--rouge); }
.toast.ok { border-left-color: var(--vert); }
.toast button { margin-left: auto; min-height: 28px; padding: 2px 9px; background: var(--accent); color: #111; border: 0; }
.modale { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 12px; }
.boite { background: var(--fond2); border: 1px solid var(--ligne); border-radius: 12px; width: min(620px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 18px; }
.boite h2 { margin: 0 0 10px; font-size: 19px; }
.boite .pied { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.projets-liste { display: flex; flex-direction: column; gap: 5px; }
.projets-liste .p { display: flex; gap: 6px; align-items: center; background: var(--fond3); border: 1px solid var(--ligne); border-radius: 8px; padding: 7px 9px; }
.projets-liste .p.courant { border-color: var(--accent); }
.projets-liste .p .etire { flex: 1; min-width: 0; }
.projets-liste .p small { color: var(--doux); display: block; }
.etapes { display: flex; gap: 6px; margin-bottom: 12px; }
.etapes i { flex: 1; height: 4px; border-radius: 2px; background: var(--fond4); }
.etapes i.fait { background: var(--accent); }
table.raccourcis { width: 100%; border-collapse: collapse; font-size: 13px; }
table.raccourcis td { padding: 4px 6px; border-bottom: 1px solid var(--ligne); }
table.raccourcis td:first-child { font-family: ui-monospace, Menlo, monospace; white-space: nowrap; color: var(--accent); }
kbd { background: var(--fond4); border-radius: 4px; padding: 0 5px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* Tablette */
@media (max-width: 1100px) {
  .panneau { width: 320px; }
  .menus .txt, .transport .txt { display: none; }
}
/* Téléphone / petite tablette : panneau en tiroir au-dessus des onglets du bas */
@media (max-width: 820px) {
  :root { --entete: 128px; --hauteur-piste: 90px; }
  .logo span, #nomUtilisateur { display: none; }
  .menus { gap: 3px; padding: 4px 6px; }
  .menus .menu { padding: 4px 6px; }
  #nomProjet { max-width: 90px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
  .transport { gap: 5px; padding: 4px 6px; }
  .transport button { padding: 4px 7px; min-height: 34px; }
  .compteur { min-width: 92px; padding: 2px 6px; }
  .compteur b { font-size: 16px; }
  .vu-master, .etat-micro { display: none; }
  .principal { flex-direction: column; }
  .cote { flex-direction: column-reverse; border-left: 0; border-top: 1px solid var(--ligne); }
  .onglets { flex-direction: row; justify-content: space-around; border-right: 0; padding: 2px 2px calc(2px + env(safe-area-inset-bottom)); }
  .onglets button { min-width: 0; flex: 1; font-size: 17px; }
  .panneau { width: 100%; max-height: 52dvh; border-bottom: 1px solid var(--ligne); }
  .entete { padding: 4px 4px 4px 9px; }
  .entete .l3 span { display: none; }
  .tl-regle .coin button { font-size: 11px; }
  .fenetre { left: 8px !important; right: 8px; width: auto; top: auto !important; bottom: 70px; max-height: 60dvh; }
}
@media (max-width: 480px) {
  .logo { display: none; }
  #nomProjet { max-width: 76px; }
  #bUtilisateur { display: none; }
}
@media (max-width: 420px) {
  .bascule-fenetre button { padding: 4px 6px; font-size: 12.5px; }
  .interrupteur span { display: none; }
  .tempo select { display: none; }
}

/* Phase 2 : automation, bus */
.piste.avec-auto { height: calc(var(--hauteur-piste) * 1.7); }
.couloir svg.auto { position: absolute; left: 0; top: 0; z-index: 3; cursor: crosshair; touch-action: none; }
.couloir svg.auto circle { cursor: grab; }
.b-auto.on { background: #ffd23f; color: #222; border-color: #ffd23f; }
.b-auto.ecrit { background: var(--rouge); color: #fff; border-color: var(--rouge); }
.badge-bus { font-size: 10.5px; font-weight: 700; padding: 3px 5px; border-radius: 5px; background: var(--accent2); color: #111; }
.piste.bus .couloir { background-color: color-mix(in srgb, var(--accent2) 6%, transparent); }
.info-bus { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--doux); font-size: 12px; white-space: nowrap; pointer-events: none; }
label.ligne { flex-wrap: nowrap; align-items: flex-start; }
label.ligne input[type=checkbox] { margin-top: 3px; }
