/* ============================================================
   Q版涂鸦生成器 — 浅色主题（参考优米生图的干净留白风格）
   ============================================================ */

:root {
  --bg: #fafafa;
  --bg-soft: #f4f4f5;
  --card: #ffffff;
  --line: #e8e8ea;
  --line-strong: #d9d9dd;
  --text: #18181b;
  --text-dim: #71717a;
  --text-faint: #a1a1aa;
  --ink: #18181b;
  --ok: #16a34a;
  --err: #dc2626;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, 0.04);
  --shadow-md: 0 8px 28px -12px rgba(16, 16, 20, 0.14);
  /* 所有图片容器的底色：柔和渐变，避免大片空白 */
  --img-bg: linear-gradient(135deg, #f3f0fa 0%, #eef4fa 55%, #f6f0f4 100%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  max-width: 100%;
  /* 老 Safari 不认 clip，先给 hidden 兜底 */
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 20px 72px;
}

/* ---------------- 顶栏 ---------------- */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding: 6px 0 22px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
}
.logo svg { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11.5px; color: var(--text-faint); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-width: 0; max-width: 100%;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  color: var(--text-dim);
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--text-faint);
}
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }
.pill.bad .dot { background: var(--err); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }
#statusText {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 标题区 ---------------- */
.hero { padding: 4px 0 20px; }
.hero h1 {
  margin: 0 0 6px;
  font-size: 27px;
  line-height: 1.3;
  letter-spacing: -0.4px;
  font-weight: 700;
}
.hero p { margin: 0; color: var(--text-dim); font-size: 13.5px; }

/* ---------------- 两种方式：固定并排（手机也不换行） ---------------- */
.modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;          /* 长方形 + 轻微切角 */
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  overflow: hidden;
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
}
.mode-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.mode-card.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), var(--shadow-md);
}

/* 用 padding-top 撑高（全浏览器通用，不依赖 aspect-ratio）
   示例图用背景图渲染；底色必须是「实色」——background-color 不接受渐变，
   否则图片加载失败时整块会变成透明/纯白 */
.thumb {
  position: relative;
  height: 0;
  padding-top: 75%;          /* 4:3 */
  background-color: #eef1f7;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  overflow: hidden;
}
.thumb-character { background-image: url('/assets/sample-character-s.jpg'); }
.thumb-edit { background-image: url('/assets/sample-edit-s.jpg'); }
/* 绝对定位 + padding 让图片填满容器内区域（不用 calc，旧内核也稳） */
.thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 8px;
  box-sizing: border-box;
  object-fit: contain;
  display: block;
}
.mode-card:hover .thumb img { transform: scale(1.015); transition: transform 0.35s ease; }

.mode-body { padding: 10px 12px 12px; }
.mode-title { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.mode-title h2 { margin: 0; font-size: 14.5px; letter-spacing: -0.2px; white-space: nowrap; }
.tag {
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.mode-body p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  /* 两行以内，超出省略 */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.tick {
  position: absolute; top: 8px; right: 8px;
  width: 21px; height: 21px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.16s, transform 0.16s;
}
.tick svg { width: 12px; height: 12px; }
.mode-card.active .tick { opacity: 1; transform: scale(1); }

/* ---------------- 工作台 ---------------- */
.bench {
  padding: 18px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.bench-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.bench-row[hidden] { display: none; }

.field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}

input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder { color: var(--text-faint); }
input[type="text"]:focus {
  border-color: var(--ink);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.07);
}



/* 上传区 */
.drop {
  position: relative;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  min-height: 92px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
  overflow: hidden;
}
.drop:hover, .drop:focus-visible, .drop.dragover {
  border-color: var(--ink);
  background: #fff;
}
.drop-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 18px;
  text-align: center;
}
.drop-empty svg { width: 22px; height: 22px; color: var(--text-dim); }
.drop-empty strong { font-size: 13px; font-weight: 600; }
.drop-empty span { font-size: 11.5px; color: var(--text-faint); }

.drop-preview { position: relative; }
.drop-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--bg-soft);
}
.drop-remove {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  border: 0; border-radius: 50%;
  background: rgba(24, 24, 27, 0.62);
  color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer;
}
.drop-remove:hover { background: rgba(24, 24, 27, 0.86); }

