/* STREAMARR — broadcast rack.
   The room this borrows from: a video engineer's equipment rack. Graphite
   chassis, silkscreened condensed labels, monospace signal readouts, and one
   amber tally lamp that means exactly one thing — this channel is live. */

:root {
  --chassis: #16181c;
  --panel: #1e2126;
  --panel-hi: #24282f;
  --rail: #2f343c;
  --paper: #e6e8ea;
  --muted: #888f99;
  --phosphor: #ffb627;   /* tally — spend it only on "live" */
  --patch: #6fd3c7;      /* interaction */
  --fault: #e8543f;

  --display: "Barlow Condensed", "Oswald", "Roboto Condensed", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --data: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r: 3px; /* rack hardware isn't rounded */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--chassis);
  color: var(--paper);
  font-family: var(--body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* Brushed-metal grain, very faint. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    90deg, rgba(255, 255, 255, .014) 0 1px, transparent 1px 3px
  );
}

button, input, select, textarea { font: inherit; color: inherit; }

.label {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

.mono { font-family: var(--data); font-variant-numeric: tabular-nums; }

/* ---------- tally lamp: the signature ---------- */
.tally {
  --lamp: #4a4034;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--lamp);
  border: 1px solid rgba(0, 0, 0, .6);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .12);
  flex: none;
  transition: background .18s, box-shadow .18s;
}
.tally.live {
  --lamp: var(--phosphor);
  box-shadow: 0 0 6px rgba(255, 182, 39, .85), 0 0 16px rgba(255, 182, 39, .35),
    inset 0 1px 1px rgba(255, 255, 255, .5);
}
.tally.standby { --lamp: #5b5240; animation: breathe 3.2s ease-in-out infinite; }
.tally.fault { --lamp: var(--fault); box-shadow: 0 0 6px rgba(232, 84, 63, .7); }

@keyframes breathe {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; box-shadow: 0 0 8px rgba(255, 182, 39, .5); }
}

