/* ==========================================================
   身份证复印件生成器 —— 样式
   ========================================================== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16181d;
  --ink-2: #454b57;
  --sub: #7b8393;
  --line: #e4e7ec;
  --line-2: #eef0f4;
  --brand: #2f62f0;
  --brand-soft: #ecf1ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1020px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

/* ---------- 头部 ---------- */
.head {
  text-align: center;
  margin-bottom: 28px;
}
.head h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: .2px;
}
.head .sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.6;
}
.head .privacy {
  display: inline-block;
  margin: 14px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: #e9f7ee;
  color: #1c7a44;
  font-size: 12.5px;
  font-weight: 500;
}

/* ---------- 上传区 ---------- */
.slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.slot {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  transition: border-color .18s, box-shadow .18s;
}
.slot.dragover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.slot-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.slot-name {
  font-size: 14px;
  font-weight: 600;
}
.slot-tip {
  font-size: 12px;
  color: var(--sub);
}
.slot-clear {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
}
.slot-clear:hover { color: #d64545; }

/* 空状态 */
.slot[data-state="empty"] .slot-body[data-role="empty"] {
  cursor: pointer;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 34px 16px;
  text-align: center;
  color: var(--sub);
  background: #fbfcfd;
  transition: border-color .18s, background .18s;
}
.slot[data-state="empty"] .slot-body[data-role="empty"]:hover {
  border-color: #c4cfe0;
  background: #f7f9fc;
}
.empty-icon {
  width: 52px;
  height: 36px;
  margin: 0 auto 12px;
  color: #b8c2d4;
}
.empty-icon svg { width: 100%; height: 100%; display: block; }
.empty-title {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--ink-2);
  font-weight: 500;
}
.empty-hint {
  margin: 0;
  font-size: 12px;
  color: var(--sub);
}

/* 预览 */
.card-frame {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line-2);
  aspect-ratio: 85.6 / 54;
}
.card-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.busy {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, .86);
  color: var(--ink-2);
  font-size: 13px;
  backdrop-filter: blur(1px);
}
.card-frame.loading .busy { display: flex; }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d3dae7;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.slot-tools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-mini {
  flex: 1;
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--ink-2);
  background: #f6f7f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-mini:hover { background: #eef1f6; }
.btn-mini.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 500;
}
.btn-mini.primary:hover { background: #2454d8; }

/* 边框编辑 */
.edit-box {
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow: hidden;
  background: #f0f2f5;
  touch-action: none;
}
.edit-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}
.edit-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--sub);
  text-align: center;
}

/* ---------- 设置面板 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}
.row-label {
  width: 36px;
  flex: none;
  font-size: 13.5px;
  color: var(--ink-2);
  font-weight: 500;
}
.seg {
  display: inline-flex;
  padding: 3px;
  background: #f2f4f7;
  border-radius: 9px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: none;
  padding: 7px 16px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink-2);
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button.on {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .1);
}
.row-note {
  margin: 10px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--sub);
}

/* ---------- 预览 ---------- */
.paper-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 20px;
}
.paper-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 600;
}
.paper-ratio {
  font-size: 12px;
  color: var(--sub);
  font-weight: 400;
}
.paper-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  background: #eceef2;
  border-radius: 10px;
  padding: 20px 16px;
}
#paper {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 620px;
  height: auto;
  background: #fff;
  box-shadow: 0 2px 14px rgba(16, 24, 40, .14);
  border-radius: 2px;
}
.paper-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--sub);
  pointer-events: none;
}
.paper-wrap.has-content .paper-empty { display: none; }

/* ---------- 按钮 ---------- */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 16px;
  font-family: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .16s, opacity .16s;
}
.btn span {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.btn small {
  font-size: 11.5px;
  color: var(--sub);
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(47, 98, 240, .24);
}
.btn.primary span { color: #fff; }
.btn.primary small { color: rgba(255, 255, 255, .78); }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

.foot {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--sub);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 16px);
  padding: 10px 20px;
  background: rgba(22, 24, 29, .92);
  color: #fff;
  font-size: 13.5px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 86vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .app { padding: 24px 14px 48px; }
  .head h1 { font-size: 21px; }
  .head .sub { font-size: 13.5px; }
  .slots { grid-template-columns: 1fr; gap: 12px; }
  .actions { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; gap: 8px 14px; }
  .seg button { padding: 7px 13px; font-size: 12.5px; }
  #paper { max-height: 440px; }
}

/* ---------- 微信提示 ---------- */
.wx-tip {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fff8e6;
  border: 1px solid #f5e2b0;
  border-radius: 10px;
  color: #8a6116;
  font-size: 12.5px;
  line-height: 1.6;
}
.wx-tip b {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 0 4px;
  background: rgba(138, 97, 22, .12);
  border-radius: 4px;
  font-weight: 600;
}
