/* studio.css — thème studio BeatSync (inspiré BEATCUT : sombre, accent rouge). */
:root {
  --bg: #0a0a0c;
  --bg-panel: #0e0e12;
  --bg-box: #141419;
  --bg-input: #1a1a20;
  --border: #26262e;
  --border-on: #3a3a44;
  --txt: #e8e8ea;
  --txt-dim: #8a8a94;
  --txt-mute: #5a5a64;
  --accent: #ef4444;
  --accent-2: #8b5cf6;
  --green: #4ade80;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; overflow: hidden;
}

/* ── Régie ── */
.regie {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--border); background: #08080a;
}
.brand { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.brand-accent { color: var(--accent); }
.regie-right { display: flex; align-items: center; gap: 20px; font-family: var(--mono); font-size: 13px; }
.regie-email { color: var(--txt-dim); }
.regie-stby { color: var(--green); font-weight: 700; }
.regie-stby.live { color: var(--accent); }
.regie-tc { color: var(--green); letter-spacing: 1px; }

/* ── Layout ── */
.studio { display: flex; height: calc(100% - 56px); }
.panel {
  width: 430px; min-width: 430px; height: 100%; overflow-y: auto;
  background: var(--bg-panel); border-right: 1px solid var(--border); padding: 18px 20px 60px;
}
.panel-title { font-family: var(--mono); color: var(--txt-mute); font-size: 12px; margin-bottom: 18px; }

.sect { margin-bottom: 26px; }
.sect h2 { font-size: 13px; font-weight: 700; letter-spacing: .5px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.sect-n { color: var(--accent); font-family: var(--mono); }
.sect + .sect { border-top: 1px dashed var(--border); padding-top: 20px; }

/* ── Drop zones ── */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-box);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: #17171d; }
.drop strong { font-size: 14px; }
.drop span { color: var(--txt-dim); font-size: 12px; }
.drop.loaded { border-color: var(--green); }

/* ── Waveform + sélection ── */
/* Marge horizontale (14px) pour que les poignées aux extrémités ne soient pas coupées. */
.wave-wrap { margin: 12px 14px 0; position: relative; height: 60px; user-select: none; touch-action: none; cursor: pointer; }
#waveform { width: 100%; height: 60px; display: block; background: #0e0e12; border-radius: 6px; }
/* Zones hors-sélection assombries par un voile (en plus du dessin canvas). */
.sel-overlay { position: absolute; top: 0; height: 100%; background: rgba(239,68,68,.08); box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); pointer-events: none; left: 0; width: 100%; border-radius: 6px; }
/* Poignée bien visible : barre + gros bouton de préhension avec repère. */
.sel-handle { position: absolute; top: -4px; width: 22px; height: calc(100% + 8px); margin-left: -11px; cursor: ew-resize; z-index: 4; touch-action: none; }
.sel-handle::before { content: ''; position: absolute; left: 10px; top: 4px; width: 3px; height: calc(100% - 8px); background: var(--accent); border-radius: 2px; }
.sel-handle::after { content: '⋮'; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 16px; height: 30px; background: var(--accent); color: #fff; border-radius: 5px; font-size: 15px; font-weight: 900; line-height: 30px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.sel-handle:hover::after, .sel-handle.dragging::after { background: #fff; color: var(--accent); }
/* Infobulle de temps pendant le drag. */
.sel-time { position: absolute; top: -22px; transform: translateX(-50%); background: var(--accent); color: #fff; font: 700 10px var(--mono); padding: 2px 6px; border-radius: 4px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 5; }
.sel-time.show { opacity: 1; }
.sel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 14px 0; }
.bpm-line { font-family: var(--mono); font-size: 12px; color: var(--txt-dim); min-height: 16px; }
.bpm-line b { color: var(--green); }
.ghost.sm { padding: 5px 10px; font-size: 12px; margin: 0; }
.sel-hint { font-size: 11px; color: var(--txt-mute); margin-top: 6px; }

/* Utilitaire : masquage (manquait → le panneau BPM vide s'affichait). */
.hidden { display: none !important; }

/* ── Panneau [01] LE SON détaillé (COMPACT) ── */
.son-panel { background: var(--bg-box); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.bpm-head { display: flex; align-items: center; justify-content: space-between; }
.bpm-big { font-family: var(--mono); font-weight: 800; font-size: 32px; line-height: 1; color: var(--green); letter-spacing: -1px; }
.bpm-big small { font-size: 12px; color: var(--txt-dim); margin-left: 5px; letter-spacing: 0; }
.bpm-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--txt-mute); }
.bpm-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.bpm-ctrl { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.chip { background: var(--bg-input); color: var(--txt); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }
.chip:hover { border-color: var(--border-on); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bpm-input { flex: 1; min-width: 54px; max-width: 80px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 7px; color: var(--txt); padding: 6px 8px; font-size: 13px; font-family: var(--mono); text-align: center; }
.calage-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.calage-label, .ef-label { font-family: var(--mono); font-size: 10px; color: var(--txt-mute); letter-spacing: .5px; }
.calage-val { font-family: var(--mono); font-size: 11px; color: var(--accent-2); margin-left: auto; }
/* Waveform : compacte, sans grosse marge (les poignées restent dans le cadre). */
.son-panel .wave-wrap { margin: 10px 11px 0; height: 52px; }
.son-panel #waveform { height: 52px; }
.extrait-line { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--txt-dim); margin: 8px 2px 0; gap: 8px; }
.extrait-fields { display: flex; align-items: center; gap: 8px; margin: 8px 2px 0; font-size: 11px; color: var(--txt-dim); flex-wrap: wrap; }
.extrait-fields label { display: flex; align-items: center; gap: 4px; }
.extrait-fields input { width: 52px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--txt); padding: 5px 6px; font-size: 12px; font-family: var(--mono); }
.son-actions { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.son-file { font-family: var(--mono); font-size: 10px; color: var(--txt-mute); margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.son-change { background: none; border: none; color: var(--accent-2); font-size: 10px; cursor: pointer; text-decoration: underline; padding: 0; font-family: inherit; }
.export-hint { font-size: 11px; color: var(--txt-mute); margin: 8px 0 0; line-height: 1.4; }

/* ── Segmented controls ── */
.seg { display: inline-flex; gap: 0; background: var(--bg-box); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  background: transparent; color: var(--txt-dim); border: none; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.seg-btn.on { background: var(--accent); color: #fff; }
.seg-btn:disabled { opacity: .4; cursor: not-allowed; }
#fond-mode, #format-sel, #cut-density { display: flex; margin-bottom: 12px; }

/* ── Box ── */
.box { background: var(--bg-box); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 12px; }
.box-label { font-family: var(--mono); font-size: 11px; color: var(--txt-mute); letter-spacing: .5px; margin-bottom: 8px; }
.ghost {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg-input); color: var(--txt);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; margin: 4px 0;
}
.ghost:hover { border-color: var(--border-on); }
.txt {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--txt); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--txt-dim); margin-top: 10px; cursor: pointer; }
.check input { margin-top: 2px; }

/* ── Bande de clips ── */
.clip-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
/* Mode flash : palette éditable + presets */
.palette-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.swatch { width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.palette-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.flash-hint { font-size: 11px; color: var(--accent-2); margin-top: 8px; line-height: 1.4; }
.dimmed { opacity: .4; pointer-events: none; }

/* ── Sous-titres [03] ── */
.sub-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-note { font-size: 11px; color: var(--accent-2); flex: 1; }
.mini-select { background: var(--bg-input); border: 1px solid var(--border); border-radius: 7px; color: var(--txt); padding: 6px 8px; font-size: 13px; font-family: inherit; }
#subs-panel textarea.txt { margin-top: 10px; resize: vertical; min-height: 70px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.style-card { background: var(--bg-box); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; transition: border-color .12s; }
.style-card:hover { border-color: var(--border-on); }
.style-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.style-card .sc-label { font-weight: 800; font-size: 13px; }
.style-card .sc-sub { font-size: 12px; color: var(--txt); font-weight: 700; margin-top: 2px; }
.style-card .sc-desc { font-size: 10px; color: var(--txt-mute); margin-top: 4px; line-height: 1.3; }
.slider-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11px; color: var(--txt-dim); }
.slider-row span:first-child { min-width: 56px; font-family: var(--mono); letter-spacing: .3px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); }
.check.inline { margin: 0; white-space: nowrap; }
.clip-thumb { position: relative; width: 60px; height: 60px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.clip-thumb video { width: 100%; height: 100%; object-fit: cover; }
.clip-thumb .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 4px; width: 18px; height: 18px; font-size: 12px; cursor: pointer; line-height: 1; }

