/* livefromset — design tokens */
:root {
  --bg-0: #07080a;
  --bg-1: #0d0e11;
  --bg-2: #14161a;
  --bg-3: #1c1f24;
  --bg-4: #262a31;
  --bg-5: #343943;

  --line-1: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.10);
  --line-3: rgba(255,255,255,0.16);

  --t-1: #f5f6f7;
  --t-2: #c9ccd2;
  --t-3: #8b8f97;
  --t-4: #5a5e66;

  --live: oklch(0.62 0.22 25);
  --live-glow: oklch(0.62 0.22 25 / 0.35);
  --live-dim: oklch(0.42 0.18 25);

  --ok: oklch(0.74 0.15 155);
  --warn: oklch(0.78 0.15 75);
  --info: oklch(0.72 0.10 230);

  --f-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;
}

* { box-sizing: border-box; }
/* Dark native form controls (date pickers, selects) to match the theme. */
:root { color-scheme: dark; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-1);
  color: var(--t-2);
  font-family: var(--f-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; }

.mono { font-family: var(--f-mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.kbd { font-family: var(--f-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--bg-3); color: var(--t-3); }

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot.live { background: var(--live); box-shadow: 0 0 0 0 var(--live-glow); animation: pulse 1.6s ease-out infinite; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--t-4); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--live-glow); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes scan {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.video-feed {
  position: relative;
  background:
    repeating-linear-gradient(
      45deg,
      #1a1d22 0 14px,
      #161a1f 14px 28px
    );
  overflow: hidden;
}
.video-feed::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 35%, rgba(255,255,255,0.05), transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(0,80,120,0.10), transparent 55%);
  pointer-events: none;
}
.video-feed::after {
  content: "";
  position: absolute; left: 0; right: 0; height: 30%;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.025), transparent);
  animation: scan 4.5s linear infinite;
  pointer-events: none;
}

.input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--t-1);
  font-family: var(--f-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.input:focus { border-color: var(--line-3); background: var(--bg-4); }
.input.mono { font-family: var(--f-mono); }

.btn {
  white-space: nowrap;
  height: 32px;
  padding: 0 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--t-1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, border-color 0.12s;
  font-weight: 500;
  text-decoration: none;
}
.btn:hover { background: var(--bg-4); border-color: var(--line-3); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: var(--t-1);
  color: var(--bg-0);
  border-color: var(--t-1);
}
.btn.primary:hover { background: #fff; }
.btn.danger {
  background: var(--live);
  border-color: var(--live);
  color: #fff;
}
.btn.danger:hover { background: oklch(0.66 0.22 25); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--t-2);
  border: 1px solid var(--line-1);
}
.chip.live { background: var(--live); color: #fff; border-color: var(--live); }
.chip.live .dot { background: #fff; box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
.chip.rec { background: rgba(0,0,0,0.5); color: var(--live); border-color: var(--live-dim); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 5px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-5); }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-3);
  border-top-color: var(--t-1);
  animation: spin 0.8s linear infinite;
}

