:root {
  --bg: #f3f5f8;
  --surface: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f0f2f5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --ok: #15803d;
  --warn: #c2410c;
  --err: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --max: 1280px;

  /* Shoelace 主题色对齐品牌蓝 */
  --sl-color-primary-50: #eff6ff;
  --sl-color-primary-100: #dbeafe;
  --sl-color-primary-200: #bfdbfe;
  --sl-color-primary-300: #93c5fd;
  --sl-color-primary-400: #60a5fa;
  --sl-color-primary-500: #3b82f6;
  --sl-color-primary-600: #2563eb;
  --sl-color-primary-700: #1d4ed8;
  --sl-color-primary-800: #1e40af;
  --sl-color-primary-900: #1e3a8a;
  --sl-color-primary-950: #172554;
  --sl-border-radius-medium: 8px;
  --sl-border-radius-large: 12px;
  --sl-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100vh; }

.topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1;
}
.nav-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: #f1f5f9; color: #334155; }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.page-head { margin-bottom: 1.1rem; }
.page-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.meta-line {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.85rem;
  line-height: 1.5;
}
.meta-line strong { color: var(--ink); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: visible;
}
.panel-body { padding: 1.25rem 1.35rem 1.35rem; }

.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.65rem;
}
.section-title:not(:first-child) { margin-top: 1.35rem; }

