:root {
  --bg: #0a0a15;
  --panel: #14141f;
  --panel-2: #1b1b29;
  --border: #2a2a3d;
  --text: #eceaf6;
  --muted: #9490ac;
  --accent: #8b5cf6;
  --accent-2: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  min-height: 100%;
}

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

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(20,20,31,.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.credits-badge {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
}

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

h1 { font-size: 26px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 14px; }
p.muted, .muted { color: var(--muted); }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 4px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
.tab.active { background: var(--accent); color: #fff; }

label { display: block; margin: 12px 0 6px; font-size: 14px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); }

.btn {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 16px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  width: auto;
}

.type-choice { display: flex; gap: 10px; }
.type-choice label {
  flex: 1;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
}
.type-choice input { display: none; }
.type-choice label.selected { border-color: var(--accent); background: rgba(139,92,246,.15); }

.error-msg { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gen-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.gen-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #000;
  display: block;
}
.gen-media.video { aspect-ratio: 16 / 9; }
.gen-body { padding: 10px 12px; }
.gen-prompt {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 8px;
}
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge.pending, .badge.processing { background: rgba(234,179,8,.18); color: var(--yellow); }
.badge.completed { background: rgba(34,197,94,.18); color: var(--green); }
.badge.failed { background: rgba(239,68,68,.18); color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1; min-width: 160px; }
.inline-form .btn { width: auto; margin-top: 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.msg {
  max-width: 80%;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.msg.staff { background: rgba(139,92,246,.14); border-color: var(--accent); margin-left: auto; }
.msg .msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg .msg-body { white-space: pre-wrap; word-break: break-word; }
