:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #d8dde6;
  --line-strong: #aeb6c5;
  --text: #1f2a37;
  --muted: #607089;
  --accent: #1268f3;
  --accent-hover: #0d52c6;
  --danger: #dc2f45;
  --ok: #1f8f55;
  --shadow: 0 20px 40px rgba(22, 34, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "Manrope", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 0% 0%, #ffffff 0%, #f6f8fb 40%, #eff2f8 100%);
  color: var(--text);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(18, 104, 243, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(18, 104, 243, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
}

.page {
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
  padding: 26px 20px 48px;
}

.hero {
  margin-bottom: 18px;
}

.hero__tag {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
}

.hero h1 {
  margin: 8px 0;
  font-size: clamp(1.4rem, 2.6vw, 2.25rem);
  letter-spacing: 0.03em;
}

.hero__desc {
  margin: 0;
  color: var(--muted);
}

.modules {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: 430px;
  animation: reveal 0.5s ease both;
}

.panel:nth-child(2) {
  animation-delay: 0.06s;
}

.panel:nth-child(3) {
  animation-delay: 0.12s;
}

.panel:nth-child(4) {
  animation-delay: 0.18s;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  line-height: 1.4;
}

.panel__head {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.panel__hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.btn {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 700;
}

.btn--ghost {
  background: #eef3ff;
  color: var(--accent);
  padding: 8px 10px;
  white-space: nowrap;
}

.btn--ghost:hover {
  background: #dce7ff;
}

.btn--danger-mini {
  background: #fdecef;
  color: #b21f36;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1;
}

.btn--danger-mini:hover {
  background: #f9d8df;
}

.btn--primary {
  background: linear-gradient(120deg, #1469f2, #1c88ff);
  color: #fff;
  min-width: 180px;
  padding: 14px 30px;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(20, 105, 242, 0.35);
}

.btn--primary:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.character-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.character-item {
  display: grid;
  gap: 8px;
}

.character-item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pair-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.slot-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 0.92rem;
}

.uploader-slot {
  min-height: 136px;
}

.uploader {
  position: relative;
  min-height: 136px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #f9fafc;
  overflow: hidden;
}

.uploader__input {
  display: none;
}

.uploader__trigger {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
}

.plus {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: #5d697e;
  font-size: 1.4rem;
  line-height: 1;
}

.upload-text {
  font-size: 0.88rem;
}

.uploader__preview {
  height: 136px;
  width: 100%;
  background: #edf1f6;
}

.uploader__preview img,
.uploader__preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.uploader__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  background: rgba(24, 33, 49, 0.72);
}

.prompt-box {
  width: 100%;
  resize: vertical;
  min-height: 280px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  padding: 12px;
  font: inherit;
  line-height: 1.6;
  color: var(--text);
  background: #fbfcfe;
}

.resolution-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.resolution-select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.resolution-select:focus {
  outline: 2px solid rgba(18, 104, 243, 0.22);
  border-color: var(--accent);
}

.prompt-box:focus {
  outline: 2px solid rgba(18, 104, 243, 0.22);
  border-color: var(--accent);
}

.action-zone {
  margin-top: 24px;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.status-text {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
}

.result {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.result h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.result video {
  width: min(100%, 900px);
  border-radius: 10px;
  background: #0f1117;
}

.result-actions {
  margin-top: 10px;
}

.btn--download {
  text-decoration: none;
  display: inline-block;
  min-width: 120px;
  text-align: center;
  padding: 10px 16px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 21, 36, 0.4);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-card {
  width: min(92vw, 370px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  text-align: center;
}

.loader {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid #d9e3f5;
  border-top-color: var(--accent);
  display: inline-block;
  animation: spin 0.85s linear infinite;
}

.loading-card p {
  margin: 12px 0 0;
  color: #2e3a4f;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .modules {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 760px) {
  .page {
    padding: 14px 12px 36px;
  }

  .modules {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }
}
