:root {
  --bg-1: #FFFFFF; --bg-2: #F5F7FA; --glass: rgba(0, 0, 0, 0.02);
  --primary: #6C7BFF; --primary-1: #4F5EF7; --accent: #38D9A9;
  --text-1: #1A2036; --text-2: #6B7280;
  --danger: #FF6B7A; --warn: #FFB454;
  --glass-border: rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg-1); color: var(--text-1); min-height: 100vh; overflow-x: hidden;
}
.bg-glow { display: none; }
.page { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-radius: 16px; margin-bottom: 18px; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: 0 4px 20px rgba(0,0,0,0.04); }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.brand span { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.slogan { font-size: 13px; color: var(--text-2); margin: 0; }
.glass-card { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.04); }
.panel { padding: 22px 24px; }
.panel-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sub-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: var(--text-1); }
.dropzone { position: relative; border: 2px dashed var(--glass-border); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; transition: all .2s; min-height: 200px; display: flex; align-items: center; justify-content: center; background: var(--bg-2); }
.dropzone.dragover { border-color: var(--primary); background: rgba(108,123,255,.08); }
.dropzone:hover { border-color: var(--primary); }
.preview-img { max-width: 100%; max-height: 300px; border-radius: 10px; object-fit: contain; }
.dz-hint { color: var(--text-2); }
.dz-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; color: var(--text-1); }
.dz-sub { font-size: 12px; margin: 0; line-height: 1.5; }
.btn { padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all .2s; }
.btn.primary { background: linear-gradient(90deg, var(--primary), var(--accent)); color: #fff; }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,123,255,.3); }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--glass-border); }
.btn.ghost:hover { color: var(--text-1); background: rgba(0,0,0,.03); }
.btn.block { display: block; width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hint { font-size: 12px; color: var(--text-2); margin: 8px 0 0; text-align: center; }
.bar { height: 8px; background: rgba(0,0,0,.06); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .4s; width: 0; }
.bar-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.percent { font-size: 18px; font-weight: 700; color: var(--accent); }
.bar-msg { font-size: 13px; color: var(--text-2); }
.task-badge { font-family: Consolas, monospace; font-size: 12px; color: var(--primary); background: rgba(108,123,255,.1); padding: 4px 10px; border-radius: 8px; }
.timeline { margin: 14px 0 0; padding: 0; list-style: none; max-height: 240px; overflow-y: auto; }
.log-item { font-size: 13px; color: var(--text-2); padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,.04); }
.log-item.ok { color: var(--accent); }
.log-item.err { color: var(--danger); }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--glass-border); }
.result-summary { display: flex; flex-direction: column; gap: 20px; }
.result-block { padding: 14px; background: var(--bg-2); border: 1px solid var(--glass-border); border-radius: 12px; text-align: center; }
.result-cartoon { max-width: 100%; max-height: 400px; border-radius: 10px; object-fit: contain; }
.frames-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.frame-thumb { width: 72px; height: 72px; object-fit: contain; background: repeating-conic-gradient(rgba(0,0,0,.025) 0% 25%, transparent 0% 50%) 0 0/16px 16px, rgba(0,0,0,.02); border-radius: 6px; }
.result-icon { color: var(--accent); margin-right: 6px; }
.hero-slogan { text-align: center; font-size: 24px; font-weight: 700; padding: 8px 0 18px; line-height: 1.3; color: var(--text-1); }
.hero-slogan .stress { color: var(--accent); font-size: 1.1em; }
.footer { text-align: center; font-size: 12px; color: var(--text-2); padding: 20px 0; }
.hidden { display: none !important; }

/* ==================== Step3 结果区 ==================== */
.step3-grid { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.cartoon-circle { width: 160px; height: 160px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 3px solid var(--glass-border); background: #f5f5f7; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.cartoon-circle img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-side { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.frame-view { aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: #f5f5f7; border: 1px solid var(--glass-border); cursor: pointer; }
.frame-view:hover { border-color: var(--primary); }
.frame-view img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; margin: 0; padding: 0; }
.frame-slider::-webkit-slider-runnable-track { height: 6px; background: rgba(0,0,0,.1); border-radius: 3px; }
.frame-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); margin-top: -11px; }
.frame-slider::-moz-range-track { height: 6px; background: rgba(0,0,0,.1); border-radius: 3px; }
.frame-slider::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.slider-meta { text-align: center; font-size: 12px; color: var(--text-2); margin: 0; }
#create-8-btn { padding: 14px 20px; }

@media (max-width: 360px) {
  .cartoon-circle { width: 130px; height: 130px; }
}

