/* ==========================================================================
   智能证件照 · 视觉重设计（Redesign Overhaul）
   设计定调：remove.bg / Photoroom 的工具感 + Linear 的克制精致
   - 冷调中性色（zinc 系）+ 单一强调色电光蓝 #2563EB（全站锁定）
   - 无阴影或极淡着色阴影，发丝边框，16/10/8 三级圆角体系
   - 系统字体栈（中文 PingFang / HarmonyOS Sans），数字规格用系统 mono
   - 暗色模式 prefers-color-scheme 自动切换，token 全部 CSS 变量化
   ========================================================================== */

/* ---------- 设计 Token ---------- */
:root {
  --bg: #f5f5f7;
  --surface: #fcfcfd;
  --surface-2: #f1f1f4;
  --border: #e3e3e8;
  --border-strong: #cfcfd7;
  --text: #1b1b1f;
  --text-2: #6e6e77;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #ebf1fe;
  --on-accent: #f5f8ff;
  --ok: #2f9e6e;
  --warn: #b45309;
  --danger: #dc3f3a;
  --check-a: #ececf0;
  --check-b: #fcfcfd;
  --backdrop: rgba(18, 18, 24, 0.55);
  --shadow-pop: 0 16px 48px rgba(18, 18, 28, 0.14);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #17171c;
    --surface-2: #1f1f26;
    --border: #2b2b34;
    --border-strong: #3c3c47;
    --text: #ebebef;
    --text-2: #9b9ba5;
    --accent: #4c82f7;
    --accent-hover: #6393f9;
    --accent-soft: #1c2740;
    --on-accent: #f5f8ff;
    --ok: #43b884;
    --warn: #d97706;
    --danger: #e5655f;
    --check-a: #22222a;
    --check-b: #17171c;
    --backdrop: rgba(4, 4, 8, 0.66);
    --shadow-pop: 0 20px 56px rgba(0, 0, 0, 0.55);
  }
}

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

/* class 规则里的 display 会盖掉 hidden 属性，统一强制隐藏 */
[hidden] { display: none !important; }

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

::selection { background: var(--accent-soft); }

/* ---------- 顶栏 ---------- */
.header {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 20px 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
}
.brand-mark svg { width: 18px; height: 18px; }
.header h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; }
.subtitle { color: var(--text-2); font-size: 13px; }

/* ---------- 布局 ---------- */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.step-no {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.group-label { font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.hint-warn { color: var(--warn) !important; white-space: pre-line; }

/* ---------- 上传 ---------- */
.dropzone {
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dz-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  color: var(--text-2);
  transition: color 0.15s ease;
}
.dz-icon svg { width: 100%; height: 100%; }
.dropzone:hover .dz-icon, .dropzone.dragover .dz-icon { color: var(--accent); }
.dz-main { font-size: 15px; font-weight: 500; margin-top: 12px; }
.dz-sub { font-size: 12px; color: var(--text-2); margin-top: 4px; }

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

.source-preview {
  margin-top: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.source-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.source-info { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); word-break: break-all; align-items: flex-start; }

/* ---------- 规格与底色 ---------- */
.config-grid { display: grid; grid-template-columns: 1fr 250px; gap: 28px; }

.size-group { margin-bottom: 16px; }
.size-group:last-child { margin-bottom: 0; }
.size-group-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.size-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.size-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
  line-height: 1.45;
}
.size-pill small { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--text-2); letter-spacing: -0.01em; }
.size-pill:hover { border-color: var(--accent); color: var(--accent); }
.size-pill:active { transform: scale(0.96); }
.size-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.size-pill.active small { color: var(--accent); }

.color-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.color-item { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; }
.color-item small { font-size: 11px; color: var(--text-2); text-align: center; line-height: 1.35; font-family: var(--mono); }
.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.color-swatch:active { transform: scale(0.92); }
.color-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.color-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--text);
  background: var(--surface);
  align-self: center;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.color-custom.active, .color-custom:hover { border-color: var(--accent); color: var(--accent); }
.color-custom input[type="color"] { width: 20px; height: 20px; border: none; padding: 0; background: none; cursor: pointer; }

/* ---------- 美颜 ---------- */
.beauty-block { margin-top: 20px; }
.beauty-row { display: flex; align-items: center; gap: 12px; }
.beauty-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.beauty-val { font-size: 12px; color: var(--text-2); min-width: 52px; text-align: right; font-family: var(--mono); }

