[hidden] { display: none !important; }
:root { color-scheme: dark; --bg:#14161d; --card:#1e212b; --fg:#e8eaf0; --muted:#9aa0b0; --accent:#9146ff; --ok:#3ecf8e; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, sans-serif; }
header { display: flex; gap: .75rem; align-items: center; padding: .75rem 1rem; background: var(--card); flex-wrap: wrap; }
h1 { font-size: 1.1rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 .5rem; }
.status { color: var(--muted); }
.status.ok { color: var(--ok); }
.version { margin-left: auto; color: var(--muted); font-size: .8rem; }
button, .btn { background: #2b2f3c; color: var(--fg); border: 1px solid #3a3f50; border-radius: 6px; padding: .4rem .8rem; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); }
.note { color: var(--muted); margin: .25rem 0 .75rem; }
.box { background: var(--card); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.code-box { font: 700 2rem/1.2 ui-monospace, monospace; letter-spacing: .25em; margin: .5rem 0 1rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.live-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.live-item { display: flex; gap: .75rem; background: var(--card); border-radius: 8px; padding: .5rem; }
.live-thumb { width: 160px; height: 90px; object-fit: cover; border-radius: 4px; background: #2b2f3c; flex: none; }
.live-meta { min-width: 0; }
.live-name { font-weight: 700; }
.live-line { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-viewers { color: var(--ok); font-size: .85rem; }
.screen { position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 70vh; width: 100%; border-radius: 6px; overflow: hidden; }
.screen video { width: 100%; height: 100%; display: block; background: #000; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; background: rgba(0,0,0,.65); }
.overlay.error { color: #ff8a8a; }
.player-bar { align-items: center; margin-top: .5rem; }
.open-form { margin-bottom: 1rem; }
.open-form input { flex: 1; min-width: 12rem; background: var(--card); color: var(--fg); border: 1px solid #3a3f50; border-radius: 6px; padding: .4rem .6rem; font: inherit; }
select { background: #2b2f3c; color: var(--fg); border: 1px solid #3a3f50; border-radius: 6px; padding: .35rem .5rem; font: inherit; }
.live-item { cursor: pointer; }
.live-item.open { outline: 2px solid var(--accent); }

/* ---- mise en page PC : liste | lecteur | chat ---- */
body { height: 100vh; display: flex; flex-direction: column; }
header .spacer { flex: 1; }
header .version { margin-left: 0; }
form.inline { display: inline; margin: 0; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; gap: 0; }
.layout.no-chat { grid-template-columns: 300px minmax(0, 1fr); }
.layout.no-chat .chat { display: none; }
.layout.no-list { grid-template-columns: minmax(0, 1fr) 340px; }
.layout.no-list.no-chat { grid-template-columns: minmax(0, 1fr); }
.layout.no-list .sidebar { display: none; }
#layout:fullscreen { background: var(--bg); }
.tile:fullscreen { background: #000; }
.sidebar { overflow-y: auto; padding: .75rem; border-right: 1px solid #2b2f3c; }
.stage { overflow-y: auto; padding: .75rem; min-width: 0; }
.chat { border-left: 1px solid #2b2f3c; min-height: 0; display: flex; }
.chat-body { flex: 1; min-width: 0; display: flex; }
.chat-body iframe { flex: 1; width: 100%; height: 100%; border: 0; background: #0e0e10; }
.chat-body .note { padding: 1rem; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.screen { max-height: calc(100vh - 140px); }
.live-item { padding: .35rem; gap: .5rem; }
.live-thumb { width: 96px; height: 54px; }
.live-name { font-size: .9rem; }
.live-line { font-size: .8rem; }
.live-viewers { font-size: .75rem; }
.login-page { display: grid; place-items: center; height: 100vh; }
.login-box { width: min(360px, 90vw); }
.login-box label { display: block; margin: .5rem 0 .25rem; color: var(--muted); }
.login-box input { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid #3a3f50; border-radius: 6px; padding: .5rem .6rem; font: inherit; margin-bottom: .75rem; }
.error { color: #ff8a8a; }
code { background: #2b2f3c; padding: 0 .3rem; border-radius: 4px; }
/* ---- panel multistream ---- */
.stage:has(.multi:not([hidden])) { display: flex; flex-direction: column; overflow: hidden; }
.multi { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mbar { align-items: center; margin-bottom: .5rem; }
.mbar .spacer { flex: 1; }
.mbar .note { margin: 0; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"], .tile-bar button[aria-pressed="true"].tb-chat { background: var(--accent); border-color: var(--accent); }
.mgrid { flex: 1; min-height: 0; display: grid; gap: 6px; }
.mgrid[data-layout="side"] { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.mgrid[data-layout="quad"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.mgrid[data-layout="stack"] { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
.tile { position: relative; background: #000; border-radius: 6px; overflow: hidden; min-height: 0; min-width: 0; outline: 2px solid transparent; outline-offset: -2px; }
.tile.chat-sel { outline-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; padding: .25rem .4rem; background: linear-gradient(rgba(0,0,0,.8), transparent); }
.tile-bar .spacer { flex: 1; }
.tile-name { font-size: .85rem; text-shadow: 0 1px 2px #000; }
.tile-bar button, .tile-bar select { padding: .15rem .45rem; font-size: .85rem; }
.tile .overlay { z-index: 1; }
.tb-handle { cursor: grab; padding: 0 .2rem; color: var(--muted); user-select: none; }
.tb-vol { width: 70px; accent-color: var(--accent); }
.tile.dragging { opacity: .5; }
.tile.drop-target { outline-color: var(--ok); }
.tile-bar button:disabled { opacity: .35; cursor: default; }
.list-tools { margin-bottom: .5rem; align-items: center; }
.list-tools select { flex: 1; min-width: 0; }
.list-tools button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.live-item { position: relative; }
button.fav { position: absolute; top: .15rem; right: .15rem; padding: 0 .35rem; background: transparent; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1.3; }
button.fav.on { color: #ffd54a; }
.mtabs { display: none; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.page-ads { height: auto; min-height: 100vh; display: block; }
.ads-main { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.verdict[data-level="ok"] { border-left: 4px solid var(--ok); }
.verdict[data-level="watch"], .verdict[data-level="provisional"] { border-left: 4px solid #ffd54a; }
.verdict[data-level="bad"] { border-left: 4px solid #ff6b6b; }
.verdict[data-level="unknown"] { border-left: 4px solid var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: 8px; padding: .75rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #2b2f3c; white-space: nowrap; }
.table-wrap th { color: var(--muted); font-weight: 600; }
.row-bad td { color: #ffb4b4; }
@media (max-width: 900px) {
  body { height: 100dvh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
  header { padding: .4rem .6rem; gap: .4rem; }
  .page-ads { display: block; height: auto; }
  header .version, #btn-list, #btn-chat, header .status, #btn-disconnect { display: none; }
  header { flex-wrap: nowrap; }
  header button { padding: .3rem .5rem; white-space: nowrap; font-size: .85rem; }
  header h1 { font-size: 1rem; }
  header .spacer { display: none; }
  #btn-multi { margin-left: auto; }
  button, .btn, select { min-height: 40px; }
  .mtabs { display: flex; background: var(--card); border-bottom: 1px solid #2b2f3c; }
  .mtabs button { flex: 1; border: 0; border-radius: 0; background: transparent; border-bottom: 3px solid transparent; }
  .mtabs button[aria-pressed="true"] { border-bottom-color: var(--accent); font-weight: 700; }
  .layout, .layout.no-chat, .layout.no-list { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .stage { order: 1; flex: none; overflow: visible; padding: 0; }
  .mtabs { order: 0; }
  .sidebar, .chat { order: 2; flex: 1; min-height: 0; border: 0; }
  .sidebar { display: block !important; overflow-y: auto; }
  .chat { display: flex !important; }
  .layout[data-tab="list"] .chat, .layout[data-tab="chat"] .sidebar { display: none !important; }
  .screen { max-height: 45dvh; border-radius: 0; }
  .player-bar { padding: .4rem .6rem; }
  .stage { border-bottom: 1px solid #2b2f3c; }
  .stage:has(.multi:not([hidden])) { height: 58dvh; padding: .25rem; overflow: hidden; }
  .mbar { margin-bottom: .25rem; gap: .3rem; }
  .mbar button { padding: .2rem .5rem; min-height: 34px; font-size: .85rem; }
  .mbar .note, #btn-mfull { display: none; }
  .empty { padding: 1rem; }
  .tile-bar { padding: .15rem .25rem; gap: .2rem; }
  .tile-bar .tb-vol, .tile-bar select { display: none; }
  .tile-bar button { min-height: 32px; min-width: 32px; }
  .live-thumb { width: 112px; height: 63px; }
}
@media (max-width: 900px) and (orientation: landscape) {
  .layout, .layout.no-chat, .layout.no-list { flex-direction: row; }
  .stage { order: 0; flex: 1 1 60%; min-width: 0; overflow-y: auto; }
  .screen { max-height: calc(100dvh - 120px); }
  .stage:has(.multi:not([hidden])) { height: auto; }
  .sidebar, .chat { flex: 0 0 38%; }
}
