/* 生成编辑器页 —— 类名统一 cv- 前缀，全部颜色走 tokens.css */

.cv {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font);
}

/* ============ 顶部 ============ */
.cv-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.cv-back {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-surface-muted);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.cv-back:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.cv-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

/* ============ 三栏骨架 ============ */
.cv-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.cv-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-surface);
}

.cv-h {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cv-hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.cv-skel {
  height: 190px;
  border-radius: var(--r-card);
  background: var(--bg-surface-muted);
  animation: cv-pulse 1.2s ease-in-out infinite;
}

@keyframes cv-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

/* ============ 左栏：自定义下拉 ============ */
.cv-select {
  position: relative;
  margin-bottom: 14px;
}

.cv-select__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface-muted);
  transition: border-color 0.18s ease;
}

.cv-select__btn:hover,
.cv-select.is-open .cv-select__btn {
  border-color: var(--border-strong);
}

.cv-select__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-select__label.is-empty {
  color: var(--text-muted);
  font-weight: 500;
}

.cv-select__caret {
  flex: none;
  font-size: 10px;
  color: var(--text-muted);
}

.cv-select__scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.cv-select__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 41;
  max-height: 300px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: 0 18px 40px var(--shadow);
}

.cv-select__item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  color: var(--text-2);
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-select__item:hover {
  color: var(--text);
  background: var(--hover-overlay);
}

.cv-select__item.is-on {
  color: var(--text);
  background: var(--bg-surface-muted);
}

.cv-select__none {
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ 左栏：模板摘要 ============ */
.cv-tpl {
  min-width: 0;
}

.cv-tpl__media {
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: var(--r-card);
  background: var(--bg-surface-muted);
}

.cv-tpl__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cv-tpl__name {
  margin: 12px 0 4px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.1px;
  word-break: break-word;
}

.cv-tpl__author {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.cv-tpl__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cv-tpl__meta span {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}

/* ============ 中栏：拖拽上传区 ============ */
.cv-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 220px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
  background: var(--bg-surface-muted);
  transition: border-color 0.18s ease, background 0.18s ease;
  cursor: pointer;
}

.cv-drop:hover,
.cv-drop.is-drag {
  border-color: var(--primary);
}

.cv-drop.is-drag {
  background: var(--hover-overlay);
}

.cv-drop.is-full {
  cursor: default;
}

.cv-file {
  display: none;
}

.cv-drop__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-surface);
}

.cv-drop__title {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.cv-drop__hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.cv-drop__foot {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.cv-thumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.cv-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

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

.cv-thumb__del {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  color: var(--text);
  border-radius: var(--r-pill);
  background: var(--bg-overlay);
}

.cv-thumb__del:hover {
  background: var(--primary);
}

.cv-thumb--add {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  border-style: dashed;
  border-color: var(--border-strong);
  background: transparent;
}

.cv-thumb--add:hover {
  color: var(--text);
  border-color: var(--primary);
}

.cv-notice {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ============ 中栏：prompt ============ */
.cv-field {
  position: relative;
  margin-top: 14px;
}

.cv-text {
  display: block;
  width: 100%;
  min-height: 128px;
  padding: 12px 14px 26px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-surface-muted);
  outline: none;
  transition: border-color 0.18s ease;
}

.cv-text::placeholder {
  color: var(--text-muted);
}

.cv-text:focus {
  border-color: var(--primary);
}

.cv-count {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ============ 中栏：参考强度 / 镜头 ============ */
.cv-opts {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.cv-opt {
  min-width: 0;
}

.cv-opt__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.cv-opt__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}

.cv-opt__val {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.cv-range {
  width: 100%;
  height: 6px;
  margin: 0;
  accent-color: var(--primary);
  border-radius: var(--r-pill);
  background: var(--bg-surface-muted);
  cursor: pointer;
}

/* ============ 胶囊组（时长 / 画质 / 镜头） ============ */
.cv-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cv-pill {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-surface-muted);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.cv-pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.cv-pill.is-on {
  color: var(--text-on-primary);
  border-color: var(--primary);
  background: var(--primary);
}

/* ============ 右栏：开关 / 估价 / 进度 ============ */
.cv-group {
  margin-bottom: 16px;
}

.cv-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}

.cv-label__hint {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.cv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cv-row__text .cv-label {
  margin-bottom: 2px;
}

.cv-toggle {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  padding: 0;
  border-radius: var(--r-pill);
  background: var(--bg-surface-muted);
  border: 1px solid var(--border);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.cv-toggle.is-on {
  background: var(--primary);
  border-color: var(--primary);
}

.cv-toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--text);
  transition: transform 0.18s ease;
}

.cv-toggle.is-on .cv-toggle__knob {
  transform: translateX(18px);
}

.cv-cost {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  margin-bottom: 16px;
  border-top: 1px solid var(--border);
}

.cv-cost__k {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}

.cv-cost__v {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text);
}

.cv-cost__v em {
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  color: var(--text-muted);
}

.cv-progress {
  margin-bottom: 12px;
}

.cv-progress__bar {
  height: 6px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--bg-surface-muted);
}

.cv-progress__fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--primary);
  transition: width 0.12s linear, background 0.2s ease;
}

.cv-progress__meta {
  margin: 6px 0 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* ============ 主按钮 ============ */
.cv-gen {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-on-primary);
  border-radius: var(--r-pill);
  background: var(--primary);
  transition: background 0.18s ease, opacity 0.18s ease;
}

.cv-gen:hover {
  background: var(--primary-hover);
}

.cv-gen.is-loading,
.cv-gen:disabled {
  cursor: default;
  opacity: 0.72;
}

.cv-spin {
  width: 13px;
  height: 13px;
  border: 2px solid var(--text-on-primary);
  border-top-color: transparent;
  border-radius: var(--r-pill);
  animation: cv-spin 0.7s linear infinite;
}

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

.cv-done {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ============ 单栏收拢 ============ */
@media (max-width: 1100px) {
  .cv-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cv-tpl__media {
    aspect-ratio: 16 / 9;
  }

  .cv-select__list {
    max-height: 240px;
  }
}

/* 付费墙提示：生成必须付费，余额不够时出现在 Generate 下面 */
.cv-paywall {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgb(var(--color-warning-rgb, 245 158 11) / 0.45);
  border-radius: var(--r-card);
  background: rgb(245 158 11 / 0.08);
}

.cv-paywall__text {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.cv-paywall__btn {
  width: 100%;
  padding: 9px 0;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-radius: var(--r-pill);
  background: var(--primary);
}

.cv-paywall__btn:hover { background: var(--primary-hover); }

/* 模板锁定时长：其它档位变灰不可点 */
.cv-pill.is-locked {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
}
