/* Streamer Regie System – App-Oberfläche (dunkles Theme, ohne Build-Schritt) */

:root {
  color-scheme: dark;
  --bg: #0e1016;
  --bg-2: #12151d;
  --panel: #171b25;
  --panel-2: #1d2230;
  --panel-3: #252b3b;
  --border: #2b3244;
  --border-strong: #3b4459;
  --text: #e9ecf3;
  --text-2: #b9c1d0;
  --muted: #8d96a9;
  --accent: #8b5cf6;
  --accent-hover: #9d74ff;
  --accent-2: #6d28d9;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --focus: #b9a2ff;
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --danger: #f04452;
  --danger-soft: rgba(240, 68, 82, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --tiktok: #ff2d6f;
  --twitch: #9146ff;
  --kick: #53fc18;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --header-h: 56px;
  --checker: repeating-conic-gradient(#1b1f2a 0 25%, #232836 0 50%) 50% / 24px 24px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
small, .small { font-size: 0.85em; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
img, video { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 1000;
  background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ---------- Laden ---------- */
.boot-loader { display: flex; gap: 10px; align-items: center; justify-content: center; min-height: 60vh; color: var(--muted); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: inline-block; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Header / Navigation ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: var(--header-h); padding: 0 16px;
  background: rgba(14, 16, 22, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.brand-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.channel-switch { min-width: 0; max-width: 240px; }
.channel-switch select { min-height: 36px; padding: 4px 30px 4px 10px; }
.header-spacer { flex: 1; }
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-hover); font-weight: 700; font-size: 0.85rem;
}
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column;
}
.menu a, .menu button {
  display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text);
  background: none; border: 0; font: inherit; cursor: pointer; min-height: 40px;
}
.menu a:hover, .menu button:hover { background: var(--panel-3); text-decoration: none; }
.menu .menu-info { padding: 8px 12px; color: var(--muted); font-size: 0.85rem; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

.app-nav {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex; gap: 4px; padding: 6px 12px;
  overflow-x: auto; scrollbar-width: thin;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.app-nav a {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 550;
  min-height: 38px;
}
.app-nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.app-nav a[aria-current="page"] { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45); }
.app-nav .nav-ico { font-size: 1.05em; }

main.page { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
main.page.wide { max-width: none; padding: 12px 12px 48px; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 2px 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Layout-Helfer ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------- Karten ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child, .card-head { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card.flat { background: var(--panel-2); border-radius: var(--radius); padding: 14px; }
.card.danger-zone { border-color: rgba(240, 68, 82, 0.4); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: var(--panel-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger-soft); border-color: rgba(240, 68, 82, 0.55); color: #ffb3ba; }
.btn-danger:hover { background: rgba(240, 68, 82, 0.28); }
.btn-solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ok { background: var(--ok-soft); border-color: rgba(34, 197, 94, 0.5); color: #a7f3c0; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.88rem; }
.btn-lg { min-height: 48px; padding: 10px 22px; font-size: 1.05rem; }
.btn-icon { min-width: 40px; padding: 6px; }
.btn-icon.btn-sm { min-width: 32px; padding: 4px; }
.btn-block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 0.9rem; color: var(--text-2); }
.field .hint { color: var(--muted); font-size: 0.82rem; }
.field .error { color: #ff9aa3; font-size: 0.85rem; }
.input, select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="url"] {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus, select:focus, textarea:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
input[type="color"] {
  width: 44px; height: 40px; padding: 2px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-2); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 28px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; min-width: 0; }
legend { padding: 0 6px; color: var(--text-2); font-weight: 600; font-size: 0.9rem; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; transition: background 0.15s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 21px; }

.segmented { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: 0.88rem;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; min-height: 32px;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.segmented button:hover:not([aria-pressed="true"]) { background: var(--panel-3); color: var(--text); }

.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field input { font-family: var(--mono); font-size: 0.85rem; }

/* ---------- Badges / Chips / Status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 650; background: var(--panel-3); color: var(--text-2); white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: #86efac; }
.badge.warn { background: var(--warn-soft); color: #fcd38d; }
.badge.danger { background: var(--danger-soft); color: #ffa3ab; }
.badge.info { background: var(--info-soft); color: #9ddcfb; }
.badge.accent { background: var(--accent-soft); color: #d4c4ff; }
.badge.outline { background: transparent; border-color: var(--border-strong); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.platform-tiktok { color: var(--tiktok); }
.platform-twitch { color: var(--twitch); }
.platform-kick { color: var(--kick); }
.platform-test { color: var(--info); }

/* ---------- Hinweise ---------- */
.callout { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); background: var(--panel-2); display: flex; gap: 10px; align-items: flex-start; }
.callout .ico { font-size: 1.15rem; line-height: 1.3; }
.callout.info { border-color: rgba(56, 189, 248, 0.35); background: var(--info-soft); }
.callout.warn { border-color: rgba(245, 165, 36, 0.45); background: var(--warn-soft); }
.callout.danger { border-color: rgba(240, 68, 82, 0.45); background: var(--danger-soft); }
.callout.ok { border-color: rgba(34, 197, 94, 0.4); background: var(--ok-soft); }
.callout p:last-child { margin-bottom: 0; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty .big { font-size: 2rem; display: block; margin-bottom: 6px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.list-item .grow { min-width: 0; }
.list-item .title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { color: var(--muted); font-size: 0.85rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2);
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 42px;
}
.tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(5, 6, 10, 0.68);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn 0.12s ease-out;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  animation: popIn 0.14s ease-out;
}
.modal.wide { width: min(860px, 100%); }
.modal.xwide { width: min(1100px, 100%); }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.1rem; flex: 1; min-width: 0; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (max-width: 600px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.xwide { width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 300; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--panel-2); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); animation: popIn 0.15s ease-out;
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Auth-Seiten ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, rgba(139, 92, 246, 0.18), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; font-size: 1.2rem; margin-bottom: 18px; }
.auth-card .brand img { width: 40px; height: 40px; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-foot { text-align: center; margin-top: 14px; color: var(--muted); }

/* ---------- Kanal-Kacheln (Dashboard) ---------- */
.channel-tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.channel-tile { display: flex; flex-direction: column; gap: 10px; }
.channel-tile .name { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.channel-tile .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--bg-2); font-family: var(--mono); font-size: 0.8rem; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-left: 38px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: #d4c4ff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}

.thumb { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; background: var(--checker); flex: none; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; overflow: hidden; }

@media (max-width: 720px) {
  .brand-name { display: none; }
  main.page { padding: 16px 12px 56px; }
  .card { padding: 14px; border-radius: var(--radius); }
  .page-head .actions { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.search-grow { flex: 1 1 220px; min-width: 160px; }
