:root {
  --ink: #191f28;
  --sub: #4e5968;
  --muted: #8b95a1;
  --line: #e5e8eb;
  --bg: #f2f4f6;
  --paper: #fff;
  --accent: #3182f6;
  --accent-press: #1b64da;
  --accent-soft: #e8f3ff;
  --danger: #e03131;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
}
body.working { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:active { background: #f2f4f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; }
.linkbtn {
  border: 0; background: none; padding: 8px 4px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer;
}

/* ---------- 머리 ---------- */
.site-head {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.head-in {
  max-width: 720px; margin: 0 auto; height: 56px; padding: 0 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 700; color: var(--ink); text-decoration: none;
}
.brand img { border-radius: 7px; }
.head-nav { margin-left: auto; display: flex; gap: 16px; }
.head-nav a { color: var(--sub); text-decoration: none; font-size: 15px; }
body.working .head-nav { display: none; }
#resetBtn { margin-left: auto; }

main { max-width: 720px; margin: 0 auto; padding: 0 0 24px; }

/* ---------- 앱 안 브라우저 안내 ---------- */
.inapp {
  margin: 12px 16px 0; padding: 14px 16px;
  background: #fff4e6; border: 1px solid #ffd8a8; border-radius: 12px;
  font-size: 15px;
}
.inapp p { margin: 0; }
.inapp-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inapp-acts .btn { min-height: 42px; font-size: 15px; }
.inapp-msg { margin-top: 6px !important; font-size: 14px; color: var(--sub); }
.inapp-msg:empty { display: none; }

/* ---------- 도구 (첫 화면 / 목록) ---------- */
.tool { background: var(--paper); padding: 28px 16px 24px; }
.tool h1 { margin: 0 0 10px; font-size: 30px; line-height: 1.3; letter-spacing: -0.02em; }
.lead { margin: 0 0 22px; font-size: 16px; color: var(--sub); }
.lead b { color: var(--ink); }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 16px 24px;
  border: 2px dashed #c9d8f5; border-radius: 16px; background: #f7faff;
  text-align: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.drop:active, .drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-ico { width: 52px; height: 52px; color: var(--accent); margin-bottom: 4px; }
.drop-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px; margin-top: 4px;
  border-radius: 12px; background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 700;
}
.drop-sub { font-size: 14px; color: var(--sub); }
.drop-pc { display: none; font-size: 14px; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .drop-pc { display: block; }
  .drop:hover { background: var(--accent-soft); }
}

.cam { margin-top: 10px; }
@media (hover: hover) and (pointer: fine) { .cam { display: none; } }

.trust {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 0;
  list-style: none; margin: 16px 0 0; padding: 0;
  font-size: 14px; color: var(--sub);
}
.trust li + li::before { content: "·"; margin: 0 8px; color: var(--muted); }

/* 목록 */
.list-head h2 { margin: 0; font-size: 22px; }
.list-head h2 b { color: var(--accent); }
.list-head p { margin: 4px 0 16px; font-size: 14px; color: var(--sub); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: flex; gap: 14px; padding: 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
}
.a4 {
  position: relative; flex: none; width: 92px; aspect-ratio: 210 / 297;
  background: #fff; border: 1px solid #d1d6db; border-radius: 2px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  padding: 0; cursor: pointer;
}
.a4 img { position: absolute; display: block; }
.meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meta .no { font-size: 16px; font-weight: 700; }
.meta .desc { font-size: 14px; color: var(--sub); }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.acts .btn { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.acts .btn:disabled { opacity: .35; }
.acts .del { color: var(--danger); }

/* ---------- 아래 막대 ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.bar .btn { flex: 1; }
.bar .btn.primary { flex: 2; }
@media (min-width: 720px) {
  .bar { padding-left: calc(50% - 344px); padding-right: calc(50% - 344px); }
}

/* ---------- 광고 ---------- */
.ad { margin: 24px auto 0; text-align: center; overflow: hidden; }
.ad:empty { display: none; }

/* ---------- 설명 ---------- */
.guide { background: var(--paper); margin-top: 12px; padding: 28px 16px; scroll-margin-top: 64px; }
.guide h2 { margin: 0 0 16px; font-size: 21px; letter-spacing: -0.01em; }
.guide p { margin: 0; }

.example { margin: 0; }
.example img { display: block; width: 100%; height: auto; border-radius: 12px; background: var(--bg); }
.example figcaption { margin-top: 12px; font-size: 15px; color: var(--sub); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.steps strong { display: block; margin-bottom: 4px; font-size: 16px; color: var(--accent); }
.steps p { font-size: 15px; color: var(--sub); }
.steps b, .tips b, details b { color: var(--ink); }

.tips { margin: 0; padding-left: 20px; font-size: 15px; color: var(--sub); }
.tips li + li { margin-top: 8px; }

details { border-bottom: 1px solid var(--line); }
details:first-of-type { border-top: 1px solid var(--line); }
summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 2px; font-size: 16px; font-weight: 600; cursor: pointer; list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; flex: none; font-size: 22px; font-weight: 400; color: var(--muted); line-height: 1; }
details[open] summary::after { content: "−"; }
details p { padding: 0 2px 16px; font-size: 15px; color: var(--sub); }

/* ---------- 바닥글 ---------- */
.site-foot {
  max-width: 720px; margin: 0 auto; padding: 20px 16px 32px;
  font-size: 13px; color: var(--muted); text-align: center;
}
.site-foot p { margin: 4px 0; }
.site-foot a { color: var(--sub); }
body.working .site-foot { padding-bottom: 24px; }

/* ---------- 개인정보처리방침 등 글 페이지 ---------- */
.doc { background: var(--paper); padding: 28px 16px; }
.doc h1 { margin: 0 0 6px; font-size: 24px; }
.doc h2 { margin: 28px 0 8px; font-size: 18px; }
.doc p, .doc li { font-size: 15px; color: var(--sub); }
.doc .date { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.doc .summary { padding: 14px 16px; background: var(--bg); border-radius: 12px; color: var(--ink); }
.doc .back { margin-top: 28px; }

/* ---------- 다듬기 화면 ---------- */
.editor {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: #17171c; color: #fff;
}
.ed-top {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.ed-title { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }
.ed-btn {
  min-height: 40px; padding: 0 14px;
  border: 1px solid #3a3a42; border-radius: 10px;
  background: #26262d; color: #fff;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ed-btn.primary { background: var(--accent); border-color: var(--accent); }
.tabs { display: flex; margin: 0 12px 8px; padding: 3px; background: #26262d; border-radius: 10px; }
.tabs button {
  flex: 1; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: #aeb5bd;
  font: inherit; font-size: 15px; cursor: pointer; touch-action: manipulation;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 700; }

.stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.stage.dragging { touch-action: none; }
.frame { position: absolute; }
.frame canvas { display: block; width: 100%; height: 100%; }
.frame svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.handle {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; border: 3px solid #fff;
  background: rgba(59, 130, 246, .35);
  box-shadow: 0 0 0 2px #3b82f6, 0 1px 4px rgba(0, 0, 0, .6);
  pointer-events: none;
}
.handle.active { transform: scale(1.3); }
.loupe {
  position: absolute; top: 12px; left: 12px; width: 120px; height: 120px;
  border-radius: 50%; border: 3px solid #fff; background: #000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .6); pointer-events: none;
}
.loupe.right { left: auto; right: 12px; }
.hint {
  position: absolute; left: 0; right: 0; bottom: 6px; margin: 0;
  text-align: center; font-size: 14px; color: #f1f3f5;
  text-shadow: 0 1px 3px #000; pointer-events: none;
}
.preview {
  position: absolute; inset: 0; display: flex; padding: 16px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
.preview canvas { display: block; flex: none; margin: auto; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .5); }

.ed-tools {
  display: grid; gap: 10px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: #1f1f25; border-top: 1px solid #2f2f37;
}
.tool-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tool-label { font-size: 14px; color: #aeb5bd; }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 4px; font-size: 15px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: #3b82f6; }
.seg { display: flex; padding: 3px; background: #26262d; border-radius: 10px; }
.seg button {
  min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: #d1d6db; font: inherit; font-size: 15px; cursor: pointer;
  touch-action: manipulation;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 700; }
.custom { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; }
.custom input {
  width: 72px; min-height: 40px; padding: 0 8px;
  border: 1px solid #3a3a42; border-radius: 10px; background: #26262d; color: #fff;
  font: inherit; font-size: 16px;
}
.ed-info { margin: 0; font-size: 13px; color: #aeb5bd; }

/* ---------- PDF 완성 창 ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .45);
}
.sheet-body {
  width: 100%; max-width: 520px; display: grid; gap: 10px;
  padding: 22px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--paper); border-radius: 20px 20px 0 0;
}
.sheet-body h2 { margin: 0; font-size: 20px; }
.sheet-info { margin: 0 0 6px; color: var(--sub); font-size: 14px; word-break: break-all; }
.sheet-tip { margin: 4px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; color: var(--sub); }
.sheet .linkbtn { justify-self: center; }
@media (min-width: 560px) {
  .sheet { align-items: center; }
  .sheet-body { border-radius: 20px; }
}

/* ---------- 처리 중 ---------- */
.busy {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5);
}
.busy p {
  margin: 0; padding: 16px 22px; border-radius: 14px;
  background: #fff; color: var(--ink); font-size: 16px; font-weight: 600;
}

/* ---------- 넓은 화면 ---------- */
@media (min-width: 720px) {
  main { padding-top: 16px; }
  .tool, .guide, .doc { border-radius: 16px; padding: 36px 40px; }
  .guide { margin-top: 16px; }
  .tool h1 { font-size: 36px; }
  .a4 { width: 110px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .inapp { margin: 0 0 16px; }
}

/* ---------- 신분증 사본 (id.html) ---------- */
.head-nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot { display: flex; flex-direction: column; gap: 6px; }
.slot-name { font-size: 14px; font-weight: 700; color: var(--sub); }
.slot-pick {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 85.6 / 54; border: 2px dashed #c9d8f5; border-radius: 12px; background: #f7faff;
  cursor: pointer; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
.slot-pick:active { background: var(--accent-soft); }
.slot.filled .slot-pick { border: 1px solid var(--line); background: #fff; }
.slot-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--accent); font-size: 14px; text-align: center; }
.slot-empty svg { width: 40px; height: 27px; }
.slot-img { display: none; width: 100%; height: 100%; object-fit: contain; }
.slot.filled .slot-img { display: block; }
.slot-acts { display: flex; gap: 6px; }
.slot-acts .btn { flex: 1; min-height: 38px; padding: 0 8px; font-size: 14px; border-radius: 10px; }
.slot-acts .del { color: var(--danger); }

.field { display: grid; gap: 6px; margin: 18px 0 14px; }
.field-name { font-size: 15px; font-weight: 700; }
.field-name small { font-weight: 400; color: var(--muted); }
.field input {
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; color: var(--ink); background: #fff;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field-hint { font-size: 13px; color: var(--sub); }
#makeBtn:disabled { background: #d1d6db; border-color: #d1d6db; color: #fff; cursor: default; }

.others .other {
  display: grid; gap: 2px; padding: 16px; border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; color: var(--ink);
}
.others .other span { font-size: 14px; color: var(--sub); }
.others .other:active { background: var(--bg); }

.slots.one { grid-template-columns: 1fr; }
.slots.one .slot-pick { aspect-ratio: 3 / 2; }
.pack {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.pack input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.pack span { display: grid; font-size: 15px; }
.pack small { font-size: 13px; color: var(--sub); }
