:root {
  --bg: #0e1420; --panel: #171e2c; --panel2: #1e2637; --line: #2a3448; --text: #e8ecf4; --dim: #7d889c;
  --blue: #2c4fd2; --blue-hi: #3c62ec; --red: #c2403d; --teal: #64d3c0; --orange: #e9a744;
  --font: 'Barlow Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; user-select: none; touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Écran IK ---------- */
#ik { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.12fr) minmax(0, 2fr); gap: 10px; height: 100vh; padding: 12px; }
.pads { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(10, 1fr); gap: 8px; min-height: 0; }
.pad { position: relative; border: 0; border-radius: 6px; background: var(--c, #8fa2f6); color: #111827; text-align: left;
  padding: 0 12px; overflow: hidden; font: 700 clamp(13px, 1.3vw, 21px)/1.1 var(--font); min-height: 0; transition: filter .08s; }
.pad:active { filter: brightness(1.15); }
.pad.empty { background: transparent; border: 1.5px dashed #3a4459; color: var(--dim); font-weight: 600; }
.pad .lbl { position: relative; z-index: 1; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad .prog { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(0, 0, 0, .3); pointer-events: none; }
.pad .rem { position: absolute; right: 8px; bottom: 4px; z-index: 1; font-size: .78em; font-variant-numeric: tabular-nums; opacity: .85; }
.pad.playing { box-shadow: inset 0 0 0 3px #fff; }
.pad.ending { animation: blink .5s steps(2) infinite; }
.pad.selected { outline: 3px solid #fff; outline-offset: 2px; }
.pad.moving { outline: 3px dashed #fff; outline-offset: 2px; animation: blink .7s steps(2) infinite; }
.pad.flash { animation: flash .35s 4; }
.pad.missing::after { content: '⚠'; position: absolute; bottom: 4px; left: 10px; font-size: .75em; }
.pad.loop::before { content: '↻'; position: absolute; top: 5px; right: 6px; z-index: 2; width: 20px; height: 20px; border-radius: 50%;
  background: #0e1420; color: #fff; font: 700 14px/20px var(--font); text-align: center; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.pad.loop .lbl { padding-right: 22px; }
body.editing .pad:not(.empty) { opacity: .92; }
body.editing .pads { outline: 2px dashed rgba(255,255,255,.18); outline-offset: 4px; border-radius: 8px; }
@keyframes blink { 50% { filter: brightness(1.45); } }
@keyframes flash { 50% { filter: brightness(1.8); transform: scale(1.03); } }

.center { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.banks-title { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; letter-spacing: .18em;
  font-size: clamp(14px, 1.25vw, 20px); padding-top: 2px; white-space: nowrap; overflow: hidden; }
.banks-title .who { color: var(--dim); letter-spacing: .08em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; flex: none; }
.dot.off { background: #ef4444; } .dot.pend { background: var(--orange); } .dot.sync { background: #60a5fa; animation: blink .8s infinite; }
.banks-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.banks-count { text-align: center; color: var(--dim); font-size: clamp(11px, .9vw, 14px); letter-spacing: .16em; font-weight: 600; }
.banks-list { display: flex; flex-direction: column; gap: 6px; }
.bank { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid #2c3546; border-radius: 6px;
  padding: 0 12px; height: clamp(30px, 4.6vh, 44px); color: #aab3c4; font-weight: 700; letter-spacing: .06em;
  font-size: clamp(14px, 1.3vw, 21px); cursor: pointer; overflow: hidden; }
.bank .n { color: var(--dim); font-size: .75em; min-width: 1em; }
.bank .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.bank .tag { flex: none; }
.banks-box, .banks-list, .bank { min-width: 0; }
.bank .tag { font-size: .55em; letter-spacing: .1em; padding: 2px 5px; border-radius: 3px; background: #33405a; color: #c9d3e6; }
.bank.far { opacity: .55; }
.bank.blank { visibility: hidden; }
.bank.cur { background: var(--teal); color: #0d1b1c; border-color: var(--teal); height: clamp(40px, 7vh, 64px); font-size: clamp(18px, 1.8vw, 30px); }
.bank.cur .n { color: #0d1b1c; }
.bank.cur .tag { background: rgba(0,0,0,.18); color: #0d1b1c; }
.sortie { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px 0; }
.sortie span { color: var(--dim); font-size: clamp(11px, .9vw, 14px); letter-spacing: .14em; font-weight: 600; }
.sortie b { color: var(--teal); font-size: clamp(14px, 1.3vw, 21px); letter-spacing: .04em; }
.cmds { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; flex: 1; min-height: 0; }
.cmd { border: 1px solid #4268f0; border-radius: 6px; background: var(--blue); color: #fff; font-weight: 700; letter-spacing: .06em;
  font-size: clamp(14px, 1.35vw, 22px); min-height: 0; white-space: nowrap; overflow: hidden; padding: 0 4px; }
.cmd:active { background: var(--blue-hi); }
.cmd.red { background: var(--red); border-color: #d9605c; }
.cmd.teal { background: var(--teal); border-color: var(--teal); color: #0d1b1c; }
.cmd.on { background: #fff; color: var(--blue); }
.cmd.rec-live { background: var(--red); animation: blink .8s steps(2) infinite; }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 14, .72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 3vh 3vw; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(640px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.wide { width: min(1100px, 100%); height: 100%; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.modal-head b { flex: 1; letter-spacing: .12em; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-head .cmd { padding: 8px 14px; font-size: 16px; flex: none; }
.modal-body { padding: 14px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; font-size: 18px; }
.modal-body label { color: var(--dim); letter-spacing: .1em; font-size: 14px; font-weight: 600; text-transform: uppercase; margin-top: 4px; }
.muted { color: var(--dim); }
.err { color: #f87171; min-height: 1.2em; }

.field { width: 100%; background: #0f1522; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 10px 12px; font: 600 20px var(--font); }
.field:focus { outline: 2px solid var(--teal); }
select.field { appearance: auto; }
.btn { border: 1px solid #4268f0; background: var(--blue); color: #fff; border-radius: 6px; padding: 10px 16px; font: 700 18px var(--font); letter-spacing: .05em; }
.btn:disabled { opacity: .4; }
.btn.red { background: var(--red); border-color: #d9605c; }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #0d1b1c; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.on { background: #fff; color: var(--blue); }
.btn.sm { padding: 6px 12px; font-size: 16px; }
.btn.big { padding: 18px; font-size: 26px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }

/* Clavier tactile */
.kb { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.kb-row { display: flex; gap: 6px; }
.kb button { flex: 1; min-width: 0; height: 52px; border-radius: 6px; border: 1px solid #33405a; background: var(--panel2); color: var(--text); font: 700 22px var(--font); }
.kb button:active { background: #33405a; }
.kb.compact button { height: 42px; font-size: 19px; }
.kb.large { gap: 8px; }
.kb.large .kb-row { gap: 8px; }
.kb.large button { height: clamp(52px, 7.4vh, 76px); font-size: 28px; }
.kb .wide2 { flex: 2; } .kb .wide4 { flex: 5; }
.kb .ok { background: var(--teal); color: #0d1b1c; border-color: var(--teal); }
.kb .on { background: #fff; color: var(--blue); }

/* Login */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.user-btn { height: 70px; border-radius: 8px; border: 1px solid #4268f0; background: var(--blue); color: #fff; font: 700 22px var(--font); display: flex; align-items: center; justify-content: center; gap: 8px; }
.user-btn.on { background: var(--teal); color: #0d1b1c; border-color: var(--teal); }
.code-head { display: flex; align-items: center; gap: 12px; font-size: 22px; }
.field.code { text-align: center; letter-spacing: .4em; font-size: 30px; }

/* ALL */
.all-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.all-tile { position: relative; min-height: 96px; border-radius: 8px; border: 1px solid #2c3546; background: var(--panel2); color: var(--text); text-align: left; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.all-tile .num { color: var(--dim); font-size: 14px; }
.all-tile b { font-size: 22px; letter-spacing: .04em; }
.all-tile small { color: var(--dim); font-size: 13px; letter-spacing: .08em; }
.all-tile.on { background: var(--teal); color: #0d1b1c; border-color: var(--teal); }
.all-tile.on small, .all-tile.on .num { color: #0d1b1c; }
.all-tile.add { border-style: dashed; align-items: center; justify-content: center; color: var(--teal); }
.tile-actions { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.mini { font-size: 14px; padding: 3px 8px; border-radius: 4px; background: #33405a; color: #fff; }
.mini.red { background: var(--red); }

/* Recherche */
.search { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.results { flex: 1; overflow: auto; min-height: 120px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.results h4 { color: var(--dim); letter-spacing: .14em; font-size: 14px; margin: 8px 0 4px; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #222b3c; }
.row .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row small { color: var(--dim); font-variant-numeric: tabular-nums; }

/* Éditeur de pad */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 48px; height: 40px; border-radius: 6px; border: 2px solid transparent; }
.sw.on { border-color: #fff; }
.snd-line { background: #0f1522; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }

/* REC */
.meter { height: 18px; background: #0f1522; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e 0 70%, #eab308 70% 90%, #ef4444 90%); transition: width .05s; }
.rec-time { font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.btn.big.on { animation: blink .8s steps(2) infinite; }

/* Config */
.cfg-section { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cfg-section h3 { letter-spacing: .14em; font-size: 16px; color: var(--teal); }
.cfg-row { display: grid; grid-template-columns: 240px 1fr; align-items: center; gap: 12px; }
.cfg-row > span { color: var(--dim); }

/* Notifications */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; align-items: center; }
.toast { background: #1f2a3e; border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 8px; font-size: 18px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-color: #ef4444; background: #3b1414; }
.toast.ok { border-color: var(--teal); }
.cmd[data-cmd="search"] { font-size: clamp(12px, 1.12vw, 20px); letter-spacing: .02em; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; flex: none; }
.chip { flex: none; border: 1px solid #33405a; background: var(--panel2); color: var(--text); border-radius: 999px; padding: 8px 16px; font: 700 18px var(--font); letter-spacing: .06em; }
.chip.on { background: var(--teal); color: #0d1b1c; border-color: var(--teal); }
.ctag { font-size: 13px; letter-spacing: .06em; padding: 2px 8px; border-radius: 4px; background: #33405a; color: #c9d3e6; white-space: nowrap; }
/* Éditeur début / fin */
.trim { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.trim-info { display: flex; gap: 18px; flex-wrap: wrap; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.trim-info .in { color: #4ade80; } .trim-info .out { color: #f87171; } .trim-info .len { color: var(--text, #e8ecf4); } .trim-info .zoom { color: var(--dim, #7d889c); font-weight: 600; }
.trim-wave { width: 100%; flex: 1; min-height: 180px; border-radius: 8px; border: 1px solid var(--line, #2a3448); touch-action: none; cursor: ew-resize; }
.trim-fine, .trim-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.trim-note { color: var(--dim, #7d889c); font-size: 15px; }
