:root {
  --ink: #24292f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: #fff; font: 14px var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid #64748b; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 600; margin-bottom: 28px; }
.muted { color: var(--muted); font-size: 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 16px; border: 1px solid transparent; border-radius: 4px; white-space: nowrap; }
.primary { color: #fff; background: var(--ink); }
.primary:hover:not(:disabled) { background: #3f4650; }
.secondary { color: var(--ink); background: #fff; border-color: #d1d5db; }
.secondary:hover:not(:disabled) { background: #f6f7f8; }
.text-button { padding: 4px 0; border: 0; color: var(--muted); background: none; white-space: nowrap; }
.text-button:hover { color: var(--ink); text-decoration: underline; }
input, textarea, select { border: 1px solid #d1d5db; border-radius: 4px; color: var(--ink); background: #fff; }
input, textarea { width: 100%; padding: 10px 12px; }
textarea { display: block; resize: vertical; min-height: 150px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #9ca3af; }
label { display: block; font-weight: 500; margin-bottom: 8px; }
.form-message { color: #b42318; margin-bottom: 16px; font-size: 13px; overflow-wrap: anywhere; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-form { width: 100%; max-width: 340px; }
.login-form h1 { margin-bottom: 32px; }
.login-form input { margin-bottom: 20px; }
.login-form .button { width: 100%; }
.workspace-header { border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1040px; min-height: 64px; margin: auto; padding: 0 24px; display: flex; align-items: center; gap: 36px; }
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
nav { display: flex; align-items: stretch; gap: 24px; align-self: stretch; }
.nav-item { border: 0; border-bottom: 2px solid transparent; padding: 0 2px; color: var(--muted); background: none; white-space: nowrap; }
.nav-item.active { border-bottom-color: var(--ink); color: var(--ink); }
.account { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: 16px; font-size: 12px; }
.account-balance { font-weight: 500; white-space: nowrap; cursor: default; }
.account-balance.negative { color: #b42318; }
.worker-status { font-weight: 500; white-space: nowrap; cursor: default; }
.worker-status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.worker-status.online { color: #28734d; }
.worker-status.offline { color: var(--muted); }
#account-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { max-width: 1008px; margin: auto; padding: 36px 24px; }
.create-view { max-width: 680px; margin: auto; }
.form-field { margin-bottom: 24px; }
.drop-zone { border: 1px solid var(--line); border-radius: 4px; padding: 16px; min-height: 70px; }
.drop-zone.dragging { border-color: #64748b; background: #f8fafc; }
.file-choice { display: flex; align-items: center; gap: 16px; }
.selected-video { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.file-info { min-width: 0; }
.file-info strong { display: block; font-weight: 500; overflow-wrap: anywhere; }
.file-info span { display: block; margin-top: 2px; }
.prompt-count { display: block; margin-top: 6px; text-align: right; color: var(--muted); font-size: 12px; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.form-footer .primary { min-width: 88px; }
.upload-progress { margin-bottom: 18px; font-size: 12px; color: var(--muted); }
.progress-track { height: 4px; background: #edf0f2; margin-bottom: 8px; overflow: hidden; }
#upload-progress-fill { display: block; width: 0; height: 100%; background: #64748b; }
.task-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 16px; }
.status-filter { display: flex; align-items: center; gap: 10px; }
.status-filter label { margin: 0; font-size: 13px; }
.status-filter select { min-width: 100px; padding: 6px 10px; }
.table-scroll { width: 100%; overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 740px; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
/* 结果列的操作按钮组不收缩（4 个文本按钮约需 180px），列宽须留足，窄屏允许换行 */
th:first-child { width: 38%; }
th:nth-child(2) { width: 12%; }
th:nth-child(3) { width: 12%; }
th:nth-child(4) { width: 18%; }
th:nth-child(5) { width: 20%; }
td { overflow-wrap: anywhere; }
.task-name { font-weight: 500; }
.task-prompt { margin-top: 5px; color: var(--muted); font-size: 12px; }
.task-prompt summary { cursor: pointer; overflow-wrap: anywhere; }
.task-prompt p { margin-top: 8px; white-space: pre-wrap; }
.badge { font-size: 12px; white-space: nowrap; }
.badge.pending { color: var(--muted); }
.badge.processing { color: #2563a6; }
.badge.completed { color: #28734d; }
.badge.error, .error-detail { color: #b42318; }
.error-detail { font-size: 12px; margin-top: 6px; white-space: pre-wrap; }
.stage-detail { margin-top: 6px; color: var(--muted); font-size: 12px; }
.task-avatar { margin-top: 5px; color: var(--muted); font-size: 12px; }
.generate-panel { margin-top: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); overflow: hidden; }
.generate-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 13px 20px; background: #f8f9fb; border-bottom: 1px solid var(--line); }
.generate-title { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.generate-title svg { flex: none; color: #64748b; }
.generate-body { padding: 20px; }
.generate-body textarea { min-height: 96px; }
.generate-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 12px; }
.generate-actions .button { min-width: 96px; }
.avatar-draft { display: flex; gap: 20px; margin-top: 20px; padding: 16px; border: 1px dashed #d1d5db; border-radius: 8px; background: #fafbfc; }
.avatar-draft img { width: 220px; height: 220px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f3f4f6; flex: none; }
.avatar-draft-info { min-width: 0; flex: 1; }
.avatar-draft-info input { max-width: 360px; }
.avatar-draft-info .muted { margin-top: 8px; }
.draft-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.avatar-card { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.avatar-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; }
.avatar-info { padding: 10px 12px 12px; }
.avatar-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.avatar-name { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.avatar-edit { flex: none; display: inline-flex; padding: 2px; border: 0; background: none; color: var(--muted); }
.avatar-edit:hover { color: var(--ink); }
.avatar-delete:hover { color: #b42318; }
.avatar-id { margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.avatar-status { display: inline-block; margin-top: 8px; }
.avatar-rename-editor { display: flex; gap: 8px; margin: 2px 0 4px; }
.avatar-rename-editor input { flex: 1; min-width: 0; width: auto; padding: 6px 8px; font-size: 13px; }
.badge.Active { color: #28734d; }
.badge.Processing { color: #2563a6; }
.badge.Failed { color: #b42318; }
.badge.Unknown { color: var(--muted); }
.task-date, .task-wait { font-size: 12px; color: var(--muted); }
.task-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.task-actions button { border: 0; background: none; padding: 0; color: var(--ink); font-size: 12px; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.task-actions button.danger { color: #b42318; }
.empty-tasks { padding: 40px 16px; text-align: center; border-bottom: 1px solid var(--line); color: var(--muted); }
.empty-tasks h2 { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.empty-tasks p { font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.pagination > div { display: flex; align-items: center; gap: 12px; }
.pagination .button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.preview-dialog { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fff; }
.preview-dialog::backdrop { background: #0008; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; }
.preview-heading h2 { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.preview-dialog video { display: block; width: 100%; max-height: 65vh; background: #111; }
.preview-dialog .form-message { margin: 16px 20px 0; }
.preview-footer { display: flex; justify-content: flex-end; padding: 16px 20px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 4px; color: #fff; background: var(--ink); font-size: 13px; z-index: 10; }

@media (max-width: 620px) {
  .header-inner { flex-wrap: wrap; padding: 16px 20px 0; gap: 16px; }
  .account { gap: 10px; }
  #account-name { max-width: 100px; }
  nav { width: 100%; order: 3; height: 38px; gap: 24px; }
  .content { padding: 28px 20px; }
  h1 { font-size: 20px; margin-bottom: 24px; }
  .file-choice { align-items: flex-start; flex-direction: column; gap: 10px; }
  .selected-video { gap: 12px; }
  .form-footer { align-items: flex-start; }
  .form-footer .muted { max-width: 200px; }
  .generate-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .avatar-draft { flex-direction: column; }
  .avatar-draft img { width: 100%; height: auto; aspect-ratio: 1; }
  .pagination { gap: 10px; }
  .pagination > div { gap: 8px; }
  .pagination .button { padding: 4px 8px; }
}
