:root {
  --bg: #0f1115;
  --card: #181b22;
  --card2: #1f232c;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #6c8cff;
  --accent2: #4cd2a0;
  --danger: #ff6b6b;
  --border: #2a2f3a;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.wrap { max-width: 920px; margin: 0 auto; padding: 28px 18px 80px; }

.topbar { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; font-size: .85rem; }
.topbar-right a { color: var(--accent); text-decoration: none; margin-left: 14px; }
.topbar-right a:hover { text-decoration: underline; }

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 18px; text-align: center; }
.login-wrap form { text-align: left; margin-top: 18px; }
.login-wrap button { width: 100%; margin-top: 8px; }

header h1 { margin: 0 0 4px; font-size: 1.7rem; }
.sub { color: var(--muted); margin: 0 0 20px; }

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

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
label.grow { flex: 1; }

textarea, input[type=file], select, input[type=range] {
  width: 100%;
  margin-top: 6px;
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}
input[type=range] { padding: 6px 0; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 200px; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.hint { color: var(--muted); font-size: .85rem; }

.banner {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: rgba(255, 107, 107, .12);
  border: 1px solid var(--danger);
  color: #ffd2d2;
}
.banner.ok { background: rgba(76, 210, 160, .1); border-color: var(--accent2); color: #c9f5e4; }

.hidden { display: none; }

/* stage tracker */
.stages { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stage {
  font-size: .78rem; padding: 5px 12px; border-radius: 20px;
  background: var(--card2); color: var(--muted); border: 1px solid var(--border);
}
.stage.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.stage.done { background: rgba(76,210,160,.15); color: var(--accent2); border-color: var(--accent2); }

/* storyboard */
.storyboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.beat {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.beat .thumb {
  aspect-ratio: 16/9; background: #0c0e12;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .8rem;
}
.beat.vert .thumb { aspect-ratio: 9/16; }
.beat .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.beat .meta { padding: 10px 12px; }
.beat .tc { font-size: .75rem; color: var(--accent2); font-weight: 600; }
.beat .pr { font-size: .8rem; color: var(--text); margin-top: 4px; max-height: 4.2em; overflow: hidden; }
.beat .err { color: var(--danger); font-size: .78rem; margin-top: 4px; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

video { width: 100%; border-radius: 10px; background: #000; margin-bottom: 14px; }

.muted { color: var(--muted); font-weight: 400; font-size: .82em; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
label.check input { width: auto; margin: 0; }

.beat .tc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: .68rem; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
  background: rgba(108,140,255,.18); color: var(--accent); border: 1px solid var(--accent);
}
.beat .pr-edit {
  width: 100%; margin-top: 8px; resize: vertical;
  background: #0c0e12; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 8px; font: inherit; font-size: .8rem; line-height: 1.35;
}
.beat .regen {
  margin-top: 8px; width: 100%; padding: 7px 10px; font-size: .82rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--accent);
}
.beat .regen:hover:not(:disabled) { background: var(--accent); color: #fff; }

#videoBlock { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }

.history { display: flex; flex-direction: column; gap: 10px; }
.hist-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.hist-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; background: #0c0e12; }
.hist-meta { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; font-size: .9rem; }
.btn.small { padding: 7px 12px; font-size: .82rem; }
code { background: var(--card2); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
