/* ============================================================
   RÉGIE — Studio de messages téléphoniques
   Direction : console de mixage nocturne. Voies numérotées,
   faders, VU-mètre ambre comme signature. Accent : vert téléphonie.
   ============================================================ */

:root{
  --ink:#0a0f1c;
  --ink-2:#0e1426;
  --panel:#141b30;
  --panel-2:#1a2238;
  --rail:#10162a;
  --line:#263150;
  --line-soft:#1d2640;
  --text:#e9edf8;
  --muted:#8a93b0;
  --signal:#34d399;      /* vert téléphonie — identité */
  --signal-dim:#1f7d5e;
  --amber:#f0b429;       /* VU-mètre — signature */
  --rose:#f06a7e;        /* pics / erreurs */
  --radius:14px;
  --strip-w:74px;
  --font-d:"Space Grotesk",system-ui,sans-serif;
  --font-b:"IBM Plex Sans",system-ui,sans-serif;
  --font-m:"IBM Plex Mono",ui-monospace,monospace;
}

*{box-sizing:border-box}
/* l'attribut hidden doit toujours l'emporter sur les display:flex/grid des classes */
[hidden]{display:none!important}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:var(--font-b);
  color:var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(52,211,153,.08), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(240,180,41,.06), transparent 55%),
    var(--ink);
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}

/* fine ligne de balayage façon écran de régie */
.scanline{
  position:fixed;inset:0;pointer-events:none;z-index:1;opacity:.35;
  background:repeating-linear-gradient(to bottom,rgba(255,255,255,.018) 0 1px,transparent 1px 3px);
}

/* ----------------------------------------------------------- topbar */
.topbar{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;justify-content:space-between;
  padding:16px clamp(16px,4vw,40px);
  background:linear-gradient(180deg,rgba(10,15,28,.96),rgba(10,15,28,.72));
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line-soft);
}
.brand{display:flex;align-items:center;gap:14px}
.led{
  width:11px;height:11px;border-radius:50%;
  background:var(--rose);box-shadow:0 0 0 0 rgba(240,106,126,.5);
  transition:.4s;flex:none;
}
.led.ok{background:var(--signal);box-shadow:0 0 14px rgba(52,211,153,.7)}
.brand-txt h1{
  font-family:var(--font-d);font-weight:700;letter-spacing:.22em;
  font-size:22px;margin:0;line-height:1;
}
.brand-txt p{margin:4px 0 0;font-size:12px;color:var(--muted);letter-spacing:.02em}
.top-right{display:flex;align-items:center;gap:10px}

/* widget solde de crédits */
.balance{
  display:flex;flex-direction:column;align-items:flex-start;gap:3px;
  background:var(--panel-2);border:1px solid var(--line);border-radius:10px;
  padding:7px 12px;cursor:pointer;transition:.16s;min-width:118px;
}
.balance:hover{border-color:var(--signal)}
.bal-label{font-family:var(--font-m);font-size:9.5px;letter-spacing:.18em;color:var(--muted);text-transform:uppercase}
.bal-val{font-family:var(--font-m);font-size:13px;color:var(--text);line-height:1}
.bal-val b{color:var(--signal);font-weight:600}
.bal-bar{display:block;width:100%;height:3px;border-radius:3px;background:var(--line);overflow:hidden;margin-top:2px}
.bal-bar i{display:block;height:100%;width:0;background:var(--signal);transition:width .4s}
.bal-bar i.warn{background:var(--amber)}
.bal-bar i.low{background:var(--rose)}
.cost{font-family:var(--font-m);font-size:12px;color:var(--amber)}
.cost.low{color:var(--rose)}

/* ----------------------------------------------------------- console */
.console{
  max-width:920px;margin:0 auto;padding:clamp(18px,3vw,34px) clamp(14px,4vw,40px) 80px;
  display:flex;flex-direction:column;gap:18px;position:relative;z-index:2;
}

/* voie / channel strip */
.strip{
  display:flex;
  background:linear-gradient(180deg,var(--panel),var(--ink-2));
  border:1px solid var(--line-soft);border-radius:var(--radius);
  overflow:hidden;
  box-shadow:0 1px 0 rgba(255,255,255,.03) inset,0 18px 40px -28px rgba(0,0,0,.9);
}
.strip-rail{
  width:var(--strip-w);flex:none;
  background:
    linear-gradient(180deg,rgba(52,211,153,.10),transparent 40%),
    var(--rail);
  border-right:1px solid var(--line-soft);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;
  padding:18px 0;
}
.strip-no{
  font-family:var(--font-m);font-weight:600;font-size:24px;color:var(--signal);
  text-shadow:0 0 18px rgba(52,211,153,.45);
}
.strip-label{
  font-family:var(--font-m);font-size:10px;letter-spacing:.28em;color:var(--muted);
  writing-mode:vertical-rl;transform:rotate(180deg);
}
.strip-body{flex:1;padding:20px clamp(16px,2.5vw,26px);min-width:0}
.strip-body h2{
  font-family:var(--font-d);font-weight:600;font-size:16px;margin:0 0 14px;letter-spacing:.01em;
}

