:root {
  color-scheme: light;
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --accent: #4da3ff;
  --line: #2a3542;
  font-family: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a3d, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
header h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: -0.02em;
}
header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
}
.card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.meta { color: var(--muted); font-size: 0.88rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }

.row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
button, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #243041;
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  cursor: pointer;
}
button.primary, .btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #041018;
  font-weight: 600;
}
button.danger, .btn.danger {
  background: color-mix(in srgb, var(--bad) 28%, #243041);
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
  color: #ffd4d4;
}

.login {
  max-width: 380px;
  margin: 12vh auto 0;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.3rem; }
input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101820;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font: inherit;
}
.error {
  margin-top: 0.75rem;
  color: var(--bad);
  font-size: 0.9rem;
}
.note {
  border-left: 3px solid var(--accent);
  padding: 0.65rem 0.8rem;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.filters .filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.filters .filter-grid-cal {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.filters label {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.filters select,
.filters input[type="date"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101820;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
  color-scheme: dark;
}
.filter-actions { display: flex; align-items: end; }
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.preset-row .preset {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.file-list { padding: 0.35rem 0.4rem; }
.file-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.thumb-link {
  flex: 0 0 auto;
  width: 112px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a0f14;
}
.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0a0f14;
}
.file-main { flex: 1; min-width: 0; }
.preview-wrap {
  margin-top: 0.85rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a0f14;
}
.preview {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}
.live-mjpeg {
  display: block;
  width: 100%;
  max-height: 70vh;
  min-height: 220px;
  object-fit: contain;
  background: #000;
}
.home-live .live-mjpeg { max-height: 56vh; }
.player-card { padding: 0.75rem; position: relative; }
.live-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.live-clock {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.live-clock-date {
  font-size: 0.78rem;
  color: #c5d0dc;
  letter-spacing: 0.02em;
}
.live-clock-time {
  font-size: 1.35rem;
  font-weight: 650;
  color: #f3f7fb;
  letter-spacing: 0.04em;
}
.player {
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  background: #000;
  display: block;
}
.live-stage .player { border-radius: 0; }
.live-stage .prep { border-radius: 0; }
.prep {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 220px;
  padding: 1.5rem 1rem;
  text-align: center;
  background: #0a0f14;
  border-radius: 12px;
}
.prep[hidden] { display: none; }
.prep-title { margin: 0; font-weight: 600; }
.prep-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #2a3544;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.file-row:last-child { border-bottom: 0; }
.file-row.motion {
  background: color-mix(in srgb, #ffb020 8%, transparent);
  border-radius: 10px;
  border-bottom-color: transparent;
  margin-bottom: 0.2rem;
}
.file-row.is-watched {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 10px;
  border-bottom-color: transparent;
}
.badge.watched {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: #9cc8ff;
}
.file-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.badge.motion {
  background: color-mix(in srgb, #ffb020 24%, transparent);
  color: #ffc857;
}

.check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem;
  margin: 0.85rem 0;
}
.check input { width: auto; }
.settings-panel label { margin-top: 0.75rem; }
.settings-panel input[type="number"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101820;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font: inherit;
}

@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; }
  .row { flex-direction: column; }
  .filters .filter-grid,
  .filters .filter-grid-cal { grid-template-columns: 1fr 1fr; }
}
