:root {
  --gap: 8px;
  --bg: #0e0f12;
  --panel: #171a1f;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #3b82f6;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid #232833;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls .spacer-left { margin-left: 12px; }

.controls input[type="number"] {
  background: #0f131a;
  color: var(--text);
  border: 1px solid #2a3240;
  border-radius: 6px;
  padding: 6px 10px;
  width: 80px;
}

.controls label.auto-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
}

.controls input[type="checkbox"] {
  accent-color: #3b82f6;
}

select, button {
  background: #0f131a;
  color: var(--text);
  border: 1px solid #2a3240;
  border-radius: 6px;
  padding: 6px 10px;
}

button:hover { border-color: var(--accent); }

main {
  padding: 12px;
  height: calc(100dvh - var(--header-h, 0px));
  overflow: hidden;
}

.grid {
  display: grid;
  gap: var(--gap);
  width: 100%;
  height: 100%;
}

.grid--1x1 { grid-template-columns: repeat(1, 1fr); grid-template-rows: repeat(1, 1fr); }
.grid--2x2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid--3x2 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid--3x3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.grid--4x4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }

.tile {
  position: relative;
  background: #0b0d11;
  border: 1px solid #1f2530;
  border-radius: 10px;
  overflow: hidden;
}

.tile__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: black;
}

/* Aspect ratio fit modes */
.tile--fit-cover .tile__video { object-fit: cover; width: 100%; height: 100%; }
.tile--fit-contain .tile__video { object-fit: contain; width: 100%; height: 100%; background: black; }
.tile--fit-fill .tile__video { object-fit: fill; width: 100%; height: 100%; }

/* Fixed aspect ratio modes: center video with defined aspect-ratio */
.tile--ratio-16x9,
.tile--ratio-4x3,
.tile--ratio-1x1,
.tile--ratio-custom { display: flex; align-items: center; justify-content: center; }
.tile--ratio-16x9 .tile__video { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; background: black; }
.tile--ratio-4x3 .tile__video { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: black; }
.tile--ratio-1x1 .tile__video { width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; background: black; }
.tile--ratio-custom .tile__video { width: 100%; height: auto; object-fit: contain; background: black; }

.tile__overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.55) 60%, rgba(0,0,0,0.8) 100%);
}

.tile__label {
  font-size: 12px;
  color: var(--muted);
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

.tile__actions { display: flex; gap: 6px; }

.tile__select,
.tile__aspect {
  background: rgba(0,0,0,0.45);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

.tile__select {
  background: rgba(0,0,0,0.45);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e5e7eb;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(59,130,246,0.3); border-color: rgba(59,130,246,0.6); }

.tile__status {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
  background: rgba(0,0,0,0.6);
  color: #d1d5db;
}

.tile--error { outline: 2px solid #ef4444; }
.tile--playing { outline: 2px solid rgba(16,185,129,0.7); }
.tile--focused { outline: 2px solid var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.35) inset; }

.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 50;
}

.login-card {
  width: 320px;
  background: var(--panel);
  border: 1px solid #232833;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card h2 { margin: 0 0 6px 0; font-size: 16px; }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card input {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #2a3240;
  background: #0f131a;
  color: var(--text);
}
.login-actions { display: flex; gap: 8px; justify-content: flex-end; }
.login-error { color: #ef4444; font-size: 12px; min-height: 16px; }


