:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #0b1220;
  --sidebar-soft: #101b2f;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #155eef;
  --primary-dark: #004eeb;
  --danger: #d92d20;
  --warning: #f79009;
  --success: #079455;
  --shadow: 0 18px 48px rgba(16, 24, 40, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(21, 94, 239, .10), transparent 26%),
    radial-gradient(circle at 8% 90%, rgba(7, 148, 85, .08), transparent 28%),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button { border: 0; }
code {
  padding: 2px 6px;
  border-radius: 7px;
  background: #eef4ff;
  color: #1849a9;
  font-size: .92em;
}

.app-frame {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(21, 94, 239, .22), transparent 38%),
    var(--sidebar);
  border-right: 1px solid rgba(255,255,255,.08);
}
.logo-block {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}
.logo-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #155eef, #0ba5ec);
  box-shadow: 0 12px 32px rgba(21, 94, 239, .35);
  font-weight: 900;
}
.logo-block strong { display: block; font-size: 17px; }
.logo-block span { color: rgba(255,255,255,.58); font-size: 13px; }
.nav-list { display: grid; gap: 8px; }
.nav-list a {
  color: rgba(255,255,255,.72);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 14px;
  transition: .16s ease;
}
.nav-list a:hover, .nav-list a.active {
  color: #fff;
  background: rgba(255,255,255,.10);
}
.sidebar-card {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 24px;
  padding: 18px;
  border-radius: 18px;
  background: var(--sidebar-soft);
  border: 1px solid rgba(255,255,255,.08);
}
.sidebar-card span, .sidebar-card small {
  display: block;
  color: rgba(255,255,255,.55);
}
.sidebar-card strong {
  display: block;
  margin: 6px 0;
  font-size: 24px;
}
.workspace {
  width: min(1440px, 100%);
  padding: 32px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}
.eyebrow, .section-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: -.035em;
}
h2 { margin-bottom: 0; font-size: 22px; }
.topbar p, .hint, .deploy-notes p { color: var(--muted); line-height: 1.7; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.metric-card, .panel {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.metric-card {
  padding: 18px;
  border-radius: 20px;
}
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong {
  display: block;
  margin: 7px 0 4px;
  font-size: 20px;
}
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(420px, .88fr);
  gap: 18px;
  align-items: start;
}
.panel { border-radius: var(--radius); }
.generator-panel, .result-panel, .config-panel { padding: 24px; }
.config-panel { margin-top: 18px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head.slim { margin-bottom: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1849a9;
  font-size: 12px;
  font-weight: 800;
}
.badge.muted { color: #475467; background: #f2f4f7; }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.upload-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
}
.upload-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}
.upload-head span { color: var(--muted); font-size: 12px; }
.drop-zone {
  position: relative;
  min-height: 210px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1.5px dashed #b2ccff;
  border-radius: 18px;
  background: linear-gradient(180deg, #f5f8ff, #ffffff);
  cursor: pointer;
  transition: .16s ease;
}
.drop-zone.dragover, .drop-zone:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(21, 94, 239, .08);
}
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.drop-placeholder {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 18px;
}
.drop-placeholder b { display: block; margin-bottom: 6px; color: #1849a9; }
.drop-placeholder small { color: var(--muted); }
.field { display: block; margin-bottom: 16px; }
.field.compact { margin: 12px 0 0; }
.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}
.field em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
}
input, textarea, select {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 12px 13px;
  font-size: 14px;
  transition: .16s ease;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: #84adff;
  box-shadow: 0 0 0 4px rgba(21, 94, 239, .10);
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 18px;
}
.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-weight: 700;
}
.switch-line input { width: auto; }
.advanced-box {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fcfcfd;
}
.advanced-box summary {
  cursor: pointer;
  font-weight: 800;
  color: #344054;
}
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 14px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, background .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .64; cursor: not-allowed; }
.btn.primary {
  width: 100%;
  min-height: 48px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #0ba5ec);
  box-shadow: 0 14px 32px rgba(21, 94, 239, .25);
}
.btn.ghost {
  min-height: 40px;
  padding: 0 14px;
  color: #344054;
  background: #fff;
  border: 1px solid var(--line);
}
.btn.danger-soft {
  min-height: 40px;
  padding: 0 14px;
  color: var(--danger);
  background: #fff5f5;
  border: 1px solid #fecaca;
}
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.error-box {
  margin-top: 14px;
  padding: 12px 14px;
  white-space: pre-wrap;
  border-radius: 16px;
  border: 1px solid #fecdca;
  color: #b42318;
  background: #fffbfa;
}
.hint { margin-bottom: 16px; }
.task-list { display: grid; gap: 14px; }
.empty-state {
  padding: 52px 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #d0d5dd;
  border-radius: 18px;
  background: #fcfcfd;
}
.task-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}
.task-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.task-title-row {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.task-thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f2f4f7;
  flex-shrink: 0;
}
.task-id {
  display: block;
  margin-bottom: 6px;
  word-break: break-all;
  font-size: 14px;
}
.task-prompt {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  color: #1849a9;
  background: #eef4ff;
}
.task-status.completed, .task-status.success, .task-status.succeed { color: #067647; background: #ecfdf3; }
.task-status.failed, .task-status.error { color: #b42318; background: #fef3f2; }
.task-status.processing, .task-status.submitting, .task-status.submitted, .task-status.pending { color: #b54708; background: #fffaeb; }
.progress-wrap {
  height: 8px;
  margin: 14px 0 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #eaecf0;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #0ba5ec);
  transition: width .25s ease;
}
.task-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.video-wrap { margin-top: 14px; }
.video-wrap video {
  width: 100%;
  max-height: 360px;
  border-radius: 16px;
  background: #000;
}
.video-wrap a {
  display: inline-block;
  margin-top: 8px;
  color: #175cd3;
  text-decoration: none;
  font-weight: 800;
}
.raw-json {
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  background: #101828;
  color: #d0d5dd;
  font-size: 12px;
}
.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.deploy-notes {
  display: grid;
  gap: 4px;
}
.deploy-notes p { margin-bottom: 0; }

@media (max-width: 1180px) {
  .app-frame { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }
  .nav-list { display: flex; flex-wrap: wrap; }
  .sidebar-card { position: static; min-width: 220px; }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .workspace { padding: 22px 14px; }
  .topbar, .section-head, .sidebar { flex-direction: column; }
  .metrics-grid, .upload-grid, .control-grid, .advanced-grid { grid-template-columns: 1fr; }
  .sidebar-card { width: 100%; }
}
@media (max-width: 560px) {
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
  .task-head { flex-direction: column; }
  .task-actions { flex-wrap: wrap; }
}