h2 .lang-pill{
  font-family:var(--font-m);font-size:10px;letter-spacing:.1em;
  color:var(--ink);background:var(--signal);border-radius:5px;padding:2px 7px;margin-left:8px;vertical-align:middle;
}

/* ----------------------------------------------------------- helpers */
.row{display:flex;align-items:center}
.row.gap{gap:10px}
.row.between{justify-content:space-between}
.row.sub{margin-top:10px}
.hint{color:var(--muted);font-size:12.5px;line-height:1.5}
.field-label{display:block;font-size:12px;color:var(--muted);margin:14px 0 6px;letter-spacing:.03em}

.inp{
  width:100%;background:var(--ink);color:var(--text);
  border:1px solid var(--line);border-radius:10px;
  padding:11px 13px;font-family:var(--font-b);font-size:14px;outline:none;transition:.18s;
}
.inp:focus{border-color:var(--signal);box-shadow:0 0 0 3px rgba(52,211,153,.16)}
.inp.area{resize:vertical;line-height:1.55;min-height:110px}
select.inp{appearance:none;cursor:pointer}

/* ----------------------------------------------------------- buttons */
.btn{
  font-family:var(--font-b);font-weight:500;font-size:13.5px;
  background:var(--panel-2);color:var(--text);
  border:1px solid var(--line);border-radius:10px;
  padding:10px 16px;cursor:pointer;transition:.16s;white-space:nowrap;
  display:inline-flex;align-items:center;gap:7px;text-decoration:none;
}
.btn:hover{border-color:var(--signal);transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none;border-color:var(--line)}
.btn.signal{background:var(--signal);color:#04221a;border-color:transparent;font-weight:600}
.btn.signal:hover{box-shadow:0 8px 24px -8px rgba(52,211,153,.6)}
.btn.ghost{background:transparent}
.btn.small{padding:8px 13px;font-size:12.5px}
.btn.tiny{padding:5px 10px;font-size:12px}
.btn.block{width:100%;justify-content:center;margin-top:18px}
.gear{font-size:15px}

/* ----------------------------------------------------------- voix */
.voice-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(170px,100%),1fr));gap:10px;margin-top:4px}
.voice-card{
  text-align:left;color:var(--text);background:var(--ink);border:1px solid var(--line);
  border-radius:11px;padding:12px 13px;cursor:pointer;transition:.16s;position:relative;
}
.voice-card:hover{border-color:var(--signal-dim);transform:translateY(-2px)}
.voice-card:focus-visible{border-color:var(--signal)}
.voice-card.sel{border-color:var(--signal);box-shadow:0 0 0 3px rgba(52,211,153,.16)}
.voice-card .vname{font-family:var(--font-d);font-weight:600;font-size:14.5px;margin:0;color:var(--text)}
.voice-card .vmeta{font-family:var(--font-m);font-size:11px;color:var(--muted);margin:5px 0 0;letter-spacing:.02em}
.voice-card .check{
  position:absolute;top:10px;right:11px;color:var(--signal);font-size:13px;opacity:0;transition:.16s;
}
.voice-card.sel .check{opacity:1}
.vplay{
  margin-top:10px;font-family:var(--font-b);font-size:11.5px;color:var(--signal);
  background:rgba(52,211,153,.08);border:1px solid var(--signal-dim);border-radius:7px;
  padding:5px 9px;cursor:pointer;transition:.15s;width:100%;
}
.vplay:hover{background:rgba(52,211,153,.16)}
.vplay.playing{background:var(--signal);color:#04221a}
.vplay.playing::before{content:"⏸ "}

.test-zone{margin-top:18px;padding-top:16px;border-top:1px dashed var(--line-soft)}
#testPlayer{width:100%;margin-top:12px}
audio{filter:invert(.92) hue-rotate(140deg) saturate(.8);border-radius:9px}

/* ----------------------------------------------------------- musique */
.tabs{display:inline-flex;gap:4px;background:var(--ink);padding:4px;border-radius:11px;border:1px solid var(--line);margin-bottom:14px}
.tab{
  font-family:var(--font-b);font-size:13px;color:var(--muted);
  background:transparent;border:0;border-radius:8px;padding:8px 14px;cursor:pointer;transition:.15s;
}
.tab:hover{color:var(--text)}
.tab.active{background:var(--panel-2);color:var(--text);box-shadow:0 1px 0 rgba(255,255,255,.05) inset}
.src-panel{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.src-panel.col{flex-direction:column;align-items:stretch}
.src-panel .inp{max-width:420px}
.src-panel .row.full{width:100%}
.src-panel .row.full .inp{max-width:none;flex:1}

.cookies-box{margin-top:4px;border:1px solid var(--line);border-radius:10px;background:var(--ink);padding:4px 12px}
.cookies-box summary{cursor:pointer;font-size:13px;color:var(--muted);padding:8px 0;list-style:none}
.cookies-box summary::-webkit-details-marker{display:none}
.cookies-box[open] summary{color:var(--text)}
.cookies-box .hint{margin:6px 0 12px}
.cookies-box code{font-family:var(--font-m);font-size:12px;color:var(--amber)}
.ck-state{font-family:var(--font-m);font-size:11px;color:var(--rose);margin-left:6px}
.ck-state.ok{color:var(--signal)}

.music-status{
  display:flex;align-items:center;gap:10px;margin-top:14px;
  background:rgba(52,211,153,.07);border:1px solid var(--signal-dim);
  border-radius:10px;padding:10px 13px;font-size:13.5px;
}
.music-status .dot{width:8px;height:8px;border-radius:50%;background:var(--signal);flex:none;box-shadow:0 0 10px var(--signal)}
.badge{
  font-family:var(--font-m);font-size:11px;color:var(--amber);
  border:1px solid rgba(240,180,41,.35);border-radius:6px;padding:2px 7px;
}

/* ----------------------------------------------------------- faders */
.faders{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:18px}
.fader{display:flex;flex-direction:column;gap:9px}
.fader.sm{gap:6px}
.fader label{font-size:12px;color:var(--muted);letter-spacing:.02em}
.fader output{font-family:var(--font-m);font-size:13px;color:var(--amber);align-self:flex-start}

input[type=range]{
  -webkit-appearance:none;appearance:none;width:100%;height:4px;border-radius:4px;
  background:linear-gradient(90deg,var(--signal),var(--signal-dim));cursor:pointer;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;width:18px;height:24px;border-radius:5px;
  background:linear-gradient(180deg,#2b3450,#161d33);border:1px solid var(--signal);
  box-shadow:0 2px 8px rgba(0,0,0,.5),0 0 0 1px rgba(0,0,0,.4);cursor:grab;
}
input[type=range]::-webkit-slider-thumb:active{cursor:grabbing}
input[type=range]::-moz-range-thumb{
  width:18px;height:24px;border-radius:5px;background:#1e273f;border:1px solid var(--signal);cursor:grab;
}

/* switch */
.switch{display:flex;align-items:center;gap:12px;margin-top:20px;cursor:pointer;font-size:13.5px;color:var(--text)}
.switch input{position:absolute;opacity:0;width:0;height:0}
.switch .track{width:42px;height:24px;border-radius:20px;background:var(--line);position:relative;transition:.2s;flex:none}
.switch .knob{position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:var(--muted);transition:.2s}
.switch input:checked + .track{background:var(--signal-dim)}
.switch input:checked + .track .knob{left:21px;background:var(--signal)}
.switch input:focus-visible + .track{box-shadow:0 0 0 3px rgba(52,211,153,.3)}

/* ----------------------------------------------------------- master */
.master{
  display:flex;border-radius:var(--radius);overflow:hidden;
  border:1px solid rgba(52,211,153,.3);
  background:linear-gradient(180deg,rgba(52,211,153,.06),var(--ink-2));
  box-shadow:0 18px 50px -30px rgba(52,211,153,.4);
}
/* VU-mètre — élément signature */
.master-meter{
  width:var(--strip-w);flex:none;background:var(--rail);border-right:1px solid var(--line-soft);
  display:flex;flex-direction:column-reverse;gap:4px;padding:16px 22px;justify-content:flex-start;
}
.master-meter span{height:10px;border-radius:2px;background:rgba(255,255,255,.06);transition:.25s}
.master-meter.live span{animation:vu 1.1s ease-in-out infinite}
.master-meter span:nth-child(-n+5){background:var(--signal)}
.master-meter span:nth-child(6),.master-meter span:nth-child(7){background:var(--amber)}
.master-meter span:nth-child(8){background:var(--rose)}
.master-meter.live span:nth-child(1){animation-delay:0s}
.master-meter.live span:nth-child(2){animation-delay:.08s}
.master-meter.live span:nth-child(3){animation-delay:.16s}
.master-meter.live span:nth-child(4){animation-delay:.24s}
.master-meter.live span:nth-child(5){animation-delay:.32s}
.master-meter.live span:nth-child(6){animation-delay:.4s}
.master-meter.live span:nth-child(7){animation-delay:.48s}
.master-meter.live span:nth-child(8){animation-delay:.56s}
@keyframes vu{0%,100%{opacity:.25}50%{opacity:1}}

.master-main{flex:1;padding:22px clamp(16px,2.5vw,28px)}
.master-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.master-head h2{font-family:var(--font-d);font-weight:600;font-size:18px;margin:0}
.fmt-tag{font-family:var(--font-m);font-size:11px;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:4px 9px}
.master-btn{
  width:100%;justify-content:center;font-size:15px;padding:14px;
  background:var(--signal);color:#04221a;border:0;font-weight:600;
}
.master-btn:hover{box-shadow:0 10px 30px -10px rgba(52,211,153,.7)}
.master-btn.busy{background:var(--amber);color:#241900;pointer-events:none}
.result{margin-top:18px;display:flex;flex-direction:column;gap:12px}
#outPlayer{width:100%}

/* ----------------------------------------------------------- modale */
.modal{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;
  background:rgba(5,8,16,.7);backdrop-filter:blur(4px);padding:20px}
.modal-card{
  width:min(460px,100%);max-height:90vh;overflow:auto;
  background:linear-gradient(180deg,var(--panel),var(--ink-2));
  border:1px solid var(--line);border-radius:16px;padding:24px;
  box-shadow:0 30px 80px -30px #000;
}
.modal-card h2{font-family:var(--font-d);font-weight:600;margin:0;font-size:18px}
.cfg-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:14px;margin-top:16px}

/* ----------------------------------------------------------- toast */
.toast{
  position:fixed;left:50%;bottom:26px;transform:translateX(-50%) translateY(20px);
  background:var(--panel-2);border:1px solid var(--line);border-left:3px solid var(--signal);
  color:var(--text);padding:12px 18px;border-radius:10px;font-size:13.5px;z-index:60;
  box-shadow:0 18px 40px -16px #000;opacity:0;transition:.25s;max-width:90vw;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.err{border-left-color:var(--rose)}

/* ----------------------------------------------------------- responsive */

/* tablette */
@media (max-width:680px){
  .console{gap:14px}
  .strip-body{padding:16px}
  h2 .lang-pill{display:inline-block}
}

/* téléphone : la voie passe d'un rail vertical à un bandeau horizontal */
@media (max-width:560px){
  .topbar{padding:12px 16px}
  .brand-txt p{display:none}
  .brand-txt h1{font-size:19px}
  #openConfig{padding:9px 11px;font-size:12.5px}
  .cfg-txt{display:none}
  .balance{min-width:92px;padding:6px 9px}
  .top-right{gap:7px}

  .strip{flex-direction:column}
  .strip-rail{
    width:auto;flex-direction:row;justify-content:flex-start;align-items:center;gap:10px;
    padding:10px 16px;border-right:0;border-bottom:1px solid var(--line-soft);
    background:linear-gradient(90deg,rgba(52,211,153,.12),transparent 60%),var(--rail);
  }
  .strip-no{font-size:18px}
  .strip-label{writing-mode:horizontal-tb;transform:none;letter-spacing:.22em}
  .strip-body{padding:16px 16px 20px}
  .strip-body h2{font-size:15px}

  /* le bloc maître se met aussi en colonne, VU-mètre en bandeau */
  .master{flex-direction:column}
  .master-meter{
    width:auto;flex-direction:row;justify-content:center;gap:5px;
    padding:12px 16px;border-right:0;border-bottom:1px solid var(--line-soft);
  }
  .master-meter span{width:18px;height:8px}
  .master-head h2{font-size:16px}
  .fmt-tag{font-size:10px;padding:3px 7px}

  /* champs + boutons empilés pour ne jamais déborder */
  .row.gap{flex-wrap:wrap}
  .row.gap > .inp{flex:1 1 100%;min-width:0}
  .row.gap > .btn{width:100%;justify-content:center}
  .test-zone .btn.signal{width:100%;justify-content:center}
  .tabs{display:flex;width:100%}
  .tab{flex:1;text-align:center;padding:8px 6px}
  .src-panel .inp{max-width:none}

  .modal{padding:12px;align-items:flex-end}
  .modal-card{padding:20px 16px;border-radius:16px 16px 0 0}
}

/* très petits écrans */
@media (max-width:360px){
  .voice-grid{grid-template-columns:1fr}
  .strip-body h2{font-size:14.5px}
}

@media (prefers-reduced-motion:reduce){
  *{animation:none!important;transition:none!important;scroll-behavior:auto}
}

:focus-visible{outline:2px solid var(--signal);outline-offset:2px}
