/* Danse Studio : feuille de style. Mobile d'abord, thèmes clair et sombre par variables. */
:root {
  --bg: #120a22; --bg2: #1a0f30; --surface: #241446; --surface2: #2f1b5a; --line: rgba(255, 255, 255, .11);
  --text: #f5f0ff; --muted: #b6a9da; --accent: #ff5fa2; --on-accent: #2a0a1c; --accent-text: #ff8fbf;
  --ok: #6dff9e; --warn: #ffe14f; --danger: #ff7a89; --focus: #4fe3ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Avenir Next", "SF Pro Rounded", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --font-d: "Avenir Next Condensed", "DIN Condensed", "Arial Narrow", "Avenir Next", sans-serif;
  --r: 14px; --stage-h: 36dvh;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f1fc; --bg2: #ffffff; --surface: #efe7fa; --surface2: #e2d4f6; --line: rgba(40, 20, 80, .14);
    --text: #241338; --muted: #5b4a7f; --accent: #d41d7a; --on-accent: #ffffff; --accent-text: #b5126a;
    --ok: #137a3f; --warn: #8a6a00; --danger: #b3212f; --focus: #0a6f8c; --shadow: 0 10px 30px rgba(60, 30, 120, .16);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f1fc; --bg2: #ffffff; --surface: #efe7fa; --surface2: #e2d4f6; --line: rgba(40, 20, 80, .14);
  --text: #241338; --muted: #5b4a7f; --accent: #d41d7a; --on-accent: #ffffff; --accent-text: #b5126a;
  --ok: #137a3f; --warn: #8a6a00; --danger: #b3212f; --focus: #0a6f8c; --shadow: 0 10px 30px rgba(60, 30, 120, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.ic .f { fill: currentColor; stroke: none; }

/* ---------- structure ---------- */
#app { display: grid; height: 100dvh; grid-template-columns: minmax(0, 1fr) 410px; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "stage panel" "tl panel"; }
#top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); min-width: 0; }
#stageWrap { grid-area: stage; position: relative; min-height: 0; background: #160a2b; overflow: hidden; }
#timeline { grid-area: tl; background: var(--bg2); border-top: 1px solid var(--line); min-width: 0; display: none; }
#panel { grid-area: panel; overflow-y: auto; overflow-x: hidden; background: var(--bg2); border-left: 1px solid var(--line); padding: 14px 16px 40px; scroll-behavior: smooth; }
#tabsBottom { grid-area: nav; display: none; }
[data-view="studio"] #timeline { display: block; }
#stage, #labels { position: absolute; inset: 0; }
#stage canvas { display: block; }
#labels { pointer-events: none; overflow: hidden; }

.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-d); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 17px; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; }
.title-input { flex: 1 1 140px; min-width: 0; max-width: 340px; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 6px 10px; font-weight: 600; text-overflow: ellipsis; }
.title-input:hover { border-color: var(--line); } .title-input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.tabs { display: flex; gap: 4px; }
.tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: transparent; color: var(--muted); padding: 9px 16px; border-radius: 999px; font-weight: 600; min-height: 42px; }
.tabs button:hover { color: var(--text); background: var(--surface); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
#tabsTop { margin: 0 auto; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 600; white-space: nowrap; transition: background .15s, transform .08s; }
.btn:hover { background: var(--surface2); } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; } .btn.danger { color: var(--danger); }
.btn.icon { padding: 0; width: 42px; } .btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; } .btn.sm.icon { width: 34px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.block { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; }
.chip:hover { background: var(--surface2); }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 700; }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid rgba(255, 255, 255, .55); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.seg { display: inline-flex; background: rgba(0, 0, 0, .35); border-radius: 12px; padding: 3px; gap: 2px; backdrop-filter: blur(6px); }
.seg button { border: 0; background: transparent; color: #e9e0ff; padding: 0 12px; min-height: 36px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
input[type="text"], input[type="number"], select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-height: 40px; width: 100%; }
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
input[type="color"] { -webkit-appearance: none; appearance: none; border: 2px solid var(--line); background: none; width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; } input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.lbl { font-family: var(--font-d); text-transform: uppercase; letter-spacing: .09em; font-size: 12px; color: var(--muted); font-weight: 700; margin: 18px 0 8px; display: block; }
h2.ttl { font-family: var(--font-d); font-size: 22px; margin: 4px 0 4px; letter-spacing: .02em; }
p.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 10px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- panneau : sections ---------- */
details.sec { border: 1px solid var(--line); border-radius: var(--r); margin: 12px 0; background: var(--surface); }
details.sec > summary { list-style: none; cursor: pointer; padding: 13px 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; min-height: 48px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
details.sec[open] > summary::after { transform: rotate(-135deg); }
details.sec > .body { padding: 2px 14px 14px; }
.row { display: flex; align-items: center; gap: 8px; margin: 8px 0; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.dancer-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.dancer-row input[type="text"] { min-height: 36px; }
.sw { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); flex: none; }

/* ---------- curseurs du corps ---------- */
.slider { margin: 12px 0 4px; }
.slider .t { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; gap: 10px; }
.slider .t b { font-variant-numeric: tabular-nums; color: var(--accent-text); font-weight: 700; white-space: nowrap; }
.parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.part { display: flex; align-items: center; gap: 9px; text-align: left; padding: 9px 11px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; }
.part i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.part[aria-pressed="true"] { border-color: var(--accent); background: var(--surface2); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--line); }
.swatches button[aria-pressed="true"] { border-color: var(--text); }
.look-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; margin: 10px 0; }
.look-row > span { font-size: 13.5px; color: var(--muted); padding-top: 8px; }