/* ── Export ── */
.export-free, .export-pro {
  width: 100%; border: none; border-radius: 10px; padding: 14px; font-size: 14px; font-weight: 700;
  cursor: pointer; margin-top: 10px;
}
.export-free { background: var(--bg-input); color: var(--txt); border: 1px solid var(--border); }
.export-free:hover { border-color: var(--border-on); }
.export-pro { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff; }
.export-pro:disabled, .export-free:disabled { opacity: .5; cursor: not-allowed; }
.export-note { font-size: 12px; color: var(--txt-dim); margin: 8px 0 0; min-height: 16px; }

/* ── Scène / phone ── */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; overflow: hidden; }
.phone {
  position: relative; height: min(72vh, 640px); aspect-ratio: 9/16;
  background: #000; border: 1px solid #2a2a32; border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0,0,0,.6);
}
.phone.f-1-1 { aspect-ratio: 1/1; }
.phone.f-16-9 { aspect-ratio: 16/9; height: auto; width: min(72vh, 900px); }
.preview { width: 100%; height: 100%; display: block; }
.phone-hud { position: absolute; top: 12px; left: 14px; right: 14px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--green); pointer-events: none; z-index: 2; }
.hud-rec.live { color: var(--accent); }
.phone-foot { position: absolute; bottom: 12px; left: 14px; right: 14px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--txt-dim); pointer-events: none; z-index: 2; }

