/* Design tokens — ui-ux-pro-max Short Video Editor (OLED) */
:root {
  --color-primary: #ec4899;
  --color-on-primary: #fff;
  --color-secondary: #db2777;
  --color-accent: #2563eb;
  --color-background: #0f172a;
  --color-foreground: #fff;
  --color-card: #192134;
  --color-muted: #201a32;
  --color-muted-fg: #94a3b8;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-destructive: #dc2626;
  --color-ring: #ec4899;
  --color-surface: #192134;
  --color-surface-hover: rgba(255, 255, 255, 0.08);
  --touch-min: 44px;
  --motion-fast: 150ms;
  --motion-normal: 250ms;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.28);
  --shadow-glow: 0 0 10px rgba(236, 72, 153, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--color-background);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(236, 72, 153, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(37, 99, 235, 0.08), transparent);
  min-height: 100vh;
  color: var(--color-foreground);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 64px;
}
.app-shell.editor-open { max-width: 1180px; }

/* ── Header & Nav ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  margin: 0 -20px 24px;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.brand-block { text-align: center; margin-bottom: 14px; }
.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 0 10px rgba(236, 72, 153, 0.35);
}
.brand-tagline { color: var(--color-muted-fg); margin-top: 4px; font-size: 0.85rem; }

.app-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--color-border);
}
.nav-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch-min);
  transition: background var(--motion-fast) ease, color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.nav-tab:hover { background: var(--color-surface-hover); color: #fff; }
.nav-tab.active {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(219, 39, 119, 0.2));
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  line-height: 1.4;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.85rem;
  opacity: 0.9;
}
.user-name { opacity: 0.85; }

.app-main { display: block; }
.view-panel { animation: fadeIn var(--motion-normal) ease; }
.view-auth { max-width: 400px; margin: 0 auto; }
.auth-lead { margin: -8px 0 18px; }
.panel-desc { margin: -8px 0 16px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .view-panel { animation: none; }
}

.editor-overlay { margin-top: 0; }

h2 { font-size: 1.1rem; margin-bottom: 16px; font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-head h2 { margin-bottom: 0; }
.editor-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.editor-head-actions button { width: auto; }
.muted { color: var(--color-muted-fg); font-size: 0.85rem; }

.template-picker-label { margin-bottom: 20px; }
.template-picker-section { margin-top: 12px; }
.template-picker-heading {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  margin-bottom: 10px;
}
.template-picker-hint { margin-top: 10px; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 520px) {
  .template-grid { grid-template-columns: repeat(3, 1fr); }
}
.template-card {
  position: relative;
  display: block;
  border: 2px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease, transform var(--motion-fast) ease;
  text-align: left;
  padding: 0;
  width: 100%;
  min-height: auto;
}
.template-card:hover {
  border-color: rgba(236, 72, 153, 0.4);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.template-card.selected {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}
.template-card-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #111;
}
.template-card-body { padding: 8px 10px 10px; }
.template-card-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.template-card-desc {
  display: block;
  font-size: 0.72rem;
  opacity: 0.6;
  margin-top: 3px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-card-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #e2e8f0;
  pointer-events: none;
}
.template-card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: auto !important;
  min-height: 28px !important;
  padding: 2px 8px !important;
  font-size: 0.7rem !important;
  background: rgba(220, 38, 38, 0.75) !important;
  border: none !important;
  opacity: 0;
  transition: opacity var(--motion-fast) ease;
}
.template-card:hover .template-card-delete,
.template-card-delete:focus-visible { opacity: 1; }

.timeline-mode-toggle { margin-bottom: 12px !important; }
.timeline-editor {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--color-border);
}
.timeline-photo-hint { margin-bottom: 12px; }
.timeline-segment-list { display: flex; flex-direction: column; gap: 10px; }
.timeline-segment {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
}
@media (min-width: 520px) {
  .timeline-segment {
    grid-template-columns: 1.2fr 80px 100px 100px 1fr auto;
    align-items: end;
  }
}
.timeline-segment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  grid-column: 1 / -1;
}
.timeline-segment-index { font-size: 0.8rem; font-weight: 600; opacity: 0.7; }
.timeline-segment-actions { display: flex; gap: 4px; }
.timeline-segment-actions button {
  width: auto !important;
  min-height: 32px !important;
  padding: 4px 8px !important;
  font-size: 0.75rem !important;
}
.timeline-segment select,
.timeline-segment input[type="number"],
.timeline-segment input[type="text"] {
  margin-top: 0;
  padding: 8px 10px;
  font-size: 0.85rem;
}
.timeline-add-btn { width: auto !important; margin-top: 10px; }
.timeline-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.timeline-add-row .btn-small { width: auto !important; }
.timeline-segment.role-intro {
  border-color: color-mix(in srgb, #6ee7a0 45%, transparent);
}
.timeline-segment.role-outro {
  border-color: color-mix(in srgb, #ffb347 45%, transparent);
}
.timeline-role-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.timeline-role-badge.intro {
  background: color-mix(in srgb, #6ee7a0 22%, transparent);
  color: #6ee7a0;
}
.timeline-role-badge.outro {
  background: color-mix(in srgb, #ffb347 22%, transparent);
  color: #ffb347;
}
.timeline-role-badge.body {
  background: color-mix(in srgb, currentColor 10%, transparent);
  opacity: 0.7;
}


.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

label { display: block; margin-bottom: var(--space-md); font-size: 0.9rem; color: rgba(255, 255, 255, 0.92); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 1rem;
  font-family: inherit; line-height: 1.45;
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.28); }
input::placeholder, textarea::placeholder { color: var(--color-muted-fg); }

button {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  color: var(--color-on-primary); font-size: 1rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer; touch-action: manipulation;
  transition: opacity var(--motion-fast) ease, box-shadow var(--motion-fast) ease, transform var(--motion-fast) ease;
}
button:hover:not(:disabled) { box-shadow: var(--shadow-glow); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-tab:focus-visible,
.btn-add-asset:focus-visible,
.template-card:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.22);
}

.btn-row { display: flex; gap: 10px; }
.btn-row button { flex: 1; }
.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-small {
  width: auto; padding: 6px 14px; font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2);
  min-height: var(--touch-min);
}
.btn-link {
  width: auto; padding: 6px 12px; font-size: 0.85rem;
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.2);
  min-height: 36px;
}

@media (max-width: 767px) {
  .draft-actions { gap: 8px; }
  .draft-actions button,
  .task-actions button,
  .photo-asset-actions button,
  .worker-actions button {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 10px 12px;
  }
  .nav-tab { font-size: 0.82rem; padding: 10px 8px; }
}

.btn-danger { background: rgba(255, 80, 80, 0.25) !important; border: 1px solid rgba(255, 80, 80, 0.4) !important; }
.draft-list { list-style: none; }
.draft-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--color-border);
  transition: background var(--motion-fast) ease;
}
.draft-item:hover { background: rgba(255, 255, 255, 0.03); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.draft-item:last-child { border-bottom: none; }
.draft-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.draft-info strong { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-actions { display: flex; gap: 6px; flex-shrink: 0; }
.draft-actions button { width: auto; padding: 6px 10px; font-size: 0.8rem; }

.user-list { list-style: none; margin-top: 16px; }
.user-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--color-border); font-size: 0.9rem;
}
.user-list li:last-child { border-bottom: none; }
.user-list-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.role-badge {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 6px;
  background: rgba(236, 72, 153, 0.25); margin-left: 8px;
}
.admin-form { margin-bottom: 8px; }
.admin-form-actions { display: flex; gap: 8px; margin-top: 8px; }
.admin-form-actions button { width: auto; }
.change-password-panel {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
}
.password-field { display: flex; gap: 8px; align-items: center; }
.password-field input { flex: 1; }
.btn-icon {
  width: auto; min-width: var(--touch-min); min-height: var(--touch-min);
  padding: 8px 10px; font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: inherit; cursor: pointer;
}
.btn-icon:hover { background: var(--color-surface-hover); }
.ok-msg { color: #6ee7a0; margin-top: 12px; font-size: 0.9rem; }
.hidden { display: none !important; }
.checkbox { display: flex !important; align-items: center; gap: 10px; }
.checkbox input { width: auto; margin: 0; }
.error { color: #ff6b6b; margin-top: 12px; }
.warn { color: #ffb347; margin-top: 8px; font-size: 0.85rem; }
#preview.task-output-preview,
#previewImage.task-output-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-top: 12px;
  background: #000;
}
.progress-bar {
  height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 4px;
  margin-top: 12px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 4px; transition: width var(--motion-normal) ease;
}
.progress-fill.indeterminate {
  width: 30% !important; animation: pulse 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill.indeterminate { animation: none; width: 50% !important; margin-left: 25%; }
}

.task-list { list-style: none; max-height: 420px; overflow-y: auto; }
.task-item {
  padding: 10px 8px; border-bottom: 1px solid var(--color-border);
  cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--motion-fast) ease;
}
.task-item:hover { background: rgba(255, 255, 255, 0.04); }
.task-item.is-active {
  background: rgba(236, 72, 153, 0.08);
  border-left: 3px solid var(--color-primary);
  padding-left: 5px;
}
.task-item:last-child { border-bottom: none; }
.task-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.task-head strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-status { font-size: 0.75rem; flex-shrink: 0; opacity: 0.85; }
.task-status.done { color: #6ee7a0; }
.task-status.failed { color: #ff6b6b; }
.task-status.warn { color: #ffb347; }
.task-meta { font-size: 0.75rem; opacity: 0.6; margin-top: 4px; }
.task-chunk-hint { font-size: 0.75rem; margin-top: 4px; color: #93c5fd; }
.task-done-hint { font-size: 0.75rem; margin-top: 4px; }
.task-item .progress-bar { margin-top: 6px; height: 6px; }
.task-preview { width: 100%; border-radius: 8px; margin-top: 10px; background: #000; }
.task-output-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.task-actions { margin-top: 6px; display: flex; gap: 8px; }
.task-actions button { width: auto; padding: 6px 12px; font-size: 0.8rem; }

.editor-layout {
  display: grid; grid-template-columns: 1fr; gap: var(--space-lg); margin-top: var(--space-md);
}
@media (min-width: 900px) {
  .editor-layout {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    align-items: start;
  }
}
.editor-draft-name { margin-top: 4px; }
.editor-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}
.editor-preview {
  background: #000; border-radius: var(--radius-md); overflow: hidden; min-height: 220px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}
@media (min-width: 900px) {
  .editor-preview {
    position: sticky;
    top: 88px;
  }
  .editor-stage:has(.caption-timeline-panel:not(.hidden)) .editor-preview,
  .editor-stage:has(.media-timeline-panel:not(.hidden)) .editor-preview {
    position: static;
  }
}
#previewMount { width: 100%; }
.editor-controls label { margin-bottom: 14px; }
.editor-section-block { margin-bottom: var(--space-lg); }
.caption-hint { margin-top: -6px; line-height: 1.5; }
.editor-section-title {
  font-size: 0.8rem; font-weight: 600; margin-bottom: 12px;
  color: var(--color-muted-fg);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding-bottom: 8px; border-bottom: 1px solid var(--color-border);
}
.caption-defaults {
  margin: 10px 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  padding: 0 10px 4px;
}
.caption-defaults > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 0;
  font-size: 0.82rem;
  color: var(--color-muted-fg);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
}
.caption-defaults > summary::-webkit-details-marker { display: none; }
.caption-defaults > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform var(--motion-fast) ease;
}
.caption-defaults[open] > summary::before { transform: rotate(90deg); }

.editor-template-badge {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  font-size: 0.82rem;
}
.editor-template-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted-fg);
}
.editor-template-badge strong { font-size: 0.9rem; }
.editor-template-badge code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #93c5fd;
}

.caption-timeline-panel,
.media-timeline-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px 14px;
  box-shadow: var(--shadow-sm);
}
.media-timeline-hint {
  margin: -2px 0 10px;
  font-size: 0.78rem;
  line-height: 1.45;
}
.caption-timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.caption-timeline-head .editor-section-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.caption-timeline {
  position: relative;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%),
    #0a0f1c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.caption-timeline-ruler {
  position: relative;
  height: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}
.timeline-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(-0.5px);
}
.timeline-mark i {
  position: absolute;
  top: 3px;
  left: 4px;
  font-style: normal;
  font-size: 0.65rem;
  color: var(--color-muted-fg);
  white-space: nowrap;
}
.caption-timeline-track {
  position: relative;
  min-height: 64px;
  height: 72px;
  margin: 8px 6px 10px;
}
.caption-timeline-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-align: center;
  font-size: 0.8rem;
}
.caption-clip {
  position: absolute;
  top: 8px;
  height: 48px;
  min-width: 28px;
  border: 1px solid rgba(37, 99, 235, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.45), rgba(236, 72, 153, 0.28));
  color: #fff;
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  text-align: left;
  transition: transform var(--motion-fast) ease, box-shadow var(--motion-fast) ease, border-color var(--motion-fast) ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.caption-clip:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.9);
}
.caption-clip.is-selected {
  border-color: #f9a8d4;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.45), var(--shadow-glow);
  z-index: 2;
}
.caption-clip.is-styled {
  border-style: dashed;
}
.caption-clip-index {
  font-size: 0.65rem;
  opacity: 0.75;
  font-weight: 700;
}
.caption-clip-text {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.media-timeline-track {
  min-height: 36px;
  height: 40px;
  cursor: pointer;
}
.media-clip {
  position: absolute;
  top: 4px;
  height: 32px;
  min-width: 6px;
  border: 1px solid color-mix(in srgb, var(--clip-color, #3b82f6) 65%, #fff);
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--clip-color, #3b82f6) 72%, #fff),
    color-mix(in srgb, var(--clip-color, #3b82f6) 38%, #0a0f1c)
  );
  color: #fff;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform var(--motion-fast) ease, box-shadow var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.media-clip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.55);
}
.media-clip.is-selected {
  border-color: #f9a8d4;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.45), var(--shadow-glow);
  z-index: 2;
}
.media-clip-index {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.9;
  pointer-events: none;
}
.media-clip-inspector {
  margin-top: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28);
  padding: 10px 12px 12px;
}
.media-detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 8px 0 0;
  font-size: 0.82rem;
}
.media-detail-grid dt {
  color: var(--color-muted-fg);
  font-size: 0.75rem;
}
.media-detail-grid dd {
  margin: 0;
  word-break: break-all;
}
.media-detail-grid code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #93c5fd;
}
.media-detail-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.caption-cue-inspector {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(236, 72, 153, 0.28);
  background: rgba(236, 72, 153, 0.06);
  animation: fadeIn var(--motion-normal) ease;
}
.cue-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cue-inspector-head strong { font-size: 0.9rem; }
.caption-cue-inspector textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
  line-height: 1.4;
}
.cue-inspector-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.cue-inspector-actions .checkbox { margin: 0; }
.asset-group { margin-bottom: var(--space-md); }
.asset-label { font-size: 0.85rem; color: var(--color-muted-fg); margin-bottom: 8px; }
.photo-asset-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.photo-asset-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.25);
}
.photo-asset-item img,
.photo-asset-item .media-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.media-type-badge {
  font-size: 0.65rem; opacity: 0.65; padding: 2px 6px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.08); flex-shrink: 0;
}
.photo-asset-item .photo-index { font-size: 0.75rem; opacity: 0.6; width: 20px; text-align: center; flex-shrink: 0; }
.photo-asset-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.photo-asset-actions button {
  width: auto; padding: 4px 8px; font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15);
}
.photo-asset-actions button.btn-danger-asset {
  background: rgba(255, 80, 80, 0.2); border-color: rgba(255, 80, 80, 0.35);
}
.btn-add-asset {
  display: block; text-align: center; padding: 10px; border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.25); cursor: pointer; font-size: 0.85rem;
  opacity: 0.85; margin-bottom: 0;
  transition: border-color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}
.btn-add-asset:hover { border-color: rgba(236, 72, 153, 0.5); opacity: 1; }
.portrait-bg-preview img { width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.portrait-video-preview video { width: 100%; max-height: 140px; border-radius: 8px; background: #000; margin-bottom: 8px; }
#portraitCaptions, #editorCaptionScript, #editorAutoCaptions {
  width: 100%; min-height: 96px; resize: vertical; margin-top: 6px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35); color: inherit; font: inherit; line-height: 1.45;
}
.caption-style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 12px 0 10px;
}
.caption-style-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  opacity: 0.92;
}
.caption-style-grid input,
.caption-style-grid select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
}
.caption-style-grid input[type="color"] {
  padding: 4px;
  height: 36px;
  cursor: pointer;
}
.caption-style-grid input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.caption-layer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 6px;
}
.caption-layer-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}
.caption-layer-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: rgba(0, 0, 0, 0.28);
}
.caption-layer-item .layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  opacity: 0.85;
}
.caption-layer-item textarea {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  color: inherit;
  font: inherit;
  line-height: 1.4;
}
.caption-layer-times {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}
.caption-layer-times label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}
.caption-layer-times input {
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  color: inherit;
  font: inherit;
}
.music-asset-preview audio { width: 100%; margin-bottom: 8px; }
.editor-param { margin-bottom: 12px; }
.editor-param .param-value { float: right; opacity: 0.7; font-size: 0.85rem; }
.editor-param input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--color-primary); }
@keyframes pulse { 0%,100% { width: 20%; margin-left: 0; } 50% { width: 60%; margin-left: 20%; } }
.tag { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 6px; background: var(--color-primary); margin-left: 8px; }

.worker-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border);
}
.worker-panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.worker-status-text { font-size: 0.95rem; font-weight: 600; }
.worker-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: #666;
}
.worker-dot.online { background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.6); }
.worker-dot.busy { background: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.worker-dot.offline { background: #888; }
.worker-job-text { margin-top: 4px; font-size: 0.85rem; }
.worker-queue-text { font-size: 0.8rem; margin-bottom: 10px; }
.worker-actions { margin-top: 4px; }
.worker-actions button { flex: 1; }
.k8s-worker-panel {
  margin: 8px 0 4px;
  padding: 8px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--border, #333) 70%, transparent);
}
.k8s-worker-text { font-size: 0.85rem; margin-bottom: 8px; }
.k8s-worker-actions {
  align-items: center;
  gap: 8px;
}
.k8s-worker-actions .btn-small {
  flex: 0 0 auto;
  min-width: 36px;
}
.k8s-worker-count {
  min-width: 2.5rem;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.worker-external-hint {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: rgba(255, 255, 255, 0.88);
}
.worker-cmd {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, "Fira Code", monospace;
  font-size: 0.78rem;
  word-break: break-all;
  color: #93c5fd;
}

@media (min-width: 768px) {
  .app-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 12px 20px;
  }
  .brand-block { text-align: left; margin-bottom: 0; grid-column: 1; grid-row: 1; }
  .user-bar { margin-top: 0; justify-content: flex-end; grid-column: 2; grid-row: 1; }
  .app-nav { grid-column: 1 / -1; grid-row: 2; }
}
