/* ========== generic tokens ========== */
:root {
  --primary: #2563eb;
  --primary-2: #14b8a6;
  --accent: #7c3aed;
  --bg: #eef3f8;
  --card-bg: rgba(255, 255, 255, 0.96);
  --border: #d7e2ee;
  --text: #102033;
  --text-muted: #64748b;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.05);
}

body {
  background:
    linear-gradient(rgba(37, 99, 235, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 184, 166, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 48%, #f7fbfa 100%);
  background-size: 30px 30px, 30px 30px, auto;
}

header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 56%, #0f766e 100%) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
header::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.10) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.2;
  pointer-events: none;
}
header > div {
  position: relative;
  z-index: 1;
}
header h1 {
  flex-wrap: wrap;
  line-height: 1.35;
}
.title-cn {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.08rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  color: #dff7ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
}
.flow-summary {
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-left: 3px solid var(--primary-2);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(240, 253, 250, 0.92));
  color: #1e293b;
  font-size: 0.86rem;
  line-height: 1.65;
  padding: 0.8rem 1rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
.section-note {
  margin-top: 0.25rem;
  padding: 0.42rem 0.6rem;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--primary-2);
  border-radius: 7px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.76rem;
  line-height: 1.5;
}

/* ========== card ========== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.95rem 1.1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transition: opacity 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}
.card:not(.disabled):hover {
  border-color: rgba(37, 99, 235, 0.24);
}
.card.disabled {
  opacity: 0.6;
  filter: grayscale(0.2);
}

#modelList { position: relative; z-index: 2; }

.step-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.step-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  line-height: 1.5;
}
.section-h {
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
}

/* ========== inputs ========== */
.input {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.42rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.86rem;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.textarea {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.88rem;
  background: #f8fafc;
  outline: none;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
}
.textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.file-input { font-size: 0.85rem; }

/* ========== buttons ========== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  padding: 0.45rem 0.95rem;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-ghost {
  background: transparent;
  color: #475569;
  padding: 0.4rem 0.85rem;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 500;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-mini {
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  cursor: pointer;
  line-height: 1;
}
.btn-mini:hover { background: #f1f5f9; }
.btn-select {
  font-size: 0.78rem;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
  width: 100%;
}
.btn-select:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}

/* ========== model chip ========== */
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.65rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.12s ease;
}
.model-chip:hover { border-color: #bfdbfe; background: #f8fbff; }
.model-chip:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eff6ff, #f0fdfa);
  color: var(--primary);
  font-weight: 600;
}
.model-chip input { accent-color: var(--primary); }

/* ========== script chooser ========== */
.script-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.script-card:hover { border-color: #bfdbfe; background: #f8fbff; }
.script-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eff6ff, #f0fdfa);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.script-card .label { font-weight: 600; color: var(--text); font-size: 0.88rem; }
.script-card .desc { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.18rem; line-height: 1.4; }

/* ========== segment / voice cards ========== */
.seg-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.6rem 0.7rem;
  background: #fff;
}
.seg-card h4 {
  font-weight: 600;
  color: var(--text);
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}
.seg-card audio { width: 100%; height: 32px; }
.seg-card .text-input {
  margin-top: 0.35rem;
  width: 100%;
  font-size: 0.78rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  font-family: inherit;
  resize: vertical;
}

/* ========== badges ========== */
.badge {
  display: inline-block;
  font-size: 0.66rem;
  padding: 0.1rem 0.42rem;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge.zero { background: #ecfeff; color: #0e7490; border: 1px solid #67e8f9; }
.badge.one  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge.model{ background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* ========== audition grid ========== */
.audi-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.audi-card .row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.audi-card .row.top { justify-content: space-between; }
.audi-card .row.id-row { gap: 0.35rem; }
.audi-card code {
  flex: 1;
  font-size: 0.72rem;
  color: #1d4ed8;
  background: #f1f5f9;
  padding: 0.18rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.audi-card audio { width: 100%; height: 32px; margin-top: 0.15rem; }
.audi-card.pending  { border-style: dashed; background: #f8fafc; }
.audi-card.cloning  { border-color: #bfdbfe; background: #f8fbff; }
.audi-card.ok       { border-color: #bfdbfe; background: #f8fbff; }
.audi-card.fail     { background: #fff5f5; border-color: #fecaca; }
.audi-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eff6ff, #f0fdfa);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.audi-card .vc-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.audi-card .vc-status.loading { color: var(--primary); }
.audi-card .vc-status.okk { color: #047857; font-weight: 700; }
.audi-card .vc-status.err { color: #b91c1c; font-weight: 700; }
.audi-card .vc-detail {
  font-size: 0.7rem;
  color: #94a3b8;
  word-break: break-all;
  line-height: 1.35;
}
.audi-card .vc-detail .err { color: #b91c1c; font-weight: 500; }
.audi-card .warn {
  font-size: 0.75rem;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 0.3rem 0.5rem;
  border-radius: 5px;
}

/* ========== upload progress rows ========== */
.upload-row {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.45rem;
  row-gap: 0.1rem;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  font-size: 0.8rem;
  align-items: center;
}
.upload-row.pending  { border-style: dashed; color: #94a3b8; background: #f8fafc; }
.upload-row.uploading{ border-color: #bfdbfe; background: #f5f3ff; }
.upload-row.done     { border-color: #bbf7d0; background: #f0fdf4; }
.upload-row.failed   { border-color: #fecaca; background: #fef2f2; }
.upload-row .upload-icon {
  grid-row: span 2;
  font-weight: 700;
  text-align: center;
  font-size: 0.95rem;
  color: #475569;
}
.upload-row.uploading .upload-icon { color: var(--primary); }
.upload-row.done      .upload-icon { color: #16a34a; }
.upload-row.failed    .upload-icon { color: #dc2626; }
.upload-row .upload-label { font-weight: 500; color: var(--text); }
.upload-row .upload-fid   { font-size: 0.68rem; color: var(--primary); text-align: right; }
.upload-row .upload-status{ grid-column: 2 / span 2; font-size: 0.68rem; color: var(--text-muted); }
.upload-row.uploading .upload-status { color: var(--primary); }
.upload-row.done      .upload-status { color: #047857; }
.upload-row.failed    .upload-status { color: #b91c1c; }

/* ========== toast ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}
#confirmModal.flex { display: flex; }
