/* 🎨 图片转绘工坊 —— 移动端优先的深色主题 */

:root {
  --bg-1: #0f172a;
  --bg-2: #1e1b4b;
  --card: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.10);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent-1: #f97316;
  --accent-2: #ec4899;
  --accent-3: #a855f7;
  --ok: #34d399;
  --err: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(168, 85, 247, 0.18), transparent 60%),
    radial-gradient(1000px 500px at -10% 10%, rgba(249, 115, 22, 0.16), transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  line-height: 1.5;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- 头部 ---------- */

.hero { text-align: center; padding: 8px 0 20px; }

.hero h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .sub { margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }

.banner {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.10);
  color: #fde68a;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
}

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

/* ---------- 上传区 ---------- */

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent-2);
  background: rgba(236, 72, 153, 0.06);
}

.dz-icon { font-size: 44px; line-height: 1; }
.dz-title { margin: 10px 0 4px; font-size: 15px; font-weight: 600; }
.dz-hint { margin: 0 0 14px; color: var(--text-dim); font-size: 12.5px; }

.dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */

.btn {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text);
  transition: transform .12s, filter .15s, opacity .15s;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(236, 72, 153, 0.28);
}

.btn.primary.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 14px; }

.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn.ghost:hover { background: rgba(255, 255, 255, 0.13); }

.btn.ghost.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }

/* ---------- 风格网格 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.style-card {
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, transform .12s, background .15s;
  user-select: none;
}

.style-card:active { transform: scale(0.96); }

.style-card .em { font-size: 26px; display: block; line-height: 1.2; }
.style-card .nm { font-size: 13px; font-weight: 600; margin-top: 6px; display: block; }
.style-card .ds { font-size: 11px; color: var(--text-dim); margin-top: 2px; display: block; }

.style-card.selected {
  border-color: transparent;
  background: linear-gradient(150deg, rgba(249, 115, 22, 0.30), rgba(236, 72, 153, 0.30));
  box-shadow: 0 0 0 2px var(--accent-2), 0 6px 18px rgba(236, 72, 153, 0.25);
}

.style-card.selected::after {
  content: "✓";
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 队列 ---------- */

#queueList { display: flex; flex-direction: column; gap: 8px; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 10px;
}

.q-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  flex: none;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.q-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.q-info { flex: 1; min-width: 0; }

.q-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.q-status { font-size: 12px; margin-top: 2px; }

.q-err { font-size: 11.5px; color: var(--err); margin-top: 2px; word-break: break-word; }

.st-ready { color: var(--text-dim); }
.st-working { color: var(--accent-1); }
.st-done { color: var(--ok); }
.st-error { color: var(--err); }

.q-rm {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.q-rm:active { transform: scale(0.92); }

/* ---------- 进度条 ---------- */

.progress {
  width: min(320px, 80vw);
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-top: 4px;
}

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

/* ---------- 结果分组 ---------- */

.result-group { margin-bottom: 18px; }

.rg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.rg-thumb {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--card-border);
}

.rg-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 选项行 ---------- */

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
}

.opt-label { color: var(--text-dim); font-size: 13.5px; }

.seg {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.seg-btn.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 600;
}

input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 12px;
  outline: none;
}

input:focus { border-color: var(--accent-2); }

input::placeholder { color: rgba(148, 163, 184, 0.7); }

/* ---------- 结果 ---------- */

.result-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.result-item {
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

.result-item img {
  width: 100%;
  display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  cursor: pointer;
}

.img-fail {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
}

.result-item .r-actions {
  display: flex;
  gap: 6px;
  padding: 8px;
}

.result-item .r-actions .btn { flex: 1; padding: 8px 4px; font-size: 12.5px; }

.elapsed { font-size: 12.5px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }

.result-actions { margin-top: 14px; text-align: center; }

/* ---------- 错误 ---------- */

.err {
  color: var(--err);
  font-size: 13px;
  margin: 12px 0 0;
  padding: 10px 12px;
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid rgba(248, 113, 113, 0.30);
  border-radius: 12px;
  word-break: break-word;
}

/* ---------- 加载遮罩 ---------- */

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 12, 24, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}

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

.loading p { margin: 0; }

#loadingText { font-size: 16px; font-weight: 600; }

.loading .time { font-size: 22px; font-weight: 700; color: var(--accent-1); font-variant-numeric: tabular-nums; }

.loading-hint { color: var(--text-dim); font-size: 12.5px; }

/* ---------- 页脚 ---------- */

.foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 16px 0 4px;
}

.hidden { display: none !important; }