/* ---------- 生成与状态 ---------- */
.result-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.status { margin-top: 16px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.status.error { color: var(--danger); }
/* 骨架式加载：胶囊微光扫过，替代传统 spinner */
.spinner {
  width: 28px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--border) 25%, var(--accent) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

/* ---------- 结果 ---------- */
.result-area {
  margin-top: 18px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.result-area:not([hidden]) { animation: rise 0.32s cubic-bezier(0.2, 0.7, 0.3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.preview-box { text-align: center; }
.preview-box img {
  max-width: 230px;
  max-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 0 0 / 16px 16px;
}
.preview-meta { font-size: 12px; color: var(--text-2); margin-top: 10px; max-width: 230px; }
.download-box { display: flex; flex-direction: column; gap: 10px; min-width: 210px; }

/* ---------- 合规检测 ---------- */
.compliance { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.compliance-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.compliance-list li { display: flex; gap: 9px; font-size: 13px; align-items: baseline; }
.compliance-list .ci-icon { flex-shrink: 0; width: 16px; text-align: center; font-weight: 600; }
.compliance-list .ci-ok .ci-icon { color: var(--ok); }
.compliance-list .ci-warn .ci-icon { color: var(--warn); }
.compliance-list .ci-unknown { color: var(--text-2); }
/* 未知态图标：一条细横线，不用符号 */
.compliance-list .ci-unknown .ci-icon::after {
  content: "";
  display: inline-block;
  width: 10px;
  border-bottom: 1.5px solid var(--border-strong);
  vertical-align: middle;
}
.compliance-list .ci-label { font-weight: 600; margin-right: 6px; }
.compliance-list .ci-msg { color: var(--text-2); }
.compliance-list .ci-warn .ci-msg { color: var(--warn); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  line-height: 1.45;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.btn-text { background: none; border: none; color: var(--accent); padding: 0; font-size: 12.5px; }
.btn-text:hover { text-decoration: underline; }
.btn-sm { padding: 6px 13px; font-size: 13px; }

/* ---------- 弹窗通用 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal:not([hidden]) .modal-body { animation: pop 0.22s cubic-bezier(0.2, 0.7, 0.3, 1); }
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-body {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

/* ---------- 拍摄弹窗（取景器，固定深色） ---------- */
#camera-modal .modal-body { max-width: 420px; background: #141419; border-color: #26262e; }
.camera-stage { position: relative; aspect-ratio: 3 / 4; background: #0c0c10; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.camera-actions { display: flex; justify-content: space-between; padding: 14px 16px; background: #1a1a21; }
.camera-actions .btn-outline { background: transparent; color: #e8e8ec; border-color: #44444e; }
.camera-actions .btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-shutter { border-radius: 999px; padding: 9px 34px; }
.camera-hint { color: #f0a8a4; padding: 0 16px 12px; margin-top: 0; background: #1a1a21; }

/* ---------- 排版打印面板 ---------- */
.layout-body {
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
}
.layout-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.layout-section { margin-bottom: 18px; }
.layout-label { display: block; font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 10px; }
.layout-paper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  margin-right: 16px;
  margin-bottom: 8px;
  cursor: pointer;
}
.layout-paper input { accent-color: var(--accent); }
.layout-paper small { color: var(--text-2); font-size: 11px; font-family: var(--mono); }

.layout-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.layout-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
  line-height: 1.45;
}
.layout-chip:hover { border-color: var(--accent); color: var(--accent); }
.layout-chip:active { transform: scale(0.96); }
.layout-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
#layout-chips-hint { color: var(--danger); margin-top: 8px; }

.layout-preview-canvas {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.layout-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }

/* ---------- 页脚 ---------- */
.footer { text-align: center; font-size: 12px; color: var(--text-2); }

/* ---------- 手机端 ---------- */
@media (max-width: 640px) {
  .header { padding: 16px 14px 2px; flex-direction: column; align-items: flex-start; gap: 2px; }
  .container { padding: 14px 14px 48px; gap: 12px; }
  .card { padding: 18px 16px; }
  .dropzone { padding: 30px 12px; }
  .config-grid { grid-template-columns: 1fr; gap: 20px; }
  .preview-box img { max-width: 200px; max-height: 300px; }
  .download-box { width: 100%; }
  .download-box .btn { width: 100%; }
  .upload-actions .btn { flex: 1; }
  .layout-body { max-width: 100%; padding: 18px 16px; }
  .layout-actions .btn { flex: 1; }
}

/* ---------- 动效兜底：用户偏好减少动态 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
