:root {
  --bg: #0b0d12; --card: #14171f; --card2: #1c212b; --line: #272d3a; --line2: #343b4b;
  --text: #eceef4; --muted: #98a1b3;
  --accent: #5b8cff; --ok: #34d399; --danger: #f0484e; --warn: #fbbf24;
  --ok-bg: #0f2a22; --warn-bg: #2f2408; --err-bg: #34141a;
  --bar: rgba(11, 13, 18, .92); --bar-solid: rgba(11, 13, 18, .96); --line3: #4a5368;
  --danger-text: #ff8b90; --onair-text: #ff6b70; --warn-text: #ffe39a; --checker-a: #12151c; --checker-b: #171b24;
  --r: 16px; --hh: 56px;
  color-scheme: dark;
}
/* Theme clair : choisi avec le bouton de l'en-tete ; « auto » suit le reglage de l'appareil. */
:root[data-theme="light"] {
  --bg: #f3f5f9; --card: #ffffff; --card2: #eaeef5; --line: #dde2ec; --line2: #c8cfdc;
  --text: #171b26; --muted: #5b6579;
  --accent: #2f62e6; --ok: #0f9d6b; --danger: #d92d3a; --warn: #b7791f;
  --ok-bg: #dff5ec; --warn-bg: #fdf1d6; --err-bg: #fde4e6;
  --bar: rgba(255, 255, 255, .92); --bar-solid: rgba(255, 255, 255, .96); --line3: #a9b3c6;
  --danger-text: #b4232e; --onair-text: #c62631; --warn-text: #7a4b05; --checker-a: #e4e8f0; --checker-b: #eef1f6;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.1rem; margin: 0; letter-spacing: .01em; display: flex; align-items: center; gap: .55rem; }
h1::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(91, 140, 255, .18); }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; font-weight: 700; letter-spacing: .005em; }
p { margin: .3rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
code { background: var(--card2); padding: .12rem .4rem; border-radius: 6px; font-size: .88rem; word-break: break-all; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- en-tete et navigation ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; height: var(--hh); padding: 0 1rem; background: var(--bar); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pill { padding: .3rem .8rem; border-radius: 999px; background: var(--card2); color: var(--muted); font-size: .85rem; font-weight: 700; border: 1px solid var(--line); }
.pill.live { background: var(--danger); border-color: var(--danger); color: #fff; }
.pill.wait { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.pill.ready { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }

main { max-width: 1120px; margin: 0 auto; padding: 1rem 1rem 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem; margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: .7rem; }

.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--bar-solid); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: .6rem 1rem calc(.5rem + env(safe-area-inset-bottom)); }
.emergency { display: block; width: 100%; max-width: 760px; margin: 0 auto .5rem; min-height: 52px; background: var(--err-bg); border-color: var(--danger); color: var(--danger-text); font-size: 1rem; }
.emergency:hover { background: var(--danger); color: #fff; }
.tabs { display: flex; max-width: 760px; margin: 0 auto; gap: .4rem; }
.tabs button { flex: 1; min-height: 46px; padding: .3rem; font-size: .9rem; background: transparent; border-color: transparent; color: var(--muted); }
.tabs button.active { background: var(--card2); border-color: var(--line2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- boutons et champs ---------- */
button, select, input, textarea { font: inherit; color: inherit; }
button { min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); cursor: pointer; font-weight: 600; touch-action: manipulation; transition: background .12s, border-color .12s, transform .06s; }
button:hover:not(:disabled) { border-color: var(--line3); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #6f9bff; border-color: #6f9bff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); }
button.small { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; }
button.big { width: 100%; min-height: 60px; font-size: 1.15rem; border-radius: 14px; }
input[type=text], input[type=password], input[type=url], select { width: 100%; min-height: 48px; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; color: var(--text); font-size: 1rem; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- ecran Live : carte principale ---------- */
.live-grid { display: grid; gap: 0; }
.hero { padding: 1.2rem; }
.hero > * + * { margin-top: 1rem; }
.hero-head h2 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
.hero-head h2.good { color: var(--ok); }
.hero-head h2.bad { color: var(--danger); }
.hero-head p { margin-top: .35rem; }
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; flex-wrap: wrap; }
.hero-head h2.onair { display: flex; align-items: center; gap: .6rem; color: var(--onair-text); }
.rec { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(240, 72, 78, .6); } 70% { box-shadow: 0 0 0 10px rgba(240, 72, 78, 0); } 100% { box-shadow: 0 0 0 0 rgba(240, 72, 78, 0); } }
.big-time { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.stepper { display: flex; list-style: none; margin: 0; padding: 0; gap: .4rem; counter-reset: s; }
.stepper li { flex: 1; display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: 999px; background: var(--card2); color: var(--muted); font-size: .85rem; font-weight: 600; border: 1px solid transparent; min-width: 0; }
.stepper .dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: .78rem; border: 1px solid var(--line2); }
.stepper .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.now { color: var(--text); border-color: var(--accent); background: rgba(91, 140, 255, .12); }
.stepper li.now .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.done { color: var(--ok); }
.stepper li.done .dot { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.hero.step-3 .stepper li.done:last-child { color: var(--onair-text); }
.hero.step-3 .stepper li.done:last-child .dot { background: var(--err-bg); border-color: var(--danger); color: var(--onair-text); }

.countdown-box { text-align: center; padding: .8rem; border-radius: 14px; background: var(--card2); }
.countdown { font-size: 3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--warn); }
.progress { height: 8px; border-radius: 999px; background: var(--card2); overflow: hidden; }
.progress > div { height: 100%; width: 3%; background: var(--warn); border-radius: 999px; transition: width 1s linear; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--muted); font-size: .86rem; }
.meta strong { color: var(--text); font-variant-numeric: tabular-nums; }
.hints { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; }
.hints li { margin: .25rem 0; }

.chips-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 54px; padding: .5rem .9rem; border-radius: 12px; background: var(--card2); text-align: left; }
.chip small, .seg small { font-weight: 500; color: var(--muted); font-size: .76rem; }
.chip.on { background: rgba(91, 140, 255, .14); border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .3rem; border-radius: 14px; background: var(--card2); }
.seg button { display: flex; flex-direction: column; align-items: center; gap: 0; min-height: 52px; background: transparent; border-color: transparent; }
.seg button.on { background: var(--bg); border-color: var(--line2); box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; }
.relays { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.relay { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .65rem .9rem; }
.relay + .relay { border-top: 1px solid var(--line); }

details.ingest summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
details.ingest summary::after { content: "▾"; color: var(--muted); }
details.ingest[open] summary::after { content: "▴"; }
details.ingest[open] summary { margin-bottom: .6rem; }
details.ingest summary::-webkit-details-marker { display: none; }

.presets-card.locked .grid { opacity: .5; }

/* ---------- presets, badges, listes ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.preset-btn { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; min-height: 92px; text-align: left; padding: .85rem; border-radius: 14px; }
.preset-btn .ico { font-size: 1.5rem; }
.preset-btn .nm { font-weight: 700; overflow-wrap: anywhere; }
.preset-btn .st { font-size: .8rem; color: var(--muted); font-weight: 500; }
.preset-btn.on { background: var(--ok-bg); border-color: var(--ok); }
.preset-btn.on .st { color: var(--ok); }
.preset-btn.busy { opacity: .6; }

.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.badge.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.badge.err { background: var(--err-bg); border-color: transparent; color: var(--danger); }

.item { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .75rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.item .main { min-width: 0; flex: 1 1 200px; }
.item .main strong { overflow-wrap: anywhere; }
.thumb { width: 64px; height: 48px; object-fit: contain; background: var(--bg); border-radius: 8px; border: 1px solid var(--line); }
audio { max-width: 100%; height: 36px; }

dialog { width: min(560px, calc(100vw - 1.5rem)); max-height: 92vh; overflow: auto; background: var(--card); color: var(--text); border: 1px solid var(--line2); border-radius: var(--r); padding: 1.2rem; }
dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 1rem; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.actions button { flex: 1; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(160px + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: .4rem; pointer-events: none; padding: 0 1rem; }
.toast { background: var(--card2); border: 1px solid var(--line2); padding: .65rem 1rem; border-radius: 12px; max-width: 520px; box-shadow: 0 8px 28px rgba(0,0,0,.55); }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

.preview { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.preview[hidden] { display: none; }
.preview-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview.off .preview-img { visibility: hidden; }
.preview.off::after { content: attr(data-msg); position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem; color: var(--muted); font-size: .95rem; background: repeating-linear-gradient(45deg, #0b0d12, #0b0d12 12px, #10131a 12px, #10131a 24px); }
.preview-tag { position: absolute; top: .5rem; left: .5rem; padding: .15rem .55rem; border-radius: 999px; background: rgba(0, 0, 0, .65); color: var(--muted); font-size: .75rem; font-weight: 700; }
.preview-tag.onair { background: var(--danger); color: #fff; }
.preview.off .preview-tag { display: none; }
textarea { width: 100%; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; resize: vertical; }
input[type=number] { width: 100%; min-height: 48px; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
input[type=number].narrow { max-width: 9rem; }
input.color { width: 100%; height: 48px; padding: .2rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: .9rem; background: var(--bg); }
.box > strong { display: block; margin-bottom: .6rem; }
.subfield { margin: .4rem 0 .8rem .4rem; padding-left: .8rem; border-left: 2px solid var(--line2); }
.subfield[hidden], .field[hidden] { display: none; }
.layer { border: 1px solid var(--line); border-radius: 12px; padding: .7rem; margin: .6rem 0; background: var(--card); }
.layer .field:last-child { margin-bottom: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; text-align: left; padding: .8rem; min-height: 120px; }
.tpl .ico { font-size: 1.5rem; }
.tpl .muted { font-weight: 400; font-size: .8rem; }
.adder .row { gap: .5rem; }
.adder > .muted { margin: .5rem 0 0; font-size: .82rem; }
.adder .subfield { margin-top: .6rem; }
.adder input[type=url], .adder input[type=text] { margin-bottom: .5rem; }
.field input[type=url], input[type=url] { width: 100%; min-height: 48px; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.mixrow { padding: .4rem 0; }
.mixrow + .mixrow { border-top: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 1.2rem .5rem; }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn); color: var(--warn-text); padding: .7rem .9rem; border-radius: 12px; font-size: .92rem; }

@media (max-width: 520px) {
  .stepper li:not(.now) .lbl { display: none; }
  .stepper li:not(.now) { flex: 0 0 auto; padding: .45rem; }
  .stepper li.now { flex: 1; }
  .hero-head h2 { font-size: 1.35rem; }
}

/* ---------- grand ecran : navigation en haut, Live sur deux colonnes ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 2rem; display: flex; flex-direction: column; }
  .top { order: 0; } .dock { order: 1; } main { order: 2; width: 100%; }
  #toasts { order: 3; }
  .dock { position: sticky; top: var(--hh); bottom: auto; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; border-top: 0; border-bottom: 1px solid var(--line); }
  .dock .tabs { order: 1; margin: 0; max-width: none; flex: 0 0 auto; }
  .dock .tabs button { flex: none; padding: .3rem 1.2rem; min-height: 42px; }
  .emergency { order: 2; width: auto; margin: 0 0 0 auto; min-height: 42px; padding: .3rem 1.1rem; max-width: none; }
  .toasts { bottom: 1.5rem; }
  main { padding-top: 1.4rem; }
  .live-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1.2rem; align-items: start; grid-template-areas: "hero preview" "presets preview" "mixer source"; }
  .area-hero { grid-area: hero; } .area-preview { grid-area: preview; position: sticky; top: calc(var(--hh) + 70px); }
  .area-presets { grid-area: presets; } .area-mixer { grid-area: mixer; } .area-source { grid-area: source; }
}

/* ---------- onglets Presets, Plateformes, Medias ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: .2rem 0 1.1rem; }
.page-head h2 { font-size: 1.5rem; margin: 0; }
.page-head p { margin: .2rem 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.pcard { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "ico body sw" "act act act"; align-items: center; gap: .8rem; padding: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); transition: border-color .12s; }
.pcard:hover { border-color: var(--line2); }
.pcard.off { opacity: .6; }
.pcard-ico, .pf-logo { grid-area: ico; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--card2); font-size: 1.5rem; }
.pf-logo { color: #fff; font-weight: 800; font-size: 1.3rem; }
.pcard-body { grid-area: body; min-width: 0; }
.pcard-body strong { overflow-wrap: anywhere; }
.pcard .switch { grid-area: sw; }
.pcard-actions { grid-area: act; display: flex; gap: .5rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.pcard-actions button { flex: 1; }
.pcard-actions button:not(.ghost) { background: var(--card2); }

.empty-state { text-align: center; padding: 2.2rem 1.2rem; }
.empty-state h3 { margin: .3rem 0; font-size: 1.15rem; }
.empty-state button { margin-top: .8rem; }
.big-ico { font-size: 2.6rem; }
.note { text-align: center; margin: .4rem 0 1rem; }

.switch { position: relative; display: inline-block; width: 50px; height: 30px; margin: 0; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line2); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.dropzone { border-style: dashed; border-color: var(--line2); background: transparent; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.tile { display: flex; flex-direction: column; gap: .6rem; padding: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.tile-view { aspect-ratio: 4 / 3; display: grid; place-items: center; border-radius: 12px; background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 16px 16px; overflow: hidden; }
.tile-view img { width: 100%; height: 100%; object-fit: contain; }
.tile-ico { font-size: 2.6rem; }
.tile-body { min-width: 0; flex: 1; }
.tile-body strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile audio { width: 100%; margin-top: .4rem; }

/* ---------- vignettes des overlays ---------- */
.preset-btn { gap: .45rem; padding: .5rem .5rem .7rem; min-height: 0; align-items: stretch; }
.preset-btn .nm, .preset-btn .st { padding: 0 .3rem; }
.thumb-box { width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--card2); display: grid; place-items: center; }
.thumb-img { width: 100%; height: 100%; object-fit: contain; }
.thumb-ico { font-size: 2rem; }
.thumb-text { font-weight: 800; font-size: 1.05rem; text-align: center; padding: .3rem .5rem; overflow-wrap: anywhere; line-height: 1.1; }
.pcard-thumb { grid-area: ico; width: 96px; }
.pcard-thumb .thumb-ico { font-size: 1.5rem; }
.pcard-thumb .thumb-text { font-size: .75rem; }
.grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* ---------- source video (camera de l'appareil) ---------- */
.src-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.btnlink { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); color: var(--text); font-weight: 600; text-decoration: none; }
.btnlink.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.source-card .seg { margin-bottom: .2rem; }

/* ---------- format vertical ---------- */
.preview.portrait { width: min(100%, 39vh); margin: 0 auto; }
.cam-preview { margin: 0 auto; }
.cam-preview[style*="9 / 16"] { width: min(100%, 34vh); }
.cam-preview[data-fit="cover"] .src-video { object-fit: cover; }
.hero .seg + .seg { margin-top: -.4rem; }

/* ---------- ecran Live : carte unique (source + format + qualite + demarrage), mode compact en direct ---------- */
.src-raw { position: fixed; left: -9999px; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.source-block { display: flex; flex-direction: column; gap: .7rem; padding: .9rem; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.source-block > * { margin: 0; }
.block-title { margin: 0; font-size: 1rem; }
.seg-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.seg-pair .seg { margin: 0; }
.cam-row { display: flex; gap: .8rem; align-items: flex-start; }
.cam-row .cam-controls { flex: 1; min-width: 0; }
.cam-preview { position: relative; background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); flex: none; }
.cam-preview[hidden] { display: none; }
.cam-preview canvas { display: block; width: 100%; height: 100%; }
.cam-preview.small { width: 150px; }
.cam-preview.tiny { width: 110px; margin-top: .5rem; }
.cam-preview[style*="9 / 16"].small { width: 100px; }
.cam-preview[style*="9 / 16"].tiny { width: 70px; }
.check.inline { min-height: 0; display: inline-flex; margin: 0; }
.src-line { margin: 0; }
.hero.compact { padding: .8rem 1rem; }
.hero.compact > * + * { margin-top: .6rem; }
.live-bar { display: flex; align-items: center; gap: .8rem 1.2rem; flex-wrap: wrap; }
.live-bar h2 { margin: 0; font-size: 1.15rem; }
.live-bar .big-time { font-size: 1.2rem; }
.live-bar button { min-height: 44px; margin-left: auto; }
.relay-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.relay-pill { font-size: .85rem; display: inline-flex; gap: .3rem; align-items: center; }
/* apercu a l'antenne plus petit */
.area-preview { max-width: 320px; }
.area-preview h2 { font-size: .95rem; }
.preview.portrait { width: min(100%, 24vh); }
@media (max-width: 899px) { .area-preview { max-width: 280px; margin-inline: auto; } .cam-row { flex-direction: column; } .cam-preview.small { width: 100%; max-width: 240px; } }
@media (min-width: 900px) {
  .live-grid { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "hero preview" "presets preview" "mixer preview"; }
  .area-preview { grid-row: 1 / span 3; }
}

/* petit ecran : une seule colonne qui ne depasse jamais la largeur de l'ecran */
.live-grid { grid-template-columns: minmax(0, 1fr); }
.live-grid > * { min-width: 0; }
.hero, .source-block, .cam-controls { min-width: 0; }
.hero select, .hero input { max-width: 100%; }
@media (max-width: 520px) {
  .seg-pair { grid-template-columns: 1fr; }
  .seg button { padding-inline: .4rem; }
  .hero { padding: .9rem; }
  .source-block { padding: .7rem; }
}

/* ---------- en direct : carte du haut = retour image + Arreter (100 % de large, 33 % de haut au plus) ---------- */
.live-grid.is-live { grid-template-columns: minmax(0, 1fr); grid-template-areas: "livetop" "presets" "mixer"; }
.area-livetop { grid-area: livetop; }
.live-top { max-height: 33vh; min-height: 150px; display: flex; flex-direction: column; gap: .5rem; overflow: hidden; padding: .7rem .9rem; }
.live-top .live-bar { flex: none; }
.live-top .live-bar button { min-height: 40px; }
.live-top .preview, .live-top .preview.portrait { flex: 1 1 0; min-height: 0; width: 100%; aspect-ratio: auto; margin: 0; display: flex; justify-content: center; background: #000; }
.live-top .preview-img { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.live-top .source-block { flex: none; padding: 0; border: 0; background: none; gap: .3rem; }
.live-top .cam-preview.tiny { display: none; }
/* overlays : grille de 2 colonnes, vignette seule */
.presets-card .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.preset-btn { position: relative; display: block; padding: 0; overflow: hidden; border-radius: 14px; min-height: 0; line-height: 0; border-width: 2px; }
.preset-btn .thumb-box { border-radius: 0; }
.preset-btn.on { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(52, 211, 153, .35); }
.tile-title { position: absolute; left: 0; right: 0; bottom: 0; padding: .45rem .5rem; text-align: center; line-height: 1.2; font-size: .95rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px #000, 0 0 3px #000; overflow-wrap: anywhere; pointer-events: none; }
.tile-kind { position: absolute; left: .4rem; top: .4rem; line-height: 1; font-size: .95rem; padding: .2rem .35rem; border-radius: 8px; background: rgba(0, 0, 0, .55); pointer-events: none; }
.tile-timer { position: absolute; right: .4rem; top: .4rem; line-height: 1; font-size: .8rem; font-weight: 700; padding: .25rem .45rem; border-radius: 999px; background: var(--ok); color: #04210f; pointer-events: none; }
.preset-btn .thumb-ico { font-size: 2.2rem; }
.live-top .preview, .live-top .preview.portrait { flex: none; height: clamp(110px, calc(33vh - 110px), 230px); }

/* ---------- en direct : barre du haut (Arreter a gauche, duree a droite) et carte du retour image ---------- */
.stop-top { min-height: 40px; padding: .3rem 1rem; background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; white-space: nowrap; }
.stop-top[hidden], #title[hidden] { display: none; }
.pill.live { background: #fb923c; border-color: #fb923c; color: #1c0a00; white-space: nowrap; }
.top { gap: .6rem; flex-wrap: nowrap; }
.live-top { height: min(33vh, 360px); min-height: 140px; max-height: 33vh; display: flex; flex-direction: column; gap: .4rem; padding: .5rem; overflow: hidden; }
.live-top .live-stage { position: relative; flex: 1 1 0; min-height: 0; display: flex; justify-content: center; background: #000; border-radius: 10px; overflow: hidden; }
.live-top .live-stage .preview, .live-top .live-stage .preview.portrait { flex: none; width: 100%; height: 100%; margin: 0; aspect-ratio: auto !important; border: 0; border-radius: 0; display: flex; justify-content: center; }
.live-top .preview-img { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.live-top .preview-tag { display: none; }
.live-top .relay-badges { position: absolute; left: .4rem; bottom: .4rem; z-index: 2; display: flex; gap: .3rem; flex-wrap: wrap; }
.live-top .relay-pill { background: rgba(0, 0, 0, .6); padding: .15rem .4rem; border-radius: 999px; font-size: .75rem; }
.live-top .source-block { flex: none; }
.live-top .source-block:empty { display: none; }
.brb-card { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: 1rem; }
.stack-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.scene-map { position: relative; width: 100%; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.scene-map.big { max-width: 360px; margin: 0 auto .9rem; }
.scene-cam { position: absolute; display: grid; place-items: center; background: rgba(91, 140, 255, .55); border: 1px solid var(--accent); font-size: 1.1rem; }
.scene-map.small .scene-cam { font-size: .7rem; }
.scene-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.scene-btn { display: flex; flex-direction: column; gap: .35rem; width: 110px; padding: .45rem; border-radius: 12px; background: var(--card2); text-align: center; font-size: .82rem; }
.scene-btn.on { border-color: var(--accent); background: rgba(91, 140, 255, .14); }
.scene-tiles .tile { gap: .6rem; padding: .8rem; }
.num-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: .8rem 0; }
.num { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: .2rem; }
.num input { min-height: 44px; width: 100%; padding: .4rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; }
.chip.check { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; }
.chat-feed { height: 46vh; min-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: .35rem; padding: .6rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.chat-msg { display: flex; align-items: flex-start; gap: .5rem; word-break: break-word; line-height: 1.3; }
.chat-badge { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .78rem; font-weight: 700; }
.chat-sources { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.chat-source { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.chat-source .chat-state { margin-left: auto; }
.chat-state.connected { color: var(--good, #3ecf8e); }
.chat-add { display: flex; gap: .5rem; }
.chat-add input { flex: 1; min-width: 0; min-height: 48px; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.scene-cam.guest { background: rgba(62, 207, 142, .45); border-color: #3ecf8e; font-size: .9rem; }
.layout-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .8rem; }
.guest-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .8rem; }
.guest-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.guest-row .row { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.guest-state.good { color: var(--good, #3ecf8e); }
.guest-state.bad { color: var(--danger-text); font-weight: 700; }
/* Dispositions d'invites sur l'ecran Live : une seule ligne, defilement lateral */
.layout-row.scroll { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: .4rem; }
.layout-row.scroll .scene-btn { flex: none; scroll-snap-align: start; }
/* Un invite par carte, nom et boutons toujours sur la meme ligne (le nom long est tronque) */
.guest-cards { display: flex; flex-direction: column; gap: .5rem; }
.guest-card { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: nowrap; padding: .6rem .8rem; background: var(--card2); border: 1px solid var(--line2); border-radius: 12px; }
.guest-card.onair { border-color: #ff6b6b; }
.guest-id { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.guest-id strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-card button { flex: none; white-space: nowrap; }
.yt-card { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }
.yt-fields { display: grid; gap: .6rem; }
.yt-fields input, .yt-fields select { width: 100%; min-height: 48px; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.yt-fields label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.yt-code { font-size: 1.8rem; font-weight: 800; letter-spacing: .12em; text-align: center; padding: .7rem; background: var(--card2); border-radius: 12px; }
.yt-ok { color: var(--good, #3ecf8e); font-weight: 700; }
.steps { padding-left: 1.2rem; line-height: 1.5; }
.accounts-card { display: flex; flex-direction: column; gap: .9rem; margin-bottom: 1rem; }
.account-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.account-row .pcard-body { flex: 1 1 160px; min-width: 0; }
.account-row select { width: 100%; min-height: 44px; margin-top: .3rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 0 .6rem; }
.page-head.sub { margin-top: 1.4rem; align-items: center; }
.page-head.sub h3 { margin: 0; font-size: 1.1rem; }
.account-row .switch { margin-right: .2rem; }
.chat-msg .chat-body { flex: 1; min-width: 0; }
.chat-author { font-weight: 700; }
.chat-hide { flex: none; background: none; border: 0; color: var(--muted, #8b93a7); font-size: 1.1rem; line-height: 1; padding: 0 .35rem; cursor: pointer; opacity: .5; }
.chat-hide:hover { opacity: 1; color: #ff6b6b; }
.chat-logo { flex: none; width: 1.5rem; height: 1.5rem; display: inline-block; }
.chat-logo svg { width: 100%; height: 100%; display: block; }
.chat-status { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.chat-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem .25rem .35rem; border-radius: 999px; background: var(--card2); border: 1px solid var(--line2); font-size: .85rem; }
.chat-chip .chat-logo { width: 1.2rem; height: 1.2rem; }
.chat-chip.connected { border-color: var(--good, #3ecf8e); }
.chat-chip.error { border-color: var(--danger); color: var(--danger-text); }

.theme-toggle { min-height: 40px; min-width: 40px; padding: .2rem .6rem; font-size: 1.1rem; line-height: 1; background: transparent; border-color: var(--line); }
.theme-toggle { margin-left: auto; margin-right: .6rem; }

.guest-num { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; margin-right: .45rem; padding: 0 .3rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .85rem; font-weight: 800; vertical-align: middle; }
.slot-picker { display: flex; flex-direction: column; gap: .5rem; margin: .5rem 0 .8rem; }
.slot-row { display: flex; align-items: center; gap: .6rem; }
.slot-row select { flex: 1; min-width: 0; min-height: 44px; padding: .4rem .6rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.slot-num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 8px; background: rgba(62, 207, 142, .35); border: 1px solid #3ecf8e; font-size: .85rem; font-weight: 800; }
.guest-state.warn { color: var(--warn); font-weight: 700; }

.conv-card .row { margin: .5rem 0; }
.conv-people { display: flex; flex-direction: column; gap: .35rem; margin: .5rem 0; }
.conv-person { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem .7rem; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); }
.conv-person.talking { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(52, 211, 153, .3); }
.conv-sync { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; }
.conv-sync input { max-width: 8rem; min-height: 44px; padding: .4rem .6rem; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; }
.err-text { color: var(--danger-text, #ff8b90); font-weight: 600; }

/* ---------- compact : moins d'espaces vides, plus de place pour les boutons et les cartes (surtout sur telephone) ---------- */
body { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
main { padding: .6rem .75rem 0; }
.card { padding: .75rem .85rem; margin-bottom: .6rem; }
h2 { margin: 0 0 .4rem; }
.stack-col { gap: .6rem; }
.hero { padding: .8rem .85rem; }
.hero > * + * { margin-top: .7rem; }
.hero-head h2 { font-size: 1.3rem; }
.stepper li { padding: .3rem .5rem; }
.page-head { margin: .1rem 0 .6rem; }
.page-head h2 { font-size: 1.3rem; }
.source-block { padding: .6rem; gap: .5rem; }
.live-top { padding: .4rem; }
.toasts { bottom: calc(120px + env(safe-area-inset-bottom)); }
.dock { padding: .4rem .75rem calc(.35rem + env(safe-area-inset-bottom)); }
.emergency { min-height: 38px; margin-bottom: .3rem; padding: .15rem .8rem; font-size: .95rem; }
/* menu du bas : defilement lateral (tous les onglets restent accessibles sur telephone) */
.tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; min-height: 42px; padding: .25rem .95rem; scroll-snap-align: center; white-space: nowrap; }
@media (min-width: 900px) { body { padding-bottom: 2rem; } .tabs { overflow: visible; } .emergency { min-height: 42px; margin: 0 0 0 auto; } .dock { padding: .5rem 1rem; } }

/* barre du haut : les boutons de l'etape prennent la place du titre */
.top { padding: 0 .6rem; }
.top-actions { display: flex; gap: .4rem; min-width: 0; align-items: center; }
.act-top { min-height: 40px; padding: .3rem .9rem; white-space: nowrap; font-weight: 700; }
.act-top[hidden], .stop-top[hidden] { display: none; }
.pill { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .top.has-actions .pill { display: none; } .pill { font-size: .75rem; padding: .25rem .55rem; } .act-top, .stop-top { padding: .3rem .65rem; font-size: .9rem; } .theme-toggle { margin-right: .3rem; } }

/* carte Conversation : decalage du son en boutons − / + (pas de clavier), version reduite en direct */
.sync-ctl { display: inline-flex; align-items: center; gap: .3rem; flex: none; }
.sync-btn { min-width: 40px; min-height: 40px; padding: 0; font-size: 1.25rem; line-height: 1; }
.conv-card.compact .sync-btn { min-width: 36px; min-height: 38px; }
.conv-card.compact .sync-val { min-width: 3.1rem; font-size: .9rem; }
.sync-val { min-width: 3.7rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.conv-sync { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; margin-top: .5rem; }
.conv-card.compact { padding: .4rem .5rem; }
.conv-line { display: flex; align-items: center; gap: .3rem; flex-wrap: nowrap; }
.conv-line > button:first-child { flex: 0 1 auto; min-width: 0; min-height: 40px; padding: .3rem .55rem; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-line > button:nth-child(2) { min-height: 42px; padding: .3rem .6rem; }
.conv-spacer { flex: 1 1 0; min-width: 0; }
.conv-card .row { margin: .4rem 0; }

/* chat : etat des plateformes sur une seule ligne (logo + coche verte ou croix rouge), fil plus haut */
.chat-status { flex-wrap: nowrap; gap: .4rem; margin-bottom: .4rem; }
.chat-chip { flex: none; gap: .25rem; padding: .15rem .45rem .15rem .25rem; font-size: .8rem; }
.chat-mark { font-size: .9rem; line-height: 1; }
.chat-chip.connected .chat-mark { color: var(--ok); }
.chat-chip.connecting .chat-mark { color: var(--warn); }
.chat-chip.error .chat-mark, .chat-chip.off .chat-mark { color: var(--danger); }
.chat-chip.off { border-color: var(--danger); }
@media (max-width: 899px) {
  .chat-head p { display: none; }
  .chat-feed { height: calc(100dvh - 290px); min-height: 220px; }
}

/* ---------- page Invites : dispositions en grille de 3 colonnes x 2 lignes, schemas reduits ---------- */
.layout-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin: .2rem 0 .4rem; }
.layout-grid .scene-btn { width: auto; min-width: 0; padding: .3rem .25rem; gap: .2rem; font-size: .72rem; line-height: 1.15; }
.layout-grid .scene-map { max-width: 76px; margin: 0 auto; }
.layout-grid .scene-map.small .scene-cam { font-size: .6rem; }
.layout-grid .scene-btn small { font-size: .65rem; }
.block-sub { margin: .5rem 0 .2rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.block-title + .block-sub { margin-top: .3rem; }

/* ---------- chat : carte pleine largeur sur telephone, fil plus large (moins de retours a la ligne) et plus haut ---------- */
.chat-card { padding: .5rem; }
.chat-card .chat-feed { height: calc(100dvh - 225px); min-height: 240px; padding: .4rem .45rem; gap: .25rem; font-size: .88rem; border-radius: 10px; }
.chat-msg { gap: .35rem; line-height: 1.25; }
.chat-msg .chat-logo { width: 1.15rem; height: 1.15rem; margin-top: .05rem; }
.chat-hide { padding: 0 .2rem; }
@media (max-width: 899px) {
  .chat-card { margin-inline: -.75rem; border-radius: 0; border-inline: 0; padding: .4rem .35rem; }
  .chat-card .chat-feed { border-radius: 8px; padding: .35rem .4rem; font-size: .85rem; }
}
@media (min-width: 900px) { .chat-card .chat-feed { height: calc(100dvh - 230px); } }

/* ---------- retour image : une seule ligne de pastilles (logo + coche ou croix) ---------- */
.relay-badges { flex-wrap: nowrap; gap: .25rem; }
.relay-pill { gap: .2rem; padding: .1rem .35rem .1rem .2rem; font-size: .75rem; }
.relay-pill .chat-logo { width: 1rem; height: 1rem; }
.relay-mark { font-size: .8rem; line-height: 1; }
.relay-mark.ok { color: #34d399; } .relay-mark.warn { color: #fbbf24; } .relay-mark.err { color: #ff6b70; }
.live-top .relay-pill { display: inline-flex; align-items: center; background: rgba(0, 0, 0, .6); border-radius: 999px; }
