/* Écran des bruitages dans la nouvelle interface (même habillage que le parcours vidéo, flow.css) */
body.studio {
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; grid-template-columns: 68px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh;
}
body.studio > .sx-rail { grid-column: 1; grid-row: 1 / -1; }
body.studio > .sx-head { grid-column: 2; grid-row: 1; }
body.studio > .sx-cards { grid-column: 2; grid-row: 2; }
body.studio > .layout { grid-column: 2; grid-row: 3; }
body.studio > .sx-bottom { grid-column: 2; grid-row: 4; }
.sx-hide { display: none !important; }

/* Rail */
/* Barre de gauche commune aux trois écrans (parcours vidéo, bruitages, Studio) : toujours visible, boutons fixes */
.sx-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 68px; z-index: 32; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 8px; }
#studio { left: 68px; }
html[data-space="flow"] body > .sx-head, html[data-space="flow"] body > .sx-cards, html[data-space="flow"] body > .layout,
html[data-space="flow"] body > .sx-bottom, html[data-space="flow"] body > .mobile-nav { visibility: hidden; }
html[data-space="flow"] body:not(.st-open) #flow-back, html[data-space="sfx"] body:not(.st-open) #sx-here, body.st-open #studio-open { background: var(--accent-soft); color: var(--accent-ink); }
html[data-space="flow"] body:not(.st-open) #flow-back::before, html[data-space="sfx"] body:not(.st-open) #sx-here::before, body.st-open #studio-open::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--grad); }
.sx-rb[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 52px; white-space: nowrap; background: var(--panel); border: 1px solid var(--border); padding: 5px 9px; border-radius: 8px; font-size: 12px; color: var(--text); z-index: 9; box-shadow: var(--shadow); pointer-events: none; }
.sx-logo img { width: 40px; height: 40px; border-radius: 11px; margin-bottom: 12px; box-shadow: 0 6px 20px var(--glow); display: block; }
.sx-rb { width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; position: relative; cursor: pointer; padding: 0; }
.sx-rb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sx-rb:hover { background: var(--panel-2); color: var(--text); }
.sx-sp { flex: 1; }

/* En-tête */
.topbar.sx-head { height: auto; padding: 12px 26px; gap: 14px; background: none; border-bottom: 1px solid var(--border); }
.sx-t { flex: 1; min-width: 0; }
.sx-t h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.sx-head .topbar-mid { border-left: 0; padding-left: 0; margin-left: 0; gap: 6px; }
.sx-head .topbar-mid .icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); }
.sx-pill { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.sx-pill:hover { border-color: var(--border-2); }
.sx-pill span:not(.sx-tog) { color: var(--accent-ink); }
.sx-pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.sx-pill.on { border-color: var(--accent-line); background: var(--accent-soft); }
.sx-tog { width: 36px; height: 20px; border-radius: 99px; background: var(--border-2); position: relative; transition: .2s; flex: none; cursor: pointer; display: inline-block; }
.sx-tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; }
.sx-tog.on, .sx-pill.on .sx-tog { background: var(--grad); }
.sx-tog.on::after, .sx-pill.on .sx-tog::after { left: 19px; }