/* Shoelace 表单组件间距 */
.ui-select,
.ui-input,
.ui-textarea {
  display: block;
  width: 100%;
  margin-bottom: 0.15rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 0.4rem; }

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-top: 0.85rem;
  border: 1px solid transparent;
}
.alert-info { background: #eff6ff; color: #1e40af; border-color: #dbeafe; }
.alert-warn { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.alert-err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.btn-secondary:hover:not(:disabled) { background: #dbeafe; }
.btn-link,
a.btn-link {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 0.2rem 0.35rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.btn-link:hover,
a.btn-link:hover { text-decoration: underline; }
.btn-link:disabled { opacity: 0.55; cursor: not-allowed; }

.form-footer {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
}
.form-footer .btn-primary { min-width: 140px; padding: 0.62rem 1.2rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  align-items: start;
}
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-span-2 { grid-column: span 2; }

/* Shoelace 表单组件 */
.ui-range,
.ui-checkbox {
  display: block;
  width: 100%;
}
.ui-select::part(combobox),
.ui-input::part(base),
.ui-textarea::part(base) {
  border-radius: var(--radius-sm);
}
.ui-details {
  margin-top: 1rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fafbfc;
}
.ui-details::part(base) {
  border: none;
  background: transparent;
}
.ui-details::part(header) {
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
}
.ui-details::part(content) {
  padding: 0 0.85rem 0.85rem;
}
.ui-checkbox {
  padding-top: 1.75rem;
}
.flex-1 { flex: 1; min-width: 0; }
.voice-preview-row {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.file-drop {
  display: block;
  position: relative;
  width: 100%;
  margin-bottom: 0.5rem;
}
.file-drop-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.file-drop-inner {
  display: block;
  position: relative;
  width: 100%;
  min-height: 128px;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fafbfc 0%, #f8fafc 100%);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.file-drop-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 128px;
  padding: 1.5rem 1.25rem;
  text-align: center;
}
.file-drop-inner:hover,
.file-drop.is-dragover .file-drop-inner {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.file-drop.is-dragover .file-drop-inner {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.file-drop-icon {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.25rem;
  color: var(--accent);
  box-shadow: var(--shadow);
}
.file-drop-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}
.file-drop-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  padding: 0.38rem 0.95rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}
.file-drop-inner:hover .file-drop-pick,
.file-drop.is-dragover .file-drop-pick {
  background: var(--accent-hover);
}
.file-drop-name {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-drop-status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.file-drop.upload-busy .file-drop-status { color: #1d4ed8; }
.file-drop.upload-ready .file-drop-status { color: var(--ok); font-weight: 500; }
.file-drop.upload-ready .file-drop-inner {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.file-drop.upload-error .file-drop-status { color: var(--err); }
.file-drop.has-file .file-drop-inner {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  border-style: solid;
}
.file-drop.has-file .file-drop-name {
  color: var(--accent);
  font-weight: 500;
}
.file-drop-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  width: min(100%, 520px);
  max-height: 160px;
  overflow: auto;
  text-align: left;
}
.file-drop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-soft);
  font-size: 0.8rem;
}
.file-drop-item + .file-drop-item { margin-top: 0.35rem; }
.file-drop-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #334155;
}
.file-drop-item-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
}
.file-drop-item.item-uploading .file-drop-item-status { color: #1d4ed8; }
.file-drop-item.item-ready .file-drop-item-status { color: var(--ok); font-weight: 500; }
.file-drop-item.item-error .file-drop-item-status { color: var(--err); }

.disk-panel { margin-bottom: 1rem; }
.disk-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.65rem;
}
.disk-free { font-size: 1.05rem; color: #0f172a; }
.disk-free strong { font-size: 1.35rem; color: var(--accent); }
.disk-meta { font-size: 0.84rem; color: var(--muted); }
.disk-bar {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.disk-bar-used {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.25s ease;
}
.disk-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.files-panel-body { padding-top: 0.75rem; }
.files-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.files-section + .files-section { margin-top: 1.5rem; padding-top: 0.25rem; }
.files-section .section-title { margin-bottom: 0.65rem; }
.files-table .task-title { font-size: 0.88rem; word-break: break-all; }
.muted { color: var(--muted); }

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.45;
}

.form-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}
.form-row sl-button { flex: 0 0 auto; margin-bottom: 0.08rem; }

.audio-preview {
  margin-top: 0.65rem;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-sm);
}

/* 队列表格 */
.queue-panel { padding: 0; }
.table-wrap { overflow-x: auto; }
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  table-layout: fixed;
}
.task-table th {
  text-align: left;
  color: #64748b;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.task-table th.col-task { width: 24%; }
.task-table th.col-progress { width: auto; }
.task-table th.col-phase { width: 96px; }
.task-table th.col-ops { width: 180px; }
.task-table th.col-done-at { width: 148px; }
.task-table th.col-pills { width: 168px; }
.task-table th.col-size { width: 88px; }
.task-table td {
  padding: 0.62rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.task-table td.ops {
  width: 180px;
  min-width: 180px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}
.task-table tbody tr:hover { background: #fafbfc; }
.task-title { font-weight: 600; color: #1e293b; }
.task-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  font-weight: 600;
}
.task-tag.music { background: #dcfce7; color: #166534; }
.task-tag.ai { background: #dbeafe; color: #1d4ed8; }
.task-meta { font-size: 0.72rem; color: #94a3b8; margin-top: 0.18rem; }
.task-sub { font-size: 0.72rem; color: #94a3b8; margin-top: 0.15rem; }

.pills { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.pill.duration { color: #475569; border-color: #e2e8f0; background: #f8fafc; }
.pill.ready { color: #1d4ed8; border-color: #bfdbfe; background: #eff6ff; }
.pill.yt-done { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.pill.yt-pending { color: #78716c; border-color: #e7e5e4; background: #fafaf9; }
.pill.yt-busy { color: #c2410c; border-color: #fed7aa; background: #fff7ed; }
.pill.yt-failed { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.pill.dy-done { color: #9a3412; border-color: #fed7aa; background: #fff7ed; }
.pill.dy-pending { color: #78716c; border-color: #e7e5e4; background: #fafaf9; }
.pill.dy-busy { color: #c2410c; border-color: #fdba74; background: #ffedd5; }
.pill.dy-failed { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.badge.running { color: #1d4ed8; border-color: #bfdbfe; background: #eff6ff; }
.badge.prep { color: #7e22ce; border-color: #e9d5ff; background: #faf5ff; }
.badge.queued { color: #c2410c; border-color: #fed7aa; background: #fff7ed; }
.badge.failed { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.badge.cancelled { color: #78716c; border-color: #e7e5e4; background: #fafaf9; }
.badge.done { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.badge.paused { color: #78716c; border-color: #e7e5e4; background: #fafaf9; }

.ops {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}
.progress-main { color: #334155; line-height: 1.45; }
.progress-tail { font-size: 0.76rem; color: #94a3b8; margin-top: 0.22rem; }
.progress-time { font-size: 0.72rem; color: #94a3b8; margin-top: 0.15rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
  border-top: 1px solid var(--line-soft);
  font-size: 0.92rem;
}

.modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(92vw, 720px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
.video-dialog {
  --width: min(92vw, 720px);
}
.video-dialog::part(body) {
  padding: 0;
  background: #000;
}
.video-dialog::part(panel) {
  border-radius: 14px;
  overflow: hidden;
}
#video-modal-player {
  width: 100%;
  max-height: 70vh;
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 0.62rem 1.1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

@media (max-width: 720px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
  .ui-checkbox { padding-top: 0; }
  .task-table { font-size: 0.8rem; }
  .hide-sm { display: none; }
  .form-footer sl-button { width: 100%; }
}
