:root {
  --bg: #0e1116; --panel: #161b22; --line: #2d333b; --text: #e6edf3; --muted: #8b949e;
  /* color option A (user, 2026-10-18): classic hardware panel – blue destinations, light-blue levels, amber group
     tabs, gray sources with the one on the selected destination in solid white */
  --d-bg: #0c1f3a; --d-line: #378add; --d-btn: #13325c; --d-text: #b5d4f4; --d-sel: #185fa5; --d-selline: #b5d4f4; --d-seltext: #ffffff;
  --d-now: #f5c46b; --d-selnow: #fbd98a;
  --g-line: #ba7517; --g-btn: #3d2c08; --g-text: #fac775; --g-sel: #ef9f27;
  --s-btn: #2a3039; --s-line: #3a424c; --s-text: #e6edf3; --s-cur: #e6edf3; --s-curtext: #0e1116;
  --l-on: #85b7eb; --l-online: #b5d4f4; --l-ontext: #042c53; --l-off: #1a2433; --l-offline: #2c3a4d; --l-offtext: #6b7a8f;
  --red: #e5484d; --green: #2fbf71; --yellow: #f5c518;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.25 -apple-system, "Segoe UI", system-ui, sans-serif; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
header b { font-size: 18px; font-weight: 600; }
.conn { font-size: 13px; color: var(--muted); }
.conn.bad { color: var(--red); }
.undo { margin-left: auto; min-height: 44px; padding: 0 22px; font-size: 16px; border-radius: 10px; border: 1px solid var(--s-line);
  background: var(--s-btn); color: var(--text); }
.undo:active { filter: brightness(1.4); }
main { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.zone { border-radius: 14px; padding: 10px; }
/* fixed-width buttons (user, 2026-10-18: less wide), as many to a row as fit, left-aligned */
.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, var(--bw, 120px)); justify-content: start; }
/* destinations: always ONE row (up to 10) – 118 px each when there is room, shrinking together when there isn't */
.dzone .grid { display: flex; flex-wrap: nowrap; }
.dzone .grid .k { flex: 0 1 118px; min-width: 0; }
.gzone .grid { --bw: 104px; }
.szone .grid { --bw: 96px; }
button.k { min-height: 64px; border-radius: 10px; border: 1px solid; padding: 6px 4px; font-size: 15px; font-weight: 600; color: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; overflow: hidden; text-align: center;
  word-break: break-word; position: relative; }
button.k small { font-size: 13px; font-weight: 400; opacity: .85; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.k:active { filter: brightness(1.3); }

.dzone { background: var(--d-bg); border: 1px solid var(--d-line); }
.d { background: var(--d-btn); border-color: var(--d-line) !important; color: var(--d-text); }
.d.sel { background: var(--d-sel); color: var(--d-seltext); border-color: var(--d-selline) !important; box-shadow: 0 0 0 2px var(--d-selline); }
/* a split destination (its levels carry different sources): a cross-hatch over its normal color */
.d.split { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.13) 0 3px, transparent 3px 11px),
  repeating-linear-gradient(-45deg, rgba(255,255,255,.13) 0 3px, transparent 3px 11px); }
/* what a destination has now: its own color – warm, so it never reads as the destination's name */
.d small { color: var(--d-now); opacity: 1; font-weight: 500; }
.d.sel small { color: var(--d-selnow); }
.d.prot::after { content: "HOLD"; position: absolute; top: 4px; right: 6px; font-size: 10px; font-weight: 700; opacity: .7; }
.d.holding { animation: hold .5s linear forwards; }
@keyframes hold { from { box-shadow: inset 0 -4px 0 0 var(--yellow); } to { box-shadow: inset 0 -64px 0 0 rgba(245,197,24,.35); } }
/* the levels: every box the same small size, all on one line (they shrink together on a narrow screen) */
.levels { display: flex; flex-wrap: nowrap; gap: 5px; margin-top: 10px; }
.lv { flex: 0 1 42px; width: 42px; min-width: 0; height: 40px; padding: 0; border-radius: 7px; border: 1px solid var(--l-online);
  font-size: 13px; font-weight: 600; background: var(--l-on); color: var(--l-ontext); }
