/* ═══ 二次元 · 樱花粉女性化主题 ═══ */
:root {
  --bg: #fff7fa;
  --bg-soft: #ffeef5;
  --panel: #ffffff;
  --panel-2: #fff2f7;
  --border: #ffd3e4;
  --text: #6b4a5c;
  --muted: #c08da6;
  --accent: #ff7fb0;
  --accent-2: #c9a2ec;
  --danger: #ff6b8f;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(255, 143, 189, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 520px at 88% -60px, rgba(255, 182, 214, 0.38), transparent 62%),
    radial-gradient(950px 440px at -12% 34%, rgba(201, 162, 236, 0.22), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 顶栏 ───────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.3px; }
.brand .ver {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: #ffe9f2;
  border: 1px solid #ffc3dc;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.topbar nav a { margin-left: 18px; color: var(--muted); font-size: 14px; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

/* ── 隐私横幅 ───────────────────────── */
.privacy-banner {
  margin: 18px auto 0;
  max-width: 920px;
  padding: 12px 18px;
  background: #ffe9f2;
  border: 1px solid #ffc3dc;
  border-radius: var(--radius);
  font-size: 14px;
  color: #a4607f;
  text-align: center;
}
.privacy-banner strong { color: var(--accent); }

/* ── 主区 ───────────────────────────── */
main {
  max-width: 920px;
  margin: 22px auto;
  padding: 0 18px;
  display: grid;
  gap: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.panel[hidden] {
  display: none;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}
.field > span { min-width: 56px; color: var(--muted); font-size: 14px; }
.field select,
.field input[type="color"],
.field input[type="file"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 14px;
}
.field input[type="range"] { flex: 1; accent-color: var(--accent); }
.field em { font-style: normal; color: var(--accent); font-size: 13px; }

.meta {
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  white-space: pre-wrap;
}

.license-row {
  font-size: 13px;
  margin: 12px 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.license-badge {
  font-weight: 700;
  color: #9b6fd8;
  background: #f3ebff;
  border: 1px solid #ddc5f7;
  padding: 2px 10px;
  border-radius: 999px;
}
.muted { color: var(--muted); font-size: 13px; }

.auto-note {
  font-size: 12.5px;
  color: #e5588f;
  background: #ffe9f2;
  border: 1px solid #ffc3dc;
  border-radius: 10px;
  padding: 7px 10px;
  margin: 8px 0 0;
}

.advanced { margin-top: 12px; font-size: 14px; }
.advanced summary {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
}
.advanced[open] summary { margin-bottom: 8px; }

/* ── Hero（二次元粉嫩首屏）──────────── */
.hero {
  text-align: center;
  padding: 30px 10px 4px;
  position: relative;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: 1px;
  background: linear-gradient(95deg, #ff7fb0 20%, #c9a2ec 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero h1::before { content: "❀ "; font-size: 0.75em; vertical-align: middle; }
.hero h1::after { content: " ❀"; font-size: 0.75em; vertical-align: middle; }
.hero-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}
.dz-icon {
  width: 42px;
  height: 42px;
  color: var(--accent);
  background: #ffe9f2;
  border: 1px solid #ffc3dc;
  border-radius: 50%;
  padding: 12px;
  box-sizing: content-box;
}
.dz-main { font-size: 17px; font-weight: 650; color: var(--text); margin: 12px 0 2px; }
.hero .dropzone { max-width: 620px; margin: 0 auto; padding: 42px 18px; }
.dz-note { margin: 10px 0 0; font-size: 12.5px; }
.hero .status { max-width: 620px; margin: 10px auto; }
.hero .auto-note { max-width: 620px; margin: 8px auto 0; text-align: left; }
.hero button.primary { margin-top: 6px; }

/* ── 拖拽区 ─────────────────────────── */
.dropzone {
  border: 2px dashed #ffb6d2;
  border-radius: 20px;
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.6);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: #fff0f6;
  color: var(--accent);
  transform: translateY(-1px);
}
.dropzone p { margin: 4px 0; }

/* 未选择图片类型时，上传区锁定（禁用点击 / 拖拽添加） */
.dropzone.locked {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #ffb6d2;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  transform: none;
}
.dropzone.locked:hover { transform: none; border-color: #ffb6d2; }
#typeLocked { margin: 10px 0 0; font-size: 12.5px; color: var(--accent); }

.progress {
  margin: 14px 0 6px;
  height: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff9fc3, #c9a2ec);
  text-indent: -9999px;
  transition: width 0.2s;
}
/* 加载权重 / 初始化会话期间：精确百分比由引擎文本状态承担，进度条显示「进行中」动画 */
.progress-bar.indeterminate {
  width: 40% !important;
  animation: progress-indeterminate 1.1s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 8px 0; }

/* ── 按钮 ───────────────────────────── */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 9px 16px;
  background: var(--panel-2);
  color: var(--text);
  transition: filter 0.15s, opacity 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { filter: brightness(1.05); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, #ff9fc3, #ff6fa5);
  border-color: transparent;
  color: #fff;
  font-weight: 650;
  box-shadow: 0 4px 14px rgba(255, 111, 165, 0.35);
}
button.primary:hover:not(:disabled) { filter: brightness(1.06); }
button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
button.ghost:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }

.buttons { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ── 结果画布：左右并排 · 带间隔 · 自适应 ── */
.canvas-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 6px;
}
.canvas-wrap figure {
  margin: 0;
  min-width: 0;
}
.canvas-wrap figcaption {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
/* 自适应边框：图片等比缩到框内（contain），不裁剪、不变形、不出界 */
.canvas-wrap canvas {
  display: block;
  margin: 0 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
#outCanvas {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ffe9f2 25%, transparent 25%),
    linear-gradient(-45deg, #ffe9f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ffe9f2 75%),
    linear-gradient(-45deg, transparent 75%, #ffe9f2 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ── 背景选项行 ─────────────────────── */
.bg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 2px;
}
.bg-label { color: var(--muted); font-size: 14px; min-width: 32px; }
.bg-opt {
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
}
.bg-opt.active {
  background: linear-gradient(135deg, #ff9fc3, #ff6fa5);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* ── 风景背景缩略图 ─────────────────── */
.bg-scene {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 4px;
}
.bg-scene .bg-label { padding-top: 8px; }
.scene-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.scene-btn {
  width: 78px;
  height: 52px;
  padding: 0;
  border-radius: 12px;
  border: 2px solid var(--border);
  background-size: cover;
  background-position: center;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.scene-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.scene-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 127, 176, 0.35), var(--shadow);
}

/* 取色器本体藏起来（点「自定义…」时程序化 click 打开拾色器；
   不能用 display:none，部分浏览器会拒绝为不可见元素打开拾色器） */
.sr-color {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

button.big {
  width: 100%;
  padding: 13px 18px;
  font-size: 16px;
  margin-top: 14px;
}

/* ── 运行环境面板 ───────────────────── */
.panel.env .muted { margin: 4px 0; }
.panel.env button.ghost { margin-top: 12px; }

/* ── 页脚 ───────────────────────────── */
footer {
  max-width: 920px;
  margin: 28px auto 40px;
  padding: 0 18px;
  font-size: 13px;
  color: var(--muted);
}
footer p { margin: 6px 0; }

/* ── 批量处理页 ─────────────────────── */
.batch-hero { padding: 22px 18px 8px; }
.batch-hero h1 { font-size: 30px; }

#countNote { margin: 14px 0 4px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}
.actions .primary { flex: 1 1 220px; }

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 6px;
}
.batch-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.card-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card-thumbs figure { margin: 0; }
.card-thumbs figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.card-thumbs .mini {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
}
#outCanvas, .card-thumbs .mini {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d7dce4 25%, transparent 25%),
    linear-gradient(-45deg, #d7dce4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d7dce4 75%),
    linear-gradient(-45deg, transparent 75%, #d7dce4 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.card-status {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}
.card-status.ok { color: #1f9d55; }
.card-status.err { color: #d23b3b; }
.card-dl { width: 100%; }

@media (max-width: 640px) {
  main { padding: 0 12px; margin: 16px auto; gap: 14px; }
  .panel { padding: 16px 14px; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 4px; }
  .brand { font-size: 15px; }
  .brand .ver { font-size: 10px; padding: 1px 6px; }
  .topbar nav {
    flex: 1 1 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px 4px;
  }
  .topbar nav a { margin-left: 0; font-size: 13px; padding: 2px 4px; }
  .privacy-banner { font-size: 13px; padding: 10px 14px; }
  /* 窄屏表单字段改为纵向铺满，下拉框/文件框占满宽度，避免挤压 */
  .field { flex-direction: column; align-items: stretch; gap: 6px; }
  .field > span { min-width: 0; }
  .field select,
  .field input[type="file"] { width: 100%; }
  .canvas-wrap { grid-template-columns: 1fr; gap: 14px; }
  .bg-opt { padding: 8px 14px; font-size: 13px; min-height: 38px; display: inline-flex; align-items: center; }
  .scene-btn { width: 64px; height: 44px; }
  .batch-card { padding: 12px; }
  .card-thumbs { grid-template-columns: 1fr; gap: 12px; }
  .actions { gap: 10px; }
  /* 触控友好：主要操作按钮在手机上至少 44–48px 高 */
  .actions button,
  .card-dl { min-height: 44px; }
  .actions .primary,
  button.big { min-height: 48px; font-size: 16px; }
  .dropzone { padding: 28px 14px; }
  .dz-main { font-size: 16px; }
}

@media (max-width: 380px) {
  .topbar nav a { font-size: 12px; }
  .brand { font-size: 14px; }
  .hero h1 { font-size: 24px; }
  .batch-hero h1 { font-size: 24px; }
}

/* Service Worker 离线可用标识（首屏联网加载一次后出现，表明可断网使用） */
.offline-badge {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, #34c759, #28a745);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 13px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.offline-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #eafff0;
}
