.fuyao-video-mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 168px;
  min-width: 168px;
  height: 30px;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid #d9e2f1;
  border-radius: 7px;
  background: #f4f7fb;
}

.fuyao-video-mode-switch button {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.fuyao-video-mode-switch button + button {
  border-left: 1px solid #d9e2f1;
}

.fuyao-video-mode-switch button.is-active {
  background: #2563eb;
  color: #fff;
}

.fuyao-editor-context {
  display: none;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.fuyao-editor-context strong {
  color: #1e3a8a;
  font-weight: 700;
}

.fuyao-editor-context .fuyao-editor-price,
.fuyao-editor-panel-head b {
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.studio-composer-head > .studio-composer-model {
  display: none !important;
}

.fuyao-action-billing {
  display: inline-flex;
  min-width: 0;
  max-width: min(300px, 34vw);
  flex: 0 1 auto;
  align-items: center;
  gap: 7px;
  color: #64748b;
  font-size: 12px;
  line-height: 30px;
  white-space: nowrap;
}

.fuyao-action-billing strong {
  min-width: 0;
  overflow: hidden;
  color: #1e3a8a;
  font-weight: 700;
  text-overflow: ellipsis;
}

.fuyao-action-billing .fuyao-action-price {
  flex: 0 0 auto;
  color: #b45309;
  font-weight: 700;
}

.fuyao-editor-panel {
  display: none;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  background: #f6f9fd;
}

.fuyao-editor-active > .studio-unified-timeline {
  display: none !important;
}

.fuyao-editor-active > .fuyao-editor-panel {
  display: flex;
}

.fuyao-editor-active .studio-composer-head > .studio-composer-mode,
.fuyao-editor-active .studio-composer-head > .studio-composer-model,
.fuyao-editor-active .studio-composer-head > .studio-composer-meta,
.fuyao-editor-active .studio-composer-head > .studio-composer-hint {
  display: none !important;
}

.fuyao-editor-active .fuyao-editor-context {
  display: inline-flex;
}

.fuyao-editor-active [data-fuyao-editor-hide] {
  display: none !important;
}

.fuyao-editor-reference-root {
  display: none;
  grid-area: reference-cards;
  min-width: 0;
}

.fuyao-editor-active .fuyao-editor-reference-root {
  display: block;
}

.fuyao-editor-active .studio-reference-cards,
.fuyao-editor-active .studio-composer-refs {
  display: none !important;
}

.fuyao-editor-reference-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.fuyao-editor-reference-card {
  position: relative;
  display: grid;
  min-width: 0;
  height: 108px;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.fuyao-editor-reference-card:hover:not(:disabled),
.fuyao-editor-reference-card:focus-visible:not(:disabled) {
  border-color: #6366f1;
  background: #f8faff;
  outline: 2px solid rgba(99, 102, 241, 0.12);
}

.fuyao-editor-reference-card:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.fuyao-editor-reference-title {
  overflow: hidden;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fuyao-editor-reference-preview {
  align-self: center;
  overflow: hidden;
  color: #6366f1;
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fuyao-editor-reference-count {
  position: absolute;
  right: 7px;
  bottom: 6px;
  color: #64748b;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.fuyao-editor-reference-list {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.fuyao-editor-reference-chip {
  display: inline-flex;
  max-width: 180px;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  border: 1px solid #dbe4f0;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  padding: 3px 5px 3px 8px;
  font-size: 10px;
}

.fuyao-editor-reference-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fuyao-editor-reference-chip button {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 0;
  border-radius: 4px;
  background: #eef2f7;
  color: #64748b;
  padding: 0;
  cursor: pointer;
}

.fuyao-editor-active .studio-send-button.fuyao-editor-busy {
  opacity: 0.65;
  cursor: wait;
}

.fuyao-editor-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid #e1e8f2;
  background: rgba(255, 255, 255, 0.88);
}

.fuyao-editor-panel-head > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.fuyao-editor-panel-head strong {
  color: #0f172a;
  font-size: 14px;
}

.fuyao-editor-panel-head span {
  color: #64748b;
  font-size: 12px;
}

.fuyao-editor-panel-head button,
.fuyao-editor-result button {
  min-height: 30px;
  border: 1px solid #d5deeb;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  padding: 0 11px;
  font-size: 12px;
  cursor: pointer;
}

.fuyao-editor-messages {
  width: min(100%, 980px);
  min-height: 0;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 44px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.fuyao-editor-empty {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #64748b;
  text-align: center;
}

.fuyao-editor-empty strong {
  color: #334155;
  font-size: 14px;
}

.fuyao-editor-empty span:last-child {
  font-size: 12px;
}

.fuyao-editor-empty-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #cdd8e8;
  border-radius: 50%;
  background: #fff;
  color: #2563eb;
  font-size: 13px;
}

.fuyao-editor-message {
  width: min(84%, 720px);
  margin-bottom: 16px;
}

.fuyao-editor-message.is-user {
  margin-left: auto;
}

.fuyao-editor-message-meta {
  margin-bottom: 5px;
  color: #64748b;
  font-size: 11px;
}

.fuyao-editor-message.is-user .fuyao-editor-message-meta {
  text-align: right;
}

.fuyao-editor-message > p {
  margin: 0;
  border: 1px solid #dce4ef;
  border-radius: 7px;
  background: #fff;
  color: #1e293b;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.fuyao-editor-message.is-user > p {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.fuyao-editor-progress {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  color: #64748b;
  font-size: 12px;
}

.fuyao-editor-progress i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2563eb;
  animation: fuyao-editor-pulse 1.1s infinite ease-in-out;
}

.fuyao-editor-progress i:nth-child(2) { animation-delay: 0.15s; }
.fuyao-editor-progress i:nth-child(3) { animation-delay: 0.3s; }

@keyframes fuyao-editor-pulse {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.fuyao-editor-result {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #dce4ef;
  border-radius: 7px;
  background: #fff;
}

.fuyao-editor-result video {
  display: block;
  width: 100%;
  max-height: 420px;
  aspect-ratio: 16 / 9;
  background: #0b1220;
  object-fit: contain;
}

.fuyao-editor-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: #64748b;
  font-size: 12px;
}

.fuyao-editor-result-row > div {
  display: flex;
  gap: 7px;
}

.dark .fuyao-video-mode-switch,
.dark .fuyao-editor-panel,
.dark .fuyao-editor-message > p,
.dark .fuyao-editor-result,
.dark .fuyao-editor-panel-head,
.dark .fuyao-editor-panel-head button,
.dark .fuyao-editor-result button,
.dark .fuyao-editor-empty-icon {
  border-color: #334155;
  background: #111827;
}

.dark .fuyao-editor-panel { background: #0b1120; }
.dark .fuyao-editor-panel-head strong,
.dark .fuyao-editor-message > p,
.dark .fuyao-editor-empty strong { color: #e5e7eb; }
.dark .fuyao-editor-context strong { color: #93c5fd; }
.dark .fuyao-action-billing strong { color: #93c5fd; }
.dark .fuyao-editor-message.is-user > p { border-color: #1d4ed8; background: #172554; }

@media (max-width: 820px) {
  .fuyao-video-mode-switch {
    width: 146px;
    min-width: 146px;
    height: 29px;
  }

  .fuyao-video-mode-switch button { font-size: 11px; }
  .fuyao-editor-context > span:last-child { display: none; }
  .fuyao-action-billing { max-width: 220px; }
  .fuyao-editor-messages { padding: 18px 12px 28px; }
  .fuyao-editor-message { width: 94%; }
  .fuyao-editor-panel-head { padding: 10px 12px; }
}

@media (max-width: 520px) {
  .studio-composer-head {
    flex-wrap: nowrap;
  }

  .fuyao-video-mode-switch {
    order: 0;
    width: 140px;
    min-width: 140px;
    margin-left: auto;
  }

  .fuyao-editor-active .fuyao-editor-context {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .fuyao-editor-active .fuyao-editor-context strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fuyao-action-billing {
    max-width: 44vw;
    gap: 5px;
    font-size: 11px;
  }
}