/* Wowza/Flowplayer container — let it fill its parent */
.wp-player-host {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.wp-player-host > div,
.wp-player-host .fp-player,
.wp-player-host video {
  width: 100% !important;
  height: 100% !important;
}

/* ─────────────────────────────────────────────────────────────
   Responsive / mobile (iPhone Safari)
   ───────────────────────────────────────────────────────────── */

/* Dynamic viewport height. On iOS Safari a 100vh element sits *behind*
   the browser's bottom toolbar, so anything anchored to the bottom
   (playback picker, fullscreen button) is hidden. 100dvh tracks the
   actually-visible area; the plain 100vh is a fallback for old engines. */
.app-viewport    { height: 100vh; height: 100dvh; }
.app-minviewport { min-height: 100vh; min-height: 100dvh; }

/* Hidden on desktop; revealed on narrow screens (drawer toggles, closers). */
.mobile-only { display: none !important; }
.rail-scrim  { display: none; }

@media (max-width: 720px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }

  /* VTR body grid collapses to one column; the watcher rail floats over it. */
  .vtr-body { grid-template-columns: 1fr !important; }

  /* Side rails (viewer chat/video + VTR watchers) stop eating layout width
     and become an off-canvas drawer that slides in from the right. */
  .side-rail {
    position: fixed !important;
    top: 0 !important; right: 0 !important; bottom: 0 !important;
    left: auto !important;
    width: min(86vw, 340px) !important;
    /* Above the z-90 floating witness monitor (VTR), below modals (100) + toasts (200). */
    z-index: 95;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    box-shadow: -14px 0 44px rgba(0,0,0,0.55);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .side-rail.open { transform: translateX(0); }

  .rail-scrim.show {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 94;
  }
}

/* ── Ask bubble (Ask.jsx): admins + VTRs, bottom-LEFT (the VTR witness monitor defaults bottom-right) ── */
.ask-root { position: fixed; left: 16px; bottom: 16px; z-index: 95; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; pointer-events: none; }
.ask-root > * { pointer-events: auto; }
.ask-fab { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-3); background: var(--bg-4); color: var(--t-1);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.5); transition: background 0.15s; }
.ask-fab:hover { background: var(--bg-5); }
.ask-panel { width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 96px)); display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: 0 18px 50px rgba(0,0,0,0.6); overflow: hidden; }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line-1); color: var(--t-1); }
.ask-tabs { display: flex; gap: 4px; }
.ask-tabs button { border: 1px solid var(--line-2); background: transparent; color: var(--t-3); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.ask-tabs button.on { background: var(--bg-5); color: var(--t-1); border-color: var(--line-3); }
.ask-x { border: 0; background: transparent; color: var(--t-3); cursor: pointer; padding: 4px; display: grid; place-items: center; border-radius: var(--r-md); }
.ask-x:hover { color: var(--t-1); background: var(--bg-4); }
.ask-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ask-note p { margin: 0 0 8px; color: var(--t-2); }
.ask-msg { max-width: 88%; padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.ask-msg.user { align-self: flex-end; background: var(--bg-5); color: var(--t-1); border-bottom-right-radius: 4px; }
.ask-msg.assistant { align-self: flex-start; background: var(--bg-3); color: var(--t-2); border-bottom-left-radius: 4px; }
.ask-msg.muted { color: var(--t-4); }
.ask-foot { border-top: 1px solid var(--line-1); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.ask-foot textarea, .ask-form input, .ask-form textarea { width: 100%; background: var(--bg-1); color: var(--t-1); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 7px 9px; font: inherit; resize: vertical; }
.ask-foot textarea { min-height: 44px; max-height: 140px; }
.ask-foot textarea:focus, .ask-form input:focus, .ask-form textarea:focus { outline: none; border-color: var(--line-3); }
.ask-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ask-row.end { justify-content: flex-end; }
.ask-btn { border: 1px solid var(--line-2); background: var(--bg-3); color: var(--t-1); border-radius: var(--r-md); padding: 6px 12px; cursor: pointer; font-size: 12.5px; }
.ask-btn:hover:not(:disabled) { background: var(--bg-4); }
.ask-btn.primary { background: var(--t-1); color: var(--bg-1); border-color: var(--t-1); font-weight: 600; }
.ask-btn.primary:hover:not(:disabled) { background: var(--t-2); }
.ask-btn.danger { color: var(--live); border-color: var(--live-dim); background: transparent; }
.ask-btn:disabled { opacity: 0.45; cursor: default; }
.ask-link { border: 0; background: none; color: var(--t-3); cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
.ask-card { background: var(--bg-3); border: 1px solid var(--line-1); border-radius: var(--r-lg); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.ask-card.draft { border-color: var(--line-3); }
.ask-card summary { cursor: pointer; color: var(--t-3); }
.ask-pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; }
.ask-muted { color: var(--t-3); }
.ask-root .small { font-size: 11.5px; }
.ask-note-box { background: var(--bg-2); border-radius: var(--r-md); padding: 6px 8px; }
.ask-badge { font-size: 10.5px; font-family: var(--f-mono); padding: 2px 7px; border-radius: 99px; background: var(--bg-4); color: var(--t-2); white-space: nowrap; }
.ask-badge.ok { color: var(--ok); }
.ask-badge.bad { color: var(--live); }
.ask-badge.off { color: var(--t-4); }
.ask-badge.open { color: var(--warn); }
.ask-form { display: flex; flex-direction: column; gap: 10px; color: var(--t-1); }
.ask-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--t-3); }
@media (max-width: 520px) {
  .ask-root { left: 12px; bottom: 12px; }
  .ask-panel { width: calc(100vw - 24px); height: calc(100dvh - 84px); }
}
