:root {
  color-scheme: light;
  --bg: #eef3f8;
  --bg-soft: #f7faff;
  --panel: #ffffff;
  --panel-2: #f8fbff;
  --text: #102033;
  --muted: #64748b;
  --line: #dce5f1;
  --line-strong: #c5d2e4;
  --blue: #2563eb;
  --blue-strong: #1557d6;
  --blue-soft: #eaf2ff;
  --green: #16a36a;
  --green-soft: #e9f8f0;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --amber: #d97706;
  --amber-soft: #fff7e6;
  --slate-soft: #f1f5f9;
  --shadow: 0 18px 42px rgba(20, 40, 80, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 1180px;
  background:
    linear-gradient(180deg, #f8fbff 0, #eef3f8 360px),
    var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1500px, calc(100vw - 40px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2f7dff, #1357e8);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand-copy strong {
  font-size: 20px;
  line-height: 1.2;
}

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

.main-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
}

.main-nav a {
  min-width: 78px;
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #4a5870;
  font-weight: 700;
  border: 1px solid transparent;
}

.main-nav a:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.main-nav a.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #c9ddff;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.account-bar {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.account-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  white-space: nowrap;
}

.account-pill strong {
  color: #0f1f33;
}

.account-pill.credit strong {
  color: var(--blue);
}

.pill-icon {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.workspace {
  width: min(1500px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 22px 0 44px;
  display: grid;
  grid-template-columns: 286px minmax(610px, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.left-rail,
.center-stage,
.right-rail {
  display: grid;
  gap: 18px;
}

.right-rail {
  position: sticky;
  top: 92px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 64px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.panel-body {
  padding: 18px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

.field span,
.range-label span {
  color: #233148;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="range"] {
  height: 22px;
  padding: 0;
  accent-color: var(--blue);
}

.btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.btn.primary {
  background: linear-gradient(135deg, #0f8ab8, var(--blue));
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #0d789f, var(--blue-strong));
}

.btn.soft,
.btn.ghost,
.btn.icon-btn,
.btn.outline {
  color: #1f2d44;
  background: #fff;
  border-color: var(--line);
}

.btn.soft:hover,
.btn.ghost:hover,
.btn.icon-btn:hover,
.btn.outline:hover {
  border-color: #b9c8db;
  background: var(--panel-2);
}

.btn.outline {
  color: var(--blue);
  border-color: #b9d0ff;
}

.btn-symbol {
  font-size: 12px;
}

.is-loading .refresh-symbol,
.btn.is-loading .btn-symbol {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.button-row,
.action-row,
.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.head-actions {
  color: var(--muted);
  font-size: 13px;
}

.status-bar {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--slate-soft);
  color: #475569;
  line-height: 1.45;
}

.status-bar.success {
  background: var(--green-soft);
  border-color: #a8e3c3;
  color: #0f7b50;
}

.status-bar.processing {
  background: var(--blue-soft);
  border-color: #bcd3ff;
  color: #1d4ed8;
}

.status-bar.warning {
  background: var(--amber-soft);
  border-color: #ffd98f;
  color: #a15c00;
}

.status-bar.error {
  background: var(--red-soft);
  border-color: #ffc1c1;
  color: #b91c1c;
}

.queue-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.queue-stat {
  min-height: 92px;
  padding: 14px 14px 12px;
  display: grid;
  align-content: start;
  gap: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.queue-stat:nth-child(2n) {
  border-right: 0;
}

.queue-stat.wide {
  grid-column: span 2;
  border-bottom: 0;
}

.queue-stat span:not(.mini-icon) {
  color: var(--muted);
  font-size: 13px;
}

.queue-stat strong {
  color: #0d1b2f;
  font-size: 28px;
  line-height: 1;
}

.mini-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.mini-icon.blue { background: var(--blue-soft); color: var(--blue); }
.mini-icon.green { background: var(--green-soft); color: var(--green); }
.mini-icon.amber { background: var(--amber-soft); color: var(--amber); }
.mini-icon.slate { background: var(--slate-soft); color: #526075; }

.guide-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.guide-steps li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
}

.guide-steps li > span {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.guide-steps strong {
  display: block;
  margin-bottom: 4px;
}

.guide-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tip-box {
  margin-top: 18px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ffd98f;
  background: var(--amber-soft);
  color: #8a5203;
  line-height: 1.5;
}

.cost-note {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.upload-card {
  position: relative;
  display: grid;
  gap: 12px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-control {
  min-height: 70px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  cursor: pointer;
}

.upload-control:hover {
  border-color: #aac4ed;
  background: var(--panel-2);
}

.upload-icon,
.source-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #071529;
  color: #79ffe3;
  font-weight: 800;
  font-size: 13px;
}

.upload-control strong {
  display: block;
  margin-bottom: 5px;
}

.upload-control small {
  display: block;
  max-width: 220px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-control em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.upload-card.uploaded .upload-control {
  border-color: #9ddfbb;
  background: #fbfffc;
}

.upload-card.uploaded .upload-control em {
  color: var(--green);
}

.clear-media {
  position: absolute;
  top: 84px;
  right: 10px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #26364e;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.media-preview {
  position: relative;
  height: 260px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #081527;
  color: #cbd5e1;
}

.media-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
  pointer-events: none;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #081527;
  display: block;
}

.media-preview img:not([src]),
.media-preview video:not([src]) {
  display: none;
}

.preview-empty {
  position: relative;
  z-index: 1;
  color: #d8e0eb;
}

.media-meta {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 16px;
  align-items: end;
}

.range-field {
  display: grid;
  gap: 8px;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-label strong {
  color: var(--blue);
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.action-row {
  margin-top: 18px;
}

.submit-btn {
  min-width: 132px;
}

.recent-panel .panel-body {
  padding-top: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.task-table th,
.task-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.task-table th {
  color: #506176;
  font-weight: 800;
  background: #f8fbff;
}

.task-table tbody tr.selected {
  background: #f1f6ff;
  outline: 1px solid #b9d0ff;
  outline-offset: -1px;
}

.task-table tbody tr[data-row-task] {
  cursor: pointer;
}

.task-table tbody tr[data-row-task]:hover {
  background: #f8fbff;
}

.task-link,
.table-action,
.text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

.table-action {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.table-action:hover {
  border-color: #b9d0ff;
  background: var(--blue-soft);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: currentColor;
}

.status-badge.success { color: var(--green); }
.status-badge.failed { color: var(--red); }
.status-badge.processing { color: var(--blue); }
.status-badge.queued { color: var(--amber); }
.status-badge.neutral { color: var(--muted); }

.table-error {
  margin-top: 5px;
  color: var(--red);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-row td {
  padding: 0 10px 12px;
}

.error-summary {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  border: 1px solid #ffc1c1;
  border-radius: 8px;
  padding: 12px;
  background: var(--red-soft);
  color: #991b1b;
}

.error-summary pre,
.error-detail pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #7f1d1d;
  font-size: 12px;
  line-height: 1.45;
}

.empty-cell {
  height: 112px;
  text-align: center !important;
  color: var(--muted);
}

.pagination {
  min-height: 38px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pagination button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.pagination button.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ellipsis {
  padding: 0 4px;
}

.result-player {
  position: relative;
  height: 470px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #071225;
  color: #d7e1ee;
}

.result-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #071225;
}

.result-player video:not([src]) {
  display: none;
}

.result-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.result-empty strong {
  font-size: 18px;
}

.result-empty span {
  color: #b9c6d8;
}

.result-open {
  width: 100%;
  margin-top: 14px;
}

.info-grid {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.info-grid div {
  min-height: 70px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.info-grid div:nth-child(3n) {
  border-right: 0;
}

.info-grid div:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.info-grid span {
  color: var(--muted);
  font-size: 12px;
}

.info-grid strong {
  font-size: 13px;
  line-height: 1.35;
}

.source-box {
  margin-top: 16px;
}

.source-box h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.source-list > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
}

.source-thumb {
  width: 42px;
  height: 42px;
  font-size: 12px;
}

.source-list p {
  min-width: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

.source-list small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-detail {
  margin-top: 16px;
  border: 1px solid #ffc1c1;
  border-radius: 8px;
  padding: 12px;
  background: var(--red-soft);
  color: #991b1b;
}

.error-detail > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 1320px) {
  body {
    min-width: 0;
  }

  .header-inner,
  .workspace {
    width: min(1180px, calc(100vw - 28px));
  }

  .workspace {
    grid-template-columns: 270px minmax(560px, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    position: static;
  }

  .result-panel .panel-body {
    display: grid;
    grid-template-columns: 390px 1fr;
    gap: 16px;
    align-items: start;
  }

  .result-open,
  .info-grid,
  .source-box,
  .error-detail {
    margin-top: 0;
  }
}

@media (max-width: 980px) {
  .app-header {
    height: auto;
    position: static;
  }

  .header-inner {
    grid-template-columns: 1fr;
    padding: 12px 0;
  }

  .main-nav,
  .account-bar {
    justify-self: start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .upload-grid,
  .settings-grid,
  .result-panel .panel-body {
    grid-template-columns: 1fr;
  }
}
