:root {
  --bg: #0f1114;
  --panel: #14171b;
  --well: #050607;
  --btn: #1a1e23;
  --line: #2a2f36;
  --line-strong: #3a414a;
  --text: #e6e8eb;
  --muted: #9aa3ad;
  --soft: #c3c9d0;
  --accent: #e5332a;
  --ok: #5fd38d;
  --err: #ff7a72;
  --star: #f5c542;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter Tight', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.noscroll { scrollbar-width: none; -ms-overflow-style: none; }
.noscroll::-webkit-scrollbar { display: none; }
[hidden] { display: none !important; }
.spacer { margin-left: auto; }

/* ---------- En-tête ---------- */
.topbar { height: 64px; padding: 0 28px; display: flex; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.topbar .icon-btn + .icon-btn, .topbar .cast-slot + .icon-btn { margin-left: -16px; }
.brand { margin: 0; font-weight: 800; font-size: 20px; letter-spacing: .5px; white-space: nowrap; }
.brand span { color: var(--accent); }
.crumb { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.clock { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.offair { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4a525c; display: inline-block; }

.icon-btn { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--btn); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover { border-color: var(--muted); }
.text-btn { height: 44px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--btn); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.text-btn:hover:not(:disabled) { border-color: var(--muted); }
.text-btn.small { height: 36px; padding: 0 12px; font-size: 11px; }
.text-btn.danger { color: var(--err); }

.cast-slot { position: relative; }
.cast-slot google-cast-launcher { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cast-slot.connected { border-color: var(--accent); color: var(--accent); }

/* ---------- Mise en page ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.main { flex: 1; min-height: 0; display: flex; gap: 20px; padding: 20px 28px 24px; }
.program { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.wall { width: 490px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.statusbar { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 24px; white-space: nowrap; overflow: hidden; }
.onair { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; }
.onair .dot { background: #fff; }
.onair.idle { background: var(--btn); color: var(--muted); }
.onair.idle .dot { background: #4a525c; }
.statusbar .tech { margin-left: auto; }
.via { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line-strong); font-weight: 600; flex-shrink: 0; }
.via.direct { color: var(--ok); border-color: rgba(95, 211, 141, .45); }
.via.relay { color: var(--star); border-color: rgba(245, 197, 66, .45); }
.backup { display: flex; flex-direction: column; gap: 8px; padding-top: 18px; }
.backup code { font-family: var(--mono); font-size: 12px; color: var(--soft); }
a.text-btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-btn:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.small-msg { font-size: 12px; color: var(--soft); min-height: 16px; }
.small-msg.bad { color: var(--err); }
#pgmLabel { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Moniteur ---------- */
.monitor { position: relative; flex: 1; min-height: 0; background: var(--well); border: 2px solid var(--accent); border-radius: 4px; overflow: hidden; }
.monitor:fullscreen { border: none; border-radius: 0; }
.monitor video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.monitor .bug { position: absolute; top: 16px; right: 16px; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.monitor .bug img { max-width: 100%; max-height: 100%; object-fit: contain; opacity: .7; }
.monitor .bug:not(:has(img)) { display: none; }
.monitor .overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px; display: flex; align-items: center; gap: 16px; background: linear-gradient(transparent, rgba(5,6,7,.88)); pointer-events: none; transition: opacity .35s; }
.overlay-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.monitor.playing:not(.awake) .hud { opacity: 0; }
.monitor.playing:not(.awake) .hud * { pointer-events: none !important; }
.monitor.playing:not(.awake) { cursor: none; }
.monitor .msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.monitor .msg strong { font-family: var(--sans); font-size: 20px; color: var(--text); }

.fav-big { pointer-events: auto; width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--line-strong); background: rgba(26,30,35,.8); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fav-big svg, .fav svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.fav-big.on, .fav.on { color: var(--star); }
.fav-big.on svg, .fav.on svg { fill: var(--star); }

.logo-box { width: 56px; height: 56px; border-radius: 8px; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-weight: 600; font-size: 14px; flex-shrink: 0; overflow: hidden; }
.logo-box.has-img { background: #2a2f36; }
.logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.pgm-name { font-weight: 800; font-size: 34px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgm-meta { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.controls { display: flex; gap: 8px; align-items: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.vol { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--btn); }
.vol input { -webkit-appearance: none; appearance: none; width: 140px; height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--fill, 50%), var(--line-strong) var(--fill, 50%)); cursor: pointer; }
.vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 2px solid var(--btn); }
.vol input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 2px solid var(--btn); }
.vol-label { width: 42px; text-align: right; font-size: 12px; color: var(--soft); }
.vol-label.boost { color: var(--star); }
.cc-wrap { position: relative; }
.cc { font-weight: 600; letter-spacing: 1px; }
.cc.on { border-color: var(--text); background: var(--text); color: var(--bg); }
.menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; min-width: 240px; max-width: 320px; padding: 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--panel); box-shadow: 0 12px 32px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 2px; }
.menu-item { height: 40px; padding: 0 12px 0 32px; border: none; border-radius: 4px; background: none; text-align: left; font-family: var(--mono); font-size: 12px; position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item:hover { background: var(--btn); }
.menu-item[aria-checked="true"]::before { content: ''; position: absolute; left: 12px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--accent); }
.mobile-fs { display: none; }

/* ---------- Mur de vignettes ---------- */
.wall-head { display: flex; align-items: center; gap: 10px; }
.search, .select { height: 36px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--well); font-family: var(--mono); font-size: 12px; min-width: 0; }
.search { flex: 1; }
.search::placeholder { color: var(--muted); }
.select { max-width: 170px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 34px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--btn); font-family: var(--mono); font-size: 12px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; text-transform: uppercase; }
.chip span { opacity: .7; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-fav:not([aria-pressed="true"]) { color: var(--star); }
.filters:not(.open) .chip.extra { display: none; }
.chip.more { border-style: dashed; color: var(--muted); }

.tiles { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 104px; gap: 10px; align-content: start; }
.tile { position: relative; min-width: 0; }
.tile-main { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; border-radius: 4px; background: var(--well); border: 1px solid var(--line); text-align: left; }
.tile-main:hover { border-color: var(--line-strong); }
.tile.pgm .tile-main { border-color: var(--accent); }
.tile-top { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tile-cat { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.st { flex-shrink: 0; }
.st.ok { color: var(--ok); }
.st.pgm { color: var(--accent); }
.st.err { color: var(--err); }
.tile-bottom { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 36px; }
.tile .logo-box { width: 36px; height: 36px; border-radius: 6px; font-size: 11px; }
.tile-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav { position: absolute; right: 8px; bottom: 10px; width: 36px; height: 36px; border-radius: 6px; border: none; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.fav:hover { color: var(--text); background: var(--btn); }
.fav.static { position: static; flex-shrink: 0; width: 44px; height: 44px; }
.empty { grid-column: 1 / -1; padding: 24px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---------- Panneau des réglages ---------- */
.panel { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: 560px; max-width: 100%; padding: 0; border: none; border-left: 1px solid var(--line); background: var(--panel); color: var(--text); display: none; flex-direction: column; }
.panel[open] { display: flex; }
.panel::backdrop { background: rgba(5,6,7,.6); }
.panel-head { height: 64px; padding: 0 20px 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-head h2 { margin: 0; font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: 1px; }
.tabs { display: flex; gap: 4px; padding: 12px 24px 0; border-bottom: 1px solid var(--line); flex-shrink: 0; overflow-x: auto; }
.tab { height: 40px; padding: 0 14px; border: none; border-bottom: 2px solid transparent; background: none; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.chlist { display: flex; flex-direction: column; gap: 6px; }
.chrow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 4px; background: var(--well); border: 1px solid var(--line); }
.chrow.is-hidden { opacity: .5; }
.chrow .logo-box { width: 36px; height: 36px; border-radius: 6px; font-size: 11px; }
.chrow-text, .listrow-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.chrow-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow-meta.bad { color: var(--err); white-space: normal; }
.chrow-meta.url { font-size: 10px; }

.switch { position: relative; display: inline-flex; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-ui { width: 100%; height: 100%; border-radius: 13px; background: var(--line-strong); transition: background .15s; position: relative; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--text); outline-offset: 2px; }

.list-rows, #presetRows { display: flex; flex-direction: column; gap: 6px; }
.listrow, .preset { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 4px; background: var(--well); border: 1px solid var(--line); }
.listrow.off .listrow-text { opacity: .55; }
.listrow-name { height: 30px; padding: 0 6px; margin-left: -6px; border: 1px solid transparent; border-radius: 4px; background: transparent; font-weight: 700; font-size: 15px; }
.listrow-name:hover, .listrow-name:focus { border-color: var(--line-strong); background: var(--bg); }
.add-list, .presets { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.add-list .search { flex: none; height: 44px; }

.radios { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.radios legend { margin-bottom: 6px; }
.progress { height: 6px; border-radius: 3px; background: var(--btn); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#testSummary { font-size: 12px; color: var(--soft); }

.pref { align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 0; }
.pref input { margin-top: 2px; }
.pref span { display: flex; flex-direction: column; gap: 4px; }
.pref strong { font-weight: 700; color: var(--text); font-size: 15px; }
.pref small { font-size: 13px; color: var(--muted); line-height: 1.4; }
.pref-select { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.pref-select .select { max-width: 120px; height: 40px; }
.pref-select .select.wide, .row .select.wide { max-width: none; flex: 1; height: 40px; }
.pref-first { padding: 0 0 14px; border-bottom: 1px solid var(--line); }
.hint.small { font-size: 13px; }
.cat-toggle { margin-top: 4px; align-self: flex-start; }
.catbox { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.catbox .chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.catbox .chip[aria-pressed="true"] { background: var(--btn); color: var(--text); border-color: var(--line-strong); }
.listrow { flex-wrap: wrap; }

/* ---------- Écran du mot de passe ---------- */
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 440px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 36px; display: flex; flex-direction: column; gap: 22px; }
.login-card h1 { margin: 0; font-weight: 800; font-size: 30px; line-height: 1.1; }
.login-card p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-family: var(--mono); font-size: 12px; color: var(--soft); }
.field input { height: 48px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--well); font-family: var(--mono); font-size: 16px; letter-spacing: 3px; }
.error { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--err); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--soft); min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.primary { height: 50px; border-radius: 4px; border: none; background: var(--accent); color: #fff; font-family: var(--mono); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-shrink: 0; }
.primary .dot { background: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .topbar { height: 56px; padding: 0 16px; gap: 12px; }
  .topbar .icon-btn + .icon-btn, .topbar .cast-slot + .icon-btn { margin-left: -4px; }
  .brand { font-size: 18px; }
  .crumb.hide-m, .topbar .crumb, .clock { display: none; }
  .main { flex-direction: column; padding: 28px 16px 0; gap: 16px; overflow: hidden; }
  .program { flex: 0 0 auto; gap: 10px; }
  .statusbar { font-size: 11px; gap: 8px; }
  .statusbar .tech { display: none; }
  #pgmLabel { flex: 1; min-width: 0; }
  .monitor { flex: none; aspect-ratio: 16 / 9; }
  .monitor .bug { width: 40px; height: 40px; top: 12px; right: 12px; }
  .monitor .overlay { padding: 12px; }
  .pgm-name { font-size: 22px; }
  .pgm-meta { display: none; }
  .monitor .overlay .logo-box { display: none; }
  .controls .text-btn:not(.cc) { display: none; }
  .controls .cc { padding: 0 10px; }
  .controls .mobile-fs { display: inline-flex; }
  .controls .spacer { display: none; }
  .vol { flex: 1; min-width: 0; padding: 0 10px; }
  .vol input { width: auto; flex: 1; min-width: 0; }
  .menu { left: auto; right: 0; }
  .wall { width: auto; flex: 1; }
  .wall-head .crumb { display: none; }
  .select { max-width: 130px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
  .chip { height: 40px; flex: 0 0 auto; }
  .filters .chip.extra { display: inline-flex; }
  .chip.more { display: none; }
  .tiles { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: 8px; padding-bottom: 24px; }
  .tile-main { flex-direction: row-reverse; align-items: center; min-height: 60px; padding: 10px 56px 10px 12px; gap: 12px; }
  .tile-top { flex-direction: column; align-items: flex-end; gap: 2px; }
  .tile-cat { display: none; }
  .tile-bottom { flex: 1; padding-right: 0; }
  .fav { right: 8px; top: 50%; bottom: auto; transform: translateY(-50%); width: 44px; height: 44px; }
  .panel { width: 100%; border-left: none; }
  .panel-head { padding: 0 16px; }
  .tabs { padding: 8px 16px 0; }
  .tabpane { padding: 16px 16px 32px; }
  .listrow { flex-wrap: wrap; }
  .login-main { padding: 24px; align-items: stretch; }
  .login-card { background: transparent; border: none; padding: 0; justify-content: center; }
}
