:root {
  --bg: #100e0b;
  --bg-2: #17140f;
  --elev: #1c1812;
  --elev-2: #241f17;
  --line: rgba(236, 214, 176, 0.12);
  --ink: #f4eadc;
  --muted: #9b8f7c;
  --faint: #6d6456;
  --accent: #e08a3c;
  --ok: #8fbf7a;
  --warn: #d4a45a;
  --bad: #d46a6a;
  --serif: "Fraunces", "Songti SC", serif;
  --sans: "Outfit", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(224, 138, 60, 0.16), transparent 55%),
    radial-gradient(900px 500px at 110% 0%, rgba(126, 184, 164, 0.1), transparent 50%),
    var(--bg);
  letter-spacing: 0.01em;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  z-index: 50;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(16, 14, 11, 0.72);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(145deg, #e08a3c, #8b4330);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 640;
}
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
}
.nav a.active, .nav a:hover { background: var(--elev); color: var(--ink); }
.rail-foot {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--elev);
}
.rail-foot .label { color: var(--muted); font-size: 12px; }
.rail-foot strong { display: block; margin-top: 4px; font-size: 20px; font-family: var(--serif); }

.main { padding: 32px 40px 64px; max-width: 1280px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 28px;
}
.page-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.03em;
}
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 46ch; }

.btn {
  border: 0;
  background: var(--accent);
  color: #1a110a;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stats.stats-3 { grid-template-columns: 1.2fr 1fr 1fr; }
.key-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.key-box {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #2a241c;
  font-size: 12px;
  word-break: break-all;
}
.code-wrap { margin-top: 14px; }
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.code {
  margin: 0;
  background: #2a241c;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.stat {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 18px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v {
  margin-top: 10px;
  font-family: var(--serif);
  font-size: 32px;
  letter-spacing: -0.03em;
}
.stat .s { margin-top: 6px; color: var(--faint); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: var(--bg-2);
}
.row > div:first-child { min-width: 0; overflow: hidden; }
.row .t {
  margin: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .m { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .m.err { color: var(--bad); white-space: nowrap; }
.task-list { max-width: 100%; }
.task-row .task-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.Queuing, .pill.PENDING { color: var(--warn); }
.pill.Executing, .pill.Processing { color: var(--accent); }
.pill.Finished, .pill.Success { color: var(--ok); }
.pill.Fail, .pill.Failed { color: var(--bad); }
.pill.Executing i, .pill.Processing i, .pill.Queuing i { animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.form-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; }
label.field { display: block; }
label.field span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
input, textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
textarea { min-height: 168px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(224,138,60,.5); }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button, .choice {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
}
.seg button.on, .choice.on {
  border-color: var(--accent);
  background: rgba(224, 138, 60, 0.12);
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.warn { color: var(--bad); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.choice b { display: block; }
.choice small { color: var(--muted); }
.ref-chip.on { outline: 2px solid var(--accent); }
.dur-row { display: flex; gap: 10px; align-items: center; }
.dur-row input[type="number"] { width: 96px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
table.ledger { width: 100%; border-collapse: collapse; }
table.ledger th, table.ledger td {
  text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 13px;
}
table.ledger th { color: var(--muted); font-weight: 500; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  background: #3a3329;
  position: relative;
}
.switch.on { background: var(--accent); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  transition: left 0.15s ease;
}
.switch.on::after { left: 21px; }

.cost-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: #2a2016;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.cost-box strong { font-family: var(--serif); font-size: 34px; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.error { color: var(--bad); font-size: 13px; }
.okmsg { color: var(--ok); font-size: 13px; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
}
.filters button.on { color: var(--ink); background: var(--elev); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.media-card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.media-card .poster, .media-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #2a241c;
}
.media-card .poster {
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 12px;
}
.media-card .body { padding: 12px 14px 14px; }
.media-card h4 { margin: 0; font-size: 14px; word-break: break-all; }
.media-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.media-card.pick { cursor: pointer; }
.media-card.pick.on { outline: 2px solid var(--accent); }

.choice-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.choice-row .choice { flex: 1; }
.ref-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ref-chip-wrap {
  position: relative;
  width: 76px;
  height: 76px;
}
.ref-x {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 2;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #2a2016;
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}
.ref-chip {
  width: 76px; height: 76px; padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #2a241c;
}
.ref-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.task-card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.task-card .stage {
  aspect-ratio: 16/9;
  background: #090807;
  display: grid;
  place-items: center;
  color: var(--faint);
  position: relative;
}
.task-card video, .task-card .stage img { width: 100%; height: 100%; object-fit: cover; }
.task-card .body { padding: 14px; }
.task-card h4 { margin: 8px 0 0; font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-card .meta { margin-top: 8px; color: var(--muted); font-size: 12px; }

.player { position: relative; border-radius: 20px; overflow: hidden; background: #090807; aspect-ratio: 16/9; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8,6,4,.72);
  display: grid; place-items: center;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-card { width: min(920px, 100%); }
.modal-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }

.banner {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #2a2016;
  color: var(--warn);
  font-size: 13px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; }
  .stats, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .main { padding: 20px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .page-head h2 { font-size: 28px; }
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(28, 24, 18, 0.92);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-err { color: var(--bad); font-size: 13px; margin: 10px 0 0; }
.hidden { display: none; }
