/* clipdeck */
:root {
  --bg: #0e0d13;
  --surface: #17151f;
  --surface-2: #211e2c;
  --border: #2d2939;
  --text: #ece9f3;
  --muted: #9a94ab;
  --accent: #ff4f7b;
  --accent-2: #ff7a59;
  --ok: #3ecf8e;
  --danger: #ff5c5c;
  --radius: 12px;
  --topbar: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
input, select, button { font: inherit; color: inherit; }
input, select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
label input { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #4a4460; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.icon { padding: 6px 9px; }
.btn:disabled { opacity: .4; cursor: default; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge[data-platform="youtube"] { background: #ff00331f; color: #ff6b81; }
.badge[data-platform="tiktok"] { background: #25f4ee1c; color: #5ff5f0; }
.badge[data-platform="instagram"] { background: #d62f8a24; color: #f47ac0; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--ok);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-left-color: var(--danger); }

/* ---------- Kopfzeile ---------- */
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.topbar-title { color: var(--muted); }
.topnav { margin-left: auto; display: flex; gap: 4px; }
.set-pick select { max-width: 42vw; }

/* ---------- Login ---------- */
body.auth { display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); display: grid; gap: 14px; }
.auth-card .brand { margin-bottom: 6px; }
.error { color: var(--danger); margin: 0; }

/* ---------- Player ---------- */
.player-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 16px; padding: 16px;
  height: calc(100vh - var(--topbar));
}
.stage-wrap { min-width: 0; min-height: 0; }
.stage {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: var(--radius); overflow: hidden; container-type: size;
}
.stage-empty { color: var(--muted); padding: 24px; text-align: center; }
.embed { width: 100%; aspect-ratio: 16 / 9; width: min(100cqw, 100cqh * 16 / 9); }
.stage.vertical .embed { aspect-ratio: 9 / 16; width: min(100cqw, 100cqh * 9 / 16); }
/* Instagram-Embed hat Kopf- und Fusszeile um das Video herum */
.stage.vertical .embed.ig { aspect-ratio: 9 / 19; width: min(100cqw, 100cqh * 9 / 19, 540px); background: #fff; }
.embed iframe, .embed > div { width: 100%; height: 100%; border: 0; display: block; }

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
.now-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.now-name { font-size: 1.35rem; font-weight: 700; margin: 10px 0 4px; overflow-wrap: anywhere; }
.now-link { font-size: .85rem; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; justify-items: center; }
.controls .auto, .controls .hint { grid-column: 1 / -1; }
.auto { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.hint { margin: 0; font-size: .85rem; text-align: center; }
.ctl {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 1.4rem; cursor: pointer; display: grid; place-items: center;
}
.ctl:hover:not(:disabled) { border-color: var(--accent); }
.ctl.big { width: 72px; height: 72px; font-size: 1.8rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.ctl:disabled { opacity: .35; cursor: default; }

.counter { text-align: center; }
.counter-label { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; font-weight: 700; }
.counter-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0; }
.counter-value { font-size: 4rem; font-weight: 900; min-width: 2ch; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counter-value.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); color: var(--accent); } }

.keys summary { cursor: pointer; }
.keys p { font-size: .85rem; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: .8rem; }

/* ---------- Verwaltung ---------- */
.admin-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; padding: 16px; align-items: start; }
.set-detail, #set-view { display: grid; gap: 16px; min-width: 0; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { flex: 1; }

.set-list, .clip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.set-item, .clip-item {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px;
}
.set-item.active { border-color: var(--accent); }
.set-open { flex: 1; min-width: 0; background: none; border: 0; text-align: left; cursor: pointer; display: grid; padding: 4px; }
.set-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handle { cursor: grab; color: var(--muted); padding: 4px; user-select: none; touch-action: none; }
.dragging { opacity: .45; }

.set-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.set-edit-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.set-edit-actions .danger { margin-left: auto; }
.admin-counter .counter-value { font-size: 3rem; }

.clip-add { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; }
.import { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.import summary { cursor: pointer; font-weight: 600; }
.import form { display: grid; gap: 10px; margin-top: 10px; }
.import textarea {
  width: 100%; resize: vertical; font: .85rem/1.5 ui-monospace, Consolas, monospace; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
}
.import-actions { display: flex; align-items: center; gap: 12px; }
.import-result { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .88rem; }
.import-result .ok { color: var(--ok); }
.import-result .err { color: var(--danger); overflow-wrap: anywhere; }
.import-result code { color: var(--muted); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.clip-pos { width: 2ch; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.clip-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.clip-name { width: 100%; background: transparent; border-color: transparent; font-weight: 600; }
.clip-name:hover, .clip-name:focus { background: var(--bg); border-color: var(--border); }
.clip-name.saved { border-color: var(--ok); }
.clip-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 11px; }
.clip-actions { display: flex; gap: 4px; align-items: center; }
.clip-move { max-width: 150px; padding: 5px 6px; font-size: .85rem; }

.streamer-pick { margin-bottom: 14px; }
.streamer-pick select { color: var(--text); }

/* ---------- Benutzer & Streamer ---------- */
.users-layout { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 16px; padding: 16px; align-items: start; }
.user-create { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.user-table th { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.user-table select { padding: 5px 8px; }
.user-table select.granted { border-color: var(--accent); color: var(--text); }
.user-name { font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.notice { margin: 0; padding: 10px 12px; border-radius: 8px; background: #3ecf8e1a; border: 1px solid #3ecf8e55; }

dialog.card { color: var(--text); width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: #000a; }
dialog form { display: grid; gap: 12px; }
.empty-state { color: var(--muted); text-align: center; padding: 48px 16px; }

/* ---------- schmale Bildschirme ---------- */
@media (max-width: 900px) {
  .player-layout { grid-template-columns: 1fr; height: auto; }
  .stage { height: min(70vh, 640px); }
  .admin-layout, .users-layout { grid-template-columns: 1fr; }
  .user-create { grid-template-columns: 1fr 1fr; }
  .clip-add, .set-edit { grid-template-columns: 1fr; }
  .clip-item { flex-wrap: wrap; }
  .clip-actions { width: 100%; justify-content: flex-end; }
  .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .topnav .btn { padding: 8px; }
  .brand span, .topbar-title { display: none; }
}
