:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2330;
  --muted: #667085;
  --border: #dfe3e8;
  --accent: #1f5fd6;
  --accent-text: #ffffff;
  --ok: #17803d;
  --ok-bg: #e3f5ea;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e28;
    --surface-2: #1f2834;
    --text: #e6eaf0;
    --muted: #97a3b6;
    --border: #2b3645;
    --accent: #5b9bff;
    --accent-text: #08111f;
    --ok: #4cc47a;
    --ok-bg: #12301f;
    --bad: #ff8a80;
    --bad-bg: #3a1a17;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); font-weight: 400; }
.grow { flex: 1; }

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-in { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.topbar h1 { font-size: 1.15rem; margin: 0; }

.btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 700; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 6px; margin: 20px 0 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  font: inherit; cursor: pointer; border: 0; background: none; color: var(--muted);
  padding: 10px 4px; margin-right: 18px; border-bottom: 2px solid transparent; font-weight: 600;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.tile-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  font-size: .85rem; font-weight: 700;
}
.tile-body {
  position: relative; aspect-ratio: 16/9; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.tile-placeholder {
  color: #8d98a8; display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; width: 100%; height: 100%; background: none; border: 0; font: inherit;
}
.tile-placeholder svg { width: 36px; height: 36px; opacity: .6; }
.tile video-stream, .tile video-rtc { width: 100%; height: 100%; display: block; background: #000; }
.tile-foot { display: flex; justify-content: flex-end; padding: 6px 8px; gap: 6px; }
.tile-foot .btn { padding: 4px 10px; font-size: .8rem; }

.rec-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.rec-form label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.rec-form select, .rec-form input {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}

.rec-list { display: grid; gap: 8px; margin-bottom: 20px; }
.rec-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.rec-row .meta { font-size: .85rem; }

.player { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.player video { width: 100%; max-height: 70vh; background: #000; border-radius: 8px; }

.notice {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem;
}
.notice.err { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
