/* Get The Flock Out — core styles (theme-agnostic; colors come from vars) */
:root {
  --bg: #0b1016;
  --bg-2: #121a23;
  --panel: #141e29;
  --panel-2: #182430;
  --line: #24313f;
  --ink: #e7eef5;
  --ink-dim: #8ea1b4;
  --ink-faint: #5f7183;
  --accent: #7ce1ff;
  --accent-ink: #062230;
  --ok: #57e39a;
  --warn: #ffce6b;
  --bad: #ff6b6b;
  --radius: 12px;
  --shadow: 0 18px 40px rgba(0,0,0,.4);
  --video-filter: none;
  --grain-opacity: 0;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --display-font: var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
button, select, input { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* ---- masthead ---------------------------------------------------------- */
.masthead {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 800;
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(0,0,0,.35);
}
.brand h1 { font-size: 17px; letter-spacing: .06em; font-family: var(--display-font); }
.brand small { color: var(--ink-faint); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.status-strip { display: flex; gap: 8px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 11px; min-width: 74px;
}
.stat span { display: block; font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .1em; }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.health { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); }
.health::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.health.warn::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.health b { font-size: 12px; }
#clock { font-family: var(--mono); color: var(--ink-dim); font-size: 13px; }

/* ---- body layout ------------------------------------------------------- */
.body {
  display: grid;
  grid-template-columns: 268px 1fr 340px;
  gap: 14px; padding: 14px; align-items: start;
}
.sidebar, .rail { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel > h3, .panel > header h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
.panel-pad { padding: 14px; }
.panel h3 .hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-faint); }

/* demo notice */
.demo-notice { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.demo-notice .panel-pad { display: flex; gap: 10px; }
.demo-notice .mark { color: var(--warn); font-size: 20px; line-height: 1; }
.demo-notice p { margin: 0; font-size: 12.5px; color: var(--ink-dim); }
.demo-notice p.action { margin-top: 8px; }
.demo-notice p.action a { color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); font-weight: 600; }
.demo-notice p.action a:hover { border-bottom-color: var(--warn); }
.demo-notice b { color: var(--ink); }

/* control rows */
.ctl { padding: 12px 14px; border-top: 1px solid var(--line); }
.ctl:first-of-type { border-top: 0; }
.ctl label { display: block; font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.ctl .row { display: flex; align-items: center; gap: 10px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.sens-val { font-family: var(--mono); color: var(--accent); min-width: 18px; text-align: right; }

.btn {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.active { background: color-mix(in srgb, var(--warn) 22%, var(--panel-2)); border-color: var(--warn); color: var(--warn); }
.mini {
  padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink-dim); cursor: pointer; font-size: 12px; transition: .15s;
}
.mini:hover { border-color: var(--accent); color: var(--ink); }
.mini.active { color: var(--warn); border-color: var(--warn); }

/* pipeline explainer */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; }
.steps b { flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; color: var(--accent); font-family: var(--mono); }
.steps strong { display: block; font-size: 12.5px; }
.steps span { font-size: 11.5px; color: var(--ink-faint); }

/* ---- feed grid --------------------------------------------------------- */
.main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.theme-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.theme-bar .lead { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
.theme-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-chip {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer; transition: .15s; line-height: 1.25;
}
.theme-chip b { font-size: 13px; }
.theme-chip small { font-size: 10px; color: var(--ink-faint); }
.theme-chip:hover:not(:disabled) { border-color: var(--accent); }
.theme-chip.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme-chip:disabled { opacity: .45; cursor: not-allowed; }
.theme-meta { font-size: 12px; color: var(--ink-dim); flex: 1 1 220px; min-width: 200px; }
.theme-meta strong { color: var(--ink); }

.feed-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.feed-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.feed-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.feed-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.feed-id .slot { font-family: var(--mono); font-size: 10px; color: var(--accent-ink); background: var(--accent); padding: 3px 6px; border-radius: 5px; font-weight: 700; }
.feed-id h3 { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-id p { margin: 0; font-size: 11px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10.5px; padding: 4px 8px; border-radius: 20px; border: 1px solid var(--line); white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }
.badge::before { content: "●"; margin-right: 5px; }
.badge.live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.badge.paused { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.badge.configured { color: var(--accent); }
.badge.offline { color: var(--ink-faint); }

.feed-surface { position: relative; width: 100%; aspect-ratio: 16/10; background: #000; overflow: hidden; }
.feed-video, .feed-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.feed-video { filter: var(--video-filter); }
.feed-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: var(--grain-opacity);
  background-image: var(--grain-image, none);
  mix-blend-mode: overlay; background-size: 180px;
}
.feed-hud {
  position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10.5px; color: rgba(255,255,255,.85);
  text-shadow: 0 1px 3px rgba(0,0,0,.9); pointer-events: none;
}
.feed-controls { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.feed-controls select { flex: 1; padding: 7px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }

/* ---- right rail -------------------------------------------------------- */
.rail-tabs { display: flex; padding: 6px; gap: 4px; border-bottom: 1px solid var(--line); }
.rail-tabs button {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--ink-dim); cursor: pointer; font-size: 12.5px; transition: .15s;
}
.rail-tabs button.active { background: var(--panel-2); border-color: var(--line); color: var(--ink); }
.catalog-tools { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.catalog-tools input[type=search] { flex: 1; min-width: 120px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.chipset { display: flex; gap: 4px; flex-wrap: wrap; }
.chipset button { padding: 5px 9px; border-radius: 20px; font-size: 11px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-dim); cursor: pointer; }
.chipset button.active { color: var(--accent); border-color: var(--accent); }
.rail-body { max-height: calc(100vh - 250px); overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rail-body .empty { color: var(--ink-faint); font-size: 12.5px; text-align: center; padding: 30px 10px; }

.obs { display: flex; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.obs img, .obs .obs-noimg { width: 56px; height: 44px; object-fit: cover; border-radius: 6px; background: #000; flex: 0 0 auto; filter: var(--thumb-filter, none); }
.obs .obs-noimg { display: grid; place-items: center; color: var(--ink-faint); }
.obs-body { min-width: 0; flex: 1; }
.obs-line { display: flex; justify-content: space-between; align-items: baseline; }
.obs-line b { font-size: 13px; }
.obs-line span { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.obs-meta { font-size: 11px; color: var(--ink-dim); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.obs-meta .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,.3); }
.obs-time { font-size: 10.5px; color: var(--ink-faint); font-family: var(--mono); margin-top: 2px; }

/* analytics */
.an-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.an-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.an-card span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.an-card strong { display: block; font-size: 22px; font-family: var(--mono); margin-top: 3px; }
.an-card strong.sm { font-size: 14px; }
.an-block { margin-top: 12px; }
.an-block h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-dim); margin-bottom: 8px; }
.an-bar { display: grid; grid-template-columns: 62px 1fr 24px; align-items: center; gap: 8px; margin-bottom: 6px; }
.an-bar label { font-size: 11.5px; color: var(--ink-dim); }
.an-bar .track { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.an-bar .track i { display: block; height: 100%; border-radius: 5px; transition: width .4s; }
.an-bar b { font-family: var(--mono); font-size: 12px; text-align: right; }
#spark { width: 100%; height: 70px; }
.export { width: 100%; margin-top: 12px; }

/* ---- footer ------------------------------------------------------------ */
.footer { border-top: 1px solid var(--line); padding: 16px 20px; background: var(--bg-2); }
.footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1100px; margin: 0 auto; }
.footer h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-dim); margin-bottom: 8px; }
.footer p, .footer li { font-size: 12.5px; color: var(--ink-faint); }
.footer ul { margin: 0; padding-left: 16px; }
.footer .tag { color: var(--ink-dim); }

/* toast */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px);
  background: var(--panel); border: 1px solid var(--warn); color: var(--ink);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: .3s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 1180px) {
  .body { grid-template-columns: 1fr 320px; }
  .sidebar { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; position: static; }
  .sidebar > * { flex: 1 1 240px; }
}
@media (max-width: 820px) {
  .body { grid-template-columns: 1fr; }
  .rail { position: static; }
  .feed-grid { grid-template-columns: 1fr; }
  .status-strip .stat { min-width: 60px; }
}
