:root {
  --bg: #080d18;
  --bg-card: #101829;
  --bg-panel: #152036;
  --bg-input: #0b1220;
  --border: rgba(148, 184, 226, 0.16);
  --border-gold: rgba(245, 208, 138, 0.45);
  --text: #edf3fc;
  --muted: #93a6c4;
  --gold: #f5d08a;
  --gold-strong: #ffd257;
  --cyan: #38bdf8;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(circle at 20% 0%, #12203a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 22px;
  background: rgba(8, 13, 24, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #ffe5a3, #e0a94b);
  box-shadow: 0 0 12px rgba(245, 208, 138, 0.85);
}
.brand-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(245, 208, 138, 0.16); color: var(--gold); border: 1px solid var(--border-gold);
}
.top-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.credit-pill {
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(52, 211, 153, 0.12); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.35);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: rgba(245, 208, 138, 0.5); background: #1a2944; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #f5c96b, #d89b32);
  color: #09101d; border-color: transparent; font-weight: 800;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); background: linear-gradient(135deg, #ffd67a, #e2a53c); }
.btn-cyan {
  background: rgba(56, 189, 248, 0.16); color: #bae6fd; border-color: rgba(56, 189, 248, 0.45);
}
.btn-cyan:hover:not(:disabled) { background: rgba(56, 189, 248, 0.25); }
.btn-danger { background: rgba(248, 113, 113, 0.14); color: #fecaca; border-color: rgba(248, 113, 113, 0.35); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 76px; }
label.lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

/* Login Overlay */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px; padding: 30px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(16, 24, 41, 0.96), rgba(11, 17, 30, 0.96));
  border: 1px solid var(--border-gold);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.login-card h1 { font-size: 21px; margin-bottom: 6px; }
.login-card p { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* Main Layout */
.layout { display: grid; grid-template-columns: 256px 1fr; min-height: calc(100vh - 57px); }
.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.72);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 12px;
}
.proj-item {
  padding: 10px 12px; border-radius: 12px; border: 1px solid transparent;
  background: rgba(21, 32, 54, 0.55); cursor: pointer; transition: all 0.15s;
}
.proj-item:hover { border-color: var(--border); background: rgba(26, 41, 68, 0.75); }
.proj-item.active { border-color: var(--border-gold); background: rgba(245, 208, 138, 0.1); }
.proj-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.proj-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-gold { background: rgba(245, 208, 138, 0.18); color: var(--gold); }
.badge-green { background: rgba(52, 211, 153, 0.16); color: var(--green); }
.badge-amber { background: rgba(251, 191, 36, 0.18); color: var(--amber); }
.badge-red { background: rgba(248, 113, 113, 0.18); color: var(--red); }
.badge-cyan { background: rgba(56, 189, 248, 0.16); color: var(--cyan); }

/* Workspace */
.main { padding: 20px 26px 60px; max-width: 1360px; width: 100%; }

/* Stepper */
.stepper {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 20px;
}
.step-tab {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-card); cursor: pointer; text-align: left; transition: all 0.15s;
}
.step-tab:hover { border-color: rgba(245, 208, 138, 0.45); }
.step-tab.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(245, 208, 138, 0.16), rgba(56, 189, 248, 0.08));
}
.step-num { font-size: 11px; color: var(--gold); font-weight: 800; letter-spacing: 0.4px; }
.step-name { font-size: 13px; font-weight: 700; margin-top: 2px; color: var(--text); }

/* Cards & Grids */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 16px; font-weight: 800; }
.card-head p { font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field { margin-bottom: 12px; }

/* Media Previews */
.thumb-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px; position: relative;
}
.thumb-card.selected { border-color: var(--gold-strong); box-shadow: 0 0 0 2px rgba(255, 210, 87, 0.25); }
.thumb-img {
  width: 100%; height: 150px; object-fit: contain; border-radius: 8px; background: #070b14;
}
.video-box {
  width: 100%; max-height: 300px; border-radius: 10px; background: #000;
}

/* Segment Cards */
.seg-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.seg-card.warn { border-color: rgba(251, 191, 36, 0.65); }
.progress-bar {
  width: 100%; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08);
  overflow: hidden; margin: 8px 0;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, #38bdf8, #ffd257); transition: width 0.3s;
}

/* Subtitle Table */
.sub-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sub-table th, .sub-table td {
  padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle;
}
.sub-table th { color: var(--muted); font-size: 12px; font-weight: 700; }

/* Studio Iframe */
.studio-frame {
  width: 100%; height: 740px; border: 1px solid var(--border-gold);
  border-radius: 14px; background: #060911;
}

/* Log Box */
.log-box {
  background: #060a13; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: #a7f3d0; max-height: 220px; overflow-y: auto; white-space: pre-wrap;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(2, 6, 14, 0.78);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-gold); border-radius: 18px; padding: 22px;
}

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700;
  background: rgba(16, 24, 41, 0.96); border: 1px solid var(--gold);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
