:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-code: #f3f4f6;
  --line: #d8dee7;
  --line-strong: #b8c1ce;
  --ink: #111827;
  --muted: #4b5563;
  --faint: #6b7280;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #eff6ff;
  --green: #047857;
  --green-soft: #ecfdf5;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --radius: 6px;
  --mono: "Cascadia Mono", "Fira Code", Consolas, monospace;
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
label.target-option,
[data-drop-zone],
[data-file-trigger] {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #e5e7eb;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: #1f2937;
  color: #bfdbfe;
  font-family: var(--mono);
  font-weight: 800;
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-caption {
  margin-top: 3px;
  color: #9ca3af;
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav-link:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: #1f2937;
  color: #ffffff;
}

.nav-link.active {
  border-color: rgba(96, 165, 250, 0.35);
  background: #172554;
  color: #dbeafe;
}

.nav-link.disabled {
  cursor: default;
  opacity: 0.62;
}

.nav-link.disabled:hover {
  border-color: transparent;
  background: transparent;
  color: #cbd5e1;
}

.nav-link.with-hint {
  align-items: flex-start;
  min-height: 48px;
  padding-top: 7px;
}

.nav-hint {
  display: block;
  margin-top: 2px;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 500;
}

.nav-icon {
  position: relative;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.nav-icon.tasks::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 4px;
  height: 1.5px;
  background: currentColor;
  box-shadow: 0 3.5px 0 currentColor, 0 7px 0 currentColor;
}

.nav-icon.new::before,
.nav-icon.new::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 6px;
  height: 1.5px;
  background: currentColor;
}

.nav-icon.new::after {
  transform: rotate(90deg);
}

.nav-icon.detail::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: currentColor;
}

