:root {
  --bg: #08080a;
  --panel: #131316;
  --line: #26262b;
  --ink: #f2efe8;
  --mute: #8f8c85;
  --red: #e0202c;    /* program tally, and half of the flag */
  --green: #12b35b;  /* preview tally, and the other half */
  --gap: 3px;
  --umd: 30px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  /* Four 16:9 tiles across, four rows down, each row carrying its label strip. */
  --tile: min(calc((100vw - 5 * var(--gap)) / 4), calc((100vh - 5 * var(--gap) - 4 * var(--umd)) / 4 * 16 / 9));
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font: 600 15px/1 "Barlow Condensed", "Arial Narrow", sans-serif; letter-spacing: 0.03em; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img, video, canvas { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* ---- The wall: a real multiviewer layout, 4x4 with the program feed taking 2x2 */
.wall {
  --h: calc(var(--tile) * 9 / 16 + var(--umd));
  display: grid;
  grid-template-columns: repeat(4, var(--tile));
  grid-template-rows: repeat(4, var(--h));
  grid-auto-rows: var(--h);
  gap: var(--gap);
  width: max-content;
  min-height: 100vh;
  align-content: center;
  margin: 0 auto;
  padding: var(--gap);
}
.pgm { grid-column: 2 / 4; grid-row: 1 / 3; display: flex; flex-direction: column; min-width: 0; outline: 3px solid var(--red); outline-offset: -3px; position: relative; z-index: 2; background: #000; }
.pgm__screen { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.pgm__still, .pgm__video, .pgm__noise { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pgm__video { opacity: 0; }
.pgm__video.is-on { opacity: 1; }
.pgm__noise { opacity: 0; image-rendering: pixelated; pointer-events: none; mix-blend-mode: normal; }
.pgm__noise.is-on { opacity: 1; }
.pgm__take { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px; height: 44px; padding: 0 14px 0 7px; background: var(--red); color: #fff; }
.pgm__name { font-size: 25px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
.pgm__brands { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.86; letter-spacing: 0.02em; }
.pgm__enter { font-size: 16px; white-space: nowrap; }
.pgm__enter span { display: inline-block; transition: transform 200ms var(--ease); }
.pgm__take:hover .pgm__enter span { transform: translateX(4px); }
.tally { display: inline-block; padding: 4px 6px 3px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; line-height: 1; }
.tally--pgm { background: #fff; color: var(--red); }

/* ---- Source monitors ---------------------------------------------------------- */
.src { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.src__screen { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.src__screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.src__screen img.is-on { opacity: 1; }
.src__umd { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--umd); padding: 0 8px; background: var(--panel); text-transform: uppercase; font-size: 17px; white-space: nowrap; }
.src__key { color: var(--mute); font-size: 14px; font-weight: 500; }
.src::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow 90ms linear; }
.src.is-pvw::after { box-shadow: inset 0 0 0 3px var(--green); }
.src.is-pvw .src__umd { background: var(--green); color: #fff; }
.src.is-pvw .src__key { color: #fff; }
.src.is-pgm::after { box-shadow: inset 0 0 0 3px var(--red); }
.src.is-pgm .src__umd { background: var(--red); color: #fff; }
.src.is-pgm .src__key { color: #fff; }

/* ---- Ident tile --------------------------------------------------------------- */
.ident { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: 0 clamp(14px, 1.7vw, 26px); background: #000; min-width: 0; }
.ident img { width: min(66%, 170px); height: auto; margin-bottom: 8px; }
.ident p { margin: 0; }
.ident p:not([class]) { font-size: clamp(22px, 2.3vw, 34px); font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em; line-height: 1; }
.ident__sub { color: var(--mute); font-size: 17px; font-weight: 500; }
.ident__tc { position: absolute; right: 8px; bottom: 8px; color: var(--mute); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ident__back { position: absolute; left: clamp(14px, 1.7vw, 26px); bottom: 8px; color: var(--mute); font-size: 15px; font-weight: 500; transition: color 150ms linear; }
.ident__back span { display: inline-block; transition: transform 200ms var(--ease); }
@media (hover: hover) {
  .ident__back:hover { color: var(--ink); }
  .ident__back:hover span { transform: translateX(-3px); }
}

@media (max-height: 700px) { .ident__sub { display: none; } }

/* ---- Small screens: the program feed pins to the top, monitors run two across --- */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  :root { --tile: calc((100vw - 3 * var(--gap)) / 2); }
  html, body { height: auto; }
  .wall { grid-template-columns: repeat(2, var(--tile)); grid-template-rows: none; grid-auto-rows: auto; align-content: start; }
  .pgm { grid-column: 1 / -1; grid-row: auto; position: sticky; top: 0; z-index: 5; }
  .pgm__screen { flex: none; aspect-ratio: 16 / 9; }
  .pgm__brands { display: none; }
  .pgm__take { grid-template-columns: auto 1fr auto; }
  .pgm__name { font-size: 21px; overflow: hidden; text-overflow: ellipsis; }
  .src__screen { flex: none; aspect-ratio: 16 / 9; }
  .ident { grid-column: 1 / -1; order: -1; flex-direction: row; align-items: center; gap: 12px; padding: 10px; }
  .ident img { width: 96px; margin: 0; }
  .ident p:not([class]) { font-size: 22px; }
  .ident__sub, .ident__tc, .ident__back { display: none; }
  .src__key { display: none; }
}
