:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --accent: #22c55e;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --danger: #ef4444;
  --line: #2a323d;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
button,
select,
input {
  font-family: inherit;
  font-size: 16px;
}
button {
  cursor: pointer;
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
}
.login-card input {
  background: #0d1117;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
}
.login-card input:focus {
  border-color: var(--accent);
}
.login-card button {
  background: var(--accent);
  color: #06230f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
}
.error {
  color: var(--danger);
  font-size: 14px;
}

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
}
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34%;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
}
.tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.12);
}
.logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
}

.screen {
  padding: 12px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Live grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.tile .video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.tile .tile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.dot.on {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.tile .tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .tag {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Playback ---------- */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 140px;
}
.field > span {
  font-size: 12px;
  color: var(--muted);
}
.field select,
.field input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.12);
}

.timeline-wrap {
  margin-top: 14px;
}
.timeline {
  position: relative;
  width: 100%;
  height: 46px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}
.tl-block {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.8;
  min-width: 2px;
}
.tl-block:hover {
  opacity: 1;
}
.tl-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 4px #fff;
  z-index: 2;
  pointer-events: none;
}
.tl-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.pb-status {
  margin-top: 10px;
}

.player {
  margin-top: 12px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.player video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
}

.download-row {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.download-controls {
  display: flex;
  gap: 8px;
}
.download-controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.download-controls button {
  background: var(--accent);
  color: #06230f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
}
.download-controls button:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}
