:root {
  color-scheme: dark;
  --bg: #0f1419;
  --card: #1a222b;
  --accent: #4da3ff;
  --text: #e8edf2;
  --muted: #8a94a0;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

h1 { font-size: 1.3rem; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1.2em; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
header h1 { margin: 0; }

/* login */
#view-login {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#view-loading {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
}

input[type="email"], input[type="date"] {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #2c3742;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}

button {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #06131f;
  cursor: pointer;
}
button:active { opacity: 0.85; }
button:disabled { opacity: 0.65; cursor: default; }
button.busy::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 8px;
  vertical-align: -0.1em;
  border: 2px solid rgba(6, 19, 31, 0.25);
  border-top-color: #06131f;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

button.link {
  width: auto;
  background: none;
  color: var(--accent);
  font-weight: 500;
  padding: 4px 0;
}

a { color: var(--accent); }

/* code entry */
.code-boxes {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 16px;
}
.code-boxes input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 1.4rem;
  border-radius: 8px;
  border: 1px solid #2c3742;
  background: var(--bg);
  color: var(--text);
}
.code-boxes input:focus { border-color: var(--accent); outline: none; }
.code-boxes input:disabled { opacity: 0.5; }
input[type="email"]:disabled { opacity: 0.6; }

/* camera list */
.camera-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--text);
  font-weight: 500;
  padding: 16px;
  margin-bottom: 8px;
  border-radius: 10px;
}
.cam-last { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.cam-last.stale { color: var(--danger); }

/* playback */
#date-picker { margin-bottom: 16px; }

.timeline {
  position: relative;
  height: 48px;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
}
.timeline .seg {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #2f6db3;
  cursor: pointer;
}
.timeline .seg:hover { background: var(--accent); }
.timeline .seg.playing { background: var(--accent); }
.timeline .playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.timeline.loading { animation: pulse 1.2s ease-in-out infinite; }
.timeline .seg.loading { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
input[type="date"]:disabled { opacity: 0.6; }

.ticks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 4px 2px 16px;
}

video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  min-height: 200px;
}

/* clip export */
.export-row { margin-top: 12px; text-align: right; }
.export-pick {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}
.export-pick .link { flex: 0 0 auto; }
.export-pick #btn-export-go { flex: 1; }
.timeline .seg.sel-in { background: #8a6a1f; }
.timeline .seg.sel-start, .timeline .seg.sel-end { background: #f5b942; }
#playback-hint a { color: var(--accent); }
