:root {
  --bg: #0e1116;
  --bg2: #161b22;
  --bg3: #1f2630;
  --fg: #e6edf3;
  --fg2: #8b949e;
  --acc: #2f81f7;
  --acc2: #1f6feb;
  --ok: #3fb950;
  --err: #f85149;
  --warn: #d29922;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}
header {
  padding: 18px 28px;
  background: var(--bg2);
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: baseline;
  gap: 16px;
}
header h1 { margin: 0; font-size: 20px; }
header .sub { color: var(--fg2); font-size: 12px; }
main {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
  display: grid;
  gap: 24px;
}
section {
  background: var(--bg2);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 20px;
}
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid #30363d;
}
.tab {
  background: transparent;
  border: none;
  color: var(--fg2);
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.tab.active {
  color: var(--fg);
  border-bottom-color: var(--acc);
}
.tab:hover { color: var(--fg); }

form { display: grid; gap: 14px; }
.block { display: grid; gap: 6px; }
.block > span:first-child {
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
textarea, input[type=text], input[type="number"], select, input[type="file"] {
  width: 100%;
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--acc); }
.grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 10px;
}
label.check { display: flex; align-items: center; gap: 6px; padding-top: 22px; }
button {
  background: var(--acc);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--acc2); }
button.ghost {
  background: transparent;
  border: 1px solid #30363d;
  color: var(--fg);
  font-weight: 500;
  padding: 4px 10px;
  font-size: 12px;
}
button.ghost:hover { background: var(--bg3); }
button.danger { background: var(--err); }
button.danger-ghost {
  background: transparent;
  border: 1px solid var(--err);
  color: var(--err);
  font-weight: 500;
}
button.danger-ghost:hover { background: rgba(248,81,73,0.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.hint { color: var(--fg2); font-size: 12px; }
#preview {
  max-height: 120px;
  border-radius: 6px;
  margin-top: 6px;
  border: 1px solid #30363d;
}

#history .hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#history .hd h2 { margin: 0; font-size: 16px; }
#history .hd-right { display: flex; gap: 8px; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .cards { grid-template-columns: 1fr; } }

.card {
  background: var(--bg3);
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.card.selected { outline: 2px solid var(--acc); }
.card .video-wrap {
  aspect-ratio: 16/9;
  background: black;
  position: relative;
  min-height: 220px;
}
.card .video-wrap video {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
  background: black;
}
.card .video-wrap video::-webkit-media-controls-panel { font-size: 14px; }
.card .video-wrap .empty-video {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg2); font-size: 12px;
}
.card .ck-overlay {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.card .ck-overlay input { cursor: pointer; transform: scale(1.3); }
.card .meta {
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.card .meta-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--fg2);
}
.card .meta-row .mode-tag {
  background: var(--bg2); border: 1px solid #30363d;
  border-radius: 4px; padding: 1px 6px; font-size: 11px;
}
.card .prompt-text {
  font-size: 14px; color: var(--fg);
  line-height: 1.4;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  min-height: calc(1.4em * 3);
}
.card .progress-block { display: flex; flex-direction: column; gap: 4px; }
.card .progress {
  background: var(--bg2); border-radius: 4px;
  height: 6px; overflow: hidden;
}
.card .progress > div {
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  height: 100%; transition: width 0.4s ease;
}
.card .progress-text {
  font-size: 11px; color: var(--fg2);
  display: flex; justify-content: space-between;
  font-variant-numeric: tabular-nums;
}
.card .actions {
  padding: 10px 14px;
  border-top: 1px solid #30363d;
  display: flex; gap: 6px; justify-content: flex-end;
}
.card .actions button { padding: 5px 12px; font-size: 13px; }

.cards .empty {
  grid-column: 1 / -1;
  text-align: center; color: var(--fg2); padding: 32px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge.queued { background: var(--warn); color: #000; }
.badge.running { background: var(--acc); }
.badge.completed { background: var(--ok); color: #000; }
.badge.failed { background: var(--err); }