/* ==================== GIF 合成页 ==================== */
.gif-layout { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.gif-preview-side { flex: 1; min-width: 0; }
.gif-control-side { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.gif-control-side .ctrl-label + .frame-slider { margin-top: -4px; }
.gif-preview { width: 300px; max-width: 100%; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: #f5f5f7; border: 2px solid var(--primary); }
.gif-preview canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.ctrl-label { font-size: 12px; color: var(--text-2); margin: 0; text-align: center; }
.move-row { display: flex; gap: 8px; justify-content: center; }
.move-btn { width: 48px; height: 48px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--glass-border); color: var(--text-1); font-size: 16px; line-height: 1; cursor: pointer; transition: all .2s; }
.move-btn:hover { background: rgba(0,0,0,.05); border-color: var(--primary); }
.gif-result-panel { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 24px 22px; border-radius: 14px; background: var(--bg-1); border: 1px solid var(--glass-border); text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.2); animation: reviewIn .2s ease; }
/* 灰白格子 view 尺寸严格等于 GIF 尺寸（300x300），GIF 与 view 1:1 对齐，
   保证 GIF 内元素位置（如人物在左下角）与预览位置完全一致，周边无空白 */
.gif-result-img-wrap { width: 300px; max-width: 100%; aspect-ratio: 1 / 1; margin: 0 auto 18px; padding: 0; border-radius: 12px; overflow: hidden; background: repeating-conic-gradient(rgba(0,0,0,.025) 0% 25%, transparent 0% 50%) 0 0/16px 16px, rgba(0,0,0,.02); }
.gif-result-img-wrap img { width: 100%; height: 100%; display: block; object-fit: fill; }
.caption-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.caption-field label { font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.caption-input { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--bg-2); color: var(--text-1); font-size: 14px; }
.caption-field input[type="color"] { width: 64px; height: 38px; padding: 2px; border: 1px solid var(--glass-border); border-radius: 8px; background: var(--bg-2); cursor: pointer; }
.gif-result-actions { display: flex; gap: 10px; justify-content: center; }
.gif-result-actions .btn { min-width: 110px; text-decoration: none; text-align: center; line-height: normal; padding: 12px 18px; }

@media (max-width: 640px) {
  .gif-layout { flex-direction: column; }
  .gif-control-side { width: 100%; }
}
@media (max-width: 640px) {
  .page { padding: 12px; }
  .panel { padding: 18px 16px; }
  .topbar { flex-direction: column; gap: 8px; }
  .hero-slogan { font-size: 20px; }
}

/* ==================== Crop 工具 ==================== */
.crop-modal { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 20px; }
.crop-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.08); backdrop-filter: blur(2px); }
.crop-panel { position: relative; z-index: 1; width: 100%; max-width: 560px; padding: 20px 22px; border-radius: 16px; background: var(--bg-1); border: 1px solid var(--glass-border); box-shadow: 0 24px 70px rgba(0,0,0,.2); animation: reviewIn .25s ease; }
.crop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.crop-title { margin: 0; font-size: 17px; font-weight: 600; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--glass-border); color: var(--text-1); font-size: 18px; line-height: 1; cursor: pointer; transition: all .2s; }
.icon-btn:hover { background: rgba(0,0,0,.05); }
.crop-hint { font-size: 12px; color: var(--text-2); margin: 0 0 14px; line-height: 1.5; }
.crop-img-wrap { position: relative; display: inline-block; max-width: 100%; }
#crop-img { display: block; max-width: 100%; max-height: 55vh; width: auto; height: auto; margin: 0 auto; border: 1px solid var(--glass-border); border-radius: 10px; user-select: none; background: #f5f5f7; }
.crop-box { position: absolute; border: 2px solid var(--primary); box-sizing: border-box; box-shadow: 0 0 0 9999px rgba(0,0,0,.1); cursor: move; touch-action: none; }
.crop-resize { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; background: var(--primary); cursor: nwse-resize; border-radius: 0 0 4px 0; touch-action: none; }
.crop-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ==================== Alert modal ==================== */
.alert-modal { position: fixed; inset: 0; z-index: 180; display: flex; align-items: center; justify-content: center; padding: 20px; }
.alert-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.08); backdrop-filter: blur(2px); }
.alert-panel { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 24px 22px; border-radius: 14px; background: var(--bg-1); border: 1px solid var(--glass-border); text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.2); animation: reviewIn .2s ease; }
.alert-msg { font-size: 14px; color: var(--text-1); line-height: 1.6; margin: 0 0 18px; white-space: pre-wrap; }
#alert-ok { min-width: 120px; }
@keyframes reviewIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
