:root {
  --bg: #0f1115;
  --card: #171a21;
  --card-2: #1d212b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --text-dim: #9aa3b2;
  --accent: #6c8cff;
  --accent-2: #9d6cff;
  --ok: #37d67a;
  --err: #ff6b6b;
  --warn: #ffb454;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2030 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 26, 33, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 20px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(108, 140, 255, 0.35);
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: default;
  background: var(--card);
}

.badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}

.badge-ok .dot {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.badge-err .dot {
  background: var(--err);
  box-shadow: 0 0 8px var(--err);
}

main {
  max-width: 920px;
  margin: 24px auto 60px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-box {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.18s, background 0.18s;
  background: var(--card-2);
}

.upload-box:hover,
.upload-box.dragover {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.06);
}

.upload-box.has-image {
  border-style: solid;
  border-color: var(--border);
}

.upload-hint {
  text-align: center;
  color: var(--text-dim);
  pointer-events: none;
}

.upload-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(108, 140, 255, 0.12);
  border: 1px solid rgba(108, 140, 255, 0.35);
}

.upload-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.upload-desc,
.upload-ext {
  margin: 0;
  font-size: 12px;
}

.upload-ext {
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.65;
}

.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b0d11;
  display: none;
}

.upload-box.has-image .preview {
  display: block;
}

.upload-box.has-image .upload-hint {
  display: none;
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: none;
  z-index: 2;
}

.upload-box.has-image:hover .remove-btn {
  display: block;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-dim);
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.18s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(108, 140, 255, 0.28);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(108, 140, 255, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-icon {
  margin-right: 4px;
}

.queue-hint {
  font-size: 12px;
  color: var(--warn);
}

.progress-area {
  margin-top: 18px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.status-text {
  font-size: 13px;
  color: var(--text-dim);
}

.progress-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--card-2);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.elapsed {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

.error-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: var(--err);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.result-head h2 {
  margin: 0;
  font-size: 16px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.result-stage {
  border-radius: 12px;
  background: #0b0d11;
  border: 1px solid var(--border);
  padding: 10px;
  text-align: center;
}

#resultImg {
  max-width: 100%;
  max-height: 620px;
  border-radius: 8px;
}

.footer {
  padding: 18px 28px 30px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.footer code {
  background: var(--card-2);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.footer-hint {
  margin-left: 12px;
  color: var(--ok);
}

@media (max-width: 640px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 14px 16px;
  }
}
