:root {
  color-scheme: light dark;
  --bg: #0d0f13;
  --bg-soft: #12151b;
  --card: #171b22;
  --card-hover: #1d222b;
  --border: #262b35;
  --text: #edeff2;
  --muted: #8b93a1;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, 0.14);
  --live: #ff5c72;
  --live-soft: rgba(255, 92, 114, 0.16);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at top, var(--bg-soft), var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(13, 15, 19, 0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.title-row { display: flex; align-items: center; gap: 0.6rem; }
.title-row .icon { font-size: 1.4rem; line-height: 1; }
h1 { font-size: 1.15rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.filters { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.filters label {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 0.4rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
}
.filters input, .filters select {
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 0.82rem;
  outline: none;
}
.filters button {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.filters button:hover { color: var(--text); border-color: var(--accent); }

.live-links { display: flex; gap: 0.6rem; flex-wrap: wrap; width: 100%; }
.live-link {
  color: var(--live);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 650;
  border: 1px solid var(--live-soft);
  background: var(--live-soft);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.live-link::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255, 92, 114, 0.6);
  animation: pulse 1.8s infinite;
}
.live-link:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(255, 92, 114, 0.2); }

main {
  padding: 1.75rem 2rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #333a47;
  background: var(--card-hover);
}

.card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #000;
}

.card .meta {
  padding: 0.7rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: 0.5rem;
}
.card .meta .when { color: var(--text); font-weight: 550; }
.card .meta .camera { color: var(--muted); font-size: 0.78rem; display: block; }

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}
.badge.motion { background: var(--accent-soft); color: var(--accent); }
.badge.ding { background: var(--live-soft); color: var(--live); }

.empty {
  color: var(--muted);
  padding: 4rem 2rem;
  text-align: center;
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.empty .icon { font-size: 2rem; opacity: 0.6; }

/* ---- Live page ---- */

.live-main {
  padding: 2rem 1.5rem 3rem;
  display: flex;
  justify-content: center;
}

.live-panel {
  width: 100%;
  max-width: 720px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--live-soft);
  color: var(--live);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.55rem;
}
.live-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.8s infinite;
}

.live-stream {
  width: 100%;
  display: block;
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

.live-controls {
  padding: 0.9rem 1.1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.live-controls audio { flex: 1; height: 32px; }

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 92, 114, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(255, 92, 114, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 92, 114, 0); }
}

/* ---- Login page ---- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-main {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 2.25rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.login-icon {
  font-size: 2rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  margin-bottom: 0.25rem;
}

.login-title { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.login-subtitle {
  margin: -0.4rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.4;
}

.login-error {
  width: 100%;
  background: var(--live-soft);
  color: var(--live);
  border: 1px solid rgba(255, 92, 114, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
  text-align: center;
}

.login-field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.login-field input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-submit {
  width: 100%;
  margin-top: 0.4rem;
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
.login-submit:hover { filter: brightness(1.08); }
.login-submit:active { transform: scale(0.98); }
