/* ============ 证件照生成器 样式 ============ */
:root {
  --primary: #4a90d9;
  --primary-dark: #2f6fb3;
  --primary-light: #e8f2fc;
  --text: #2b3440;
  --text-light: #6b7684;
  --border: #dde4ec;
  --bg: #f4f7fa;
  --card: #ffffff;
  --ok: #1f9d55;
  --warn: #e0a800;
  --bad: #d64545;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(43, 52, 64, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性优先级保障（防止 display:flex 等覆盖导致隐藏失效） */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 头部 ---------- */
.app-header {
  background: linear-gradient(135deg, #4a90d9, #2f6fb3);
  color: #fff;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 { font-size: 20px; font-weight: 600; }
.header-tip { font-size: 12px; opacity: 0.9; }

/* ---------- 步骤条 ---------- */
.steps {
  max-width: 1080px; margin: 18px auto 0; padding: 0 20px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.step {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-light); white-space: nowrap;
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #dfe6ee; color: var(--text-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.step.active { color: var(--primary-dark); font-weight: 600; }
.step.active .step-num { background: var(--primary); color: #fff; }
.step.done .step-num { background: var(--ok); color: #fff; }
.step.done { color: var(--ok); }
.step-line { flex: 0 1 24px; height: 2px; background: #dfe6ee; min-width: 10px; }
.step-line.done { background: var(--ok); }

/* ---------- 主区域 ---------- */
.app-main { max-width: 1080px; margin: 14px auto 40px; padding: 0 20px; }

.panel {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.panel-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.panel-desc { font-size: 13px; color: var(--text-light); margin-bottom: 18px; }
.panel-actions {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; flex-wrap: wrap;
}

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 8px; cursor: pointer;
  padding: 10px 22px; font-size: 14px; font-weight: 500;
  transition: all 0.15s ease; font-family: inherit;
  background: var(--primary); color: #fff;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline {
  background: #fff; color: var(--primary-dark);
  border: 1px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-group { display: flex; gap: 6px; }
.btn.btn-small.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---------- 上传区 ---------- */
.drop-zone {
  border: 2px dashed #b9cede; border-radius: var(--radius);
  padding: 44px 20px; text-align: center; cursor: pointer;
  background: #fafcfe; transition: all 0.2s ease;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.dz-text { font-size: 15px; font-weight: 500; margin-top: 12px; }
.dz-sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.upload-examples {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px;
}
.example-card {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f8fafc; border-radius: 8px; padding: 12px;
  font-size: 13px;
}
.example-card b { display: block; font-size: 13px; }
.example-card p { color: var(--text-light); font-size: 12px; }
.ex-icon {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 14px;
}
.ex-icon.ok { background: var(--ok); }
.ex-icon.bad { background: var(--bad); }

#btnCamera { margin-top: 14px; }

/* ---------- 规格选择 ---------- */
.spec-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px;
}
.spec-card {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 14px; cursor: pointer; background: #fff;
  transition: all 0.15s ease; text-align: left; font-family: inherit;
}
.spec-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(74,144,217,0.15); }
.spec-card.selected {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}
.spec-card.selected .spec-badge { background: var(--primary); color: #fff; }
.spec-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; background: #eef2f7; color: var(--text-light); margin-bottom: 6px;
}
.spec-name { font-size: 15px; font-weight: 600; }
.spec-dims { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.spec-bg { font-size: 12px; margin-top: 3px; }
.bg-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.15); vertical-align: -1px; margin-right: 3px;
}
.spec-note { font-size: 11px; color: var(--warn); margin-top: 4px; }

.spec-custom {
  margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 16px;
}
.spec-custom h3 { font-size: 14px; margin-bottom: 10px; }
.custom-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.custom-form label { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.custom-form input {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px;
  font-size: 14px; width: 110px; font-family: inherit;
}
.custom-form input[type="text"] { width: 140px; }
.custom-form input:focus { outline: none; border-color: var(--primary); }

.bg-pick { margin-top: 16px; font-size: 13px; color: var(--text-light); }
.bg-pick b { color: var(--text); }

/* ---------- 处理中 ---------- */
.progress-wrap { margin: 24px 0; }
.progress-bar {
  height: 10px; border-radius: 6px; background: #e6ecf3; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #4a90d9, #2f6fb3);
  border-radius: 6px; transition: width 0.3s ease;
}
.progress-text { font-size: 13px; color: var(--text-light); margin-top: 10px; text-align: center; }
.process-log {
  max-height: 150px; overflow-y: auto; background: #f8fafc;
  border-radius: 8px; padding: 10px 14px; font-size: 12px; color: var(--text-light);
  font-family: Consolas, monospace;
}
.process-log div { padding: 2px 0; }
.process-log .log-warn { color: var(--warn); }
.process-log .log-err { color: var(--bad); }
.process-log .log-ok { color: var(--ok); }

/* ---------- 微调布局 ---------- */
.adjust-layout {
  display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 22px;
}
@media (max-width: 860px) {
  .adjust-layout { grid-template-columns: 1fr; }
}

.preview-col { display: flex; flex-direction: column; gap: 10px; }
.preview-stage {
  position: relative; width: 100%; border-radius: 10px; overflow: hidden;
  background: repeating-conic-gradient(#eef1f5 0% 25%, #fff 0% 50%) 0 0 / 20px 20px;
  border: 1px solid var(--border);
  touch-action: none;
}
#previewCanvas { display: block; width: 100%; height: auto; cursor: grab; }
#previewCanvas.dragging { cursor: grabbing; }
.crop-guide { position: absolute; inset: 0; pointer-events: none; }
.guide-line { position: absolute; }
.hline { left: 0; right: 0; height: 1px; background: rgba(217, 0, 27, 0.4); border-top: 1px dashed rgba(217, 0, 27, 0.35); }
.hline.top { top: 20%; }
.hline.mid { top: 45%; }
.vline { top: 0; bottom: 0; width: 1px; left: 50%; background: rgba(217, 0, 27, 0.35); border-left: 1px dashed rgba(217, 0, 27, 0.3); }
.drag-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(43, 52, 64, 0.65); color: #fff; font-size: 11px;
  padding: 3px 10px; border-radius: 10px; pointer-events: none; white-space: nowrap;
}

.zoom-row { display: flex; align-items: center; gap: 8px; }
.zoom-row input[type="range"] { flex: 1; }
.adjust-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 控制列 ---------- */
.control-col { display: flex; flex-direction: column; gap: 16px; }
.ctrl-group {
  background: #f8fafc; border-radius: 10px; padding: 14px 16px;
}
.ctrl-group h3 {
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}

/* 背景色块 */
.bg-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--border); transition: all 0.15s;
}
.swatch:hover { transform: scale(1.06); }
.swatch.active {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px var(--primary);
}

/* 滑杆 */
.slider-row {
  display: grid; grid-template-columns: 42px 1fr 32px;
  align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px;
}
.slider-row span { text-align: right; color: var(--text-light); font-size: 12px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px;
  background: #d8e2ec; border-radius: 3px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
}

/* 开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cdd6e0; border-radius: 22px; transition: 0.2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* 正装模板 */
.suit-options { display: flex; gap: 8px; flex-wrap: wrap; }
.suit-opt {
  border: 1.5px solid var(--border); background: #fff; border-radius: 8px;
  padding: 8px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 4px; font-size: 12px; color: var(--text-light);
  font-family: inherit; transition: all 0.15s;
}
.suit-opt:hover { border-color: var(--primary); }
.suit-opt.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.suit-options.disabled { opacity: 0.45; pointer-events: none; }

/* 检测列表 */
.check-list { list-style: none; font-size: 13px; }
.check-list li {
  display: flex; align-items: flex-start; gap: 8px; padding: 5px 0;
  border-bottom: 1px dashed #e4eaf1;
}
.check-list li:last-child { border-bottom: none; }
.check-list .mark { flex-shrink: 0; width: 20px; text-align: center; }
.check-list .advice { display: block; color: var(--text-light); font-size: 12px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(30, 40, 52, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 20px;
  max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto;
}
.modal-box.wide { max-width: 720px; }
.modal-box h3 { font-size: 16px; margin-bottom: 6px; }
.modal-desc { font-size: 13px; color: var(--text-light); margin-bottom: 12px; }
.modal-canvas-wrap {
  position: relative; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); touch-action: none; background: #222;
}
.modal-canvas-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.modal-toolbar {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin-top: 12px; font-size: 13px;
}
.modal-toolbar label { display: flex; align-items: center; gap: 6px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px;
}

/* ---------- 导出 ---------- */
.export-layout {
  display: grid; grid-template-columns: minmax(240px, 360px) 1fr; gap: 22px;
}
@media (max-width: 860px) { .export-layout { grid-template-columns: 1fr; } }
.export-preview {
  background: repeating-conic-gradient(#eef1f5 0% 25%, #fff 0% 50%) 0 0 / 20px 20px;
  border-radius: 10px; border: 1px solid var(--border);
  padding: 14px; text-align: center;
}
#exportCanvas {
  max-width: 100%; max-height: 420px; height: auto; width: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12); display: inline-block;
}
.export-meta { font-size: 12px; color: var(--text-light); margin-top: 10px; }
.paper-options { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.paper-opt {
  flex: 1; min-width: 130px; border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; padding: 10px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 2px; font-family: inherit;
  transition: all 0.15s;
}
.paper-opt:hover { border-color: var(--primary); }
.paper-opt.active { border-color: var(--primary); background: var(--primary-light); }
.paper-opt b { font-size: 14px; }
.paper-opt span { font-size: 12px; color: var(--text-light); }
.paper-count { font-size: 13px; color: var(--text); margin-bottom: 10px; }
.print-tip {
  font-size: 12px; color: var(--text-light); background: #fff8e6;
  border-radius: 8px; padding: 10px 12px; margin-top: 14px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(43, 52, 64, 0.92); color: #fff; font-size: 14px;
  padding: 10px 22px; border-radius: 24px; z-index: 200;
  animation: toastIn 0.25s ease; max-width: 86vw; text-align: center;
}
.toast.warn { background: rgba(190, 130, 10, 0.95); }
.toast.err { background: rgba(214, 69, 69, 0.95); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 页脚 ---------- */
.app-footer {
  text-align: center; padding: 20px; font-size: 12px; color: var(--text-light);
  border-top: 1px solid var(--border);
}

/* ---------- 移动端 ---------- */
@media (max-width: 600px) {
  .steps { gap: 2px; }
  .step-label { display: none; }
  .step.active .step-label { display: inline; }
  .panel { padding: 16px; }
  .upload-examples { grid-template-columns: 1fr; }
  .panel-actions { flex-direction: column; }
  .panel-actions .btn { width: 100%; }
  .modal-box { padding: 14px; }
  .swatch { width: 36px; height: 36px; }
  .header-tip { display: none; }
}
