:root {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8eef7;
  --muted: #9aa8bc;
  --accent: #4da3ff;
  --error: #ff6b6b;
}

* {
  box-sizing: border-box;
}

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

body:has(.camera-stack) {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body:has(.camera-stack) .top-bar {
  flex-shrink: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.card {
  width: min(100%, 24rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.error {
  margin: 0 0 1rem;
  color: var(--error);
}

form {
  display: grid;
  gap: 0.75rem;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

button {
  margin-top: 0.25rem;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #04101f;
  font-weight: 600;
  cursor: pointer;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  min-width: 0;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.host-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.host-chip {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.host-chip.is-charging {
  color: var(--accent);
}

.host-chip.is-warn {
  color: var(--error);
  border-color: var(--error);
}

.logout {
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
}

.camera-stack {
  --feed-columns: 1;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(var(--feed-columns), minmax(0, 1fr));
  align-content: start;
  gap: 0.75rem;
  padding: 1rem;
}

.camera-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
}

.camera-tile.is-expanded {
  grid-column: 1 / -1;
}

.camera-stack:not(.is-single) .camera-tile:not(.is-expanded) .camera-meta {
  display: none;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.camera-header h2 {
  margin: 0;
  font-size: 1rem;
}

.camera-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.thermal-toggle,
.slow-toggle {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font: inherit;
  cursor: pointer;
}

.slow-toggle[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--accent);
}

.resolution,
.offline-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.camera-tile.is-offline .stream {
  opacity: 0.35;
}

.offline-note {
  color: var(--error);
}

.stream-frame {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  cursor: pointer;
  color: inherit;
}

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

.thermal-pip {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 31.6%;
  height: 31.6%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #000;
}