/* ---------- buttons ---------- */
.btn {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--rail);
  border-radius: var(--r);
  padding: 7px 13px;
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: border-color .15s, color .15s, transform .06s;
}
.btn:hover { border-color: var(--patch); color: var(--patch); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--patch); color: var(--patch); }
.btn.primary:hover { background: rgba(111, 211, 199, .12); }
.btn.danger:hover { border-color: var(--fault); color: var(--fault); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.input {
  background: #101215;
  border: 1px solid var(--rail);
  border-radius: var(--r);
  padding: 8px 11px;
  width: 100%;
  color: var(--paper);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
}
.input:focus { outline: none; border-color: var(--patch); box-shadow: inset 0 1px 3px rgba(0,0,0,.5), 0 0 0 2px rgba(111, 211, 199, .18); }
.input::placeholder { color: #5a616b; }

:focus-visible { outline: 2px solid var(--patch); outline-offset: 2px; }

/* ---------- login ---------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 182, 39, .07), transparent 60%),
    radial-gradient(circle at 50% 120%, rgba(111, 211, 199, .06), transparent 55%);
}

.console {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel), #191c21);
  border: 1px solid var(--rail);
  border-radius: 5px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
}

/* Rack ears — the two screw holes on either side of the faceplate. */
.console-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--rail);
  background: linear-gradient(180deg, #22262c, #1b1e23);
}
.screw {
  width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4b525c, #23272d);
  box-shadow: inset 0 0 2px rgba(0, 0, 0, .9);
  flex: none;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin: 0;
  flex: 1;
  text-align: center;
  color: var(--paper);
}
.wordmark em { font-style: normal; color: var(--phosphor); }

.console-body { padding: 22px 20px 24px; }
.console-body h2 {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: 600;
}
.console-body p.hint { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.5; }

.field { margin-bottom: 13px; }
.field label { display: block; margin-bottom: 5px; }

.msg {
  font-size: 13px;
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: var(--r);
  border: 1px solid transparent;
  display: none;
}
.msg.err { display: block; border-color: rgba(232, 84, 63, .4); background: rgba(232, 84, 63, .1); color: #ff9484; }
.msg.ok { display: block; border-color: rgba(111, 211, 199, .4); background: rgba(111, 211, 199, .1); color: var(--patch); }

/* ---------- app shell ---------- */
.shell { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }

header.rail {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 52px;
  background: linear-gradient(180deg, #22262c, #1a1d22);
  border-bottom: 1px solid var(--rail);
  flex: none;
}
header.rail .wordmark { font-size: 20px; flex: none; text-align: left; }

.onair {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--rail);
  border-radius: var(--r);
  background: #14161a;
  max-width: 46vw;
}
.onair .now {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.onair.live .now { color: var(--phosphor); }

.spacer { flex: 1; }

.whoami { font-family: var(--data); font-size: 12px; color: var(--muted); }
.whoami b { color: var(--paper); font-weight: 500; }
.role-chip {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  border: 1px solid var(--rail);
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--patch);
}

main { flex: 1; display: flex; min-height: 0; }

/* ---------- groups sidebar ---------- */
aside {
  width: 218px;
  flex: none;
  border-right: 1px solid var(--rail);
  background: #191c21;
  overflow-y: auto;
  padding: 12px 0;
}
aside .label { padding: 0 14px 8px; display: block; }

.group {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.group:hover { background: #1f232a; color: var(--paper); }
.group.on { border-left-color: var(--phosphor); color: var(--paper); background: #1f232a; }
.group .n { margin-left: auto; font-family: var(--data); font-size: 11px; color: #5f6670; }
.group .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- viewer ---------- */
.viewer { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.stage {
  position: relative;
  background: #000;
  border-bottom: 1px solid var(--rail);
  aspect-ratio: 16 / 9;
  max-height: 52vh;
  flex: none;
}
.stage video { width: 100%; height: 100%; display: block; background: #000; }

.stage .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: #4d545e;
  text-align: center;
  padding: 20px;
}
.stage .placeholder .label { color: #4d545e; }

/* Lower third — the broadcast convention, used for what it's actually for. */
.lower-third {
  position: absolute;
  left: 0;
  bottom: 0;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  background: linear-gradient(90deg, rgba(10, 11, 13, .92), rgba(10, 11, 13, 0));
  border-left: 3px solid var(--phosphor);
  max-width: 80%;
  pointer-events: none;
}
.lower-third.show { display: flex; }
.lower-third .lt-name {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lower-third .lt-grp { font-family: var(--data); font-size: 11px; color: var(--muted); }

.stage-status {
  position: absolute;
  top: 10px; right: 12px;
  font-family: var(--data);
  font-size: 11px;
  color: var(--muted);
  background: rgba(10, 11, 13, .75);
  padding: 3px 8px;
  border-radius: 2px;
  pointer-events: none;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rail);
  background: #1b1e23;
  flex: none;
}
.toolbar .input { max-width: 320px; }
.count { font-family: var(--data); font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- patch bay ---------- */
.bay { flex: 1; overflow-y: auto; padding: 8px 0 20px; }

.strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid #202429;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.strip:hover { background: #1f232a; }
.strip.on { background: #22262d; border-left-color: var(--phosphor); }

.strip .num { font-family: var(--data); font-size: 11px; color: #5a616b; width: 34px; flex: none; }
.strip .logo {
  width: 40px; height: 26px; flex: none;
  object-fit: contain;
  background: #0e1013;
  border: 1px solid #262a31;
  border-radius: 2px;
}
.strip .meta { min-width: 0; flex: 1; }
.strip .cname {
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.strip .cgrp { font-family: var(--data); font-size: 11px; color: #5f6670; }

.star {
  background: none; border: 0; cursor: pointer;
  color: #4d545e; font-size: 15px; padding: 4px 6px; flex: none;
  line-height: 1;
}
.star:hover { color: var(--phosphor); }
.star.on { color: var(--phosphor); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .label { display: block; margin-bottom: 6px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; }
.pager .mono { font-size: 12px; color: var(--muted); }

/* ---------- modals ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8, 9, 11, .72);
  display: none; place-items: center;
  padding: 20px;
}
.scrim.show { display: grid; }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--rail);
  border-radius: 5px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .7);
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--rail);
  background: linear-gradient(180deg, #22262c, #1b1e23);
  position: sticky; top: 0;
}
.modal-head h3 {
  margin: 0; flex: 1;
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 15px;
  font-weight: 600;
}
.modal-body { padding: 16px; }
.modal-body h4 {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .14em;
  font-size: 12px; color: var(--muted); margin: 22px 0 10px; font-weight: 600;
  border-top: 1px solid var(--rail); padding-top: 16px;
}
.modal-body h4:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 13px 16px; border-top: 1px solid var(--rail); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.help { font-size: 12px; color: var(--muted); margin: 5px 0 0; line-height: 1.5; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--patch); width: 15px; height: 15px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .12em;
  font-size: 11px; color: var(--muted); text-align: left; font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--rail);
}
td { padding: 7px 8px; border-bottom: 1px solid #23272e; }
td .mono { font-size: 13px; }

select.input { appearance: none; background-image: none; }

@media (max-width: 820px) {
  aside { display: none; }
  aside.open {
    display: block; position: absolute; z-index: 10; top: 52px; bottom: 0; left: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  }
  .stage { max-height: 40vh; }
  .onair { max-width: 34vw; }
  .toolbar .input { max-width: none; }
}
@media (min-width: 821px) { .burger { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Slot counter: providers sell a fixed number of concurrent connections, so
   the count of open upstream pipes is worth showing on the faceplate. */
.tuners {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--rail);
  border-radius: var(--r);
  padding: 4px 8px;
  background: #14161a;
  white-space: nowrap;
}
@media (max-width: 820px) { .tuners { display: none; } }
