:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa1ad;
  --accent: #d9a24b;
  --accent-2: #c98a2e;
  --green: #4caf7d;
  --red: #e0665b;
  --yellow: #d9b24b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

header {
  padding: 24px 32px 12px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

header p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

nav {
  display: flex;
  gap: 4px;
  padding: 16px 32px 0;
}

nav button {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font-size: 14px;
}

nav button.active {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}

main {
  padding: 24px 32px 64px;
  max-width: 980px;
}

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

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.hidden { display: none !important; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 12px 0 4px;
}

label:first-of-type { margin-top: 0; }

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 56px; }

input[type="file"] {
  color: var(--text-dim);
  font-size: 13px;
}

button.primary {
  background: var(--accent);
  color: #1a1206;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
}

button.primary:hover { background: var(--accent-2); }
button.primary:disabled { opacity: 0.5; cursor: default; }

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

button.danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.row { display: flex; gap: 16px; }
.row > * { flex: 1; }

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.char-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.char-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.char-card .name { padding: 8px; font-size: 13px; font-weight: 600; }
.char-card .del { position: absolute; top: 6px; right: 6px; }

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

.scene-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.pending { background: #2a2f3a; color: var(--text-dim); }
.badge.generating, .badge.stitching { background: #3a3220; color: var(--yellow); }
.badge.done { background: #1d3328; color: var(--green); }
.badge.failed { background: #3a2222; color: var(--red); }
.badge.scenes_ready { background: #2a2f3a; color: var(--text-dim); }

.episode-card { margin-bottom: 16px; }
.episode-card .idea { font-weight: 600; margin-bottom: 4px; }
.episode-card .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 10px; }
.episode-card video { width: 100%; max-width: 360px; border-radius: 8px; display: block; margin-top: 10px; }

.error-text { color: var(--red); font-size: 13px; margin-top: 8px; }
.hint { color: var(--text-dim); font-size: 12px; margin-top: 10px; }
a { color: var(--accent); }