/* Cartes */
.sx-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 14px 26px 0; }
.sx-cards[hidden] { display: none; }
.sx-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 9px 16px; text-align: left; color: var(--text); font: inherit; }
button.sx-card { cursor: pointer; }
button.sx-card:hover { border-color: var(--border-2); }
.sx-card .k { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.sx-card .v { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; display: flex; align-items: baseline; gap: 6px; min-height: 26px; }
.sx-card .v small { font-size: 12.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.sx-card.hero { background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--grad) border-box; border: 1px solid transparent; }
.sx-card.hero .v { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sx-card.warn { border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: linear-gradient(135deg, rgba(251, 191, 36, .12), transparent 70%), var(--panel); }
.sx-card.warn .v { color: var(--gold); }
.sx-card.ok .v small { color: var(--ok); }

/* Colonnes */
body.studio .layout { padding: 16px 26px; gap: 14px; grid-template-columns: 240px minmax(0, 1fr) 360px; }
body.studio .panel { border-radius: 16px; }
body.studio .center { overflow: auto; }
body.studio .seg-panel { min-height: 240px; }
.inspector .tabs { padding: 8px; gap: 2px; background: var(--bg-2); margin: 10px 10px 0; border-radius: 12px; border: 1px solid var(--border); }
.inspector .tab { flex: 1; border-radius: 9px; }
.inspector .tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.sx-split { display: inline-flex; }

/* Sections repliables */
details.sx-sec { border-top: 1px solid var(--border); padding: 2px 0; }
details.sx-sec > summary, #exp-extra-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 0; }
details.sx-sec > summary::-webkit-details-marker { display: none; }
details.sx-sec > summary b { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
details.sx-sec > summary .sx-sum-r { flex: 1; text-align: right; font-style: normal; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.sx-sec > summary::after { content: "›"; color: var(--muted); transition: .2s; font-size: 18px; line-height: 1; }
details.sx-sec[open] > summary::after { transform: rotate(90deg); }
details.sx-sec[open] { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }

/* Barre du bas */
.sx-bottom { display: flex; align-items: center; gap: 12px; padding: 14px 26px; border-top: 1px solid var(--border); background: var(--bg-2); position: relative; }
.sx-sum { flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.sx-sum b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.sx-sum .summary { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-stat { display: flex; flex-direction: column; gap: 4px; max-width: 320px; min-width: 0; }
.sx-stat .status { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-stat .progress { width: 220px; }
.sx-actions { display: flex; gap: 10px; align-items: center; }
.sx-actions .btn { height: 42px; border-radius: 999px; padding: 0 18px; }
.sx-split .btn.primary { background: var(--grad); color: #06121a; border: 0; box-shadow: 0 8px 26px var(--glow); }
.sx-split #export { border-radius: 999px 0 0 999px; padding-right: 14px; }
.sx-split .sx-caret { border-radius: 0 999px 999px 0; padding: 0 14px 0 10px; border-left: 1px solid rgba(6, 18, 26, .25); }
.sx-caret svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.sx-split .btn.primary:disabled { opacity: .35; box-shadow: none; }

/* Menu d'export */
.sx-menu { position: absolute; right: 26px; bottom: 76px; width: 390px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 10px; z-index: 30; max-height: calc(100vh - 130px); overflow: auto; }
.sx-menu .head { background: var(--bg-2); border-radius: 12px; padding: 14px; margin-bottom: 6px; }
.sx-menu .head b { display: block; }
.sx-menu .head p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.sx-menu .chk { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
.sx-menu .chk .tx { flex: 1; }
.sx-menu .chk b { font-size: 13.5px; }
.sx-menu .chk small { display: block; color: var(--muted); font-size: 12px; }
.sx-menu h4 { margin: 12px 10px 6px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.sx-menu button.it { display: flex; width: 100%; align-items: center; gap: 12px; border: 0; background: none; padding: 9px 10px; border-radius: 10px; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.sx-menu button.it:hover { background: var(--panel-2); }
.sx-menu .it .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); flex: none; font-weight: 800; font-size: 11px; }
.sx-menu .it .ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.sx-menu .it:hover .ic { color: var(--accent-ink); }
.sx-menu .it .tx { flex: 1; font-weight: 600; }
.sx-menu .it .tx small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 1px; }
.sx-menu .it em { font-style: normal; font-size: 11.5px; color: var(--faint); }
.sx-menu .it .cb { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-2); flex: none; display: grid; place-items: center; }
.sx-menu .it.pick .cb { background: var(--grad); border-color: transparent; }
.sx-menu .it.pick .cb::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 800; }
.sx-menu .go { padding: 8px 6px; }
.sx-menu .go .btn { width: 100%; justify-content: center; height: 42px; border-radius: 999px; background: var(--grad); color: #06121a; border: 0; }
.sx-menu .foot { margin: 6px 4px 2px; padding: 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.sx-menu .foot svg { width: 15px; height: 15px; fill: none; stroke: var(--ok); stroke-width: 2; }

/* Contrôle qualité : colonne des corrections */
.qc-fix { text-align: right; white-space: nowrap; }

@media (max-width: 1180px) {
  body.studio .layout { grid-template-columns: 210px minmax(0, 1fr) 310px; padding: 14px 18px; }
  .sx-cards { padding: 14px 18px 0; }
  .topbar.sx-head, .sx-bottom { padding-left: 18px; padding-right: 18px; }
  .sx-stat { display: none; }
}
@media (max-width: 920px) {
  body.studio { display: block; height: auto; padding-left: 68px; }
  .topbar.sx-head { flex-wrap: wrap; padding: 12px 16px; }
  .sx-head .topbar-end { gap: 6px; }
  .sx-cards { grid-template-columns: 1fr 1fr; padding: 12px 16px 0; gap: 10px; }
  body.studio .layout { padding: 12px 16px; grid-template-columns: minmax(0, 1fr); }
  .sx-card { padding: 10px 12px; }
  .sx-card .k { font-size: 10px; letter-spacing: .06em; }
  .sx-card .v { font-size: 20px; min-height: 0; }
  .sx-card .v small { display: none; }
  #sx-qc .v small, #sx-dur small { display: inline; font-size: 12px; }
  .sx-bottom { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); flex-wrap: wrap; padding: 10px 16px; z-index: 10; }
  .sx-actions { width: 100%; }
  .sx-actions #sheet-open, .sx-actions #qc-run { display: none; }
  .sx-split { flex: 1; }
  .sx-split #export { flex: 1; justify-content: center; }
  #engine .label { display: none; }
  .sx-menu { left: 12px; right: 12px; width: auto; bottom: 64px; }
}
@media (max-width: 560px) {
  .sx-pill { height: 32px; padding: 0 10px; font-size: 12px; }
  .sx-sum b { font-size: 18px; }
}

/* Téléphone : la barre commune passe en haut, mêmes boutons dans le même ordre */
@media (max-width: 860px) {
  .sx-rail { bottom: auto; right: 0; width: auto; height: 50px; flex-direction: row; padding: 6px 10px; gap: 2px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sx-logo img { width: 32px; height: 32px; margin: 0 6px 0 0; border-radius: 9px; }
  .sx-rb { width: 38px; height: 38px; border-radius: 10px; flex: none; }
  .sx-rail .sx-rb::before, .sx-rb[data-tip]:hover::after { display: none !important; }
  body.studio { padding-left: 0; padding-top: 50px; }
  #studio { left: 0; top: 50px; }
}

/* --- Harmonisé avec le parcours vidéo -------------------------------------------------- */
.sx-head #install { display: none !important; }
.sx-cards-set[hidden], #sx-cards-set[hidden] { display: none; }
#sx-cards-set .sx-card { padding: 16px 18px; border-radius: 16px; }
#sx-cards-set .sx-card .v { font-size: 26px; margin-top: 14px; }
/* Aucune piste : la page de dépôt prend toute la largeur, comme celle du parcours vidéo */
body.sx-empty .layout { grid-template-columns: minmax(0, 1fr) !important; }
body.sx-empty .panel.tracks { display: none; }
body.sx-empty .inspector { display: none; }
body.sx-empty.sx-drawer .inspector { display: flex; position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 41; border-radius: 0; border: 0; border-left: 1px solid var(--border); box-shadow: var(--shadow); }
.sx-dh { display: none; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.sx-dh h3 { margin: 0; font-size: 17px; }
.sx-dh .icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); }
body.sx-drawer .sx-dh { display: flex; }
.sx-scrim { display: none; }
body.sx-empty.sx-drawer .sx-scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--backdrop, rgba(4, 6, 14, .55)); backdrop-filter: blur(3px); }
/* Page de dépôt */
.sx-drop { border-radius: 18px; }
.sx-drop .dropzone-inner { max-width: 620px; gap: 0; }
.sx-drop-ico { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 18px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent-ink); }
.sx-drop-ico svg, .sx-drop .btn.primary svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sx-drop .btn.primary svg { width: 17px; height: 17px; }
.sx-drop h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.sx-drop p { line-height: 1.5; }
.sx-drop .drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0 14px; }
.sx-drop .drop-actions .btn { height: 42px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: 14px; gap: 8px; }
.sx-more { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; }
.sx-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sx-chip:hover { color: var(--text); border-color: var(--border-2); }
.sx-chip .ico { display: inline-flex; }
.sx-drop .fine { font-size: 12.5px; }
/* Boutons arrondis comme dans le parcours vidéo */
body.studio > .layout .btn { border-radius: 999px; }
/* Barre du bas : l'état du moteur s'écrit comme dans le parcours vidéo */
.sx-bottom #engine { border: 0; background: none; padding: 0; font-size: 12px; color: var(--muted); gap: 7px; }
.sx-bottom #engine .dot { width: 7px; height: 7px; }
.sx-bottom #engine.ready .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
body.sx-empty #sheet-open, body.sx-empty #qc-run { display: none; }
body.sx-empty .sx-sum .summary { font-size: 13px; }
@media (max-width: 920px) {
  #sx-cards-set .sx-card .v { font-size: 20px; margin-top: 6px; }
  .sx-local { display: none; }
}
/* Mêmes mesures que le parcours vidéo : en-tête, cartes, marges */
.topbar.sx-head { padding: 16px 26px; min-height: 81px; }
.sx-cards { gap: 14px; padding: 22px 26px 0; }
.sx-card { border-radius: 16px; padding: 10px 18px; }
#sx-cards-set .sx-card .v { font-size: 28px; margin-top: 8px; }
body.sx-empty .layout { padding-top: 18px; padding-bottom: 22px; }
@media (max-width: 920px) {
  .topbar.sx-head { min-height: 0; padding: 12px 16px; }
  .sx-cards { padding: 12px 16px 0; gap: 10px; }
  #sx-cards-set .sx-card .v { font-size: 20px; margin-top: 6px; }
}
button.sx-card { display: flex; flex-direction: column; justify-content: flex-start; }
body.sx-empty .mobile-nav { display: none !important; }
@media (max-width: 920px) { body.sx-empty .sx-bottom { bottom: 0; } }

/* --- Studio dans la nouvelle interface : même en-tête, mêmes cartes arrondies, timeline colorée ---------- */
.st-gone { position: absolute !important; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
#studio.st { padding: 0 26px 18px; gap: 14px; --grad: linear-gradient(135deg, var(--accent), var(--accent-2)); }
#studio .st-top { height: auto; min-height: 81px; margin: 0 -26px; padding: 14px 26px; gap: 14px; }
#studio .st-t { min-width: 0; }
#studio .st-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
#studio .st-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#studio .st-top .icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); }
#studio .st-top .seg-control, #studio .st-inspector .seg-control { border-radius: 999px; background: var(--panel); border-color: var(--border); padding: 3px; }
#studio .st-top .seg-control button, #studio .st-inspector .seg-control button { border-radius: 999px; }
#studio .btn { border-radius: 999px; }
#studio .st-top .btn { height: 36px; padding: 0 14px; font-weight: 600; }
#studio #st-export { height: 40px; padding: 0 18px; background: var(--grad); color: #06121a; border: 0; box-shadow: 0 8px 26px var(--glow); }
#studio .st-body { gap: 14px; }
#studio .st-media, #studio .st-inspector, #studio .st-stage, #studio .st-timeline { border-radius: 16px; }
#studio .st-media h2 { font-size: 11px; font-weight: 700; letter-spacing: .09em; }
#studio .st-sources li { border-radius: 12px; }
#studio .st-add .btn { flex: none; justify-content: flex-start; height: 40px; border-radius: 12px; background: var(--panel-2); border-color: var(--border); }
#studio .st-preview { border-radius: 12px; }
#studio .st-stage { padding: 12px; }
#studio .st-transport #st-play { min-width: 0; width: 46px; height: 46px; border-radius: 50%; padding: 0; justify-content: center; background: var(--grad); color: #06121a; border: 0; box-shadow: 0 6px 20px var(--glow); font-size: 0; }
#studio .st-transport #st-play svg { width: 18px; height: 18px; }
#studio .st-inspector { padding: 16px; }
#studio .st-tools { padding: 8px 12px; gap: 6px; }
/* Blocs de la timeline : arrondis, une couleur par piste */
#studio .st-block { border-radius: 9px; }
#studio .st-tlane:not(.tinted) .st-block { border-color: rgba(255, 255, 255, .14); }
#studio .st-tlane:not(.tinted) .st-clip { background: linear-gradient(180deg, rgba(56, 132, 255, .62), rgba(56, 100, 230, .44)); }
#studio .st-tlane:not(.tinted) .st-layer.text { background: linear-gradient(180deg, rgba(139, 92, 246, .62), rgba(124, 58, 237, .45)); }
#studio .st-tlane:not(.tinted) .st-mus { background: linear-gradient(180deg, rgba(167, 139, 250, .45), rgba(139, 92, 246, .3)); }
#studio .st-tlane.audio:not(.tinted) { background: color-mix(in srgb, var(--accent) 3%, transparent); }
#studio .st-playhead { background: var(--accent-ink); }
#studio .st-playhead::before { border-top-color: var(--accent-ink); }
@media (max-width: 1100px) {
  #studio .st-sub { display: none; }
}
@media (max-width: 920px) {
  #studio.st { padding: 0 12px 12px; }
  #studio .st-top { margin: 0 -12px; padding: 10px 12px; min-height: 0; }
}
#studio .st-add { display: flex; flex-direction: column; gap: 8px; }
#studio .st-add .btn { width: 100%; padding: 0 12px; }
