@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,500&display=swap");

:root {
  --bg: #0c0d12;
  --surface: #151821;
  --surface2: #1c2030;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #ff2d6a;
  --accent-dim: #ff6b94;
  --ok: #3dd68c;
  --warn: #ffc233;
  --r: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 45, 106, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(99, 102, 241, 0.08), transparent);
}

.app { max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}
.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--accent-dim); }

.logo-icon { font-size: 2.5rem; display: block; margin-bottom: 0.25rem; }
h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  background: linear-gradient(120deg, #fff 0%, var(--accent-dim) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { color: var(--muted); font-size: 0.9rem; margin: 0; max-width: 36rem; margin-inline: auto; }

.banner-key {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  font-size: 0.75rem;
}
.banner-key span {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.35rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-num {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #c41e5c);
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}

.template-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  background: var(--surface2);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  text-align: left;
}
.template-card:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}
.template-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.template-card input { position: absolute; opacity: 0; pointer-events: none; }
.template-card .t-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
.template-card .t-desc { font-size: 0.72rem; color: var(--muted); line-height: 1.35; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: rgba(255, 255, 255, 0.02);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(255, 45, 106, 0.06);
}
.drop-zone p { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.drop-zone .dz-main { font-size: 0.95rem; color: var(--text); }
.preview-wrap {
  margin-top: 0.75rem;
  display: none;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 220px;
}
.preview-wrap.show { display: block; }
.preview-wrap img { width: 100%; height: auto; display: block; vertical-align: middle; }

label.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
input[type="url"],
input[type="number"].duration-input,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
input[type="number"].duration-input { max-width: 12rem; }
input[type="url"]:focus,
input.duration-input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 45, 106, 0.15);
}
textarea { min-height: 88px; resize: vertical; }

.hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; }

.reachability-warn {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--r);
  border: 1px solid rgba(255, 194, 51, 0.45);
  background: rgba(255, 194, 51, 0.08);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
}
.reachability-warn code {
  font-size: 0.78em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface2);
}
.reachability-warn a { color: var(--accent-dim); }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c41e5c);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 45, 106, 0.35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }

.status-panel {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--r);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.status-panel.show { display: block; }

.progress-line {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.65rem 0;
}
.progress-line > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.video-result {
  margin-top: 1rem;
  display: none;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.video-result.show { display: block; }
.video-result video { width: 100%; display: block; max-height: 520px; }

.err { color: #ff7b7b; font-size: 0.85rem; margin-top: 0.5rem; }

.footer-note {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
.footer-note a { color: var(--accent-dim); }

.key-missing {
  background: rgba(255, 194, 51, 0.12);
  border: 1px solid rgba(255, 194, 51, 0.35);
  color: var(--warn);
  padding: 0.75rem 1rem;
  border-radius: var(--r);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.key-missing.show { display: block; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 100;
  transition: transform 0.35s ease;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
  .template-grid { grid-template-columns: 1fr; }
}
