:root {
  --bg: #f5f6f1;
  --surface: #ffffff;
  --surface-2: #eef1ea;
  --ink: #151915;
  --muted: #657067;
  --line: #d8ddd2;
  --green: #1d6b4f;
  --green-2: #e3f1e9;
  --red: #b93d35;
  --red-2: #f8e7e4;
  --blue: #245f8f;
  --amber: #a26a16;
  --shadow: 0 18px 42px rgba(26, 33, 28, 0.11);
  --radius: 8px;
  --font-body: "Aptos", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Avenir Next", "Noto Serif SC", "Songti SC", serif;
  /* Spacing / type scale tokens. Use in new or touched rules; legacy rules keep raw px. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 17px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    linear-gradient(90deg, rgba(21, 25, 21, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(21, 25, 21, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 16px;
  max-width: 1680px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

#envLine {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.button-row,
.panel-head,
.form-title {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-name-btn {
  min-height: 36px;
  padding: 0 12px;
}

#quotaPill,
#arkCostPill {
  max-width: min(360px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

.avatar-management-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 0.65fr) minmax(520px, 1.6fr);
  gap: 16px;
  align-items: start;
}

.avatar-base-tabs {
  grid-column: 1 / -1;
  min-width: 0;
}

.avatar-base-tab-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 2px 2px 10px;
}

.avatar-base-tab-list .base-look-item {
  flex: 0 0 190px;
  min-height: 62px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0;
  align-items: start;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.avatar-rail {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.embedded-avatar-rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: none;
}

.panel-head,
.form-title {
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.form-title {
  padding: 0 0 16px;
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill,
.count-pill,
.file-label,
.inline-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  border: 1px solid var(--line);
  background: var(--surface);
}

.pill-loading {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

.pill-loading::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: material-spin 0.85s linear infinite;
}

.pill-ok {
  color: var(--green);
  background: var(--green-2);
  border-color: #b8dcc7;
}

.pill-warn {
  color: var(--amber);
  background: #fff3d8;
  border-color: #e8cb84;
}

.count-pill,
.file-label {
  color: var(--muted);
  background: var(--surface-2);
}

.inline-status {
  color: var(--muted);
  background: transparent;
}

.icon-btn {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 19px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.icon-btn:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--surface-2);
}

.icon-btn.is-loading {
  color: var(--green);
}

.icon-btn.strong {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.search-box {
  display: grid;
  gap: 6px;
  padding: 0 18px 14px;
}

.search-box span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 10px 11px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 107, 79, 0.14);
}

.stack-list,
.video-list,
.jobs-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 16px;
}

.video-list {
  max-height: clamp(220px, 30vh, 360px);
  overflow: auto;
  overscroll-behavior: contain;
}

.list-item,
.video-item,
.job-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  text-align: left;
}

.list-item,
.video-item {
  width: 100%;
}

.avatar-group {
  display: grid;
  gap: 8px;
}

.composition-form select[multiple] {
  height: auto;
  min-height: 128px;
  padding: 8px;
}

.composer-step {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.composer-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer-step-head strong {
  font-size: 15px;
}

.composer-step label {
  display: grid;
  gap: 6px;
}

.composition-results {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.composition-list {
  display: grid;
  gap: 8px;
}

.composition-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
}

.composition-thumb {
  display: grid;
  width: 76px;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

button.composition-thumb {
  border: 0;
  padding: 0;
}

.composition-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.composition-thumb .skeleton-thumb {
  width: 100%;
  height: 100%;
}

.composition-info {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.composition-info strong,
.composition-info span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composition-info span {
  color: var(--muted);
  font-size: 12px;
}

.composer-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 14px;
  align-items: start;
}

.composer-editor-panel,
.composer-timeline-panel,
.material-timeline-panel {
  display: grid;
  min-width: 0;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.composer-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.composer-panel-head strong {
  font-size: 15px;
}

.composer-panel-head span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-script-list,
.composer-asset-list {
  display: grid;
  max-height: min(54vh, 560px);
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.composer-segment-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.composer-segment-card b {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.composer-segment-card span {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.composer-segment-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.composer-segment-card.active {
  border-color: var(--green);
  background: var(--green-2);
}

.composer-segment-card.active b {
  background: var(--green);
  color: #fff;
}

.composer-asset-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.composer-asset-card > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.composer-asset-card strong,
.composer-asset-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-asset-card small {
  color: var(--muted);
  font-size: 12px;
}

.composer-asset-card.active {
  border-color: var(--green);
  background: var(--green-2);
}

.composer-map-panel {
  margin-top: 14px;
}

.composer-map-list {
  display: grid;
  max-height: min(58vh, 640px);
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.composer-map-card {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(260px, 1.2fr);
  align-items: stretch;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
}

.composer-map-card.active {
  border-color: var(--green);
  background: var(--green-2);
}

.composer-map-script {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.composer-map-script b {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.composer-map-card.active .composer-map-script b {
  background: var(--green);
  color: #fff;
}

.composer-map-script span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.composer-map-script strong {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.composer-map-script small {
  color: var(--muted);
  font-size: 12px;
}

.composer-match-strip {
  display: flex;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 2px;
}

.composer-match-chip {
  display: grid;
  grid-template-columns: 58px minmax(76px, 1fr);
  align-items: center;
  flex: 0 0 172px;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  padding: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.composer-match-chip.aligned {
  border-color: #bbf7d0;
}

.composer-match-chip.image {
  border-color: #e9d5ff;
}

.composer-match-chip.trim {
  border-color: #fed7aa;
}

.composer-match-chip.missing {
  border-color: #fecaca;
}

.composer-match-thumb {
  display: grid;
  width: 58px;
  aspect-ratio: 1 / 1;
  place-items: center;
  overflow: hidden;
  border-radius: calc(var(--radius) - 3px);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.composer-match-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-match-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.composer-match-copy strong,
.composer-match-copy small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-match-copy small {
  color: var(--muted);
  font-size: 12px;
}

.empty-state.compact {
  align-self: center;
  margin: 0;
  padding: 8px 10px;
  font-size: 12px;
}

.composer-preview-media video {
  width: 100%;
  height: 100%;
  max-height: min(62vh, 620px);
  object-fit: contain;
}

.duration-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.duration-badge.aligned {
  background: var(--green-2);
  color: var(--green);
}

.duration-badge.image {
  background: #f3e8ff;
  color: #7e22ce;
}

.duration-badge.trim {
  background: #fff7ed;
  color: #c2410c;
}

.duration-badge.extend,
.duration-badge.unknown {
  background: #eff6ff;
  color: #1d4ed8;
}

.duration-badge.missing {
  background: #fef2f2;
  color: #b91c1c;
}

.composer-timeline-panel {
  margin-top: 14px;
}

.material-timeline-panel,
.reality-timeline-panel {
  margin-top: 18px;
}

.timeline-ruler {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.composer-timeline {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

.timeline-lane-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.timeline-lane {
  display: flex;
  min-width: 0;
  height: 38px;
  gap: 3px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 4px;
}

.timeline-block {
  min-width: 26px;
  border: 0;
  border-radius: calc(var(--radius) - 3px);
  padding: 0 6px;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-spacer {
  flex: 0 1 auto;
  min-width: 0;
}

.timeline-match-wrap {
  position: relative;
  display: flex;
  min-width: 26px;
}

.timeline-match-wrap .timeline-block {
  width: 100%;
  min-width: 0;
}

.timeline-clear-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
}

.timeline-clear-btn:hover {
  border-color: #b91c1c;
  background: #fef2f2;
}

.timeline-block.script {
  background: #64748b;
}

.timeline-block.visual.aligned {
  background: #16a34a;
}

.timeline-block.visual.image {
  background: #9333ea;
}

.timeline-block.image-thumb {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  background: #242833;
}

.timeline-block.image-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.timeline-block.image-thumb span {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: rgba(21, 25, 21, 0.72);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.timeline-block.visual.trim {
  background: #f97316;
}

.timeline-block.visual.extend,
.timeline-block.visual.unknown {
  background: #2563eb;
}

.timeline-block.visual.missing {
  background: #dc2626;
}

.material-gap-card-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  overscroll-behavior: contain;
}

.material-gap-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  align-items: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
}

.material-gap-copy {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.material-gap-copy b {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 15px;
  line-height: 1;
}

.material-gap-copy strong {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.material-gap-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.material-thumb-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.material-inline-thumb {
  display: grid;
  width: 54px;
  aspect-ratio: 9 / 16;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  padding: 0;
  background: #111411;
  color: #d9eadf;
  font-size: 11px;
  font-weight: 700;
}

button.material-inline-thumb {
  cursor: pointer;
}

.material-inline-thumb:disabled {
  cursor: default;
  opacity: 0.9;
}

.material-inline-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.material-lazy-state {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 4px;
  color: #d9eadf;
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
}

.material-inline-thumb.lazy-loaded .material-lazy-state {
  display: none;
}

.material-inline-thumb .material-loader {
  width: 22px;
  height: 22px;
  border-width: 3px;
}

.material-inline-thumb.is-failed {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.material-settings-summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.material-settings-summary strong {
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
}

.material-settings-summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-round-select {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  max-width: 520px;
}

.reality-reason-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
}

.reality-reason {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
}

.reality-reason b {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.reality-reason span {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.reality-reason small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.reality-reason.aligned {
  border-color: #b8dcc7;
  background: var(--green-2);
}

.reality-reason.trim {
  border-color: #fed7aa;
  background: #fff7ed;
}

.reality-reason.image {
  border-color: #e9d5ff;
  background: #faf5ff;
}

.reality-reason.missing {
  border-color: #fecaca;
  background: #fef2f2;
}

.reality-library-category {
  background: var(--surface-2);
}

.reality-material-group {
  margin-left: 18px;
  grid-template-columns: 64px minmax(0, 1fr) auto;
}

.reality-material-group .composition-thumb {
  width: 64px;
}

.timeline-block.active {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.material-preview-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(21, 25, 21, 0.42);
}

.material-preview-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(21, 25, 21, 0.28);
}

.material-preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.material-preview-head > div {
  min-width: 0;
}

.material-preview-head strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-preview-body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 14px;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.material-preview-image {
  display: grid;
  min-height: min(70vh, 720px);
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.composer-preview-media {
  background: #111411;
  color: #fff;
}

.material-preview-image img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(70vh, 720px);
  object-fit: contain;
  display: block;
}

.material-prompt-editor {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.material-preview-error {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: calc(var(--radius) - 2px);
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.5;
}

.material-preview-error strong {
  font-size: 12px;
}

.material-prompt-editor label {
  display: grid;
  gap: 6px;
}

.material-prompt-editor textarea {
  min-height: 360px;
  resize: vertical;
}

.base-look-section {
  display: grid;
  gap: 8px;
}

.base-look-list {
  display: grid;
  max-height: min(34vh, 360px);
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.avatar-group + .avatar-group {
  margin-top: 10px;
}

.avatar-look-stage {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.avatar-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.avatar-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.base-look-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.avatar-cover {
  display: grid;
  width: 54px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #101511;
  color: #d9eadf;
  font-weight: 900;
}

.small-cover {
  width: 44px;
}

.avatar-cover img,
.avatar-cover video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-copy {
  min-width: 0;
}

.avatar-loading-list .avatar-loading-card {
  pointer-events: none;
}

.avatar-loading-card {
  border-color: var(--line);
  background: var(--surface);
}

.avatar-loading-cover,
.avatar-loading-line,
.avatar-loading-portrait {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #e3e7df 0%, #f7f8f5 45%, #e0e7e3 100%);
}

.avatar-loading-cover::after,
.avatar-loading-line::after,
.avatar-loading-portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  animation: avatar-loading-shimmer 1.2s ease-in-out infinite;
}

.avatar-loading-line {
  display: block;
  height: 12px;
  border-radius: 999px;
}

.avatar-loading-copy {
  display: grid;
  gap: 8px;
}

.avatar-loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
}

.avatar-loading-inline .material-loader {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.avatar-loading-stage {
  min-height: 360px;
}

.avatar-loading-preview {
  display: grid;
  gap: 12px;
  min-height: 360px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
}

.avatar-loading-portrait {
  width: min(260px, 52vw);
  max-width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
}

.avatar-loading-preview-copy {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(320px, 100%);
}

@keyframes avatar-loading-shimmer {
  to {
    transform: translateX(100%);
  }
}

.skeleton-box,
.skeleton-line,
.skeleton-thumb {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #e3e7df 0%, #f7f8f5 45%, #e0e7e3 100%);
}

.skeleton-box::after,
.skeleton-line::after,
.skeleton-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  animation: avatar-loading-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line {
  display: block;
  height: 12px;
  border-radius: 999px;
}

.skeleton-thumb {
  display: block;
  border-radius: 6px;
}

.skeleton-card {
  pointer-events: none;
}

.skeleton-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.skeleton-loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.skeleton-loading-inline .material-loader {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.module-loading-panel {
  display: grid;
  gap: 12px;
  min-height: 220px;
}

.module-loading-grid {
  display: grid;
  gap: 10px;
}

.segment-audio-skeleton {
  width: 100%;
  min-height: 40px;
  border-radius: 999px;
}

.document-sentence-skeleton {
  display: grid;
  gap: 10px;
  line-height: 1;
}

.avatar-cover .skeleton-thumb,
.small-cover .skeleton-thumb,
.lazy-video-preview .skeleton-thumb {
  width: 100%;
  height: 100%;
}

.lazy-video-preview .skeleton-thumb {
  min-height: 140px;
}

.segment-workspace {
  position: relative;
}

.segment-workspace.is-loading {
  min-height: 220px;
}

.workspace-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  gap: 10px;
  background: rgba(248, 250, 247, 0.72);
  backdrop-filter: blur(2px);
  color: var(--ink);
  font-weight: 900;
  pointer-events: none;
}

.segment-avatar-picker {
  display: grid;
  gap: 12px;
}

.segment-avatar-group {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segment-avatar-scenes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.segment-avatar-scene {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.segment-avatar-scene.active {
  border-color: var(--green);
  background: var(--green-2);
}

.segment-avatar-scene span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-scene-preview {
  display: grid;
  gap: 8px;
}

.avatar-create-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.avatar-create-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.avatar-create-head h2,
.avatar-create-section h3 {
  margin: 0;
}

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

.avatar-create-section {
  display: grid;
  gap: 10px;
  align-content: start;
}

.avatar-form-create-mode > :not(#avatarCreatePanel) {
  display: none !important;
}

.avatar-form-create-mode #avatarCreatePanel {
  display: grid;
}

.avatar-scene-media {
  width: 100%;
  max-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101511;
}

.avatar-scene-media img,
.avatar-scene-media video {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.list-item:hover,
.video-item:hover {
  border-color: #9ab5a7;
}

.list-item.active,
.video-item.active {
  border-color: var(--green);
  background: var(--green-2);
}

.item-title,
.job-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
}

.item-title span:first-child,
.video-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-count {
  flex: 0 0 auto;
  min-width: 24px;
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.base-look-item.active .mini-count {
  background: #fff;
  color: var(--green);
}

.item-sub,
.meta-line {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.avatar-card-description {
  display: -webkit-box;
  max-height: calc(1.35em * 2);
  overflow: hidden;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--amber);
}

.status-dot.ready {
  background: var(--green);
}

.tab-strip {
  position: sticky;
  top: 18px;
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 6px;
  height: max-content;
  max-height: calc(100vh - 36px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border: 1px solid var(--line);
  border-right: 0;
  background: var(--surface-2);
  border-radius: var(--radius) 0 0 var(--radius);
}

.editor-panel > .tab-strip {
  grid-template-columns: 1fr;
}

.tab {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  padding: 0 12px;
  text-align: left;
}

.tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.pane {
  display: none;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 20px;
}

.pane[hidden] {
  display: none !important;
}

.pane.active {
  display: block;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
}

.wide,
.form-title {
  grid-column: 1 / -1;
}

.check-line {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 40px;
  gap: 8px;
}

.check-line input {
  width: 18px;
  height: 18px;
}

.narration-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mode-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.mode-tab.active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--green);
}

.voice-preview:empty {
  display: none;
}

.voice-preview audio {
  width: 100%;
}

.button-row {
  grid-column: 1 / -1;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-btn {
  min-height: 34px;
  padding: 0 11px;
}

.primary-btn,
.danger-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 15px;
  font-weight: 800;
}

.link-btn {
  text-decoration: none;
}

.primary-btn {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
}

.primary-btn:hover {
  background: #15563f;
}

.primary-btn:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.danger-btn {
  border: 1px solid var(--red);
  background: var(--red-2);
  color: var(--red);
}

.danger-btn:hover {
  background: #f1d1cc;
}

.video-item {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.video-thumb {
  width: 92px;
  aspect-ratio: var(--thumb-ratio, 16 / 9);
  overflow: hidden;
  border-radius: 6px;
  background: #101511;
}

.video-thumb .skeleton-thumb,
.asset-thumb .skeleton-thumb {
  width: 100%;
  height: 100%;
}

.skeleton-video-preview {
  width: 100%;
  min-height: 220px;
  border-radius: 6px;
}

.video-thumb.portrait {
  width: 62px;
}

.video-thumb img,
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.lazy-video-preview {
  display: grid;
  gap: 10px;
}

.lazy-video-preview img,
.lazy-video-preview video {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 6px;
  background: #101511;
}

.thumb-error::after {
  content: "预览不可用";
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #d9eadf;
  font-size: 11px;
}

.video-inspector {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.video-inspector label {
  display: grid;
  gap: 6px;
}

.inspector-media {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101511;
  overflow: hidden;
}

.inspector-media video {
  width: 100%;
  display: block;
  background: #101511;
}

.asset-section {
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

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

.asset-list {
  display: grid;
  gap: 8px;
}

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

.asset-thumb {
  display: grid;
  width: 72px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #101511;
  color: #d9eadf;
  font-size: 11px;
}

.asset-thumb img,
.asset-thumb video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.asset-thumb audio {
  width: 64px;
}

.asset-actions {
  display: flex;
  justify-content: flex-end;
}

.library-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.library-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}

.library-card .form-title {
  padding: 0 0 14px;
  margin-bottom: 14px;
}

.library-card .search-box,
.library-card .video-list,
.library-card .video-inspector {
  padding-left: 0;
  padding-right: 0;
}

.library-card .search-box {
  padding-bottom: 14px;
}

.library-videos .video-list {
  max-height: 560px;
}

.library-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-assets {
  grid-column: 1 / -1;
}

.asset-upload-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.asset-upload-form label {
  display: grid;
  gap: 6px;
}

.asset-upload-form .asset-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.segment-workspace {
  display: grid;
  gap: 16px;
}

.segment-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.segment-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.segment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 14px;
  align-items: start;
}

.segment-set-list,
.segment-rows,
.clip-preview-list {
  display: grid;
  gap: 8px;
}

.segment-sentence-panel {
  gap: 12px;
}

.sentence-chip-list {
  display: grid;
  gap: 8px;
}

.sentence-chip {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.sentence-chip b {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.sentence-chip span {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sentence-chip small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.sentence-chip.active {
  border-color: var(--green);
  background: var(--green-2);
}

.sentence-chip.active b {
  background: var(--green);
  color: #fff;
}

.document-sentence-list {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.document-sentence-list .sentence-chip {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 12px;
}

.document-sentence-list .sentence-chip:last-child {
  border-bottom: 0;
}

.document-sentence-list .sentence-chip span {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-sentence-list .sentence-chip small {
  grid-column: 3;
  white-space: nowrap;
  align-self: start;
  padding-top: 5px;
}

.document-sentence-list .sentence-chip.active {
  background: var(--green-2);
}

.document-sentence-flow {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 2.05;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}

.document-sentence-token {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0 2px 0 0;
  border: 0;
  border-radius: 4px;
  padding: 2px 3px;
  background: transparent;
  color: var(--ink);
  line-height: inherit;
  text-align: left;
  vertical-align: baseline;
  white-space: normal;
  overflow-wrap: anywhere;
}

.document-sentence-token:hover {
  background: var(--surface-2);
}

.document-sentence-token.active {
  background: var(--green-2);
  outline: 1px solid rgba(29, 107, 79, 0.28);
  outline-offset: -1px;
}

.doc-text {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.sentence-timeline-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sentence-time-lane {
  height: 42px;
}

.timeline-block.sentence-time-block {
  background: #64748b;
}

.timeline-block.sentence-time-block.active {
  background: var(--green);
}

.segment-set-list {
  max-height: 260px;
  overflow: auto;
  overscroll-behavior: contain;
}

.segment-row {
  display: grid;
  grid-template-columns: 26px minmax(86px, 0.7fr) minmax(86px, 0.7fr) minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--surface-2);
}

.segment-row textarea {
  min-height: 40px;
}

.segment-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  justify-self: center;
}

.segment-row audio,
.segment-source audio,
.clip-preview audio,
.clip-preview video {
  width: 100%;
}

.clip-preview {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
}

.clip-preview video {
  max-height: 260px;
  border-radius: 6px;
  background: #101511;
}

.segment-clip-status {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.segment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.segment-actions .inline-status {
  min-width: 0;
  white-space: normal;
}

.asset-copy {
  min-width: 0;
}

.empty {
  padding: 18px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.job-item {
  display: grid;
  gap: 8px;
}

.job-progress-item {
  gap: 10px;
}

.job-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  color: var(--blue);
  background: #e6f0f7;
}

.job-badge.failed,
.job-badge.download_failed,
.job-badge.interrupted {
  color: var(--red);
  background: var(--red-2);
}

.job-badge.completed {
  color: var(--green);
  background: var(--green-2);
}

.job-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--red-2);
  color: var(--red);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.job-progress-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.job-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--blue);
  transition: width 220ms ease;
}

.material-process-item.is-loading .job-progress-fill {
  background-image: linear-gradient(90deg, var(--green), var(--blue));
}

.material-loader {
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: material-spin 0.85s linear infinite;
}

@keyframes material-spin {
  to {
    transform: rotate(360deg);
  }
}

.job-progress-item.complete .job-progress-fill {
  background: var(--green);
}

.job-progress-item.failed .job-progress-fill {
  background: var(--red);
}

.job-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.job-progress-meta span:first-child {
  min-width: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
  user-select: text;
}

.toast.error {
  border-color: var(--red);
  background: var(--red);
}

.toast.success {
  border-color: var(--green);
  background: var(--green);
}

.empty-guide-link {
  display: inline-block;
  margin-left: 8px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.empty-guide-link:hover {
  color: var(--blue);
}

/* Workflow step badges on workspace tabs (visual layer only; selectors unchanged). */
.tab[data-step] {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab[data-step]::before {
  content: attr(data-step);
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.75;
}

.tab.active[data-step]::before {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  opacity: 1;
}

.tab[data-tab-group="review"]:first-of-type,
.tab[data-tab-group="review"] {
  opacity: 0.92;
}

.tab[data-tab="library"] {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding-top: 6px;
}

.narration-audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.narration-audio-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.narration-speed-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.narration-check-line {
  display: flex;
  align-items: center;
  min-height: 38px;
}

.narration-check-line input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.narration-audio-list {
  display: grid;
  gap: 10px;
}

.narration-audio-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.narration-audio-item.active {
  border-color: var(--green);
  background: var(--green-2);
}

.narration-audio-player audio {
  width: 100%;
}

.narration-audio-skeleton-player {
  width: 100%;
  min-height: 36px;
  border-radius: 999px;
}

.narration-audio-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.narration-audio-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.narration-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e6f0f7;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.narration-badge.completed {
  color: var(--green);
  background: var(--green-2);
}

.narration-badge.failed {
  color: var(--red);
  background: var(--red-2);
}

.narration-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px 12px;
  color: var(--muted);
  font-size: 13px;
}

.video-cover-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.video-cover-preview-grid,
.video-cover-list {
  display: grid;
  gap: 10px;
}

.video-cover-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
  text-align: left;
  width: 100%;
}

