:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f2330;
  --text: #e8eaf0;
  --muted: #8b92a5;
  --accent: #ff4d5a;
  --accent-2: #ff7a84;
  --ok: #3ddc84;
  --border: #2a2f3d;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: var(--accent-2); }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
header h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
header h1 .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.pill { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill b { color: var(--text); }
main { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; width: 100%; display: flex; align-items: center; justify-content: center; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.frame { position: relative; overflow: hidden; width: 100%; height: 100%; }
.layer { position: absolute; inset: 0; will-change: transform; }
.layer video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.stage { position: absolute; inset: 0; pointer-events: none; container-type: inline-size; overflow: hidden; }
.stage.zoommode { pointer-events: auto; cursor: zoom-in; touch-action: none; }
.frame.zoomed .stage.zoommode { cursor: grab; }
.zoom-badge { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 999px; pointer-events: none; display: none; z-index: 5; }
.frame.zoomed .zoom-badge { display: block; }

/* Stickers */
.sticker { position: absolute; transform: translate(-50%, -50%); width: calc(var(--w) * 1cqw); pointer-events: none; user-select: none; -webkit-user-select: none; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
.sticker img { width: 100%; height: auto; display: block; }
.sticker.emoji { width: auto; font-size: calc(var(--w) * 1cqw); line-height: 1; text-align: center; }
.sticker.out { animation: fxOut .45s ease-in forwards !important; }
.stage.editable .sticker { pointer-events: auto; cursor: grab; touch-action: none; }
.stage.editable .sticker.dragging { cursor: grabbing; filter: drop-shadow(0 0 0 2px var(--accent)); }
.stage.editable .sticker.pinned::after { content: ''; position: absolute; inset: -4px; border: 1px dashed rgba(255,255,255,.35); border-radius: 6px; pointer-events: none; }
.sticker-x { position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 11px; line-height: 22px; background: var(--accent); color: #fff; border: 0; display: none; z-index: 2; }
.stage.editable .sticker:hover .sticker-x { display: block; }
.anim-pop { animation: fxPop .5s cubic-bezier(.2,1.4,.4,1) both; }
.anim-float { animation: fxFloat 3s ease-out both; }
.anim-pulse { animation: fxPulse 1s ease-in-out infinite; }
.anim-shake { animation: fxShake .6s ease-in-out infinite; }
.anim-spin { animation: fxSpin 2s linear infinite; }
@keyframes fxPop { 0% { transform: translate(-50%,-50%) scale(0); opacity: 0 } 70% { transform: translate(-50%,-50%) scale(1.15); opacity: 1 } 100% { transform: translate(-50%,-50%) scale(1) } }
@keyframes fxFloat { 0% { transform: translate(-50%,-50%) scale(.6); opacity: 0 } 15% { opacity: 1; transform: translate(-50%,-50%) scale(1) } 100% { transform: translate(-50%,-220%) scale(1.1); opacity: 0 } }
@keyframes fxPulse { 0%,100% { transform: translate(-50%,-50%) scale(1) } 50% { transform: translate(-50%,-50%) scale(1.18) } }
@keyframes fxShake { 0%,100% { transform: translate(-50%,-50%) rotate(-8deg) } 50% { transform: translate(-50%,-50%) rotate(8deg) } }
@keyframes fxSpin { from { transform: translate(-50%,-50%) rotate(0) } to { transform: translate(-50%,-50%) rotate(360deg) } }
@keyframes fxOut { to { transform: translate(-50%,-50%) scale(.3); opacity: 0 } }

/* Pluie */
.rain { position: absolute; top: -15%; width: calc(var(--w) * 1cqw); pointer-events: none; animation: fxFall linear both; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.rain img { width: 100%; display: block; }
.rain.emoji { width: auto; font-size: calc(var(--w) * 1cqw); line-height: 1; }
@keyframes fxFall { 0% { top: -15%; transform: translateX(0) rotate(0); opacity: 0 } 8% { opacity: 1 } 100% { top: 115%; transform: translateX(var(--sway)) rotate(var(--rot)); opacity: .9 } }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 8px 14px; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }

/* Régie (hôte) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; padding: 6px; overflow: hidden; transition: border-color .15s, transform .05s; -webkit-user-select: none; user-select: none; }
.tile:hover { border-color: var(--accent); }
.tile:active { transform: scale(.96); }
.tile img { max-width: 100%; max-height: 60%; object-fit: contain; }
.tile .big { font-size: 34px; line-height: 1; }
.tile .lbl { font-size: 10px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .key { position: absolute; top: 4px; left: 6px; font-size: 10px; color: var(--muted); }
.tile .del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 10px; line-height: 20px; background: rgba(0,0,0,.5); border: 0; color: #fff; display: none; }
.tile:hover .del { display: block; }
.tile.sound { background: linear-gradient(160deg, #23283a, #1a1d27); }
.tile.sound.playing { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.tile.sound.playing .big::after { content: ' ⏹'; font-size: 16px; }
.seek { display: flex; align-items: center; gap: 10px; }
.seek input[type=range] { flex: 1; accent-color: var(--accent); }
.seek span { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 90px; text-align: right; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.settings select, .settings input[type=range] { accent-color: var(--accent); background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px; font-size: 13px; }
.settings output { color: var(--text); }
button.toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(10,12,16,.82); text-align: center; padding: 20px; }
.overlay.hidden { display: none; }
.overlay p { margin: 0; color: var(--muted); font-size: 15px; max-width: 420px; }
button, .btn { appearance: none; border: 0; border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); transition: background .15s, transform .05s; }
button:hover { background: #262b3a; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-2); }
button.danger { color: var(--accent-2); }
button:disabled { opacity: .45; cursor: not-allowed; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
input[type=text], input[type=password] { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 15px; flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.status { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.status .led { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.live .led { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.warn .led { background: #ffb020; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.item.active { border-color: var(--accent); }
.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.item .size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item button { padding: 8px 12px; font-size: 13px; }
progress { width: 100%; height: 10px; border-radius: 6px; overflow: hidden; accent-color: var(--accent); }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--accent); background: rgba(255,77,90,.06); }
.drop input { display: none; }
.transport { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.transport button { padding: 14px 10px; }
.share { display: flex; gap: 8px; align-items: center; }
.share code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 13px; }
footer { padding: 10px 16px; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 600px) {
  main { padding: 10px; gap: 10px; }
  header { padding: 10px 12px; }
  .player { border-radius: 10px; }
}

/* QR plein écran */
.qr-modal { position: fixed; inset: 0; z-index: 100; background: #fff; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; cursor: pointer; }
.qr-modal.open { display: flex; }
.qr-modal img { width: min(80vw, 70vh); height: auto; image-rendering: pixelated; }
.qr-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(16px, 4vw, 28px); color: #0f1115; font-weight: 600; text-align: center; word-break: break-all; }
.qr-hint { color: #6b7280; font-size: 14px; }

/* Onglets : uniquement sur mobile */
.sticky-top { display: flex; flex-direction: column; gap: 16px; }
.tabs { display: none; gap: 6px; }
.tabs button { flex: 1; padding: 10px 6px; font-size: 13px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 700px) {
  main { gap: 10px; }
  .tabs { display: flex; }
  .tabpane { display: none; }
  .tabpane.active { display: flex; }
  /* Bloc collant (lecteur + transport + onglets) : reste visible pendant qu'on manipule la régie */
  .sticky-top { position: sticky; top: 0; z-index: 30; background: var(--bg); gap: 8px; padding-bottom: 8px; margin: -10px -10px 0; padding-left: 10px; padding-right: 10px; padding-top: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
  .sticky-top .card { padding: 10px 12px; gap: 8px; }
  .sticky-top .card h2 { display: none; }
  .transport { grid-template-columns: repeat(3, 1fr); }
  .show-mobile { display: flex !important; }
  .transport button { padding: 12px 6px; font-size: 14px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
  .tile .big { font-size: 28px; }
  .tile .del { display: block; opacity: .7; }
  .sticker-x { display: block; }
  .settings { grid-template-columns: repeat(2, 1fr); }
  .hide-mobile { display: none; }
}