.transport { display: flex; gap: 12px; }
.tr-play, .tr-stop { border: none; border-radius: 9px; padding: 12px 26px; font-size: 15px; font-weight: 700; cursor: pointer; }
.tr-play { background: var(--accent); color: #fff; }
.tr-play.playing { background: var(--bg-input); color: var(--txt); border: 1px solid var(--border); }
.tr-stop { background: var(--bg-input); color: var(--txt-dim); border: 1px solid var(--border); }
.stage-hint { color: var(--txt-mute); font-size: 13px; margin: 0; text-align: center; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c1c24; border: 1px solid var(--border-on); color: var(--txt); padding: 12px 20px;
  border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--accent); }

@media (max-width: 900px) {
  .studio { flex-direction: column; }
  .panel { width: 100%; min-width: 0; height: auto; max-height: 50vh; border-right: none; border-bottom: 1px solid var(--border); }
  .stage { padding: 12px; }
  .phone { height: min(46vh, 420px); }
}

/* ══ Timeline d'édition (rail) ══════════════════════════════════════════════ */
.edit-tl {
  width: 100%;
  max-width: 920px;
  margin: 14px auto 0;
  background: #0b0b11;
  border: 1px solid #1f2430;
  border-radius: 12px;
  padding: 10px 12px 12px;
  box-sizing: border-box;
}
.edit-tl-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.edit-tl-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #6b7280;
}
.tl-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #2b3a52;
  background: #141b28;
  color: #cbd5e1;
  cursor: pointer;
  transition: all .12s;
}
.tl-btn:hover:not(:disabled) { border-color: #fc1c46; color: #fff; }
.tl-btn.danger:hover:not(:disabled) { border-color: #fc1c46; background: rgba(252,28,70,.14); color: #fff; }
.tl-btn:disabled { opacity: .4; cursor: not-allowed; }
.edit-tl-hint {
  flex: 1 1 100%;
  font-size: 11px;
  color: #4b5563;
  margin-top: 2px;
}
#edit-timeline {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: #0b0b11;
  cursor: default;
}
@media (max-width: 900px) {
  .edit-tl { max-width: 100%; }
  .edit-tl-hint { display: none; }
}

/* Édition d'un mot de paroles dans la timeline */
.tl-word-edit { display: inline-flex; align-items: center; gap: 8px; }
.tl-word-edit[hidden] { display: none; }
.tl-word-tag { font-size: 12px; font-weight: 700; color: #fc1c46; letter-spacing: .02em; }
.tl-word-input {
  font-size: 13px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid #fc1c46; background: #12161f; color: #fff;
  min-width: 160px; outline: none;
}
.tl-word-input:focus { box-shadow: 0 0 0 2px rgba(252,28,70,.25); }
