:root {
  --bg: #1b1f24; --panel: #22272e; --row: #263028; --row-up: #322d25; --line: #39404a;
  --text: #e6e6e6; --muted: #9aa4ae; --blue: #1e88e5; --red: #e53935; --green: #43a047; --amber: #fb8c00;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-top: 44px; }
/* player shown: the list behind must not scroll (wheel/touch over slots included) */
html.player-open { overflow: hidden; overscroll-behavior: none; }
html.player-open body { position: fixed; left: 0; right: 0; overflow: hidden; } /* top set inline to keep the list position */
.muted { color: var(--muted); }

#bar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; height: 44px; }
#toggle { flex: 1; border: 0; color: #fff; font-size: 20px; cursor: pointer; background: var(--blue); }
#toggle.hide { background: var(--red); }

/* player overlay: covers everything under the bar; only playing slots take space */
#player { position: fixed; inset: 44px 0 0 0; z-index: 20; background: rgba(20,22,26,.96); overscroll-behavior: contain; touch-action: none; }
#player[hidden] { display: none; }
#slots { display: grid; width: 100%; height: 100%; gap: 4px; padding: 4px; }
#slots.n1 { grid-template: 1fr / 1fr; }
#slots.n2 { grid-template: 1fr / 1fr 1fr; }
#slots.n3 { grid-template: 1fr 1fr / 1fr 1fr; }
#slots.n3 > .slot.span2 { grid-column: 1 / span 2; }
#slots.n4 { grid-template: 1fr 1fr / 1fr 1fr; }
.slot { position: relative; background: #000; min-height: 0; min-width: 0; border: 1px solid #333; }
.slot[hidden] { display: none; }
.slot iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* slot chrome is shown only while the pointer is over the slot (class set by JS; :hover is unreliable over iframes);
   the latency badge (.lat) is always visible */
.slot .hud { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; gap: 6px; align-items: center; z-index: 2; opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s; pointer-events: none; }
.slot.active .hud { opacity: 1; visibility: visible; }
.slot .hud * { pointer-events: auto; }
.slot .label { flex: 1; font-size: 12px; background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .hud button { border: 0; border-radius: 3px; width: 28px; height: 26px; color: #fff; cursor: pointer; font-size: 14px; }
.slot .dup { background: #6d4c9f; } .slot .fs { background: var(--blue); } .slot .reload { background: var(--amber); } .slot .close { background: var(--red); }
.slot .lat { position: absolute; bottom: 6px; right: 6px; z-index: 2; font: 12px ui-monospace, monospace; background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 3px; }
.slot .num { position: absolute; bottom: 6px; left: 6px; z-index: 2; font-size: 12px; background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 3px; opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s; }
.slot.active .num { opacity: 1; visibility: visible; }

#list { padding: 8px 12px 40px; }
#tools { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; color: var(--muted); }
#search { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 5px 8px; width: 240px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 700; text-transform: uppercase; font-size: 13px; padding: 8px; border-bottom: 1px solid var(--line); }
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]::after { content: ' \2195'; color: var(--muted); font-size: 11px; }
th[data-sort][data-dir="asc"]::after { content: ' \25B2'; color: var(--text); }
th[data-sort][data-dir="desc"]::after { content: ' \25BC'; color: var(--text); }
tr.filters th { padding: 4px 8px 10px; }
tr.filters select { width: 100%; max-width: 220px; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 3px; }
td { padding: 10px 8px; border-bottom: 1px solid #2c333b; vertical-align: middle; }
tbody tr { background: var(--row); cursor: pointer; }
tbody tr.up { background: var(--row-up); cursor: default; }
tbody tr:hover { filter: brightness(1.15); }
tbody tr.playing { outline: 2px solid var(--green); outline-offset: -2px; }
.live { color: #fff; background: var(--red); padding: 2px 6px; border-radius: 3px; font-size: 12px; font-weight: 700; }
.src small { display: block; color: var(--muted); font-size: 11px; }
.slotbtns { display: flex; gap: 4px; }
.slotbtns button { width: 30px; height: 26px; border: 0; border-radius: 3px; background: var(--green); color: #fff; font-weight: 700; cursor: pointer; }
.slotbtns button.on { background: var(--amber); }
tr.up .slotbtns button { background: #555; cursor: not-allowed; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* options panel open in the slot's iframe: clip this page's overlays to the area left of it (see setPanelCover) */
.slot.panel-open .hud, .slot.panel-open .lat { clip-path: inset(0 var(--panel-w, 0) 0 0); }
.slot.panel-full .hud, .slot.panel-full .lat, .slot.panel-full .num { visibility: hidden; }
