* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0f0f0f;
  --surface: #1a1a2e;
  --surface-2: #16213e;
  --accent: #0f3460;
  --primary: #e94560;
  --primary-hover: #ff6b81;
  --green: #00c853;
  --red: #ff1744;
  --orange: #ff9100;
  --text: #eaeaea;
  --text-muted: #8a8a9a;
  --border: #2a2a4a;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: block;
  margin: 0 auto 20px;
  height: 40px;
  width: auto;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 22px;
}

.login-box p {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

.error-msg {
  color: var(--red);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  touch-action: manipulation;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:active:not(:disabled) {
  background: #00b34a;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:active:not(:disabled) {
  background: #e0153c;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 12px 16px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

/* Dashboard Layout */
.dashboard {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 32px;
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 28px;
  width: auto;
}

.header h1 {
  font-size: 20px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Status Grid */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.orange { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

/* Preview */
.preview-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  max-width: 100%;
}

.preview-img.active {
  display: block;
}

.preview-offline {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.preview-offline.hidden {
  display: none;
}

/* Controls */
.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Scene List */
.scene-list {
  list-style: none;
}

.scene-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 15px;
  border: 1px solid transparent;
}

.scene-item:active {
  background: var(--surface-2);
}

.scene-item + .scene-item {
  margin-top: 4px;
}

.scene-item.active {
  background: var(--accent);
  border-color: var(--primary);
}

.scene-item input[type="radio"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

/* Settings */
.settings-group {
  margin-bottom: 14px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-group input,
.settings-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.settings-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8a9a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.settings-group input:focus,
.settings-group select:focus {
  border-color: var(--primary);
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 14px;
}

.toggle-label {
  font-size: 15px;
}

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--green);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* OBS disconnected banner */
.obs-banner {
  background: var(--red);
  color: white;
  text-align: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
}

.obs-banner.show {
  display: block;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: 16px;
  max-width: 400px;
  margin: 0 auto;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--accent); }

/* Safe area for phones with notch/dynamic island */
@supports (padding: env(safe-area-inset-bottom)) {
  .dashboard {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* Mobile-first is default, wider screens get minor tweaks */
@media (min-width: 600px) {
  .dashboard { padding: 24px; }
  .header h1 { font-size: 22px; }
  .card { padding: 20px; }
}
