@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* Verhindert, dass eigene display-Regeln das hidden-Attribut aushebeln
   (bekannter CSS-Stolperstein: Autor-Styles gewinnen sonst gegen den
   Browser-Standard fuer [hidden], unabhaengig von Spezifitaet/Reihenfolge) */
[hidden] { display: none !important; }

:root {
  --bg: #14161b;
  --panel: #1c1f26;
  --panel-2: #232732;
  --border: #2e3340;
  --text: #e7e9ee;
  --text-muted: #8b93a3;
  --accent: #ff9f45;
  --accent-2: #5ac8fa;
  --danger: #ff5c5c;
  --success: #33d17a;
  --radius: 10px;
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --border: #dde1e8;
  --text: #1b1e24;
  --text-muted: #5b6472;
  --accent: #e8791f;
  --accent-2: #0f7fb3;
  --danger: #d64545;
  --success: #1f9d5c;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent-2); }
[data-theme="light"] .theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon, :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun, :root:not([data-theme]) .theme-toggle .icon-sun { display: inline; }

.brand-logo { height: 30px; width: auto; display: block; }

/* ---------- Hauptnavigation ---------- */
.main-nav { display: flex; gap: 4px; }
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.active { color: var(--accent); background: rgba(255,159,69,0.12); }
@media (max-width: 900px) { .main-nav { display: none; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 20px 0 40px; }
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
}
.footer-inner a { color: var(--accent-2); }
.footer-links { display: flex; align-items: center; gap: 10px; }
.footer-sep { color: var(--text-muted); }
.footer-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.footer-link:hover { color: var(--accent-2); }
.support-dropdown { position: relative; display: inline-block; }
.support-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 10;
}
.support-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.support-menu a:hover { background: var(--panel-2); }

/* ---------- Modal (Impressum) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-box h2 { margin-bottom: 12px; }
.modal-box p { margin-bottom: 12px; font-size: 0.9rem; line-height: 1.6; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.page-link:hover { border-color: var(--accent-2); color: var(--text); }
.page-link.active { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }

/* ---------- FAQ-Layout ---------- */
.faq-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .faq-layout { grid-template-columns: 1fr; } }
.faq-toc {
  position: sticky;
  top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.faq-toc h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; }
.faq-toc ul { list-style: none; }
.faq-toc li { margin-bottom: 2px; }
.faq-toc a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.faq-toc a:hover { background: var(--panel-2); color: var(--text); }
.faq-toc a.active { background: rgba(255,159,69,0.12); color: var(--accent); font-weight: 600; }
.faq-content section { scroll-margin-top: 20px; }
.faq-content section p { line-height: 1.6; margin-bottom: 10px; }
.faq-content code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.85em; }

/* ---------- Formular-Zeilen (z.B. Vor-/Nachname) ---------- */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row-2 { grid-template-columns: 1fr; } }

.auth-footer-link { text-align: center; margin-top: 16px; font-size: 0.85rem; }
.auth-footer-link a { color: var(--accent-2); }

/* ---------- Bewegter Hintergrund auf Login/Setup-Seiten ---------- */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.auth-bg::before, .auth-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.3;
}
[data-theme="light"] .auth-bg::before, [data-theme="light"] .auth-bg::after { opacity: 0.2; }
.auth-bg::before {
  width: 380px; height: 380px;
  background: var(--accent);
  top: -100px; left: -80px;
  animation: authFloat1 18s ease-in-out infinite;
}
.auth-bg::after {
  width: 320px; height: 320px;
  background: var(--accent-2);
  bottom: -80px; right: -60px;
  animation: authFloat2 22s ease-in-out infinite;
}
@keyframes authFloat1 {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(50px, 40px); }
}
@keyframes authFloat2 {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(-40px, -30px); }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 1.05rem; letter-spacing: 0.01em; }
p { line-height: 1.5; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.82rem; margin: 6px 0 0; }

a { color: var(--accent-2); }

/* ---------- Auth-Seiten (Login/Setup) ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 8px; }
.auth-logo { height: 40px; margin-bottom: 20px; }
.auth-theme-toggle { position: fixed; top: 20px; right: 20px; }

/* ---------- Layout ---------- */
.app-shell { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,159,69,0.18);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 720px) { .panel-grid { grid-template-columns: 1fr; } }

/* ---------- Formulare ---------- */
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 14px; }
input[type="text"], input[type="password"], input[type="number"], select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(90,200,250,0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #1a1200; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: rgba(255,92,92,0.4); }
.btn-danger-outline:hover { background: rgba(255,92,92,0.1); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px; }
.alert-error { background: rgba(255,92,92,0.12); color: #ff9d9d; border: 1px solid rgba(255,92,92,0.3); }
.alert-success { background: rgba(51,209,122,0.12); color: #8be8ae; border: 1px solid rgba(51,209,122,0.3); }

.save-status { font-size: 0.82rem; color: var(--success); margin-left: 10px; opacity: 0; transition: opacity 0.2s; }
.save-status.visible { opacity: 1; }
.save-status.error { color: var(--danger); }

/* ---------- Bildschirm-Panel-Header ---------- */
.screen-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; flex-wrap: wrap; gap: 8px; }
.screen-name { margin: 0; }
.screen-header-actions { display: flex; gap: 8px; }
.playlist-heading { margin: 22px 0 12px; font-size: 0.95rem; }
.screen-panel + .screen-panel { margin-top: 20px; }

.value-unit-row { display: flex; gap: 8px; }
.value-unit-row input { flex: 2; }
.value-unit-row select { flex: 1; }

/* ---------- Link-Zeile ---------- */
.link-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.link-row input {
  flex: 1;
  min-width: 240px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-2);
}

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent-2); background: rgba(90,200,250,0.05); }
.dropzone p { margin: 4px 0; }

.upload-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.upload-item { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.upload-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { flex: 1; height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; max-width: 160px; }
.upload-bar-fill { height: 100%; background: var(--accent-2); width: 0%; transition: width 0.15s; }
.upload-item.done .upload-bar-fill { background: var(--success); }
.upload-item.failed { color: var(--danger); }

/* ---------- Medien-Grid ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.empty-state { grid-column: 1 / -1; text-align: center; padding: 30px 0; }

.media-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--success);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: grab;
}
.media-card.is-disabled { border-top-color: var(--text-muted); opacity: 0.55; }
.media-card.dragging { opacity: 0.4; }

.drag-handle {
  position: absolute; top: 6px; left: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.media-preview { aspect-ratio: 16 / 9; background: #000; position: relative; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.type-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.media-meta { padding: 10px 12px 4px; }
.media-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-size { font-size: 0.75rem; font-family: var(--font-mono); }
.duration-label { margin-top: 8px; font-size: 0.75rem; }
.duration-input { font-family: var(--font-mono); }

.media-actions { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 12px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 22px; transition: 0.15s;
}
.slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(16px); }