.lv.off { background: var(--l-off); color: var(--l-offtext); border-color: var(--l-offline); }

/* groups as tabs joined to the top of the sources box: the selected tab takes the box's color and opens into it */
.srcbox { display: flex; flex-direction: column; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px; margin-bottom: -1px; position: relative; z-index: 1; }
.tab { min-width: 96px; height: 40px; padding: 0 16px; border: 1px solid var(--g-line); border-bottom: none; border-radius: 10px 10px 0 0;
  background: var(--g-btn); color: var(--g-text); font-size: 14px; font-weight: 600; }
.tab.sel { background: var(--panel); color: var(--text); border-color: var(--line); box-shadow: inset 0 3px 0 var(--g-sel); }
.tab:active { filter: brightness(1.3); }
.srcbox.tabbed .szone { border-top-left-radius: 0; }
.destbox { display: flex; flex-direction: column; }
.destbox .tab.sel { background: var(--d-bg); border-color: var(--d-line); }
.destbox.tabbed .dzone { border-top-left-radius: 0; }
/* a destination group with more than 10 (up to 32): rows of buttons instead of one squeezed row */
.dzone .grid.many { flex-wrap: wrap; }
.dzone .grid.many .k { flex: 0 0 118px; }

.szone { background: var(--panel); border: 1px solid var(--line); }
.s { background: var(--s-btn); border-color: var(--s-line) !important; color: var(--s-text); }
.s.cur { background: var(--s-cur); color: var(--s-curtext); border-color: #ffffff !important; }   /* on the selected destination */
.s small.desc { font-style: italic; color: var(--muted); opacity: 1; font-size: 12px; line-height: 1.15;  /* its description: */
  white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }    /* up to two lines */
.s.cur small.desc { color: #4a5360; }
.s.part { outline: 3px dashed var(--s-cur); outline-offset: -3px; }                                /* on some of its levels */
/* the live video window: beside the sources (a third of the width) – above them on a portrait screen */
.lower { display: flex; gap: 12px; align-items: flex-start; }
.lower .srcbox { flex: 1 1 auto; min-width: 0; }
.vzone { flex: 0 0 34%; background: var(--panel); border: 1px solid var(--line); padding: 8px; }
.vhead { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 6px; min-width: 0; }
.vhead b { font-size: 14px; white-space: nowrap; }
.vhead small { color: var(--d-now); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vframe { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; }
.vframe video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vstat { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; text-align: center; padding: 8px; }
.vsound { position: absolute; right: 6px; bottom: 6px; border: 0; border-radius: 6px; padding: 6px 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; }
@media (orientation: portrait) {
  .lower { flex-direction: column-reverse; align-items: stretch; }
  .vzone { flex: none; }
  .vframe { max-height: 36vh; margin: 0 auto; }
}
.empty { color: var(--muted); padding: 12px; font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #3d1d1f; color: #ffd7d9; border: 1px solid var(--red);
  padding: 12px 18px; border-radius: 10px; font-size: 15px; max-width: 90vw; }
.toast.ok { background: #12301f; color: #c8f3d9; border-color: var(--green); }

/* sign-in (a panel with a password): nothing else shows until it's done */
body.locked header, body.locked main { display: none; }
.signin { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; background: var(--bg); }
.signin[hidden] { display: none; }
.signin b { font-size: 22px; font-weight: 600; }
.signin input { width: min(320px, 100%); font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--d-line); background: var(--panel); color: var(--text); -webkit-user-select: text; user-select: text; }
.signin button { width: min(320px, 100%); font: inherit; font-size: 18px; font-weight: 600; padding: 12px; border-radius: 10px;
  border: 1px solid var(--d-line); background: var(--d-sel); color: #fff; cursor: pointer; }
.si-msg { min-height: 1.2em; color: var(--muted); }
