:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e5e8;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo { height: 72px; width: auto; }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }

.status-pill {
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  background: #e5e7eb;
  color: #374151;
}
.status-pill.open { background: #d1fae5; color: #065f46; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  max-width: 1300px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.card.wide { grid-column: 1 / -1; }

.card h2 { margin: 0 0 8px; font-size: 16px; }
.card h3 { margin: 0 0 6px; font-size: 14px; }

.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.detail { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.timing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.timing-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.timing-row input[type="number"] {
  width: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}

.secondary, .upload-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.upload-btn {
  display: inline-block;
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.screens-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.screen-tile {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  background: #fff;
}

.screen-tile.active { border-color: #111827; background: #f3f4f6; font-weight: 600; }

.groups-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.group-chip {
  position: relative;
  padding: 10px 16px 10px 26px;
  border: 2px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  background: #fff;
}

.group-chip.selected { border-color: #111827; background: #f3f4f6; font-weight: 600; }

.group-chip .dot {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
}

.group-chip.live .dot { background: #16a34a; }

.group-chip .range {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

.group-form, .group-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  background: #fafafa;
}

.group-form input[type="text"],
.group-detail input[type="text"],
.group-form input[type="date"],
.group-detail input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.date-hint { margin-top: -10px; }

.group-detail .group-name-input { min-width: 160px; }
.group-detail .group-date-input { width: 150px; }
.group-detail .badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
}
.group-detail .badge.live { background: #d1fae5; color: #065f46; }
.group-detail .badge.default { background: #dbeafe; color: #1e40af; }

.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.slide-tile {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}

.slide-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #eee;
}

.slide-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.slide-tile .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

.slide-tile .filename {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4px 6px;
  font-size: 11px;
  background: rgba(0,0,0,.55);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.membership-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
}

.membership-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
}

.membership-chip input { margin: 0; }

.membership-chip.checked {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.empty-note { color: var(--muted); font-size: 13px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

/* ===== Cloud-Steuerung: Erweiterungen ===== */
.topbar { flex-wrap: wrap; }
.topbar h1 { flex: 0 1 auto; margin-right: 12px; }
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab {
  padding: 10px 16px; border: none; border-radius: 8px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab:hover { background: #f3f4f6; }
.tab.active { background: #111827; color: #fff; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.tab-panel { display: flex; flex-direction: column; gap: 20px; }
.tab-panel[hidden] { display: none; }

button { font-family: inherit; }
.primary {
  padding: 10px 16px; border-radius: 8px; border: 1px solid #b72221; background: #b72221;
  color: #fff; font-size: 14px; cursor: pointer;
}
.primary:hover { background: #9c1c1b; }
.secondary:hover { background: #f3f4f6; }
.danger { color: #b72221; border-color: #f3c4c3; }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.inline-form input[type="text"], .inline-form textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.inline-form textarea { flex: 1; min-width: 280px; }

.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(17, 24, 39, .72);
  display: flex; align-items: center; justify-content: center;
}
.overlay[hidden] { display: none; }
.login-card {
  background: #fff; padding: 32px 36px; border-radius: 14px; width: min(360px, 90vw);
  display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center;
}
.login-card h2 { margin: 0; }
.login-card input { padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
.login-logo { height: 110px; width: auto; align-self: center; }
.error { color: #b72221; min-height: 1.2em; margin: 0; font-size: 13px; }

.players-list { display: flex; flex-direction: column; gap: 16px; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.player-name {
  font-size: 18px; font-weight: 700; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 8px; min-width: 220px; font-family: inherit; color: var(--text); background: transparent;
}
.player-name:hover, .player-name:focus { border-color: var(--border); background: #fff; }
.player-status { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: #d1d5db; display: inline-block; }
.status-dot.online { background: #16a34a; box-shadow: 0 0 0 4px #d1fae5; }
.status-dot.offline { background: #dc2626; }
.live-line { font-size: 14px; margin-bottom: 12px; }
.warn { color: #b45309; }
.pair-box { background: #fef3c7; border: 1px solid #fcd34d; padding: 8px 14px; border-radius: 10px; font-size: 14px; }
.pair-box.expired { background: #fee2e2; border-color: #fca5a5; }
.pair-code { font-size: 22px; letter-spacing: 3px; font-family: Consolas, monospace; margin: 0 8px; }

.player-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 12px; }
.player-grid label, .settings-row label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.player-grid select, .settings-row input[type="text"], .settings-row input[type="number"], .settings-row input[type="url"] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff;
}
.player-checks { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 14px; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 14px !important; color: var(--text) !important; }

.settings-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.settings-row label.wide { flex: 1; min-width: 300px; }
.settings-row input[type="number"] { width: 130px; }

.group-chip .count {
  background: #e5e7eb; border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-left: 6px; color: #374151;
}

@media (max-width: 700px) {
  .page { padding: 14px; }
}

[hidden] { display: none !important; }

/* ===== Vorschau ===== */
.preview-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 14px 0 16px; }
.preview-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.preview-controls select, .preview-controls input[type="date"] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff;
}
.preview-frame-wrap {
  position: relative; width: 100%; max-width: 1100px; aspect-ratio: 16 / 9;
  background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
}
.preview-frame-wrap iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #000; }
.preview-meta { margin: 12px 0 0; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.preview-meta .warn { color: #b45309; }
.preview-slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; max-width: 1100px; }
.pv-tile {
  display: flex; flex-direction: column; border: 2px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #fff; cursor: pointer; padding: 0; text-align: left; font-family: inherit;
}
.pv-tile:hover { border-color: #9ca3af; }
.pv-tile.active { border-color: #b72221; }
.pv-thumb { aspect-ratio: 16 / 9; background: #eee; display: flex; align-items: center; justify-content: center; font-size: 30px; overflow: hidden; }
.pv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-thumb.special { background: linear-gradient(160deg, #24302b, #3a4a42); }
.pv-label { padding: 6px 8px; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-nr { color: var(--muted); margin-right: 4px; }
