/* ---------------- 主题变量 ---------------- */
:root[data-theme='dark'] {
  --bg: #0b0e14;
  --bg-soft: #131a26;
  --card: #151b27;
  --surface: #0e131c;
  --line: #232c3d;
  --text: #e6ebf5;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --topbar: rgba(11, 14, 20, 0.78);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.22);
  --glow: rgba(99, 102, 241, 0.16);
  --code-bg: rgba(255, 255, 255, 0.06);
}

:root[data-theme='light'] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --surface: #f8fafc;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #0891b2;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --topbar: rgba(255, 255, 255, 0.82);
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.06);
  --glow: rgba(79, 70, 229, 0.14);
  --code-bg: rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  font-size: 14px;
  transition: background 0.25s ease, color 0.25s ease;
}

:root[data-theme='dark'] body {
  background-image: radial-gradient(1100px 560px at 82% -12%, #1e2a44 0%, transparent 62%);
}

:root[data-theme='light'] body {
  background-image: radial-gradient(1100px 560px at 82% -12%, #e5ecff 0%, transparent 62%);
}

/* ---------------- 顶部导航栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.logo {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.32);
}

.brand-text {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover {
  color: var(--text);
  background: var(--code-bg);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

.topright {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: 0.18s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun {
  display: none;
}

:root[data-theme='light'] .icon-sun {
  display: block;
}

:root[data-theme='light'] .icon-moon {
  display: none;
}

/* ---------------- 页面容器 ---------------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 22px 64px;
}

.page {
  display: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.page.active {
  display: grid;
  animation: pageIn 0.26s ease;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------- 卡片 ---------------- */
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px 20px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.step {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------------- 布局 ---------------- */
.grid-2,
.grid-3 {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
}

.field.switch,
.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

/* ---------------- 表单控件 ---------------- */
input,
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

input[readonly] {
  color: var(--muted);
}

input[type='file'] {
  padding: 8px 10px;
  cursor: pointer;
}

input[type='checkbox'] {
  width: auto;
  accent-color: var(--accent);
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: 0.16s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: transparent;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.28);
}

.btn.ghost {
  background: transparent;
}

.row-end {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

/* ---------------- 标签 / 提示 ---------------- */
.chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}

.chip-ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}

.chip-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.chip-err {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 45%, transparent);
}

.chip-run {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
}

.hintbox {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

code {
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 11.5px;
}

.tip {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 10px;
}

/* ---------------- 映射表 ---------------- */
.mapping {
  display: grid;
  gap: 8px;
}

.mapping-head,
.mapping-row {
  display: grid;
  grid-template-columns: 170px 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.mapping-head {
  color: var(--muted);
  font-size: 11.5px;
  padding: 0 12px;
}

.mapping-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  transition: border-color 0.16s ease;
}

.mapping-row:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.mapping-row .label {
  color: var(--text);
  font-size: 13px;
}

.mapping-row .label small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* ---------------- 结果 / 任务 ---------------- */
.result {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.result video {
  width: 100%;
  max-width: 560px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #000;
}

.bar {
  height: 8px;
  min-width: 120px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.warnbar {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------------- 拖拽上传区 ---------------- */
.uploads {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 14px 0 2px;
}

.drop {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 156px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: 0.18s ease;
}

.drop:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.drop.over {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 0 0 3px var(--glow);
}

.drop-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

.drop-title small {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.drop-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  align-content: flex-start;
}

.drop-preview:empty {
  display: none;
}

.thumb {
  position: relative;
  width: 62px;
  height: 62px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .n {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 10px;
}

.thumb .x,
.file-chip .x {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.file-chip {
  position: relative;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 26px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  font-size: 11.5px;
  color: var(--muted);
}

.file-chip b {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}

.drop-hint {
  padding-top: 2px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
}

.hidden-file {
  display: none;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------------- 任务宫格 ---------------- */
.jobs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(246px, 1fr));
  gap: 14px;
}

.job {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.job:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  transform: translateY(-2px);
}

.job-media {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.job-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.job-media .ph {
  color: var(--muted);
  font-size: 12px;
}

.job-title {
  font-size: 12.5px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-sub {
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.job-status .bar {
  flex: 1;
  min-width: 0;
}

.job-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.job-actions .btn {
  padding: 7px 12px;
}

.empty {
  color: var(--muted);
  font-size: 12.5px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

/* ---------------- 预览模态框 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.modal[hidden] {
  display: none;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}

.modal-box {
  position: relative;
  max-width: min(960px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  animation: zoomIn 0.2s ease;
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.modal-x:hover {
  color: var(--text);
  border-color: var(--accent);
}

.modal-title {
  padding-right: 40px;
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  display: grid;
  place-items: center;
  min-height: 120px;
  overflow: auto;
}

.modal-body img {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.modal-body video {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 12px;
  background: #000;
}

.modal-body audio {
  width: min(520px, 80vw);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------- 文档页 ---------------- */
[hidden] {
  display: none !important;
}

.docs-picker {
  width: auto;
  min-width: 180px;
  padding: 7px 10px;
}

.docs {
  font-size: 13px;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.docs h1,
.docs h2,
.docs h3,
.docs h4 {
  margin: 20px 0 8px;
  line-height: 1.35;
}

.docs h1 {
  font-size: 19px;
}

.docs h2 {
  font-size: 16.5px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.docs h3 {
  font-size: 14.5px;
}

.docs h4 {
  font-size: 13.5px;
  color: var(--muted);
}

.docs p {
  margin: 8px 0;
}

.docs ul,
.docs ol {
  margin: 8px 0;
  padding-left: 22px;
}

.docs li {
  margin: 3px 0;
}

.docs a {
  color: var(--accent-2);
}

.docs blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  color: var(--muted);
}

.docs hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 16px 0;
}

.docs pre.md-code {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.docs pre.md-code code {
  padding: 0;
  border: 0;
  background: none;
  font-family: ui-monospace, Consolas, 'Cascadia Code', monospace;
  font-size: 12px;
  white-space: pre;
}

.md-table {
  margin: 10px 0;
  overflow-x: auto;
}

.docs table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.docs th,
.docs td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
}

.docs th {
  background: var(--surface);
  font-weight: 650;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 980px) {
  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 860px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .mapping-head,
  .mapping-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .mapping-head {
    display: none;
  }

  .uploads {
    grid-template-columns: minmax(0, 1fr);
  }

  .jobs {
    grid-template-columns: minmax(0, 1fr);
  }
}