.nav-icon.settings::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 5px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.sidebar-note {
  margin: 18px 6px 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 18px 22px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.crumb {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.top-actions,
.row-actions,
.page-actions,
.config-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.language-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.language-switch button {
  min-width: 38px;
  height: 26px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.language-switch button.active {
  background: var(--ink);
  color: #ffffff;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.lead {
  margin: 6px 0 0;
  max-width: 900px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn.primary {
  border-color: var(--brand-strong);
  background: var(--brand);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn.ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.btn.soft {
  border-color: #bfdbfe;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.btn.danger {
  border-color: #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.readonly-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric,
.panel,
.config-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric {
  min-height: 78px;
  padding: 12px;
}

.metric-label,
.field-label,
.table th,
.kv-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.metric-value {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
}

.metric-note {
  margin-top: 4px;
  color: var(--green);
  font-size: 11px;
}

.metric-note.danger {
  color: var(--red);
}

.panel {
  padding: 12px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title {
  font-size: 14px;
  font-weight: 850;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table th {
  height: 32px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.table th:last-child,
.table td:last-child {
  text-align: right;
}

.table td {
  height: 58px;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
}

.table.compact {
  font-size: 11px;
}

.table.compact td {
  height: auto;
  padding: 7px 8px 7px 0;
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: 0;
}

.file-name,
.artifact-name,
.config-name,
.step-title {
  font-weight: 850;
}

.file-meta,
.artifact-meta,
.step-meta,
.small-muted {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.done {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.status.running {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--blue);
}

.status.partial,
.status.waiting {
  border-color: #fde68a;
  background: var(--amber-soft);
  color: var(--amber);
}

.status.failed {
  border-color: #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.status.idle {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.form-layout,
.detail-layout,
.settings-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

.form-layout {
  grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.05fr);
}

.drop-area {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.drop-area:hover,
.drop-area.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.drop-area.has-file {
  border-color: var(--green);
  background: var(--green-soft);
}

.upload-glyph {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
}

.drop-title {
  font-size: 16px;
  font-weight: 850;
}

.drop-copy {
  max-width: 400px;
  margin: 8px auto 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.upload-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--brand-strong);
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
}

.drop-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.selected-file {
  display: grid;
  gap: 3px;
  max-width: 430px;
  margin: 14px auto 0;
  padding: 9px 10px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  text-align: left;
}

.selected-file.empty {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.selected-file-name {
  color: var(--ink);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.selected-file-meta {
  color: var(--green);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.field input,
.field select {
  height: 34px;
  padding: 0 9px;
}

.field textarea {
  min-height: 82px;
  padding: 9px;
  resize: vertical;
  line-height: 1.45;
}

.target-options {
  display: grid;
  gap: 7px;
}

.target-option {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.target-option:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.target-option input {
  width: auto;
  height: auto;
  margin-top: 2px;
  accent-color: var(--brand);
}

.target-option strong,
.target-option small {
  display: block;
}

.target-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

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

.preset-card,
.generation-summary {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid #edf0f4;
}

.kv:first-of-type {
  border-top: 0;
}

.kv.compact {
  padding: 5px 0;
}

.kv-value {
  display: block;
  min-width: 0;
  padding: 5px 7px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: var(--surface-code);
  color: #1f2937;
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-confirm-panel {
  border-color: #f59e0b;
  background: #fffdf5;
}

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

.detail-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.progress-track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.pipeline {
  display: grid;
  gap: 10px;
}

.pipeline-branch {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.branch-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.branch-pills,
.branch-board {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.branch-board {
  margin-top: 10px;
}

.branch-card {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.branch-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 5px;
}

.branch-steps {
  display: grid;
  gap: 6px;
}

.step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.step-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--surface-code);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 900;
}

.step.done .step-index {
  background: var(--green);
  color: #ffffff;
}

.step.running .step-index {
  background: var(--blue);
  color: #ffffff;
}

.step.failed .step-index {
  background: var(--red);
  color: #ffffff;
}

.checkpoint-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.checkpoint-chip {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.checkpoint-chip strong {
  color: var(--ink);
}

.checkpoint-details {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.checkpoint-details pre,
.log-details {
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  color: #dbeafe;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.retry-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.retry-board.single {
  grid-template-columns: 1fr;
}

.retry-box,
.video-summary {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.retry-title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 850;
}

.video-summary {
  margin: 10px 0;
}

.scene-row {
  display: grid;
  grid-template-columns: 34px auto minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid #edf0f4;
  font-size: 11px;
}

.scene-row:first-of-type {
  border-top: 0;
}

.danger-text {
  color: var(--red);
}

.artifact-list {
  display: grid;
  gap: 7px;
}

.artifact {
  display: flex;
  justify-content: space-between;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.debug-controls,
.debug-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 10px;
  align-items: start;
}

.debug-controls {
  margin-bottom: 10px;
}

.log-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.auto-refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.auto-refresh-toggle input {
  accent-color: var(--brand);
}

.task-log-list {
  display: grid;
  gap: 6px;
  max-height: 430px;
  overflow: auto;
}

.task-log-row,
.debug-summary-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.task-log-row.error {
  border-color: #fecaca;
  background: var(--red-soft);
}

.task-log-row.warning {
  border-color: #fde68a;
  background: var(--amber-soft);
}

.task-log-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.log-level,
.log-step {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}

.log-time {
  margin-left: auto;
}

.log-message {
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.debug-summary-row {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
  color: var(--red);
  font-size: 11px;
}

.debug-artifact-title {
  margin-top: 12px;
}

.notice {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #713f12;
  font-size: 12px;
  line-height: 1.45;
}

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

.config-card {
  padding: 12px;
}

.config-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.config-name {
  font-size: 14px;
}

.config-source {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

[data-ui-lang="en"] .zh,
[data-ui-lang="zh"] .en {
  display: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
  }

  .brand {
    min-height: 0;
    padding: 0;
    border-bottom: 0;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    margin-top: 0;
  }

  .sidebar-note {
    display: none;
  }

  .form-layout,
  .detail-layout,
  .debug-grid,
  .debug-controls,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 12px;
  }

  .page-head,
  .topbar,
  .panel-head {
    display: grid;
  }

  .metrics,
  .preset-grid,
  .manual-param-grid,
  .retry-board {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