/* 主按钮 */
.primary {
  flex: none;
  height: 46px;
  padding: 0 26px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.primary:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.primary.loading .btn-text::after {
  content: "";
  display: inline-block;
  width: 11px; height: 11px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: -1px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 结果 ---------------- */
.result {
  padding: 18px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.result-head h3 { margin: 0; font-size: 14.5px; }
.state { font-size: 12px; color: var(--text-faint); }
.state.ok { color: var(--ok); }
.state.bad { color: var(--err); }

.stage { position: relative; min-height: 220px; }

.stage-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px;
  padding: 54px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--img-bg);
  color: var(--text-faint);
  text-align: center;
}
.stage-empty svg { width: 30px; height: 30px; opacity: 0.6; }
.stage-empty strong { font-size: 13.5px; color: var(--text-dim); }
.stage-empty span { font-size: 12px; }

/* 交付中动画 */
.delivering {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 46px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(520px 180px at 50% 0%, rgba(24, 24, 27, 0.05), transparent 70%),
    var(--bg);
  text-align: center;
  animation: fadeIn 0.25s ease both;
}
.pencil {
  position: relative;
  width: 56px; height: 56px;
  color: var(--ink);
  margin-bottom: 2px;
}
.pencil > svg:first-child { width: 56px; height: 56px; animation: spin 1.6s linear infinite; }
.pencil > svg:first-child circle { stroke-opacity: 0.14; }
.pencil .pencil-icon {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto;
  width: 21px; height: 21px;
  color: var(--text);
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(-1px) rotate(-6deg); }
  50% { transform: translateY(1px) rotate(6deg); }
}
.delivering strong {
  font-size: 15px;
  letter-spacing: 0.3px;
}
.delivering strong::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  text-align: left;
  animation: dots 1.4s steps(4, end) infinite;
}
.delivering > span { font-size: 12.5px; color: var(--text-faint); }

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.track {
  width: min(320px, 78%);
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: var(--ink);
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

/* 结果图 */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  animation: fadeIn 0.3s ease both;
}
.shots.single { grid-template-columns: minmax(0, 520px); justify-content: center; }

.shot {
  position: relative;
  padding: 10px;                 /* 露出容器底色，查看时不至于整屏空白 */
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--img-bg);
  cursor: zoom-in;
}
/* 图片按自身比例完整显示（object-fit 需要显式尺寸，这里直接用 auto 高度最稳） */
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.shot-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.62));
  opacity: 0;
  transition: opacity 0.16s;
}
.shot:hover .shot-bar { opacity: 1; }
.shot-bar a, .shot-bar button {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  color: #fff;
  font: inherit; font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.shot-bar a:hover, .shot-bar button:hover { background: rgba(255, 255, 255, 0.3); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 失败 */
.failed {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.03);
  text-align: center;
}
.failed strong { color: var(--err); font-size: 14px; }
.failed p { margin: 0; font-size: 12.5px; color: var(--text-dim); max-width: 560px; word-break: break-word; }
.ghost {
  margin-top: 4px;
  height: 34px; padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--ink); }

/* ---------------- 记录 ---------------- */
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.history-head h3 { margin: 0; font-size: 14.5px; }
.link {
  border: 0; background: transparent;
  color: var(--text-dim);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 7px;
}
.link:hover { background: var(--bg-soft); color: var(--text); }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.hist {
  position: relative;
  height: 0;
  padding-top: 100%;          /* 1:1 */
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--img-bg);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.hist:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.hist img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 5px;
  box-sizing: border-box;
  object-fit: cover;
  border-radius: 7px;
  display: block;
}
.hist .hist-tag {
  position: absolute; top: 7px; left: 7px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--text-dim);
}
.hist .hist-time {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 10.5px;
  text-align: center;
}
.hist-empty {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--img-bg);
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ---------------- 作品详情弹窗 ---------------- */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(9, 9, 11, 0.62);
  backdrop-filter: blur(3px);
}
.detail-card {
  position: relative;
  display: flex;
  max-width: min(880px, 95vw);
  max-height: 92vh;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.2s ease both;
}
.detail-img {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 14px;                 /* 露底色，查看大图时不会整块空白 */
  background: var(--img-bg);
}
.detail-img img {
  display: block;
  max-width: min(560px, 62vw);
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
}
.detail-info {
  flex: 0 0 208px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 20px 16px 16px;
  border-left: 1px solid var(--line);
  background: #fff;
}
.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.detail-row b { color: var(--text); font-weight: 600; font-size: 13px; }
.detail-dl {
  margin-top: auto;
  padding: 11px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.detail-dl:hover { background: #000; }
.detail-close {
  position: absolute; top: 9px; left: 9px; z-index: 2;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 17px; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.detail-close:hover { background: #fff; border-color: var(--line-strong); }

/* ---------------- 响应式：优先手机，两卡片仍固定并排 ---------------- */
@media (max-width: 760px) {
  .page { padding: 14px 12px 56px; }
  .hero { padding: 2px 0 14px; }
  .hero h1 { font-size: 21px; }
  .hero p { font-size: 12.5px; }
  .modes { gap: 10px; margin-bottom: 14px; }
  .mode-body { padding: 8px 9px 10px; }
  .mode-title { gap: 5px; margin-bottom: 2px; }
  .mode-title h2 { font-size: 13px; }
  .tag { display: none; }
  .mode-body p { font-size: 11px; line-height: 1.45; -webkit-line-clamp: 3; }
  .tick { width: 18px; height: 18px; top: 6px; right: 6px; }
  .tick svg { width: 10px; height: 10px; }
  .bench { padding: 14px; }
  .bench-row { flex-direction: column; align-items: stretch; }
  .primary { width: 100%; }
  .result, .history { padding: 14px; }
  .history-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

@media (max-width: 640px) {
  .detail { padding: 12px; }
  .detail-card { flex-direction: column; max-height: 90vh; }
  .detail-img img { max-width: 100%; max-height: 58vh; }
  .detail-info { flex: none; border-left: 0; border-top: 1px solid var(--line); }
  .detail-row { font-size: 12px; }
}

@media (max-width: 380px) {
  .page { padding: 12px 10px 48px; }
  .mode-title h2 { font-size: 12px; }
  .mode-body p { font-size: 10.5px; }
  .modes { gap: 8px; }
}