/* ---------- bibliothèque ---------- */
.search { position: relative; } .search svg { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.search input { padding-left: 38px; }
.mcard { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 11px 13px 12px 17px; margin: 8px 0; position: relative; overflow: hidden; }
.mcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--accent)); }
.mcard:hover { background: var(--surface2); }
.mcard[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface2); }
.mcard .n { font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mcard .m { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.mcard .d { color: var(--muted); font-size: 13px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lvl { letter-spacing: 2px; color: var(--accent-text); }
.addbar { position: sticky; bottom: -40px; margin: 14px -16px -40px; padding: 10px 16px 28px; background: var(--bg2); border-top: 1px solid var(--accent); box-shadow: 0 -10px 24px rgba(0, 0, 0, .25); z-index: 4; }
.addbar .who-row { margin: 4px 0; } .addbar .chip { min-height: 32px; font-size: 13px; padding: 0 11px; }
.addbar .nm { font-weight: 700; margin-bottom: 8px; }

/* ---------- scène : surimpressions ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; position: absolute; }
.hud-tl { top: 10px; left: 10px; } .hud-tr { top: 10px; right: 10px; } .hud-bl { bottom: 10px; left: 10px; } .hud-br { bottom: 10px; right: 10px; }
.hud-bar { left: 10px; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 10px; background: rgba(15, 6, 30, .72); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px; padding: 8px 10px; color: #f5f0ff; }
.hud-bar .btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; } .hud-bar .btn.primary { background: var(--accent); color: var(--on-accent); }
.hud-bar input[type="range"] { flex: 1; }
.beats { display: flex; gap: 5px; align-items: center; } .beats i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .22); } .beats i.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 8px; background: rgba(15, 6, 30, .72); backdrop-filter: blur(8px); color: #fff; padding: 7px 12px; border-radius: 999px; font-weight: 700; border: 1px solid rgba(255, 255, 255, .12); max-width: 70vw; }
.badge small { font-weight: 500; color: #cdbff0; }
.badge.big { font-family: var(--font-d); font-size: 19px; letter-spacing: .03em; text-transform: uppercase; }
.tag, .ptag { position: absolute; left: 0; top: 0; will-change: transform; white-space: nowrap; }
.tag { display: flex; align-items: center; gap: 6px; background: rgba(15, 6, 30, .66); color: #fff; padding: 3px 10px 3px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-top: -4px; }
.tag i { width: 10px; height: 10px; border-radius: 50%; }
.ptag { pointer-events: auto; display: flex; align-items: center; gap: 6px; background: rgba(15, 6, 30, .8); color: #fff; border: 1px solid rgba(255, 255, 255, .25); padding: 4px 10px 4px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; min-height: 28px; }
.ptag i { width: 10px; height: 10px; border-radius: 3px; } .ptag.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.beatnum { font-variant-numeric: tabular-nums; }

/* ---------- chorégraphie : transport et frise ---------- */
.tl-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tl-bar .time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 112px; }
.tl-bar .time small { color: var(--muted); font-weight: 500; display: block; font-size: 11.5px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: transparent; width: 36px; min-height: 40px; } .stepper button:hover { background: var(--surface2); }
.stepper input { width: 56px; border: 0; background: transparent; text-align: center; font-weight: 700; padding: 0; min-height: 40px; border-radius: 0; font-variant-numeric: tabular-nums; }
.tl-scroll { overflow: auto; max-height: 232px; position: relative; -webkit-overflow-scrolling: touch; }
.tl-inner { position: relative; min-height: 60px; user-select: none; touch-action: pan-x pan-y; }
.tl-ruler { position: sticky; top: 0; z-index: 5; height: 28px; background: var(--bg2); border-bottom: 1px solid var(--line); cursor: ew-resize; touch-action: none; }
.tl-ruler .tk { position: absolute; top: 14px; bottom: 0; width: 1px; background: var(--line); } .tl-ruler .tk.m { top: 6px; background: rgba(255, 255, 255, .28); }
.tl-ruler .nm { position: absolute; top: 2px; font-size: 11px; color: var(--muted); padding-left: 4px; font-variant-numeric: tabular-nums; }
.tl-row { position: relative; height: 44px; border-bottom: 1px solid var(--line); }
.tl-row.form { height: 36px; background: rgba(255, 255, 255, .025); }
.tl-row .grid { position: absolute; inset: 0; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); pointer-events: none; opacity: .5; }
.tl-label { position: sticky; left: 0; z-index: 4; width: 112px; height: 100%; display: flex; align-items: center; gap: 7px; padding: 0 8px; background: var(--bg2); border-right: 1px solid var(--line); font-size: 12.5px; font-weight: 600; overflow: hidden; }
.tl-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .tl-label .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tl-row.sel .tl-label { box-shadow: inset 3px 0 0 var(--accent); }
.clip { position: absolute; top: 5px; height: 34px; border-radius: 9px; background: var(--c); color: #1a0b2e; font-size: 12px; font-weight: 700; padding: 0 14px 0 8px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; border: 2px solid rgba(0, 0, 0, .18); touch-action: pan-x pan-y; cursor: grab; }
.clip.sel { outline: 3px solid var(--text); outline-offset: 1px; z-index: 2; }
.clip .rs { position: absolute; right: 0; top: 0; bottom: 0; width: 18px; touch-action: none; cursor: ew-resize; background: linear-gradient(to right, transparent, rgba(0, 0, 0, .25)); }
.clip .rep { margin-left: 6px; opacity: .7; font-weight: 600; }
.flag { position: absolute; top: 4px; height: 28px; padding: 0 10px 0 8px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line); display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; touch-action: none; cursor: pointer; }
.flag.sel { outline: 3px solid var(--text); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 6; pointer-events: none; box-shadow: 0 0 8px var(--accent); }
.playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: var(--accent); }
.tl-tools { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; min-height: 54px; }
.tl-tools .who { font-weight: 700; margin-right: 6px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- fenêtres et messages ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 3, 18, .66); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); width: min(640px, 100%); max-height: 88dvh; display: flex; flex-direction: column; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); } .modal header h3 { margin: 0; font-family: var(--font-d); font-size: 20px; flex: 1; }
.modal .mb { padding: 14px 16px; overflow: auto; } .modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal pre { white-space: pre-wrap; font: 13px/1.55 ui-monospace, Menlo, monospace; margin: 0; }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- mode spectacle ---------- */
.show #top, .show #timeline, .show #panel, .show #tabsBottom { display: none !important; }
.show #app, #app.show { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "stage"; }
.show #hud > * { display: none !important; } .show #hud .keep { display: flex !important; }