.video-cover-card.active {
  border-color: var(--green);
  background: var(--green-2);
}

.video-cover-card.processing {
  border-color: #d3b04f;
  background: #fff8df;
}

.video-cover-card.failed {
  border-color: var(--red);
  background: var(--red-2);
}

.video-cover-thumb {
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.video-cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-cover-thumb .skeleton-thumb {
  width: 100%;
  height: 100%;
}

.video-cover-info {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.video-cover-info strong,
.video-cover-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-cover-info span {
  color: var(--muted);
  font-size: 12px;
}

.video-cover-status {
  display: inline-flex;
  width: max-content;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  background: #e6f0f7;
  color: var(--blue);
}

.video-cover-status.processing,
.video-cover-status.queued {
  background: #fff1bd;
  color: #7a5200;
}

.video-cover-status.failed {
  background: var(--red-2);
  color: var(--red);
}

.video-cover-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(122, 82, 0, 0.18);
  border-top-color: #b07a00;
  border-radius: 50%;
  animation: video-cover-spin 0.8s linear infinite;
}

@keyframes video-cover-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .avatar-management-workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .video-cover-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: space-between;
  }

  .workspace,
  .avatar-management-workspace,
  .avatar-create-grid,
  .editor-panel {
    grid-template-columns: 1fr;
  }

  .tab-strip {
    position: static;
    grid-row: auto;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    grid-template-columns: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius);
  }

  .tab {
    text-align: left;
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .tab[data-tab="library"] {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
    margin-left: 10px;
    border-left: 1px dashed var(--line);
    border-radius: 0;
  }

  .pane {
    grid-column: 1;
    grid-row: auto;
    border-radius: var(--radius);
  }

  .avatar-rail {
    position: static;
    max-height: none;
  }

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

  .library-workspace,
  .asset-upload-form,
  .segment-toolbar,
  .segment-grid,
  .composer-edit-grid {
    grid-template-columns: 1fr;
  }

  .composer-asset-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .composer-asset-card .duration-badge {
    grid-column: 2;
    justify-self: start;
  }

  .composer-map-card {
    grid-template-columns: 1fr;
  }

  .composer-match-strip {
    justify-content: flex-start;
  }

  .composer-match-chip {
    flex-basis: 156px;
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .composer-match-thumb {
    width: 52px;
  }

  .composer-timeline {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .material-gap-card {
    grid-template-columns: 1fr;
  }

  .material-thumb-strip {
    justify-content: flex-start;
  }

  .material-settings-summary {
    grid-template-columns: auto auto;
  }

  .material-settings-summary small {
    grid-column: 1 / -1;
  }

  .material-preview-layer {
    padding: 12px;
  }

  .material-preview-body {
    grid-template-columns: 1fr;
  }

  .material-preview-image {
    min-height: 42vh;
  }

  .material-preview-image img {
    max-height: 42vh;
  }

  .material-prompt-editor textarea {
    min-height: 220px;
  }

  .segment-row {
    grid-template-columns: 24px minmax(72px, 1fr) minmax(72px, 1fr);
  }

  .segment-row .form-grid,
  .segment-row .danger-btn {
    grid-column: 1 / -1;
  }

  .asset-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .asset-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .video-item {
    grid-template-columns: max-content minmax(0, 1fr);
  }

  .video-thumb {
    width: 78px;
  }

  .video-thumb.portrait {
    width: 54px;
  }
}
