:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --panel: #17181d;
  --panel-2: #202126;
  --border: #333640;
  --text: #f5f6f8;
  --muted: #9ca3af;
  --orange: #ff7a00;
  --orange-2: #ffae00;
  --green: #16a34a;
  --red: #ef4444;
  --blue: #38bdf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #111217;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--orange);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
}

.brand-sub, .muted {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: var(--orange);
  color: #fff;
}

.user-card {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.user-name {
  margin: 8px 0 4px;
  font-weight: 700;
}

.main {
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions, .actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.panel.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fed7aa;
  background: rgba(255, 122, 0, 0.15);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: #d1d5db;
  font-size: 13px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: #111217;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus, textarea:focus {
  border-color: var(--orange);
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  color: #fff;
  cursor: pointer;
  background: var(--panel-2);
}

.btn.primary {
  background: linear-gradient(90deg, var(--orange), var(--orange-2));
  color: #111;
  font-weight: 700;
}

.btn.secondary {
  border: 1px solid var(--border);
  background: #22242b;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.upload-box {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.asset-grid.empty, .task-list.empty {
  display: block;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 22px;
}

.asset {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111217;
  aspect-ratio: 1;
}

.asset img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  color: #d1d5db;
  background: #22242b;
  cursor: pointer;
}

.tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #111;
  font-weight: 700;
}

.form-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #131419;
  padding: 18px;
}

.json-preview {
  white-space: pre-wrap;
  margin: 16px 0 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #dbeafe;
  background: #0f172a;
}

.json-preview.hidden, .toast.hidden {
  display: none;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #131419;
  padding: 16px;
}

.task-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.task-title {
  font-weight: 800;
}

.status {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: #2b2d34;
  color: #d1d5db;
}

.status.completed { background: rgba(22, 163, 74, .2); color: #86efac; }
.status.failed { background: rgba(239, 68, 68, .2); color: #fecaca; }
.status.processing { background: rgba(56, 189, 248, .16); color: #bae6fd; }

.progress {
  height: 8px;
  border-radius: 999px;
  background: #272a31;
  overflow: hidden;
  margin: 12px 0 8px;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-2));
  width: 0;
}

.result-media {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  gap: 12px;
  margin-top: 12px;
}

.result-media img, .result-media video {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 8px;
  background: #0b0c0f;
  border: 1px solid var(--border);
}

.task-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.task-links a {
  color: #fdba74;
  text-decoration: none;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  top: 22px;
  max-width: 440px;
  padding: 13px 16px;
  border-radius: 8px;
  background: #26212b;
  border: 1px solid #7c2d12;
  color: #fff;
  box-shadow: 0 12px 38px rgba(0,0,0,.35);
  z-index: 100;
}

@media (max-width: 1280px) {
  body { min-width: 1024px; }
  .asset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