/* ---------- mobile ---------- */
@media (max-width: 959px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto var(--stage-h) auto minmax(0, 1fr) auto; grid-template-areas: "top" "stage" "tl" "panel" "nav"; }
  [data-view="studio"] { --stage-h: 31dvh; }
  #top { padding: 6px 10px; gap: 8px; } #tabsTop { display: none; } .brand span { display: none; }
  #panel { border-left: 0; border-top: 1px solid var(--line); padding: 12px 14px 30px; }
  #tabsBottom { display: flex; background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  #tabsBottom button { flex: 1; flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 4px; border-radius: 12px; min-height: 52px; }
  .tl-scroll { max-height: 26dvh; } .tl-label { width: 84px; font-size: 11.5px; }
  .tl-bar { padding: 6px 10px; gap: 6px; } .tl-bar .time { min-width: 92px; }
  .addbar { bottom: -30px; margin-bottom: -30px; padding-bottom: 20px; }
  #toast { bottom: 90px; }
  .look-row { grid-template-columns: 1fr; gap: 2px; } .look-row > span { padding-top: 0; }
}
@media (min-width: 960px) { #tabsTop { display: flex; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

.mwrap { position: relative; } .mdel { position: absolute; right: 8px; top: 8px; z-index: 2; }
.who-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; align-items: center; }
.who-row select { width: auto; min-height: 36px; }

@media (max-width: 959px) {
  [data-view="atelier"] { --stage-h: 46dvh; }
  .tl-bar .btn.icon { width: 40px; min-height: 40px; } .stepper button { width: 32px; } .stepper input { width: 46px; }
  .badge.big { font-size: 15px; max-width: calc(100vw - 210px); } .badge.big small { display: none; }
  .hud-tl.badge { max-width: calc(100vw - 170px); font-size: 13px; padding: 6px 10px; }
  .hud-tl.badge small { display: none; }
  .seg button { padding: 0 9px; min-height: 34px; }
}
