:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-input: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --text-muted: #8a93a5;
  --accent: #7c5cff;
  --accent-hover: #9277ff;
  --danger: #e5484d;
  --ok: #46c07a;
  --warn: #f5a623;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--bg-input); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

/* ------------------------------------------------------------ Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 22px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; white-space: nowrap; }
.brand-sub { color: var(--accent-hover); font-weight: 500; font-size: 0.85em; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--text-muted);
}
.mainnav a:hover { color: var(--text); text-decoration: none; background: var(--bg-input); }
.mainnav a.active { color: var(--text); background: var(--bg-input); }
.userbox { color: var(--text-muted); font-size: 0.9em; white-space: nowrap; }
.userbox .username { color: var(--text); margin-right: 10px; }

/* --------------------------------------------------------- Container --- */
.container { max-width: 960px; margin: 0 auto; padding: 26px 20px 60px; }
h1 { font-size: 1.5rem; margin: 0 0 18px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- Forms --- */
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.9em; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
input[type="file"] { padding: 8px; }

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.grid-4 label { margin-top: 14px; }

details.advanced { margin-top: 14px; }
details.advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9em;
  user-select: none;
}
details.advanced[open] summary { margin-bottom: 6px; }

.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 22px;
}

/* ----------------------------------------------------------- Buttons --- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-small { padding: 5px 12px; font-size: 0.85em; }
.btn-block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: 0.55; cursor: wait; }

/* -------------------------------------------------------------- Tabs --- */
.tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.tab {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ------------------------------------------------------------ Alerts --- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: 0.92em;
}
.alert-error { background: rgba(229, 72, 77, 0.12); border: 1px solid var(--danger); color: #ff9296; }
.alert-warn { background: rgba(245, 166, 35, 0.1); border: 1px solid var(--warn); color: #ffcf7d; }

/* ------------------------------------------------------------- Login --- */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 380px; text-align: center; }
.login-card h1 { margin-bottom: 4px; }
.login-card form { text-align: left; }

/* ------------------------------------------------------------- Queue --- */
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.queue-item .qi-prompt { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .qi-meta { color: var(--text-muted); font-size: 0.85em; }
.queue-item .qi-side { text-align: right; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-running { border-color: var(--accent); color: var(--accent-hover); }
.badge-pending { border-color: var(--warn); color: var(--warn); }
.badge-done { border-color: var(--ok); color: var(--ok); }
.badge-error, .badge-canceled { border-color: var(--danger); color: var(--danger); }

.progress-track {
  grid-column: 1 / -1;
  height: 7px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* Wartende Jobs haben keinen messbaren Fortschritt — ein laufendes
   Streifenmuster zeigt „eingereiht", ohne einen Stand vorzutäuschen. */
.progress-wartend {
  width: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--bg-input) 0 10px,
    #343a49 10px 20px
  );
  background-size: 200% 100%;
  animation: warten 1.4s linear infinite;
}

@keyframes warten {
  from { background-position: 0 0; }
  to { background-position: -40px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-wartend { animation: none; }
}

.pod-card .pod-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pod-actions { display: flex; gap: 8px; }

/* ----------------------------------------------------------- Gallery --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.video-card { padding: 0; overflow: hidden; }
.video-card video { width: 100%; display: block; background: #000; aspect-ratio: 16 / 9; }
.video-meta { padding: 12px 14px 14px; }
.prompt-text {
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.92em;
}
.video-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ Sequenz --- */
.seq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.seq-block {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.seq-block label { font-weight: 600; font-size: 0.85em; color: var(--text-muted); }
.seq-block textarea { margin-bottom: 2px; }
.seq-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.seq-block-title { font-weight: 600; font-size: 0.85em; color: var(--text-muted); }
.seq-remove {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 1.1em;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
}
.seq-remove:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.seq-remove:disabled { opacity: 0.3; cursor: default; }
.seq-add { margin-top: 2px; }
.seq-refs summary { font-size: 0.85em; }
.seq-refs .ref-count { color: var(--accent); font-weight: 600; }
.ref-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ref-thumb {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.seq-ref-hint.warn { color: var(--danger); }

/* ------------------------------------------------------------- Konto --- */
.stack > div { margin-bottom: 12px; }
.stack input[type="password"] { max-width: 380px; }

.upload-row { display: flex; gap: 14px; align-items: flex-start; }
.image-preview {
  max-width: 180px;
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.hint-card ul { margin: 8px 0 0; padding-left: 20px; }

/* --------------------------------------------------------- Adminportal --- */
h2 { font-size: 1.1rem; margin: 0 0 6px; }
h3 { font-size: 0.98rem; margin: 18px 0 6px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 18px; }

.alert-ok { background: rgba(70, 192, 122, 0.1); border: 1px solid var(--ok); color: #7ee0a5; }

.switch { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 10px; }
.switch input { width: auto; }

.test-result { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.check-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; }
.check-icon { font-weight: 700; line-height: 1.4; }
.check-ok .check-icon { color: var(--ok); }
.check-fail .check-icon { color: var(--danger); }
.check-fail code { color: #ff9296; }

/* ------------------------------------------------- Bereitschaftsanzeige --- */
.readiness {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.readiness-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.readiness-ready { border-left-color: var(--ok); }
.readiness-downloading, .readiness-booting { border-left-color: var(--accent); }
.readiness-stopped, .readiness-unconfigured { border-left-color: var(--text-muted); }
.readiness-log { list-style: none; margin: 0; padding: 0; }
.readiness-log li { padding: 1px 0; }
.readiness-log li::before { content: "· "; color: var(--text-muted); }

.pod-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pod-toolbar #template-state { flex: 1; }

.pod-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pod-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pod-entry-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pod-entry-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.user-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.user-table th, .user-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.user-table th { color: var(--text-muted); font-size: 0.85em; font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------- Flüchtige Galerie --- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.78em;
  border: 1px solid var(--border);
  margin-left: 4px;
}
.tag-ok { border-color: var(--ok); color: var(--ok); }
.tag-warn { border-color: var(--warn); color: var(--warn); }
.video-card.undownloaded { border-color: var(--warn); }

.history-card summary { cursor: pointer; user-select: none; }
.history-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.history-list .prompt-text { -webkit-line-clamp: 1; margin: 0; }
